• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Properly using XYZ?

Status
Not open for further replies.
Level 12
Joined
Dec 10, 2008
Messages
850
Hey, so after trying to break off my "relationship" with the PolarProjectionBJ stuff.

I've been wondering, how do I properly set up a XYZ system that gets the X and Y offset from the caster's point, and then make a proper circle?

I've tryed several functions, but none of the seem to do the job right. It's propbably really easy, call me a noob if you must, but it isnt working that well for me right now.....
 
JASS:
function PolarProjectionBJ takes location source, real dist, real angle returns location
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    return Location(x, y)
endfunction

Thats how you do polar projection.

Also, as for setting a units height properly, use this.
 
Level 12
Joined
Dec 10, 2008
Messages
850
Ok, I'll pot it. I've probably made a mistake somewere, and I havnt patched all the leaks yet, I had to rename a few things

JASS:
scope Light initializer InitTrig_Light

     globals
          private constant string  Lightning        = "HWSB" //RAWCODE!
          private constant integer SPELL_ID  = 'A003'
          private constant integer DUM_ID    = 'h002'
          private constant integer DUM_SPEL  = 'A004'
          private constant integer DUM_BUFF  = 'BTLF'
          private constant string  Effect    = "Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl"
          private constant real    Real1     = 90
          private constant real    Real2     = 180
          private constant real    Real3     = 270
          private constant real    Real4     = 360
          private constant real    Real5     = 400
          private constant real    Real6     = 750
     endglobals     
     

     private function Light_Conditions takes nothing returns boolean
          return GetSpellAbilityId() == SPELL_ID
     endfunction

     private function Light_Actions takes nothing returns nothing
          local unit      C  = GetSpellAbilityUnit()
          local location CL = GetUnitLoc(C)
          local real      CR = GetUnitX(C)
          local real      RC = GetUnitY(C)
          local player    Y  = GetOwningPlayer(C)
          local integer   Level = GetUnitAbilityLevel(C,SPELL_ID)
          local rect      R  = RectFromCenterSizeBJ(CL,Real6,Real6)
          local real X1 = CR + Real5 * Cos(Real1*bj_DEGTORAD)
          local real X2 = CR + Real5 * Cos(Real2*bj_DEGTORAD)
          local real X3 = CR + Real5 * Cos(Real3*bj_DEGTORAD)
          local real X4 = CR + Real5 * Cos(Real4*bj_DEGTORAD)
          local real Y1 = RC + Real5 * Sin(Real1*bj_DEGTORAD)
          local real Y2 = RC + Real5 * Sin(Real2*bj_DEGTORAD)
          local real Y3 = RC + Real5 * Sin(Real3*bj_DEGTORAD)
          local real Y4 = RC + Real5 * Sin(Real4*bj_DEGTORAD)
          local lightning G1 = AddLightning(Effect,true,X1,Y1,X2,Y2)
          local lightning G2 = AddLightning(Effect,true,X2,Y2,X3,Y3)
          local lightning G3 = AddLightning(Effect,true,X3,Y3,X4,Y4)
          local lightning G4 = AddLightning(Effect,true,X4,Y4,X1,Y1)
          local location M
          local integer P = 1
          local unit D  = CreateUnitAtLoc(Y,DUM_ID,CL,Real6)
          call UnitAddAbility(D,DUM_SPEL)
          call SetUnitAbilityLevel(D,DUM_ID,Level)
          loop
               exitwhen P==15
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect,M))
               call RemoveLocation(M)
               call TriggerSleepAction(.3)
               set P=P+1
          endloop
          call UnitApplyTimedLife(D,DUM_BUFF,.5)
          call RemoveRect(R)
          call DestroyLightning(G1)
          call DestroyLightning(G2)
          call DestroyLightning(G3)
          call DestroyLightning(G4)
     endfunction

//===========================================================================
     private function InitTrig_Light takes nothing returns nothing
          local trigger I = CreateTrigger()
          call TriggerRegisterAnyUnitEventBJ(I, EVENT_PLAYER_UNIT_SPELL_CAST )
          call TriggerAddCondition(I, Condition( function Light_Conditions ) )
          call TriggerAddAction(I, function Light_Actions )
          set I=null
          call Preload(Effect)
          call Preload(Lightning)
     endfunction
endscope

EDIT: After being able to look at it on the site, I've reliased I was using the effects instead of the lightning's when I created it.
 
Status
Not open for further replies.
Top