• 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.

Why does this trigger cause lag?

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
Hi, I have an Control Point Based income system, a player gains gold based on how many Control Points he has. There are 3 different types, 15g, 25g and 35g.

However when this trigger runs every 1 minute it causes the map to lag and I'n not sure why?

The trigger detects every Control Point within a unit group (CPGroup), CPs are added to this group at map startup and whenever one is captured. It used to be that the trigger calculated how many CP in the whole map every minute, I though this was what was causing the lag so changed it to a unit group but it is still causing lag :/

  • ActualIncome
    • Events
      • Time - Elapsed game time is 1.00 seconds
      • Time - Income expires
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in CPGroup and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to (==) Control Point 15g
            • Then - Actions
              • Set PlayerIncome[(Player number of (Owner of (Picked unit)))] = (PlayerIncome[(Player number of (Owner of (Picked unit)))] + 15)
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to (==) Control Point 25g
                • Then - Actions
                  • Set PlayerIncome[(Player number of (Owner of (Picked unit)))] = (PlayerIncome[(Player number of (Owner of (Picked unit)))] + 25)
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to (==) Control Point 35g
                    • Then - Actions
                      • Set PlayerIncome[(Player number of (Owner of (Picked unit)))] = (PlayerIncome[(Player number of (Owner of (Picked unit)))] + 35)
                    • Else - Actions
        • Do ActionFor each (Integer A) from 1 to 12, do (Player - Add PlayerIncome[(Integer A)] to (Player((Integer A))) Current gold)
        • Do ActionFor each (Integer A) from 1 to 12, do (Set PlayerIncome[(Integer A)] = 0)
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Try caching (Picked unit) and (Player number of Owner of picked unit) before executing the code. It can reduce the computational effort somewhat.

In the integer A loop, you should use an integer variable for looping. Integer A can cause issues sometime. You can also merge the two actions so that both are executed with each iteration.

edit

You may want to check the Income timer and see if you accidentally use a wrong interval.

Why don't you use a periodic trigger instead?
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
erm, well it wasn't actually me that did this it was someone who was supposed to be helping me with the triggers. I am not at expert at triggering at all I can only do the basic stuff, I'm more of a terrainer.

I don't really understand about caching and integer A :(

If I send you the map would you have time to edit this income trigger for me please? :)

I will give you credits.

EDIT: its for my Lordaeron the aftermath Map as see in my sig.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Great thanks! What will take me hours if not longer to work out will probably take you 10 minutes! I suck a triggers.

The triggers that need looking at are those relating to CPs and can be found in the Income and Multiboard Trigger folders.

Obviously please don;t give anyone else the unprotected version otherwise we'll have loads of noobs creating diff versions.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Great thanks! What will take me hours if not longer to work out will probably take you 10 minutes! I suck a triggers.

The triggers that need looking at are those relating to CPs and can be found in the Income and Multiboard Trigger folders.

Obviously please don;t give anyone else the unprotected version otherwise we'll have loads of noobs creating diff versions.

Trust me. I have been fixing a ton of maps already :3
 
Status
Not open for further replies.
Top