• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] What's wrong?

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2009
Messages
201
Income Trigger
  • Actions
    • For each (Integer B) from 1 to 8, do (Actions)
      • Loop - Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[(Integer B)]) and do (Actions)
          • Loop - Actions
            • Player - Add IncomeMoney[(Integer B)] to (Owner of (Picked unit)) Current gold
    • For each (Integer B) from 9 to 18, do (Actions)
      • Loop - Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[(Integer B)]) and do (Actions)
          • Loop - Actions
            • Player - Add IncomeMoney[(Integer B)] to (Owner of (Picked unit)) Current lumber
Setting the integer

  • Actions
    • Set IncomeUNIT_TYPE[1] = Tavern
    • Set IncomeMoney[1] = 125
    • Set IncomeUNIT_TYPE[2] = Temple
    • Set IncomeMoney[2] = 300
    • Set IncomeUNIT_TYPE[3] = Holy Temple
    • Set IncomeMoney[3] = 500
    • Set IncomeUNIT_TYPE[4] = Market
    • Set IncomeMoney[4] = 750
    • Set IncomeUNIT_TYPE[5] = Castle Keep
    • Set IncomeMoney[5] = 1000
    • Set IncomeUNIT_TYPE[6] = Royal Castle
    • Set IncomeMoney[6] = 1300
    • Set IncomeUNIT_TYPE[7] = Nuclear Power Plant
    • Set IncomeMoney[7] = 1900
    • Set IncomeUNIT_TYPE[8] = Trade Center
    • Set IncomeMoney[8] = 2750
    • Set IncomeUNIT_TYPE[9] = Pile of Flesh
    • Set IncomeMoney[9] = 25
    • Set IncomeUNIT_TYPE[10] = Advanced Pile of Flesh
    • Set IncomeMoney[10] = 50
    • Set IncomeUNIT_TYPE[11] = Farm
    • Set IncomeMoney[11] = 100
    • Set IncomeUNIT_TYPE[12] = Lumber Mill
    • Set IncomeMoney[12] = 225
    • Set IncomeUNIT_TYPE[13] = Efficient Lumber Mill
    • Set IncomeMoney[13] = 350
    • Set IncomeUNIT_TYPE[14] = Quarry
    • Set IncomeMoney[14] = 525
    • Set IncomeUNIT_TYPE[15] = Blacksmith
    • Set IncomeMoney[15] = 850
    • Set IncomeUNIT_TYPE[16] = Windmill
    • Set IncomeMoney[16] = 1350
    • Set IncomeUNIT_TYPE[17] = Advanced Windmill
    • Set IncomeMoney[17] = 2200
    • Set IncomeUNIT_TYPE[18] = Solar Pannel Network
    • Set IncomeMoney[18] = 3000
Initiating the Income Trigger

  • Events
    • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IncomeTime Equal to 1
        • Then - Actions
          • Set IncomeTime = 45
          • Trigger - Run Income <gen> (checking conditions)
        • Else - Actions
          • Set IncomeTime = (IncomeTime - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SecondTime Equal to 59
        • Then - Actions
          • Set SecondTime = 0
          • Set MinuteTime = (MinuteTime + 1)
        • Else - Actions
          • Set SecondTime = (SecondTime + 1)
      • Multiboard - Set the text for Multiboard item in column 3, row 1 to (String(IncomeTime))
      • Multiboard - Set the text for Multiboard item in column 5, row 1 to (String(MinuteTime))
      • Multiboard - Set the text for Multiboard item in column 6, row 1 to (String(SecondTime))
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Multiboard - Set the text for Multiboard item in column 5, row ((Player number of (Picked player)) + 2) to (String(((Picked player) Current gold)))
          • Multiboard - Set the text for Multiboard item in column 6, row ((Player number of (Picked player)) + 2) to (String(((Picked player) Current lumber)))

Not sure what is wrong with it but it only player red gets income, If it seems like I'm missing something please tell me. Any help at all would be greatly appreciated. (For setting up the integers 1-8 is for the gold income and 9-18 is for the lumber income)
 
Last edited:
Level 7
Joined
Dec 20, 2007
Messages
151
Like

[trigger=example:]
Actions
For each "LOOP" from 1 to 18, do (Actions)
Loop - Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE["LOOP"]) and do (Actions)
Loop - Actions
Player - Add IncomeMoney["LOOP"] to (Owner of (Picked unit)) Current gold
[/trigger]

I think this is all what Maker Says :p

Where "LOOP" is Integer Variable.
 
Level 6
Joined
Apr 1, 2009
Messages
201
I tried what you had suggested and it still doesn't work. Only player red gets income still. Here is the updated income trigger,

  • Income
    • Events
    • Conditions
    • Actions
      • For each (Integer IncomeInteger) from 1 to 8, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[IncomeInteger]) and do (Actions)
            • Loop - Actions
              • Player - Add IncomeMoney[IncomeInteger] to (Owner of (Picked unit)) Current gold
      • For each (Integer IncomeInteger) from 9 to 18, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[IncomeInteger]) and do (Actions)
            • Loop - Actions
              • Player - Add IncomeMoney[IncomeInteger] to (Owner of (Picked unit)) Current lumber
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Make the game print out what units are actually picked.

Code:
function GetUnitsOfTypeIdAllFilter takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId
endfunction

function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction

An idea I have at the moment is that you reset bj_MAX_PLAYER_SLOTS somewhere because you say it only works for Player Red and the variable is used in the pick action (see function above) but it's a tail loop so it works for the first player even if bj_MAX_PLAYER_SLOTS is zero or negative.

Another possibility could be that you have playerstate changes events.
 
Level 6
Joined
Apr 1, 2009
Messages
201
Make the game print out what units are actually picked.

Code:
function GetUnitsOfTypeIdAllFilter takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId
endfunction

function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction

An idea I have at the moment is that you reset bj_MAX_PLAYER_SLOTS somewhere because you say it only works for Player Red and the variable is used in the pick action (see function above) but it's a tail loop so it works for the first player even if bj_MAX_PLAYER_SLOTS is zero or negative.

Another possibility could be that you have playerstate changes events.

