Hell all, so I have this spell and im using structs in order to pass variables into a timer. my problem is if the spell is cast more than once it stops the previous one in order to do then next one! So aperantly my struct variables are being overwritten causing it to stop! I'm wondering if I implemented them wrong, I'm no pro so this could very well be the problem! Anyway heres the code hopefully someone can enlighten me!
note: This is not finished code, i know there are leaks and inefficiencies
JASS:
truct divide
unit hole
unit hole2
endstruct
function Black_Hole_Filter takes nothing returns boolean
return true//IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false and(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT)==false or Black_Hole_IsBear(GetFilterUnit()))and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetUnit(H2Tx(GetTriggeringTrigger()),"g8")))
endfunction
function Trig_Divide_By_0_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A01P039;
endfunction
function kill_group takes nothing returns nothing
local location loc = GetUnitLoc(GetEnumUnit())
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Undead\\Darksummoning\\DarkSummonTarget.mdl", loc))
call KillUnit(GetEnumUnit())
call ShowUnit(GetEnumUnit(), false)
endfunction
function move_unit2 takes nothing returns nothing
local divide divide_data = GetCSData(GetExpiredTimer())
local unit hole = divide_data.hole2
local location lN0=GetUnitLoc(GetEnumUnit())
local location lN1=GetUnitLoc(hole)
local location lN2 =PolarProjectionBJ(lN1,DistanceBetweenPoints(lN1,lN0)-1,AngleBetweenPoints(lN1,lN0))
call SetUnitPositionLoc(GetEnumUnit(),lN2)
call RemoveLocation(lN0)
call RemoveLocation(lN1)
call RemoveLocation(lN2)
endfunction
function move_unit takes nothing returns nothing
local timer move = GetExpiredTimer()
local divide divide_data = GetCSData(GetExpiredTimer())
local boolexpr Group_Check = Condition (function Black_Hole_Filter)
local unit hole = divide_data.hole2
local real loc1 = GetUnitX(hole)
local real loc2 = GetUnitY(hole)
local group move_group
set move_group = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(move_group,GetUnitLoc(hole),650, Group_Check)
call ForGroup(move_group, function move_unit2)
call GroupEnumUnitsInRangeOfLoc(move_group,GetUnitLoc(hole),20, Group_Check)
call ForGroup(move_group, function kill_group)
if (not(GetUnitState(hole, UNIT_STATE_LIFE)>0))then
call PauseTimer(move)
call DestroyTimer(move)
call divide_data.destroy()
endif
endfunction
function Spell_Effect takes nothing returns nothing
local timer Effect = GetExpiredTimer()
local unit Black_Hole
local integer count = 0
local divide divide_data = GetCSData(GetExpiredTimer())
local unit hole = divide_data.hole
local real loc1 = GetUnitX(hole)
local real loc2 = GetUnitY(hole)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
if (not(GetUnitState(hole, UNIT_STATE_LIFE)>0))then
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
call PauseTimer(Effect)
call DestroyTimer(Effect)
call divide_data.destroy()
endif
endfunction
function Trig_BlackHole_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer count = 0
local unit Black_Hole
local unit Black_Hole_2
local timer Effect = CreateTimer()
local timer move = CreateTimer()
local divide divide_data = GetCSData(GetExpiredTimer())
local real loc1 = GetUnitX(caster)
local real loc2 = GetUnitY(caster)
set Black_Hole = CreateUnit(GetOwningPlayer(caster),039;e004039;,GetUnitX(caster),GetUnitY(caster),270)
set Black_Hole_2 = CreateUnit(GetOwningPlayer(caster),039;e004039;,GetUnitX(caster),GetUnitY(caster),270)
call SetUnitPathing(Black_Hole,false)
call SetUnitPathing(Black_Hole_2,false)
call UnitApplyTimedLife(Black_Hole,039;BTLF039;,20)
call UnitApplyTimedLife(Black_Hole_2,039;BTLF039;,24)
set divide_data.hole = Black_Hole
set divide_data.hole2 = Black_Hole_2
call TimerStart(move, 0.02, true, function move_unit)
call TimerStart(Effect, 0.2, true, function Spell_Effect)
call TriggerSleepAction(24)
loop
set Black_Hole = CreateUnit(GetOwningPlayer(caster),039;e000039;,loc1, loc2,270)
call UnitApplyTimedLife(Black_Hole,039;BTLF039;,0.1)
exitwhen count == 5
call SetUnitScale( Black_Hole, 4,4,4)
set count = count + 1
endloop
endfunction
//===========================================================================
function InitTrig_BlackHole takes nothing returns nothing
local trigger gg_trg_BlackHole = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_BlackHole, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition ( gg_trg_BlackHole, Condition (function Trig_BlackHole_Conditions) )
call TriggerAddAction( gg_trg_BlackHole, function Trig_BlackHole_Actions )
endfunction
note: This is not finished code, i know there are leaks and inefficiencies