• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Trigger desyncing?

Status
Not open for further replies.
Level 6
Joined
Mar 20, 2008
Messages
208
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.

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.
 
Level 14
Joined
Nov 18, 2007
Messages
816
JASS:
function ICH takes nothing returns nothing
     local unit u
     local unit k

    if (GetUnitTypeId(GetAttacker()) == 'Hjai') and (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 UnitApplyTimedLife(k, 'BTLF', 1)
        set u = null
        set k = null
    endif
endfunction

A cleaner version, but as far as i can see theres no code potentially desyncing. Do you use GetLocationZ somewhere?
 
Level 6
Joined
Mar 20, 2008
Messages
208
No, the only code that is used is the code thats shown.

Oh, yeah I forgot about the ands and ors, was giving me some errors when I was making it so I just doubled the if-then check.
 
Status
Not open for further replies.
Top