A Question about Speed (JASS)

LurkerAspect

Now officially a Super Lurker
PREVIEW SUMMARY: Curious about fixing lengthy loops containing many if statements so that they don't run over each other and produce weird things

Hi there :D

The below callback runs through a set of 10 units and compares and tests a lot of things and has multiple outcomes. However, when run, I think the loop is so slow that many loops are being handled at the same time, and it produces the same results on different units.
JASS:
// Everything in CAPS is a private scope global

private function callback takes nothing returns nothing
    local integer i = 0
    local boolean explorerNearby = false
    local boolean demonNearby = false
    local group g = NewGroup() // This jass function uses GroupUtils by Rising_Dusk
    local boolexpr b = null
    local unit exp = null
    local unit dem = null
   
    if TIME_COUNTER >= REWARD_INCREMENT_TIME*NODE_COUNT then // this incrementally increases the gold per second reward
        set TIME_COUNTER = 0
        set REWARD_LEVEL = REWARD_LEVEL+1
        set CURRENT_GOLD_REWARD = CURRENT_GOLD_REWARD+GOLD_CONSTANT_REWARD_INCREMENT
        call Debug("Reward level increased")
    endif
   
   
    loop // The loop in question!
        exitwhen i > NODE_COUNT-1
        set RELEVANT_NODE = NODE<i>
       
        if NODE_OWNER<i> == 1 and NODE_STATE<i> == 1 then // Add a gold-per-second reward to the owning faction
            call ForForce(EXPLORERS,function AddGoldConstantBonus)
        elseif NODE_OWNER<i> == 2 and NODE_STATE<i> == 1 then
            call ForForce(DEMONS,function AddGoldConstantBonus)
        endif
       
       
        if NODE_OWNER<i> == 0 and NODE_STATE<i> == 1 then // check if the node is on
            set b = Filter(function CheckForExplorers)
            call GroupEnumUnitsInRange(g,GetUnitX(NODE<i>),GetUnitY(NODE<i>),CHECK_RANGE,b) // look for members of faction 1
            set exp = FirstOfGroup(g)
            if exp != null then
                set explorerNearby = true
            endif
            call DestroyBoolExpr(b)
            call GroupClear(g)
            set b = Filter(function CheckForDemons)
            call GroupEnumUnitsInRange(g,GetUnitX(NODE<i>),GetUnitY(NODE<i>),CHECK_RANGE,b) // look for members of factions 2
            set dem = FirstOfGroup(g)
            if dem != null then
                set demonNearby = true
            endif
            call DestroyBoolExpr(b)
            call ReleaseGroup(g) // clear (I hope?)
           
            if explorerNearby == true and demonNearby == false then // check the capture state depending on nearby units, then display a counter
                set NODE_SCORE<i> = NODE_SCORE<i>+1
                call SetUnitAnimation(NODE<i>,&quot;stand work&quot;)
                call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|cff00FF00&quot;) // this function uses TextTag by Cohadar
            elseif explorerNearby == false and demonNearby == true then
                set NODE_SCORE<i> = NODE_SCORE<i>-1
                call SetUnitAnimation(NODE<i>,&quot;stand work&quot;)
                call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|cffFF0000&quot;)
            elseif explorerNearby == false and demonNearby == false then
                if NODE_SCORE<i> &gt; 0 then
                    set NODE_SCORE<i> = NODE_SCORE<i>-1
                    call TextTag_Unit(NODE<i>,&quot;+&quot;+I2S(NODE_SCORE<i>),&quot;|c00C0C0C0&quot;)
                elseif NODE_SCORE<i> &lt; 0 then
                    set NODE_SCORE<i> = NODE_SCORE<i>+1
                    call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|c00C0C0C0&quot;)
                endif
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            endif
           
            if NODE_SCORE<i> &gt;= NODE_REQUIRED_SCORE then // check the resulting score and apply a final action
                call SetUnitOwner(NODE<i>,GetOwningPlayer(exp),true)
                call UnitRemoveAbility(NODE<i>,'Avul')
                call DestroyEffect(AddSpecialEffect(EXPLORER_SUCCESS_SFX,GetUnitX(NODE<i>),GetUnitY(NODE<i>)))
                set NODE_OWNER<i> = 1
                call ForForce(EXPLORERS,function AddInstantGoldBonus)
                call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been captured by the Explorers!|r&quot;)
                set NODE_SCORE<i> = 0
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            elseif NODE_SCORE<i> &lt;= (-1)*NODE_REQUIRED_SCORE then
                call SetUnitOwner(NODE<i>,GetOwningPlayer(dem),true)
                call UnitRemoveAbility(NODE<i>,'Avul')
                call DestroyEffect(AddSpecialEffect(DEMON_SUCCESS_SFX,GetUnitX(NODE<i>),GetUnitY(NODE<i>)))
                set NODE_OWNER<i> = 2
                call ForForce(DEMONS,function AddInstantLumberBonus)
                call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been captured by the Demon!|r&quot;)
                set NODE_SCORE<i> = 0
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            endif
            set exp = null
            set dem = null
        endif
        set i = i+1
    endloop
    set NODE_CYCLE = NODE_CYCLE+1
