I believe this is a source of desyncs on my map, would appreciate a few more sets of eyes looking it over and letting me know if there are any red flags.
Basically its a poorly coded Nova proc on attacks.
It works and doesn't lag the map, just that I believe its desyncing.
This is the code that runs when the hero is selected from a tavern.
udg_HelpUnits[3] is a global variable storing the pointer to her for the other triggers to use, it doesn't get touched by anything else.
This is what the above is registering the unit to.
convert unit type 2 = structure
Checks which event happened
Then checks if its a structure, then if its an enemy, then if its already been targetted (so the spell doesn't happen twice+).
If its all good it registers the unit to the last trigger.
This is the function takes the unit from the above function and runs this every time its attacked by something.
It creates a unit, forces it to shoot a nova, then removes the unit.
Now, it works, I haven't gotten complaints of lag, but I am trying to root out desync issues and it seem to happen when this certain hero is being played.
Any help is appreciated.
Basically its a poorly coded Nova proc on attacks.
It works and doesn't lag the map, just that I believe its desyncing.
This is the code that runs when the hero is selected from a tavern.
udg_HelpUnits[3] is a global variable storing the pointer to her for the other triggers to use, it doesn't get touched by anything else.
JASS:
elseif(GetUnitTypeId(n) == 'Hjai') then
set udg_HelpUnits[3] = n
call TriggerRegisterUnitEvent( gg_trg_IM_CH_Acq, udg_HelpUnits[3], EVENT_UNIT_ACQUIRED_TARGET )
call TriggerRegisterUnitEvent( gg_trg_IM_CH_Acq, udg_HelpUnits[3], EVENT_UNIT_ISSUED_TARGET_ORDER )
This is what the above is registering the unit to.
convert unit type 2 = structure
Checks which event happened
Then checks if its a structure, then if its an enemy, then if its already been targetted (so the spell doesn't happen twice+).
If its all good it registers the unit to the last trigger.
JASS:
function CH_Acq takes nothing returns nothing
local unit u = GetOrderTargetUnit()
if(u == null)then
set u = GetEventTargetUnit()
endif
if (IsUnitType(u, ConvertUnitType(2)) == false) then
if (IsUnitEnemy(u, GetOwningPlayer(udg_HelpUnits[3]))) then
if(IsUnitInGroup(u, udg_IceMaidenGroup) == false)then
call GroupAddUnit(udg_IceMaidenGroup,u)
call TriggerRegisterUnitEvent(gg_trg_IM_CH_Attacked, u, EVENT_UNIT_ATTACKED)
endif
endif
endif
set u = null
endfunction
//===========================================================================
function InitTrig_IM_CH_Acq takes nothing returns nothing
set gg_trg_IM_CH_Acq = CreateTrigger( )
call TriggerAddAction( gg_trg_IM_CH_Acq, function CH_Acq )
endfunction
This is the function takes the unit from the above function and runs this every time its attacked by something.
It creates a unit, forces it to shoot a nova, then removes the unit.
JASS:
function ICH takes nothing returns nothing
local unit u
local unit k
if(GetUnitTypeId(GetAttacker()) == 'Hjai') then
if(GetRandomInt(0,100) < 10) then
set u = GetTriggerUnit()
set k = CreateUnit(Player(12),'nbdw',GetUnitX(u), GetUnitY(u), 0)
call SetUnitVertexColor(k, 0, 0, 0, 0)
call IssueTargetOrder(k, "frostnova", u)
call TriggerSleepAction(1)
call RemoveUnit(k)
set u = null
set k = null
endif
endif
endfunction
//===========================================================================
function InitTrig_IM_CH_Attacked takes nothing returns nothing
set gg_trg_IM_CH_Attacked = CreateTrigger( )
call TriggerAddAction( gg_trg_IM_CH_Attacked, function ICH )
endfunction
Now, it works, I haven't gotten complaints of lag, but I am trying to root out desync issues and it seem to happen when this certain hero is being played.
Any help is appreciated.