- Reaction score
- 888
So I have some code here:
Unfortunately for me, as I watch my test map progress with this trigger, it gets laggier and laggier. Not so when I disable this trigger. So I naturally think there must a leak somewhere. Can anybody find one?
Update: Well, well. Curiouser and curiouser. When I comment the random integer part, it does not lag. So it seems I need to find a way to prevent random integers from leaking? But I thought integers didn't leak.
Update 2: So now I have this code:
The lagging proceeds as normal. How odd.
Update 3: Using a recycled global for the integer makes no difference. Also, if it helps, I'm using Jesus4Lyf's Damage system.
JASS:
scope Abilities initializer StartAbilities
private function AbilitiesActions takes nothing returns nothing
local unit tower = GetEventDamageSource()
local unit target = GetTriggerUnit()
local real towerX = GetUnitX(tower)
local real towerY = GetUnitY(tower)
local unit dummy = CreateUnit(GetOwningPlayer(tower), dummyID, towerX, towerY, 0.0)
if(GetUnitTypeId(GetEventDamageSource()) == 039;o00N039; and GetRandomInt(1, 10) < 4) then
call UnitApplyTimedLife(dummy, 039;BTLF039;, 1.0)
call UnitAddAbility(dummy, 039;A02C039;)
call IssueTargetOrder(dummy, "chainlightning", target)
endif
set tower = null
set target = null
set dummy = null
endfunction
private function CheckUnitType takes nothing returns boolean
return GetUnitPointValue(GetEventDamageSource()) == 10
endfunction
private function StartAbilities takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction(t, function AbilitiesActions)
call TriggerAddCondition(t, Condition(function CheckUnitType))
call Damage_RegisterEvent(t)
endfunction
endscope
Unfortunately for me, as I watch my test map progress with this trigger, it gets laggier and laggier. Not so when I disable this trigger. So I naturally think there must a leak somewhere. Can anybody find one?
Update: Well, well. Curiouser and curiouser. When I comment the random integer part, it does not lag. So it seems I need to find a way to prevent random integers from leaking? But I thought integers didn't leak.
Update 2: So now I have this code:
JASS:
scope Abilities initializer StartAbilities
private function AbilitiesActions takes nothing returns nothing
local unit tower = GetEventDamageSource()
local unit target = GetTriggerUnit()
local real towerX = GetUnitX(tower)
local real towerY = GetUnitY(tower)
local unit dummy = CreateUnit(GetOwningPlayer(tower), dummyID, towerX, towerY, 0.0)
local integer temp
if(GetUnitTypeId(GetEventDamageSource()) == 039;o00N039;) then//and GetRandomInt(1, 10) < 4) then
set temp = GetRandomInt(1, 10)
if(temp < 4) then
call UnitApplyTimedLife(dummy, 039;BTLF039;, 1.0)
call UnitAddAbility(dummy, 039;A02C039;)
call IssueTargetOrder(dummy, "chainlightning", target)
endif
endif
set tower = null
set target = null
set dummy = null
set temp = 0
endfunction
private function CheckUnitType takes nothing returns boolean
return GetUnitPointValue(GetEventDamageSource()) == 10
endfunction
private function StartAbilities takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction(t, function AbilitiesActions)
call TriggerAddCondition(t, Condition(function CheckUnitType))
call Damage_RegisterEvent(t)
endfunction
endscope
The lagging proceeds as normal. How odd.
Update 3: Using a recycled global for the integer makes no difference. Also, if it helps, I'm using Jesus4Lyf's Damage system.