- Joined
- Apr 6, 2008
- Messages
- 760
i have some problems with this spell iv tried anything but nothing seems to work... when u cast the spell i summon 4 shades that follow ur hero around, and when the hero attack the shades attack to, but the event for detecting when the hero moves dont work if like a unit get close to the hero...
JASS:
scope Spell
globals
private constant integer Abil_id = 'A000'
private constant integer NumberOfIllus = 4
private constant integer Dum_id = 'h000'
endglobals
private struct Data
unit c
unit array illu [NumberOfIllus]
trigger trig
integer order
timer t
endstruct
private function atkf takes nothing returns boolean
local Data dat = GetTriggerStructA(GetTriggeringTrigger())
local boolean ok = GetAttacker() == dat.c
return ok
endfunction
private function UnitFilter takes nothing returns boolean
local Data dat = GetTriggerStructA(GetTriggeringTrigger())
local unit f = GetFilterUnit()
local boolean ok = GetWidgetLife(f) > .405 and not IsUnitType(f,UNIT_TYPE_STRUCTURE) and IsUnitEnemy(f,GetOwningPlayer(dat.c))
set f = null
return ok
endfunction
private function Atk takes nothing returns nothing
local Data dat = GetTriggerStructA(GetTriggeringTrigger())
local integer a = 0
local group g = CreateGroup()
local unit d
loop
exitwhen a == NumberOfIllus
set a = a + 1
call SetUnitAnimation(dat.illu[a],"Attack")
call GroupEnumUnitsInRange(g,GetUnitX(dat.illu[a]),GetUnitY(dat.illu[a]),100,Filter(function UnitFilter))
loop
set d = FirstOfGroup(g)
exitwhen d == null
call GroupRemoveUnit(g,d)
call UnitDamageTarget(dat.c,d,150,false,false,null,null,null)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",GetUnitX(d),GetUnitY(d)))
endloop
endloop
call DestroyGroup(g)
set g = null
endfunction
private function Exe takes nothing returns nothing
local Data dat = GetTriggerStructA(GetTriggeringTrigger())
local integer a = 0
set dat.order = GetIssuedOrderId()
call BJDebugMsg(I2S(dat.order))
if dat.order == 851971 or dat.order == 851990 then
loop
exitwhen a == NumberOfIllus
set a = a + 1
call SetUnitAnimationByIndex(dat.illu[a],2)
endloop
endif
if dat.order == 851972 or dat.order == 851993 then
loop
exitwhen a == NumberOfIllus
set a = a + 1
call SetUnitAnimation(dat.illu[a],"stand - 1")
endloop
endif
endfunction
private function Move takes nothing returns nothing
local Data dat = GetTimerStructA(GetExpiredTimer())
local real x = GetUnitX(dat.c)
local real y = GetUnitY(dat.c)
local integer a = 0
local real Dist = 300.
local real f = GetUnitFacing(dat.c)
local real angle = 45.
loop
exitwhen a == NumberOfIllus
set a = a + 1
call SetUnitX(dat.illu[a],x+Dist*Cos(angle*3.14159/180))
call SetUnitY(dat.illu[a],y+Dist*Sin(angle*3.14159/180))
call SetUnitFacing(dat.illu[a],f)
set angle = angle + 90
endloop
endfunction
private function Actions takes nothing returns nothing
local Data dat = Data.create()
local trigger t = CreateTrigger()
local integer a = 0
local real x
local real y
local real Dist = 300.
local real f = GetUnitFacing(dat.c)
local real angle = 45.
set dat.c = GetTriggerUnit()
set x = GetUnitX(dat.c)
set y = GetUnitY(dat.c)
set dat.trig = CreateTrigger()
loop
exitwhen a == NumberOfIllus
set a = a + 1
set dat.illu[a] = CreateUnit(GetOwningPlayer(dat.c),Dum_id,x+Dist*Cos(angle*3.14159/180),y+Dist*Sin(angle*3.14159/180),f)
call SetUnitVertexColor(dat.illu[a],0,0,0,95)
call PauseUnit(dat.illu[a],true)
set angle = angle + 90
endloop
call SetTriggerStructA(dat.trig,dat)
call SetTriggerStructA(t,dat)
call TriggerRegisterUnitEvent(dat.trig,dat.c, EVENT_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterUnitEvent(dat.trig,dat.c, EVENT_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterUnitEvent(dat.trig,dat.c, EVENT_UNIT_ISSUED_ORDER)
call TriggerAddAction(dat.trig,function Exe)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction(t,function Atk)
call TriggerAddCondition(t,Filter(function atkf))
set dat.t = NewTimer()
call SetTimerStructA(dat.t,dat)
call TimerStart(dat.t,.035,true,function Move)
endfunction
private function conds takes nothing returns boolean
return GetSpellAbilityId()==Abil_id
endfunction
public function InitTrig takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddAction(t,function Actions)
call TriggerAddCondition(t,Filter(function conds))
endfunction
endscope
Attachments
Last edited: