Will this trigger cause any lag or delay?

Valtarian

Member
Reaction score
3
Give Wood
Events
Time - Every 0.50 seconds of game time
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Bank[1] Greater than or equal to 3000000
Then - Actions
Set Bank[1] = (Bank[1] - 500000)
Player - Add 1 to Player 1 (Red) Current lumber
Else - Actions
I'm going to loop this trigger through six players. Would this cause any lag or delay? Thanks!
 

Solu9

You can change this now in User CP.
Reaction score
216
Your player group leaks because you create a new player group (All players) every 0.50 secs. Either destroy you unit group in the trigger or assign all players playing to a specific unit group in the beginning of the game.

Also. You add 1 to Player 1's Current Lumber. If you loop it six times, Player 1 will end up with 6 lumber and the other players will get none.

You want an integer variable (array) which you have in Bank[x] and loop every integer A(1-6) do action.
 

vypur85

Hibernate
Reaction score
803
> You add 1 to Player 1's Current Lumber
True. Just change the Player 1 (Red) to 'Picked Player'.
And change Bank[1] to 'Bank[Player number of (Picked player)]'.

> I'm going to loop this trigger through six players
No need anymore loop. The player group is already a loop by itself. Then again, it depends on what you are planning to do as well.

To answer your question, no, it will not lag.

Just to clarify, All player does not leak. Do not attempt to destroy this force in any way possible. Or else, something odd might happen. :)
 

Valtarian

Member
Reaction score
3
Very helpful, thank you very much! I'm running into another problem, though.

Here is my trigger:




Code:
Bank Copy
    Events
        Time - Next_Level expires
    Conditions
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[1] Greater than 1000000
                    Then - Actions
                        Set Bank[1] = (Bank[1] + (Income[1] - 1000000))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[2] Greater than 1000000
                    Then - Actions
                        Set Bank[2] = (Bank[2] + (Income[2] - 1000000))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[3] Greater than 1000000
                    Then - Actions
                        Set Bank[3] = (Bank[3] + (Income[3] - 1000000))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[4] Greater than 1000000
                    Then - Actions
                        Set Bank[4] = (Bank[4] + (Income[4] - 1000000))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[5] Greater than 1000000
                    Then - Actions
                        Set Bank[5] = (Bank[5] + (Income[5] - 1000000))
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Income[6] Greater than 1000000
                    Then - Actions
                        Set Bank[6] = (Bank[6] + (Income[6] - 1000000))
                    Else - Actions



I've only tested this as red (player 1), but every time the timer ends, I end up with 6x the number that I should have in the bank.

Example: I receive 1,012,075 income.
1,000,000 of it is deducted, as shown in the equation (because 1M is the gold cap).
Technically, 12,075 should be in the bank. But it's not, it's 12,075x6, which turns out to give the player 72,450 gold in the bank.
Does anyone know what's wrong with my trigger? Thanks!

Edit: Note: I've tried different ways to assign the arrayed integer variables to player number and etc. The only solution I've found is to divide the final product of each equation by 6 to get almost the right amount-but I think that regardless, it would interfere with other players' banks.
 

vypur85

Hibernate
Reaction score
803
Code:
[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]For each (Integer A) from 1 to 6, do (Actions)[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]  Loop - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]    If (All Conditions are True) then do (Then Actions) else do (Else Actions)[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        If - Conditions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]          Income[Integer A] Greater than 1000000[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        Then - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]          Set Bank[Integer A] = (Bank[Integer A] + (Income[Integer A] - 1000000))[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        Else - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]

It looped 6 times because of the reason mentioned above.

The whole reason why you use a loop is to simplify your trigger. The above will do the trick. It will work for all your players.

In fact, this works better:
Code:
[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]Player Group - Pick every player in (All players) and do (Actions)[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]  Loop - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]    If (All Conditions are True) then do (Then Actions) else do (Else Actions)[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        If - Conditions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]            Bank[Player number of (Picked player) ] Greater than or equal to 3000000[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        Then - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]            Set Bank[Player number of (Picked player)] = (Bank[ Player number of (Picked player)] - 500000)[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]            Player - Add 1 to (Picked player) Current lumber[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]        Else - Actions[/FONT][/FONT]
[FONT=Consolas][FONT=Consolas]

If you look closely, it's what I've suggested in my other post above. :)








Edit: Wtf. I hate new forum formatting...
 

Valtarian

Member
Reaction score
3
Why do I always over-think things? I've spent at least 4-5 hours on this trigger, and it's as easy as THAT?!

Thank you so much man-tested and working. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top