Bogrim
y hello thar
- Reaction score
- 154
My triggered ability creates a shield which heals the next 2/4/6 damage sources from enemy player units. But each time the shield triggers, the game freezes for a small moment (like 0.1 seconds).
The way the trigger functions is that it checks for which buff the unit currently has, using different buffs to "count" the number of stacks left. The hero's ability adds the 6 stack buff.
I also tested if:
- The sleep wait action was causing the lag, but the trigger still lagged even without the second trigger.
- The graphic on the buff was causing the lag, but the trigger still lagged even without graphic on the buffs.
Is there a smarter way to do this or a way to reduce the lag? Please help. I love the idea of this ability and don't want to ditch it.
The way the trigger functions is that it checks for which buff the unit currently has, using different buffs to "count" the number of stacks left. The hero's ability adds the 6 stack buff.
Trigger:
- Ability Gear Shield
- Events
- Game - GDD_Event becomes Equal to 0.00
- Conditions
- ((Owner of GDD_DamageSource) controller) Equal to User
- Or - Any (Conditions) are true
- Conditions
- (GDD_DamagedUnit has buff Gear Shield (1)) Equal to True
- (GDD_DamagedUnit has buff Gear Shield (2)) Equal to True
- (GDD_DamagedUnit has buff Gear Shield (3)) Equal to True
- (GDD_DamagedUnit has buff Gear Shield (4)) Equal to True
- (GDD_DamagedUnit has buff Gear Shield (5)) Equal to True
- (GDD_DamagedUnit has buff Gear Shield (6)) Equal to True
- Conditions
- Actions
- Set temp_location[0] = (Position of GDD_DamagedUnit)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Percentage life of GDD_DamagedUnit) Equal to 100.00
- Then - Actions
- Set temp_real = GDD_Damage
- Set temp_unit = GDD_DamagedUnit
- Trigger - Run Ability Gear Shield full <gen> (ignoring conditions)
- Else - Actions
- Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
- If - Conditions
- Unit - Create 1 Dummy Unit for (Owner of GDD_DamagedUnit) at temp_location[0] facing Default building facing degrees
- Custom script: call RemoveLocation( udg_temp_location[0] )
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (GDD_DamagedUnit has buff Gear Shield (6)) Equal to True
- Then - Actions
- Unit - Remove Gear Shield (6) buff from GDD_DamagedUnit
- Unit - Add Gear Shield (5) to (Last created unit)
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (GDD_DamagedUnit has buff Gear Shield (5)) Equal to True
- Then - Actions
- Unit - Remove Gear Shield (5) buff from GDD_DamagedUnit
- Unit - Add Gear Shield (4) to (Last created unit)
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (GDD_DamagedUnit has buff Gear Shield (4)) Equal to True
- Then - Actions
- Unit - Remove Gear Shield (4) buff from GDD_DamagedUnit
- Unit - Add Gear Shield (3) to (Last created unit)
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (GDD_DamagedUnit has buff Gear Shield (3)) Equal to True
- Then - Actions
- Unit - Remove Gear Shield (3) buff from GDD_DamagedUnit
- Unit - Add Gear Shield (2) to (Last created unit)
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (GDD_DamagedUnit has buff Gear Shield (2)) Equal to True
- Then - Actions
- Unit - Remove Gear Shield (2) buff from GDD_DamagedUnit
- Unit - Add Gear Shield (1) to (Last created unit)
- Else - Actions
- Unit - Remove Gear Shield (1) buff from GDD_DamagedUnit
- Unit - Remove (Last created unit) from the game
- Skip remaining actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
- Unit - Order (Last created unit) to Undead Lich - Frost Armor GDD_DamagedUnit
- Events
JASS:
function Trig_Ability_Gear_Shield_full_Func003001 takes nothing returns boolean
return ( GetUnitLifePercent(udg_temp_unit) < 100.00 )
endfunction
function Trig_Ability_Gear_Shield_full_Actions takes nothing returns nothing
local unit u = udg_temp_unit
local real r = udg_temp_real
loop
exitwhen ( Trig_Ability_Gear_Shield_full_Func003001() )
call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
endloop
call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
set u = null
endfunction
//===========================================================================
function InitTrig_Ability_Gear_Shield_full takes nothing returns nothing
set gg_trg_Ability_Gear_Shield_full = CreateTrigger( )
call TriggerAddAction( gg_trg_Ability_Gear_Shield_full, function Trig_Ability_Gear_Shield_full_Actions )
endfunction
I also tested if:
- The sleep wait action was causing the lag, but the trigger still lagged even without the second trigger.
- The graphic on the buff was causing the lag, but the trigger still lagged even without graphic on the buffs.
Is there a smarter way to do this or a way to reduce the lag? Please help. I love the idea of this ability and don't want to ditch it.