killingdyl
Active Member
- Reaction score
- 6
Ok so im making an omnislash ability but i cant seem to figure out how to make the whole spell stop when there arent any units in range. heres my code. Please dont point out leaks, the code is unfinished and i dont remove leaks til im done.
JASS:
function Trig_Omnislash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A00C039;
endfunction
function Trig_Omnislash_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local player p = GetOwningPlayer(caster)
local real x
local real y
local real angle
local integer random
local integer Loop = GetUnitAbilityLevel(caster, 039;A00C039;)*10
local integer i = 1
local group g = CreateGroup()
local unit fog
local effect fx = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", caster, "weapon")
call SetUnitVertexColor(caster, 255, 255, 255, 125)
loop
exitwhen i > Loop
set angle = GetRandomInt(0, 35) * 10 + GetRandomInt(0, 18) * 10
call SetUnitFacing(caster, angle-180)
set x = GetUnitX(target) + 50 * Cos(angle * bj_DEGTORAD)
set y = GetUnitY(target) + 50 * Sin(angle * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", x, y))
call SetUnitX(caster, x)
call SetUnitY(caster, y)
call GroupEnumUnitsInRange(g, x, y, 600, null)
loop
set fog = GroupPickRandomUnit(g)
exitwhen fog == null
if (IsUnitAlly(fog, p) == false) and (IsUnitType(fog, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(fog, UNIT_TYPE_STRUCTURE) == false) and not(GetUnitState(fog, UNIT_STATE_LIFE) <=0) then
set target = fog
set fog = null
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
call GroupRemoveUnit(g, fog)
endloop
else
call GroupRemoveUnit(g, fog)
endif
endloop
set i = i + 1
call SetUnitAnimationByIndex(caster, 2)
call TriggerSleepAction(0.40)
endloop
endfunction
//===========================================================================
function InitTrig_Omnislash takes nothing returns nothing
local trigger Omnislash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Omnislash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( Omnislash, Condition( function Trig_Omnislash_Conditions ) )
call TriggerAddAction( Omnislash, function Trig_Omnislash_Actions )
endfunction