endfunction</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


The most notable result is that when a unit captures a single node, 4-6 are "captured" by his faction as well as the one he actually did capture.

For those who want to look at it, the full scope is below.
JASS:
scope PowerNode initializer init 

globals
    private constant real CHECK_RANGE = 300
    private constant integer NODE_REQUIRED_SCORE = 15
    private constant integer REWARD_INCREMENT_TIME = 300
    private constant integer NODE_COUNT = 10
    private constant integer GOLD_INSTANT_REWARD_BASE = 800
    private constant integer GOLD_INSTANT_REWARD_INCREMENT = 200
    private constant integer LUMBER_INSTANT_REWARD_BASE = 4
    private constant integer LUMBER_INSTANT_REWARD_INCREMENT = 1
    private constant integer GOLD_CONSTANT_REWARD_BASE = 0
    private constant integer GOLD_CONSTANT_REWARD_INCREMENT = 5
    private constant string EXPLORER_SUCCESS_SFX = &quot;Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl&quot;
    private constant string DEMON_SUCCESS_SFX = &quot;Objects\\Spawnmodels\\Undead\\UCancelDeath\\UCancelDeath.mdl&quot;
    private constant string NEUTRALISE_SUCCESS_SFX = &quot;Units\\NightElf\\Wisp\\WispExplode.mdl&quot;
    private constant string ACTIVATE_SFX = &quot;Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl&quot;
   
    private unit array NODE[9]
    private integer array NODE_OWNER[9] // 0 = neutral passive, 1 = explorers, 2 = demons
    private integer array NODE_STATE[9] // 0 = off, 1 = on
    private integer array NODE_SCORE[9] // determines the current capture state of the node. Postive value = explorer ownership, negative = demons
   
    private integer CURRENT_NODE = -1
    private timer TIMER = CreateTimer()
    private integer TIME_COUNTER = 0
    private integer REWARD_LEVEL = 0
    private integer CURRENT_GOLD_REWARD = GOLD_CONSTANT_REWARD_BASE
    private integer ACTIVE_NODES = 0
   
    private unit RELEVANT_NODE = null
   
    private integer DEBUG_COUNTER = 0
   
endglobals

private function AddGoldConstantBonus takes nothing returns nothing
    call PlayerAddGold(GetEnumPlayer(),CURRENT_GOLD_REWARD)
    call TextTag_GoldBounty(RELEVANT_NODE, I2S(CURRENT_GOLD_REWARD), GetEnumPlayer())
endfunction

private function AddInstantGoldBonus takes nothing returns nothing
    call PlayerAddGold(GetEnumPlayer(),GOLD_INSTANT_REWARD_BASE+GOLD_INSTANT_REWARD_INCREMENT*REWARD_LEVEL)
    call TextTag_GoldBounty(RELEVANT_NODE, I2S(GOLD_INSTANT_REWARD_BASE+GOLD_INSTANT_REWARD_INCREMENT*REWARD_LEVEL), GetEnumPlayer())
endfunction

