cleeezzz
The Undead Ranger.
- Reaction score
- 268
all the examples of PUI and in the tutorial uses PUI within the scope to tell if the struct is created or not, and then do some more stuff with the old struct.
heres my code (read the comments in it)
heres my code (read the comments in it)
JASS:
scope GS initializer Init
private struct Data
timer t
unit d
real x
real y
integer i
group g = CreateGroup()
private method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
call RemoveUnit(.d)
call DestroyGroup(.g)
set .g = null
set .d = null
endmethod
endstruct
private function Shift takes nothing returns nothing
local Data d = GetCSData(GetExpiredTimer())
local unit u
local real a
local real dist
local real x2
local real y2
local real f
local real f2
local group g = CreateGroup()
local Data e
set d.x = GetUnitX(d.d)
set d.y = GetUnitY(d.d)
call GroupAddGroupAdv(Arrows,g)
if GetUnitState(d.d,UNIT_STATE_LIFE)<.405 then
call d.destroy()
set u = null
call DestroyGroup(g)
set g = null
return
endif
loop
set u = FirstOfGroup(g)
exitwhen u == null
set e = Data<u> //heres where i want to retrieve a struct and set it as e
set x2 = GetUnitX(u)
set y2 = GetUnitY(u)
set f = GetUnitFacing(u)
set f2 = f + 180
set dist = DistanceXY(d.x,d.y,x2,y2)
if dist <= d.i then
set a = Rad2Deg(AngleXY(x2,y2,d.x,d.y))
if a < 0 then
set a = a + 360
endif
if f > 180 then
if a <= f and a >= f2 - 360 then
call SetUnitFacing(u, GetUnitFacing(u) - (e.moved/11)) //takes some data from the struct e and uses it (this gives an error though moved is not a member of GS_Data which i know its not a member, but i want it to take moved from the struct in data e.)
else
call SetUnitFacing(u, GetUnitFacing(u) + (e.moved/11))
endif
else
if a >= f and a <= f2 then
call SetUnitFacing(u, GetUnitFacing(u) + 3)
else
call SetUnitFacing(u, GetUnitFacing(u) - 3)
endif
endif
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
set u = null
endfunction
//=======================================================================
private function Actions takes nothing returns nothing
local Data d = Data.create()
local unit u = GetTriggerUnit()
local location l = GetSpellTargetLoc()
call RemoveUnit(GF[GetPlayerId(GetOwningPlayer(u))])
set GF[GetPlayerId(GetOwningPlayer(u))] = null
set d.t = NewTimer()
set d.x = GetLocationX(l)
set d.y = GetLocationY(l)
set d.d = CreateUnit(GetOwningPlayer(u), 039;h00L039;, d.x, d.y, 0)
set GF[GetPlayerId(GetOwningPlayer(u))] = d.d
set d.i = (200 + (100 * GetUnitAbilityLevel( u, 039;A01W039;)))
call TimerStart(d.t, 0.03, true, function Shift)
call SetCSData(d.t, d)
call RemoveLocation(l)
set u = null
set l = null
endfunction
//=======================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A01W039;
endfunction
//=======================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trig,Condition(function Conditions))
call TriggerAddAction(trig,function Actions)
endfunction
endscope
</u>