• 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] What is leaking?

Status
Not open for further replies.
Level 3
Joined
Aug 15, 2007
Messages
37
Everytime this trigger is called, the game lags terribly. What needs fixed? Does it have anything to do with the InitTrig functions?

JASS:
function Trig_ChannelManaStopped_Copy_Conditions takes nothing returns boolean
    local unit u = GetOrderedUnit()
    
    if ( GetUnitTypeId(u) != 'e002' and  GetIssuedOrderId() != OrderId("stop") ) then
        set u = null
        return false
    endif
    
    set u = null
    return true
endfunction

function Trig_ChannelManaStopped_Copy_Actions takes nothing returns nothing
    local unit u = GetOrderedUnit()
    
    call TriggerSleepAction( 1.00 )
    call IssueImmediateOrderById(u,852548)
    
    set u = null
endfunction

//===========================================================================
function InitTrig_ChannelManaStopped_Copy takes nothing returns nothing
    set gg_trg_ChannelManaStopped_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ChannelManaStopped_Copy, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_ChannelManaStopped_Copy, Condition( function Trig_ChannelManaStopped_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_ChannelManaStopped_Copy, function Trig_ChannelManaStopped_Copy_Actions )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Weird. Something tells me the trigger fires itself, but it doesn't look like it should.

PS. a better version of the condition is;

JASS:
function Trig_ChannelManaStopped_Copy_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'e002' and GetIssuedOrderId() == 851972
endfunction
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Nah, it orders "replenishmana" only if "stop" is ordered, which is what's weird about it causing lag.

Also, an infinite loop would crash the game.

I've often found order triggers to be prone to infinite loops, even when logically they shouldn't. It may order both replenishmana AND stop (random Blizzard randomness).

Check it out with debug messages, I suggest.

Also, avoid global on order events if you can, as they get called a hell of a lot.
 
Level 3
Joined
Aug 15, 2007
Messages
37
I cleaned up the Conditions func like Poot said and it works 10x better. But it still starts lagging after about 30 secs that the code is called.
Maybe if I explain more about whats going on, someone will be able to tell whats wrong.

When you select to autocast the replenish mana spell, this trig is called
JASS:
function Trig_ChannelManaBeginCast_Copy_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A00D' )
endfunction

function Trig_ChannelManaBeginCast_Copy_Actions takes nothing returns nothing
    local player p  = GetOwningPlayer(GetTriggerUnit())

    if ( GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) > 0 )  then
        call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) - 1) ) 
    else
        call IssueImmediateOrder(GetTriggerUnit(),"stop")
    endif
    
    set p = null
endfunction

//===========================================================================
function InitTrig_ChannelManaBeginCast_Copy takes nothing returns nothing
    set gg_trg_ChannelManaBeginCast_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ChannelManaBeginCast_Copy, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_ChannelManaBeginCast_Copy, Condition( function Trig_ChannelManaBeginCast_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_ChannelManaBeginCast_Copy, function Trig_ChannelManaBeginCast_Copy_Actions )
endfunction

The idea behind this is that the unit that casts the replenish mana spell, is converting gold (changed to magic in the interface) into Generic Mana (typless) and storing it so the player can cast spells that require that type of mana. There are other units that convert it into other types as well (black, white, red etc..), but I'm not using any at the time.
When there is no gold, I order the unit to stop (because there is no magic to convert) and it calls the lagging trigger every second until more gold is harvested.
I have four wells (the units that are casting replenish) working at the same time. I imagine this could be the problem, but I'm not exactly sure of a better method for checking if there is gold. Unless someone knows of a way to issue orders only to units that have a specific spell set to autocast. Then I could set up a trig that gets called when a players gold becomes > 0 and group those units, then tell them to cast the spell.

I hope that helps. Thanks
 
Level 3
Joined
Aug 15, 2007
Messages
37
Yeah, I thought the same thing until I tested everything. There is absolutely no lag until I have 3 or more of the mana wells calling that trigger at the same time. What about the globals that Captain Griffon was talking about. Am I calling globals in the order event?
 
Status
Not open for further replies.
Top