Carnerox
The one and only.
- Reaction score
- 84
I made a spell which creates a glaive that circles around the caster for #n spins and then is destroyed after, but for some reason, when you cast it sometimes, the glaive will be created, but wont circle around the caster.
Here is the trigger.
Here is the trigger.
JASS:
scope MoonGlaive
globals
private constant integer ABIL_ID = 039;A003039;
private constant integer GLAIVE_ID = 039;h00P039;
private constant real PERIODIC = 0.00235
private constant string EFFECT_ID = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
private constant string ATTACHMENT = "chest"
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_HERO
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
private constant weapontype WEAPON_TYPE = null
private unit GLAIVE
private group GROUP
endglobals
native UnitAlive takes unit whitchUnit returns boolean
private function Distance takes nothing returns real
return 200.00
endfunction
private function MaxSpins takes integer level returns real
return 2.00*level+2.00
endfunction
private function AreaOfEffect takes nothing returns real
return 160.00
endfunction
private function Damage takes integer level returns real
return 120.00
endfunction
struct MoonGlaive
unit caster
unit glaive
player owner
integer level
integer spins
real casterX
real casterY
real distance
real angle
static method onDamage takes nothing returns boolean
local unit t = GetFilterUnit()
if (IsUnitEnemy(t,GetOwningPlayer(GLAIVE)) and UnitAlive(t)) and not (IsUnitInGroup(t,GROUP)) then
call UnitDamageTargetEx(GLAIVE,t,Damage,true,false,ATTACK_TYPE,DAMAGE_TYPE,WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(EFFECT_ID,t,ATTACHMENT))
call GroupAddUnit(GROUP,t)
endif
set t=null
return false
endmethod
static method onLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = GetTimerData(t)
local real x
local real y
set this.casterX=GetUnitX(this.caster)
set this.casterY=GetUnitY(this.caster)
if (this.angle>=360.00) then
set this.angle=0.00
set this.spins=this.spins+1
call GroupClear(GROUP)
if (this.spins>=MaxSpins(this.level)) then
call KillUnit(this.glaive)
call ReleaseTimer(t)
call ReleaseGroup(GROUP)
call DestroyGroup(GROUP)
call DestroyTimer(t)
set t=null
set GROUP=null
endif
else
set this.angle=this.angle+1.00
endif
set x=this.casterX+Distance()*Cos(this.angle*bj_DEGTORAD)
set y=this.casterY+Distance()*Sin(this.angle*bj_DEGTORAD)
call SetUnitX(this.glaive,x)
call SetUnitY(this.glaive,y)
set GLAIVE=this.glaive
call GroupEnumUnitsInArea(GROUP,x,y,AreaOfEffect(),Filter(function thistype.onDamage))
set t=null
endmethod
static method onEffect takes nothing returns boolean
local thistype this = thistype.allocate()
local timer t = NewTimer()
local real x
local real y
set this.caster=GetTriggerUnit()
set this.owner=GetOwningPlayer(this.caster)
set this.level=GetUnitAbilityLevel(this.caster,ABIL_ID)
set this.casterX=GetUnitX(this.caster)
set this.casterY=GetUnitY(this.caster)
set this.angle=0.00
set this.spins=0
set x=this.casterX+Distance()*Cos(this.angle*bj_DEGTORAD)
set y=this.casterY+Distance()*Sin(this.angle*bj_DEGTORAD)
set this.glaive=CreateUnit(this.owner,GLAIVE_ID,x,y,0.00)
set GROUP=NewGroup()
call SetTimerData(t,this)
call TimerStart(t,PERIODIC,true,function thistype.onLoop)
set t=null
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerAddCondition(GT_RegisterStartsEffectEvent(trig,ABIL_ID),Condition(function thistype.onEffect))
endmethod
endstruct
endscope