- Joined
- Apr 6, 2008
- Messages
- 760
Help!! Argh Going Nuts!!!
this code is driving me nuts nothing is going as i want!
ok this is what i got so far but there is a problem after u have casted this sometimes the dummy unit will only how for like 0.1 sec, and after somemore cast it wont even show...(code is a mess atm)
oh one more thing is there something better then
this code is driving me nuts nothing is going as i want!
ok this is what i got so far but there is a problem after u have casted this sometimes the dummy unit will only how for like 0.1 sec, and after somemore cast it wont even show...(code is a mess atm)
oh one more thing is there something better then
call GroupAddGroup(dat.g,g)
?
JASS:
scope ZhaosBomb initializer Init
globals
private constant integer Abil_id = 'A005'
private constant integer Slow_id = 'A006'
private constant integer Dum_caster = 'h000'
private constant integer Dum = 'h006'
endglobals
private struct Data
unit c
unit t
unit dum
real x
real y
real angle
real cos
real sin
real distbetween
real dist
integer count
group g
timer time
method onDestroy takes nothing returns nothing
call PauseTimer(.time)
call ClearTimerStructA(.time)
call DestroyTimer(.time)
endmethod
endstruct
private function Stop takes nothing returns nothing
local timer t = GetExpiredTimer()
local Data dat = GetTimerStructA(t)
call PauseTimer(t)
call ClearTimerStructA(t)
call DestroyTimer(t)
call dat.destroy()
endfunction
private function Check takes nothing returns nothing
local Data dat = GetTimerStructA(GetExpiredTimer())
local unit d
local group g = CreateGroup()
local real dist
local real ux
local real uy
call GroupAddGroup(dat.g,g)
loop
set d = FirstOfGroup(g)
exitwhen d == null
call GroupRemoveUnit(g,d)
set ux = GetUnitX(d)
set uy = GetUnitY(d)
if SquareRoot((dat.x-ux)*(dat.x-ux)+(dat.y-uy)*(dat.y-uy)) >= 400 then
call UnitDamageTarget(dat.c,d,50,false,false,null,null,null)
call GroupRemoveUnit(dat.g,d)
call UnitRemoveAbility(d,'Bslo')
endif
endloop
call DestroyGroup(g)
set g = null
endfunction
private function Wait takes nothing returns nothing
local Data dat = GetTimerStructA(GetExpiredTimer())
local unit d
local group g = CreateGroup()
local unit dum
local player p = GetOwningPlayer(dat.c)
local timer t = CreateTimer()
set dat.g = CreateGroup()
call PauseTimer(dat.time)
call GroupEnumUnitsInRange(g,dat.x,dat.y,200,null)
loop
set d = FirstOfGroup(g)
exitwhen d == null
call GroupRemoveUnit(g,d)
call GroupAddUnit(dat.g,d)
set dum = CreateUnit(p,Dum_caster,dat.x,dat.y,0.)
call UnitAddAbility(dum,Slow_id)
call IssueTargetOrder(dum,"slow",d)
call UnitApplyTimedLife(dum,'BTLF',2.)
set dum = null
endloop
call SetTimerStructA(t,dat)
call TimerStart(t,4.,false,function Stop)
call TimerStart(dat.time,.5,true,function Check)
call DestroyGroup(g)
set g = null
set t = null
set p = null
endfunction
private function Move takes nothing returns nothing
local Data dat = GetTimerStructA(GetExpiredTimer())
local real x = GetUnitX(dat.dum)+20*dat.cos
local real y = GetUnitY(dat.dum)+20*dat.sin
local group g
local unit d
set dat.dist = dat.dist + 20
if dat.dist < dat.distbetween then
call SetUnitFlyHeight(dat.dum,JumpParabola(dat.dist,dat.distbetween,6.),0.)
call SetUnitX(dat.dum,x)
call SetUnitY(dat.dum,y)
else
set g = CreateGroup()
call RemoveUnit(dat.dum)
call PauseTimer(dat.time)
call GroupEnumUnitsInRange(g,dat.x,dat.y,200.,null)
loop
set d = FirstOfGroup(g)
exitwhen d == null
call GroupRemoveUnit(g,d)
call UnitDamageTarget(dat.c,d,100,false,false,null,null,null)
endloop
call TimerStart(dat.time,1.,false,function Wait)
call DestroyGroup(g)
endif
set g = null
endfunction
private function Actions takes nothing returns nothing
local Data dat = Data.create()
local location loc = GetSpellTargetLoc()
local real x
local real y
set dat.c = GetTriggerUnit()
set x = GetUnitX(dat.c)
set y = GetUnitY(dat.c)
set dat.x = GetLocationX(loc)
set dat.y = GetLocationY(loc)
set dat.distbetween = SquareRoot((dat.x-x)*(dat.x-x)+(dat.y-y)*(dat.y-y))
set dat.angle = Atan2(dat.y-y,dat.x-x)*57.27589
set dat.cos = Cos(dat.angle*3.14159/180)
set dat.sin = Sin(dat.angle*3.14159/180)
set dat.time = CreateTimer()
set dat.dum = CreateUnit(GetOwningPlayer(dat.c),Dum,x+50*dat.cos,y+50*dat.sin,0.)
call SetTimerStructA(dat.time,dat)
call TimerStart(dat.time,.035,true,function Move)
call RemoveLocation(loc)
set loc = null
endfunction
private function Conds takes nothing returns boolean
return GetSpellAbilityId()==Abil_id
endfunction
public function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t,function Actions)
call TriggerAddCondition(t,Filter(function Conds))
endfunction
endscope