- Joined
- Jan 18, 2005
- Messages
- 5,782
When working on our map, we noticed that when casting spells that affect whole squad using our system it causes a lag, which didn't happen under older version. Here is a trigger that manages those spells:
It may be that some commands cause lag in the new version for some reason? Maybe could be another trigger, but the lag occurs when casting spells.
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Battalion_spells_Conditions takes nothing returns boolean
local integer battallionIndex
if ( LoadInteger(udg_hashtable, GetHandleId(GetSpellTargetUnit()), 0) > 0 and GetBatalionAbility(GetSpellAbilityId()) > 0) then
return true
else
return false
endif
endfunction
function CastSpell takes nothing returns nothing
local unit dummy
local integer abilityIndex = GetBatalionAbility(udg_Tempint)
//call BJDebugMsg(I2S(GetSpellAbilityId()))
set dummy = CreateUnit( GetOwningPlayer(GetTriggerUnit()), 'h60H', GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()), bj_UNIT_FACING)
call IssueTargetOrderById( dummy, udg_BattalionSpellOrderID[abilityIndex], GetEnumUnit() )
call UnitApplyTimedLife( dummy, 'BTLF', 1.00 )
set dummy = null
endfunction
function Trig_Battalion_spells_Actions takes nothing returns nothing
local integer battallionIndexTarget = LoadInteger(udg_hashtable, GetHandleId(GetSpellTargetUnit()), 0)
local integer battallionIndexCaster = LoadInteger(udg_hashtable, GetHandleId(GetTriggerUnit()), 0)
set udg_Tempint = GetSpellAbilityId()
call GroupRemoveUnit( udg_Battallion[battallionIndexCaster], GetTriggerUnit() )
call GroupTargetOrder( udg_Battallion[battallionIndexCaster], "smart", GetTriggerUnit() )
call GroupAddUnit( udg_Battallion[battallionIndexCaster], GetTriggerUnit() )
call DisableTrigger( GetTriggeringTrigger() )
call ForGroup( udg_Battallion[battallionIndexTarget], function CastSpell )
call EnableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Battalion_spells takes nothing returns nothing
set gg_trg_Battalion_spells = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Battalion_spells, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Battalion_spells, Condition( function Trig_Battalion_spells_Conditions ) )
call TriggerAddAction( gg_trg_Battalion_spells, function Trig_Battalion_spells_Actions )
endfunction
It may be that some commands cause lag in the new version for some reason? Maybe could be another trigger, but the lag occurs when casting spells.