private function AddInstantLumberBonus takes nothing returns nothing
    call PlayerAddLumber(GetEnumPlayer(),LUMBER_INSTANT_REWARD_BASE+LUMBER_INSTANT_REWARD_INCREMENT*REWARD_LEVEL)
    call TextTag_LumberBounty(RELEVANT_NODE, I2S(LUMBER_INSTANT_REWARD_BASE+LUMBER_INSTANT_REWARD_INCREMENT*REWARD_LEVEL), GetEnumPlayer())
endfunction
   
private function CheckForExplorers takes nothing returns boolean
    return (GetWidgetLife(GetFilterUnit()) &gt; 0 and IsUnitExplorer(GetFilterUnit()))
endfunction
   
private function CheckForDemons takes nothing returns boolean
    return (GetWidgetLife(GetFilterUnit()) &gt; 0 and IsUnitDemon(GetFilterUnit()))
endfunction
   

private function callback takes nothing returns nothing
    local integer i = 0
    local boolean explorerNearby = false
    local boolean demonNearby = false
    local group g = NewGroup() // This jass function uses GroupUtils by Rising_Dusk
    local boolexpr b = null
    local unit exp = null
    local unit dem = null
   
    if TIME_COUNTER &gt;= REWARD_INCREMENT_TIME*NODE_COUNT then // this incrementally increases the gold per second reward
        set TIME_COUNTER = 0
        set REWARD_LEVEL = REWARD_LEVEL+1
        set CURRENT_GOLD_REWARD = CURRENT_GOLD_REWARD+GOLD_CONSTANT_REWARD_INCREMENT
        call Debug(&quot;Reward level increased&quot;)
    endif
   
   
    loop // The loop in question!
        exitwhen i &gt; NODE_COUNT-1
        set RELEVANT_NODE = NODE<i>
       
        if NODE_OWNER<i> == 1 and NODE_STATE<i> == 1 then // Add a gold-per-second reward to the owning faction
            call ForForce(EXPLORERS,function AddGoldConstantBonus)
        elseif NODE_OWNER<i> == 2 and NODE_STATE<i> == 1 then
            call ForForce(DEMONS,function AddGoldConstantBonus)
        endif
       
       
        if NODE_OWNER<i> == 0 and NODE_STATE<i> == 1 then // check if the node is on
            set b = Filter(function CheckForExplorers)
            call GroupEnumUnitsInRange(g,GetUnitX(NODE<i>),GetUnitY(NODE<i>),CHECK_RANGE,b) // look for members of faction 1
            set exp = FirstOfGroup(g)
            if exp != null then
                set explorerNearby = true
            endif
            call DestroyBoolExpr(b)
            call GroupClear(g)
            set b = Filter(function CheckForDemons)
            call GroupEnumUnitsInRange(g,GetUnitX(NODE<i>),GetUnitY(NODE<i>),CHECK_RANGE,b) // look for members of factions 2
            set dem = FirstOfGroup(g)
            if dem != null then
                set demonNearby = true
            endif
            call DestroyBoolExpr(b)
            call ReleaseGroup(g) // clear (I hope?)
           
            if explorerNearby == true and demonNearby == false then // check the capture state depending on nearby units, then display a counter
                set NODE_SCORE<i> = NODE_SCORE<i>+1
                call SetUnitAnimation(NODE<i>,&quot;stand work&quot;)
                call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|cff00FF00&quot;) // this function uses TextTag by Cohadar
            elseif explorerNearby == false and demonNearby == true then
                set NODE_SCORE<i> = NODE_SCORE<i>-1
                call SetUnitAnimation(NODE<i>,&quot;stand work&quot;)
                call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|cffFF0000&quot;)
            elseif explorerNearby == false and demonNearby == false then
                if NODE_SCORE<i> &gt; 0 then
                    set NODE_SCORE<i> = NODE_SCORE<i>-1
                    call TextTag_Unit(NODE<i>,&quot;+&quot;+I2S(NODE_SCORE<i>),&quot;|c00C0C0C0&quot;)
                elseif NODE_SCORE<i> &lt; 0 then
                    set NODE_SCORE<i> = NODE_SCORE<i>+1
                    call TextTag_Unit(NODE<i>,I2S(NODE_SCORE<i>),&quot;|c00C0C0C0&quot;)
                endif
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            endif
           
            if NODE_SCORE<i> &gt;= NODE_REQUIRED_SCORE then // check the resulting score and apply a final action
                call SetUnitOwner(NODE<i>,GetOwningPlayer(exp),true)
                call UnitRemoveAbility(NODE<i>,'Avul')
                call DestroyEffect(AddSpecialEffect(EXPLORER_SUCCESS_SFX,GetUnitX(NODE<i>),GetUnitY(NODE<i>)))
                set NODE_OWNER<i> = 1
                call ForForce(EXPLORERS,function AddInstantGoldBonus)
                call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been captured by the Explorers!|r&quot;)
                set NODE_SCORE<i> = 0
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            elseif NODE_SCORE<i> &lt;= (-1)*NODE_REQUIRED_SCORE then
                call SetUnitOwner(NODE<i>,GetOwningPlayer(dem),true)
                call UnitRemoveAbility(NODE<i>,'Avul')
                call DestroyEffect(AddSpecialEffect(DEMON_SUCCESS_SFX,GetUnitX(NODE<i>),GetUnitY(NODE<i>)))
                set NODE_OWNER<i> = 2
                call ForForce(DEMONS,function AddInstantLumberBonus)
                call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been captured by the Demon!|r&quot;)
                set NODE_SCORE<i> = 0
                call SetUnitAnimation(NODE<i>,&quot;stand alternate&quot;)
            endif
            set exp = null
            set dem = null
        endif
        set i = i+1
    endloop