I already have a trigger that displays your income. It works in game and displays the correct amounts. Here is the trigger and also what do you mean by playerstate changing events? Do you mean where the players income changes because of more buildings created?

  • Income Command
    • Events
      • Player - Player 1 (Red) types a chat message containing -income as An exact match
      • Player - Player 2 (Blue) types a chat message containing -income as An exact match
      • Player - Player 3 (Teal) types a chat message containing -income as An exact match
      • Player - Player 4 (Purple) types a chat message containing -income as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -income as An exact match
      • Player - Player 6 (Orange) types a chat message containing -income as An exact match
      • Player - Player 7 (Green) types a chat message containing -income as An exact match
      • Player - Player 8 (Pink) types a chat message containing -income as An exact match
      • Player - Player 9 (Gray) types a chat message containing -income as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -income as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -income as An exact match
      • Player - Player 12 (Brown) types a chat message containing -income as An exact match
    • Conditions
    • Actions
      • Set Trigger_Player = (Player group((Triggering player)))
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set IncomeUnit[(Integer A)] = (Number of units in (Units owned by (Triggering player) of type IncomeUNIT_TYPE[(Integer A)]))
          • Set IncomeAmount[(Integer A)] = (IncomeUnit[(Integer A)] x IncomeMoney[(Integer A)])
          • Set IncomeTotal = (IncomeAmount[1] + (IncomeAmount[2] + (IncomeAmount[3] + (IncomeAmount[4] + (IncomeAmount[5] + (IncomeAmount[6] + (IncomeAmount[7] + IncomeAmount[8])))))))
      • For each (Integer A) from 9 to 18, do (Actions)
        • Loop - Actions
          • Set IncomeUnit[(Integer A)] = (Number of units in (Units owned by (Triggering player) of type IncomeUNIT_TYPE[(Integer A)]))
          • Set IncomeAmount[(Integer A)] = (IncomeUnit[(Integer A)] x IncomeMoney[(Integer A)])
          • Set IncomeTotal2 = (IncomeAmount[9] + (IncomeAmount[10] + (IncomeAmount[11] + (IncomeAmount[12] + (IncomeAmount[13] + (IncomeAmount[14] + (IncomeAmount[15] + (IncomeAmount[16] + (IncomeAmount[17] + IncomeAmount[18])))))))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Not equal to Player 10 (Light Blue)
          • (Triggering player) Not equal to Player 11 (Dark Green)
          • (Triggering player) Not equal to Player 12 (Brown)
        • Then - Actions
          • Game - Display to Trigger_Player the text: (|cffc0c0c0Currency Income|r: + (String((Integer((Real(IncomeTotal)))))))
          • Game - Display to Trigger_Player the text: (|cff4169e1Energy Income|r: + (String((Integer((Real(IncomeTotal2)))))))
        • Else - Actions
          • Game - Display to Trigger_Player the text: (|cff4169e1Energy Income|r: + (String((Integer((Real(IncomeTotal2)))))))
      • Custom script: call DestroyForce (udg_Trigger_Player)


Instead of 1 to 8 (im guessing this is players) do 1 to number of players in the game

The 1 to 8 are the buildings that give an income of gold and the 9 to 18 are the buildings that give an income of lumber
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
  • Player - Player 1 (Red)'s Current gold becomes Greater than 100.00
That is a playerstate changes event (Player - Properties). It also reacts if you change the player's property via trigger.

Anyway, build in test messages to investigate why the other players won't get their resources. Check the parameters that are put in the Player - Add Property action and whether the code runs till that point in the first place.

That's debugging and is a general thing to do if your code does not do what you want and you have no clue why.
 
Level 6
Joined
Apr 1, 2009
Messages
201
I followed your suggestion and are completely lost now. I have no clue where to go from here. I added in the text triggers and found that its skipping the 1-8 action and going to the 9-18 action, but player red still gets full income. I searched through the other triggers and couldn't find any player state changes. Here is the trigger:

  • Income
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1
      • For each (Integer IncomeInteger) from 1 to 8, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: 1a
          • Custom script: set bj_wantDestroyGroup = true
          • Game - Display to (All players) the text: 1b
          • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[IncomeInteger]) and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) the text: 1c
              • Player - Add IncomeMoney[IncomeInteger] to (Owner of (Picked unit)) Current gold
              • Game - Display to (All players) the text: 1d
      • Game - Display to (All players) the text: 2
      • For each (Integer IncomeInteger) from 9 to 18, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: 2a
          • Custom script: set bj_wantDestroyGroup = true
          • Game - Display to (All players) the text: 2b
          • Unit Group - Pick every unit in (Units of type IncomeUNIT_TYPE[IncomeInteger]) and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) the text: 2c
              • Player - Add IncomeMoney[IncomeInteger] to (Owner of (Picked unit)) Current lumber
              • Game - Display to (All players) the text: 2d

What was displayed was as follows, 2a,2b,2c,2d,2a,2b,2a,2b,2a,2b,2a,2b,2a,2b,2a,2b,

So what I understand from that is the part of the trigger that stops the leaks runs again and again and again. Is that to stop the leaks or does that identify a possible leak? Also it displayed the player getting just lumber and not gold, but when I tested it player red got both gold and lumber. I have no clue what to do. :(
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
So what I understand from that is the part of the trigger that stops the leaks runs again and again and again. Is that to stop the leaks or does that identify a possible leak?

Of course it is repeated, therefore it is in a loop.

Also it displayed the player getting just lumber and not gold, but when I tested it player red got both gold and lumber. I have no clue what to do. :(

Well, you could look where else you set player properties via trigger. You can use the object manager to find GUI triggers that use specific actions and other things. If you do not get the gold directly from triggers, it would be from ingame mechanics. So think of which things can give you gold and which are possible to take place in your map in the given situations.

Gold is produced from harvesting a gold mine, killing units (bounty), selling items, cancelling structures and such.
 
Status
Not open for further replies.
Top