endfunction
           
private function initForces takes nothing returns nothing
    call ForceAddPlayer(EXPLORERS,Player(0))
    call ForceAddPlayer(EXPLORERS,Player(1))
    call ForceAddPlayer(EXPLORERS,Player(2))
    call ForceAddPlayer(EXPLORERS,Player(3))
    call ForceAddPlayer(EXPLORERS,Player(4))
    call ForceAddPlayer(EXPLORERS,Player(5))
    call ForceAddPlayer(EXPLORERS,Player(6))
    call ForceAddPlayer(EXPLORERS,Player(7))
    call ForceAddPlayer(EXPLORERS,Player(8))
    call ForceAddPlayer(EXPLORERS,Player(9))
    call ForceAddPlayer(EXPLORERS,Player(10))
    call ForceAddPlayer(DEMONS,Player(11))
endfunction
           
private function initArrays takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i &gt; 9
        set NODE_OWNER<i> = 0
        set NODE_STATE<i> = 0
        set NODE_SCORE<i> = 0
        set i = i+1
    endloop
       
    set NODE[0] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint1),GetRectCenterY(gg_rct_CommandPoint1),bj_UNIT_FACING)
    set NODE[1] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint2),GetRectCenterY(gg_rct_CommandPoint2),bj_UNIT_FACING)
    set NODE[2] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint3),GetRectCenterY(gg_rct_CommandPoint3),bj_UNIT_FACING)
    set NODE[3] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint4),GetRectCenterY(gg_rct_CommandPoint4),bj_UNIT_FACING)
    set NODE[4] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint5),GetRectCenterY(gg_rct_CommandPoint5),bj_UNIT_FACING)
    set NODE[5] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint6),GetRectCenterY(gg_rct_CommandPoint6),bj_UNIT_FACING)
    set NODE[6] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint7),GetRectCenterY(gg_rct_CommandPoint7),bj_UNIT_FACING)
    set NODE[7] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint8),GetRectCenterY(gg_rct_CommandPoint8),bj_UNIT_FACING)
    set NODE[8] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint9),GetRectCenterY(gg_rct_CommandPoint9),bj_UNIT_FACING)
    set NODE[9] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint10),GetRectCenterY(gg_rct_CommandPoint10),bj_UNIT_FACING)
   
    //call Debug(&quot;Power node Arrays initialized&quot;)
endfunction

private function CreateNode takes integer i returns nothing
    if i == 0 then
        set NODE[0] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint1),GetRectCenterY(gg_rct_CommandPoint1),bj_UNIT_FACING)
    elseif i == 1 then
        set NODE[1] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint2),GetRectCenterY(gg_rct_CommandPoint2),bj_UNIT_FACING)
    elseif i == 2 then
        set NODE[2] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint3),GetRectCenterY(gg_rct_CommandPoint3),bj_UNIT_FACING)
    elseif i == 3 then
        set NODE[3] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint4),GetRectCenterY(gg_rct_CommandPoint4),bj_UNIT_FACING)
    elseif i == 4 then
        set NODE[4] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint5),GetRectCenterY(gg_rct_CommandPoint5),bj_UNIT_FACING)
    elseif i == 5 then
        set NODE[5] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint6),GetRectCenterY(gg_rct_CommandPoint6),bj_UNIT_FACING)
    elseif i == 6 then
        set NODE[6] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint7),GetRectCenterY(gg_rct_CommandPoint7),bj_UNIT_FACING)
    elseif i == 7 then
        set NODE[7] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint8),GetRectCenterY(gg_rct_CommandPoint8),bj_UNIT_FACING)
    elseif i == 8 then
        set NODE[8] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint9),GetRectCenterY(gg_rct_CommandPoint9),bj_UNIT_FACING)
    elseif i == 9 then
        set NODE[9] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'o006',GetRectCenterX(gg_rct_CommandPoint10),GetRectCenterY(gg_rct_CommandPoint10),bj_UNIT_FACING)
    endif
endfunction
       
private function TestNode takes nothing returns nothing
    set NODE_STATE[5] = 1
    call TimerStart(TIMER,1,true,function callback)
endfunction
   
private function DeathActions takes nothing returns nothing
    local integer i = 0
    local boolean nodeRunning = false
    if GetUnitTypeId(GetTriggerUnit()) == 'o006' then
        loop
            exitwhen i &gt; NODE_COUNT-1
            if GetTriggerUnit() == NODE<i> then
                call RemoveUnit(NODE<i>)
                call CreateNode(i)
                set NODE_STATE<i> = 0
                set NODE_OWNER<i> = 0
                set ACTIVE_NODES = ACTIVE_NODES-1
                //call Debug(&quot;loop tick = &quot;+I2S(i))
                call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been deactivated!|r&quot;)
                call PingMinimapEx(GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),5,0,128,255,true)
                call DestroyEffect(AddSpecialEffect(NEUTRALISE_SUCCESS_SFX,GetUnitX(NODE<i>),GetUnitY(NODE<i>)))
                //call UnitAddAbility(NODE<i>,'Avul')
            endif
            set i = i+1
        endloop
       
        if ACTIVE_NODES == 0 then
            call PauseTimer(TIMER)
            call Debug(&quot;The timer was paused&quot;)
        endif
    endif
endfunction
   
public function ActivateNode takes nothing returns nothing
    local integer i = 0
    local integer array rarray
    local integer rcount = 0
    local integer result = 0
    local integer tempRandom = 0
    //local string msg = &quot;Array looks like this: &quot;
    loop
        exitwhen i &gt; NODE_COUNT-1
        set rarray<i> = -1
        set i=i+1
    endloop
    set i = 0
    loop
        exitwhen i &gt; NODE_COUNT-1
        if NODE_STATE<i> == 0 then
            set rarray[rcount] = i
            set rcount = rcount+1
        endif
        set i = i+1
    endloop    
    set tempRandom = GetRandomInt(1,rcount)-1
    //call Debug(&quot;tempRandom = &quot;+I2S(tempRandom))
    set result = rarray[tempRandom]
    //call Debug(&quot;rcount = &quot;+I2S(rcount))
    //call Debug(msg)
    if rcount == 0 then
        call Debug(&quot;Can't activate any more nodes, they're all lit :/&quot;)
    elseif result == -1 then
        call Debug(&quot;Result was -1, your system is shit xD&quot;)
    else
        set NODE_STATE[result] = 1
        set NODE_OWNER[result] = 0
        //call Debug(&quot;Activated node: &quot;+I2S(result))
        set ACTIVE_NODES = ACTIVE_NODES+1
        //call CreateNode(result)
        call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;|cff87ceebA Power Node has been activated!|r&quot;)
        call PingMinimapEx(GetUnitX(NODE[result]),GetUnitY(NODE[result]),5,0,128,255,false)
        call DestroyEffect(AddSpecialEffect(NEUTRALISE_SUCCESS_SFX,GetUnitX(NODE[result]),GetUnitY(NODE[result])))
        call PlaySoundBJ(gg_snd_Warning)
    endif
   
    if ACTIVE_NODES == 1 then
        call TimerStart(TIMER,1/I2R(NODE_COUNT),true,function callback)
        //call Debug(&quot;The timer was started!&quot;)
    endif
endfunction  
   
private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-node&quot;,true)
    call TriggerAddAction(t,function ActivateNode)
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(t,function DeathActions)
    set t = null
    call initArrays()
    call initForces()
endfunction

endscope
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


My solution was to reduce the callback interval to 0.1 and address one unit at a time per callback, and use a counter to cycle through the currently checked unit.

If you have a moment to show a rookie coder how things are supposed to work, I'd be really grateful :) it might go a long way to fixing some of my broken and discarded maps!
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
My solution was to reduce the callback interval to 0.1 and address one unit at a time per callback, and use a counter to cycle through the currently checked unit.
That's basically an "update pool" in the jardon of game programming. You iterate through an array per interval, and calling the update() functions while you're iterating an element.

In each update() function, you normally put in checking conditions and update your variables accordingly to the conditions that were met. It's been so long seeing JASS, but I think it is possible to divide-and-conquer your calls into short functions. Since each unit does something different, try and see if you can separate each unit actions and conditions that are to be called inside a single JASS function.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • C Cherry.Grove:
    So what's the whole reforged situation? Do we have to run the classic version bootleg now?
  • C Cherry.Grove:
    My boyfriend is super into Bethesda modding so I'm probably going to join him in that for a bit, then move on to making mobile/browser games.
  • C Cherry.Grove:
    I mostly just want to look at my old projects because I know I posted uploads on here somewhere.
  • C Cherry.Grove:
    My one game was basically Among Us but you sabotaged an entire medieval city simulated drastically inefficiently with dynamic NPCs :S
  • C Cherry.Grove:
    of course I never finished it x D
  • jonas jonas:
    xD
  • jonas jonas:
    I think you can still run the original game, just there's a chance your map won't work with the newer patches
  • jonas jonas:
    what development framework have you been looking at for mobile development?
  • jonas jonas:
    I'm currently creating (as a hobby) a space invaders like game for mobile using Xamarin, after starting a few larger projects that I also may not have finished :rolleyes::p
  • The Helper The Helper:
    Awesome! you should look at the Atari VCS platform it does not have a huge user base but the one it has is super active at around 11k and they have no games in there store
  • The Helper The Helper:
    basically it is linux
  • The Helper The Helper:
    OMG it is BanLord as Blackveiled on the forum
  • The Helper The Helper:
    what is up buddy
  • jonas jonas:
    thanks for the tip, that sounds cool. Never heard about the VCS before but seems like it should be a good match
  • tom_mai78101 tom_mai78101:
    The winter vacation left a toll on me. I missed staying up late and sleeping in late.
  • C Cherry.Grove:
    i haven't looked into it yet
  • C Cherry.Grove:
    If I could use something Python compatible it would save me some learning
  • C Cherry.Grove:
    But Unity might be easiest
  • C Cherry.Grove:
    looking at old posts here makes me happy. Makes me be all like "wow I was pretty smart in 2009"
  • C Cherry.Grove:
    mostly failing at life through adulthood really demotivated me for a while
  • C Cherry.Grove:
    ....what I don't get is why the fuck they would force us to permanently convert to a version of the game everyone fucking hated : \
  • C Cherry.Grove:
    Raid Shadow Legends texture pack smh
  • jonas jonas:
    Most people fail at life throughout their adulthood. Sometimes we get to learn from it. Usually it just feels like crap.
  • The Helper The Helper:
    What does not kill you makes you stronger is what they say

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top