• 🏆 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!

INCOME SYSTEM

Status
Not open for further replies.
Level 4
Joined
Jan 27, 2020
Messages
51
income system that increases the income whenever units are sent to the enemy.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Income is just a simple Integer Array. Increase it whenever a Player trains a unit or does something that should add Income.
  • Events:
  • Every 10 seconds
  • Actions:
  • Pick every player in All Players
  • Add PlayerIncome[Player number of picked player] Gold to Picked Player
Then I assume you're increasing the Income by training units.
  • Events:
  • A unit is trained
  • Conditions:
  • Unit Type of Trained-Unit equal to Shaman
  • Actions:
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + 3
^This trigger increases the Players Income by 3 whenever they train a Shaman.

A system for doing this would require two more variables and a configure trigger:
UnitType = Unit Type Array
Income = Integer Array
  • Events:
  • Map Initialization
  • Actions:
  • Set UnitType[1] = Shaman
  • Set Income[1] = 3
  • Set UnitType[2] = Footman
  • Set Income[2] = 1
  • Set UnitType[3] = Abomination
  • Set Income[3] = 10
Then change the "A unit is trained" trigger to Loop through all of the possible units and add the corresponding Income.
  • Events:
  • A unit is trained
  • Actions:
  • For Each IntegerA from 1 to 3 do
  • If Unit Type of Trained-Unit equal to UnitType[IntegerA] then
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + Income[IntegerA]
I don't have the Editor with me at the moment so I just gave you a rough idea. It shouldn't be too hard to look up these Actions though, Search For Text for similar words.
 
Last edited:
Level 4
Joined
Jan 27, 2020
Messages
51
Income is just a simple Integer Array. Increase it whenever a Player trains a unit or does something that should add Income.
  • Events:
  • Every 10 seconds
  • Actions:
  • Pick every player in All Players
  • Add PlayerIncome[Player number of picked player] Gold to Picked Player
Then I assume you're increasing the Income by training units.
  • Events:
  • A unit is trained
  • Conditions:
  • Unit Type of Trained-Unit equal to Shaman
  • Actions:
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + 3
^This trigger increases the Players Income by 3 whenever they train a Shaman.

A system for doing this would require two more variables and a configure trigger:
UnitType = Unit Type Array
Income = Integer Array
  • Events:
  • Map Initialization
  • Actions:
  • Set UnitType[1] = Shaman
  • Set Income[1] = 3
  • Set UnitType[2] = Footman
  • Set Income[2] = 1
  • Set UnitType[3] = Abomination
  • Set Income[3] = 10
Then change the "A unit is trained" trigger to Loop through all of the possible units and add the corresponding Income.
  • Events:
  • A unit is trained
  • Actions:
  • For Each IntegerA from 1 to 3 do
  • If Unit Type of Trained-Unit equal to UnitType[IntegerA] then
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + Income[IntegerA]
Thanks youuuu
 
Level 4
Joined
Jan 27, 2020
Messages
51
Income is just a simple Integer Array. Increase it whenever a Player trains a unit or does something that should add Income.
  • Events:
  • Every 10 seconds
  • Actions:
  • Pick every player in All Players
  • Add PlayerIncome[Player number of picked player] Gold to Picked Player
Then I assume you're increasing the Income by training units.
  • Events:
  • A unit is trained
  • Conditions:
  • Unit Type of Trained-Unit equal to Shaman
  • Actions:
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + 3
^This trigger increases the Players Income by 3 whenever they train a Shaman.

A system for doing this would require two more variables and a configure trigger:
UnitType = Unit Type Array
Income = Integer Array
  • Events:
  • Map Initialization
  • Actions:
  • Set UnitType[1] = Shaman
  • Set Income[1] = 3
  • Set UnitType[2] = Footman
  • Set Income[2] = 1
  • Set UnitType[3] = Abomination
  • Set Income[3] = 10
Then change the "A unit is trained" trigger to Loop through all of the possible units and add the corresponding Income.
  • Events:
  • A unit is trained
  • Actions:
  • For Each IntegerA from 1 to 3 do
  • If Unit Type of Trained-Unit equal to UnitType[IntegerA] then
  • Set PlayerIncome[Player number of triggering player] equal to PlayerIncome[Player number of triggering player] + Income[IntegerA]
I don't have the Editor with me at the moment so I just gave you a rough idea. It shouldn't be too hard to look up these Actions though, Search For Text for similar words.

This works but it add only 1 gold even i trained unit soo many
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Post your trigger.

Also, I forgot to mention in that "For Each IntegerA" Loop you need to set 3 to be equal to the total number of Trainable Units that your system uses.

See how I used 3 units, Shaman, Footman, and Abomination. If you used more units then you need to change 3 to however many you used.

Another thing. I think this might be the problem. Instead of doing "Unit type of Trained Unit" you need to do "Trained unit-type".
  • (Trained unit-type) Equal to Footman
Edit: You may be using "Sold" instead of "Trained", sorry I should be asleep right now :p
Anyway, I attached a map with a working example.
 

Attachments

  • Income System v1.w3m
    21.5 KB · Views: 42
Last edited:
Level 4
Joined
Jan 27, 2020
Messages
51
Post your trigger.

Also, I forgot to mention in that "For Each IntegerA" Loop you need to set 3 to be equal to the total number of Trainable Units that your system uses.

See how I used 3 units, Shaman, Footman, and Abomination. If you used more units then you need to change 3 to however many you used.

Another thing. I think this might be the problem. Instead of doing "Unit type of Trained Unit" you need to do "Trained unit-type".
  • (Trained unit-type) Equal to Footman
Edit: I may have meant to say "Sold" instead of "Trained", sorry I should be asleep right now :p
Anyway, I attached a map with a working example.
Sir i cant open the example of your trigger

Unable to load file Income System v1.w3x

-level info data missing or invalid
My trigger

  • Events:
  • Time - time expires
  • Conditions:
  • Actions:
  • Player Group - Pick every player in (All players) and do (Actions)
  • Loop - Actions:
  • Player - Add Income[(Player number of (Picked player))] to (Picked player) Current gold
  • Events:
  • Unit - A unit Finishes training a unit
  • Conditions:
  • (Trained unit-type) Equal to Militia
  • Actions:
  • Set Income[(Player number of (Trigger player))] = Income[((Player number of (triggering player)) + 1
  • Events:
  • Unit - A unit finishes training a unit
  • Conditions:
  • Actions:
  • For each (Integer A) from 1 to 3, do (Actions)
  • If - Conditions:
  • (Trained unit-type) equal to Unittype[(IntegerA)]
  • Then - Actions:
  • Set Income [(Player Number of (Triggering player))] = Income [((Player Number of (Triggering player)) + Income[(Integer A])]
  • Else - Actions:
  • Do Nothing
  • Events:
  • Map Initialization
  • Conditions:
  • Events:
  • Set Unittype[1] = Militia
  • Set Income[1] = 1
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
That means you're not on the latest patch.

How To Post Your Trigger

  • Income Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable TotalTrainedUnits = 3
      • -------- - --------
      • Set Variable UnitType[1] = Peasant
      • Set Variable Income[1] = 1
      • -------- - --------
      • Set Variable UnitType[2] = Footman
      • Set Variable Income[2] = 2
      • -------- - --------
      • Set Variable UnitType[3] = Knight
      • Set Variable Income[3] = 3
You can use this trigger if you TRAIN the units. See picture below.
  • Train Units Option 1
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrainedUnits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Trained unit-type) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Variable PlayerIncome[(Player number of (Triggering player))] = (PlayerIncome[(Player number of (Triggering player))] + Income[(Integer A)])
            • Else - Actions
You can use this trigger if you SELL the units. See picture below.
  • Sell Units Option 2
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrainedUnits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Variable PlayerIncome[(Player number of (Triggering player))] = (PlayerIncome[(Player number of (Triggering player))] + Income[(Integer A)])
            • Else - Actions
  • Add Income
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add PlayerIncome[(Player number of (Picked player))] to (Picked player) Current gold
          • Game - Display to (All players) for 5.00 seconds the text: Income:
          • Game - Display to (All players) for 5.00 seconds the text: (String(PlayerIncome[(Player number of (Picked player))]))
 

Attachments

  • a.png
    a.png
    990.7 KB · Views: 84
Level 4
Joined
Jan 27, 2020
Messages
51
That means you're not on the latest patch.

How To Post Your Trigger

  • Income Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable TotalTrainedUnits = 3
      • -------- - --------
      • Set Variable UnitType[1] = Peasant
      • Set Variable Income[1] = 1
      • -------- - --------
      • Set Variable UnitType[2] = Footman
      • Set Variable Income[2] = 2
      • -------- - --------
      • Set Variable UnitType[3] = Knight
      • Set Variable Income[3] = 3
You can use this trigger if you TRAIN the units. See picture below.
  • Train Units Option 1
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrainedUnits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Trained unit-type) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Variable PlayerIncome[(Player number of (Triggering player))] = (PlayerIncome[(Player number of (Triggering player))] + Income[(Integer A)])
            • Else - Actions
You can use this trigger if you SELL the units. See picture below.
  • Sell Units Option 2
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrainedUnits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Variable PlayerIncome[(Player number of (Triggering player))] = (PlayerIncome[(Player number of (Triggering player))] + Income[(Integer A)])
            • Else - Actions
  • Add Income
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add PlayerIncome[(Player number of (Picked player))] to (Picked player) Current gold
          • Game - Display to (All players) for 5.00 seconds the text: Income:
          • Game - Display to (All players) for 5.00 seconds the text: (String(PlayerIncome[(Player number of (Picked player))]))
What is the latest world editor?
 
Level 4
Joined
Jan 27, 2020
Messages
51
Are you selling units or training them?

Train = Training a Footman from a Barracks.

Sold = Buying a Troll from a Mercenary Camp.

I posted new triggers above. If you create all 4 of those triggers exactly as I did then it will work.

Also, try posting your triggers again, but use this How To Post Your Trigger
As my examplei make my townhall from a sold unit mean im selling then i have a one question what kind of variable do you use in the 4 new posted by you yesterday looks illike im making some mistakes
 
Level 4
Joined
Jan 27, 2020
Messages
51
TotalTrainedUnits = Integer
UnitType = Unit Type (Array)
PlayerIncome = Integer (Array)
Income = Integer (Array)

  • dad
    • Events
      • Time - Time expires
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add Income[(Player number of (Picked player))] to (Picked player) Current gold
          • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: Income:
          • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: (String(Income[(Player number of (Picked player))]))
  • income2
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Trained unit-type) Equal to Militia
    • Actions
      • Set Income[(Player number of (Triggering player))] = Income[((Player number of (Triggering player)) + 1)]
  • option2
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrain, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Trained unit-type) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set Income[(Player number of (Triggering player))] = Income[((Player number of (Triggering player)) + IncomeT[(Integer A)])]
            • Else - Actions
              • Do nothing
  • income initiali
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TotalTrain = 1
      • -------- - --------
      • Set UnitType[1] = Militia
      • Set Income[1] = 1
      • -------- - --------
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
In option2 you're using "Trained unit-type" in the condition when it needs to be "Sold unit".

Also, you need to use "Set PlayerIncome[player number of triggering player]". You're using "Set Income[Player number of triggering player]". Those are two different variables.

Another thing, I see "Set IncomeT[player number of triggering player]". It should be "Set Income[player number of triggering player]" with no T.
 
Last edited:
Level 4
Joined
Jan 27, 2020
Messages
51
In option2 you're using "Trained unit-type" in the condition when it needs to be "Sold unit".

Also, you need to use "Set PlayerIncome[player number of triggering player]". You're using "Set Income[Player number of triggering player]". Those are two different variables.

Another thing, I see "Set IncomeT[player number of triggering player]". It should be "Set Income[player number of triggering player]" with no T.
  • dad
    • Events
      • Time - Time expires
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add PlayerIncome[(Player number of (Picked player))] to (Picked player) Current gold
          • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: Income:
          • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: (String(PlayerIncome[(Player number of (Picked player))]))
  • income2
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Militia
    • Actions
      • Set PlayerIncome[(Player number of (Triggering player))] = PlayerIncome[((Player number of (Triggering player)) + 1)]
  • option2
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TotalTrain, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to UnitType[(Integer A)]
            • Then - Actions
              • Set PlayerIncome[(Player number of (Triggering player))] = PlayerIncome[((Player number of (Triggering player)) + Income[(Integer A)])]
            • Else - Actions
              • Do nothing
  • income initiali
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TotalTrain = 1
      • -------- - --------
      • Set UnitType[1] = Militia
      • Set Income[1] = 1
      • -------- - --------
so i follow what you say that two variables are not the same
so i change then the gold is now not adding to my current gold

do you want me to pass my map to you? so my problem can be resolve
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Delete income2. You don't need that trigger. option2 does the same exact thing.

Are you sure you're Selling the unit and not Training it?

That's why I made those two triggers.

"Train Units Option 1" works for Training units

"Sell Units Option 2" works for Selling/Buying units

Also, what building is selling/training the unit? Is it owned by you or a computer? Like is it Neutral Passive.
 
Level 4
Joined
Jan 27, 2020
Messages
51
Delete income2. You don't need that trigger. option2 does the same exact thing.

Are you sure you're Selling the unit and not Training it?

That's why I made those two triggers.

"Train Units Option 1" works for Training units

"Sell Units Option 2" works for Selling/Buying units

Also, what building is selling/training the unit? Is it owned by you or a computer? Like is it Neutral Passive.
The building selling own by me
My example is a unit enter the region of town hall then it will instantly move to the first stage i change it to neutral passive with certain color (invulnerable) unit then it will change to my own unit after it send to the enemy
 
Level 4
Joined
Jan 27, 2020
Messages
51
I don't know what to tell you man. You didn't copy my triggers properly. Just make them look 100% the same as mine and it will work.

You can also upload your map and I'll edit it for you.

to make more easier i will give my map to you so you know what i mean what i sayin' to you

have discord?
--> .DotQ#8182
 

Attachments

  • WorldEditTestMap.w3x
    88 KB · Views: 23

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Okay I figured it out. For some reason the PlayerIncome variable wasn't working. I deleted it and made a new one JUST LIKE IT and it works now... So weird.

Oh and another thing, you had this wrong in your Time expires trigger:
  • Player - Add PlayerIncome[(Player number of (Picked player))] to (Picked player).Current gold
You had "Player number of Triggering Player" in there when it was supposed to be Picked player.

I don't know if you can open the map but I edited it for you.
 

Attachments

  • WorldEditTestMap U1.w3x
    85.4 KB · Views: 26
Level 4
Joined
Jan 27, 2020
Messages
51
Okay I figured it out. For some reason the PlayerIncome variable wasn't working. I deleted it and made a new one JUST LIKE IT and it works now... So weird.

Oh and another thing, you had this wrong in Time Expires trigger:
  • Player - Add PlayerIncome[(Player number of (Picked player))] to (Picked player).Current gold
You had "Player number of Triggering Player" in there when it was supposed to be Picked player.

I don't know if you can open the map but I edited it for you.
i cant open the map, should i make my own i delet e the player income then remake a new one?i
or show me the trigger that you edit on my map. Are you using your reforge world editor?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Yeah, you can fix it yourself.

Here's what I did in this exact order:
Make a new Integer (Array) variable and call it something like "PlayerIncomeNew".

Then go through all of the triggers and replace PlayerIncome with PlayerIncomeNew.

Now you can delete PlayerIncome. Doing it like this is nice because it won't mess up your triggers.

Then do that thing I said for the Time expires trigger.

Change "Add PlayerIncome[Player number of TRIGGERING PLAYER]" to "Add PlayerIncome[Player number PICKED PLAYER]".

Since it's Pick every Player in All Players you have to use Picked Player and not Triggering Player.
 
Last edited:
Level 4
Joined
Jan 27, 2020
Messages
51
Yeah, you can fix it yourself.

Here's what I did in this exact order:
Make a new Integer (Array) variable and call it something like "PlayerIncomeNew".

Then go through all of the triggers and replace PlayerIncome with PlayerIncomeNew.

Now you can delete PlayerIncome. Doing it like this is nice because it won't mess up your triggers.

Then do that thing I said for the Time expires trigger.

Change "Add PlayerIncome[Player number of TRIGGERING PLAYER]" to "Add PlayerIncome[Player number PICKED PLAYER]".

Since it's Pick every Player in All Players you have to use Picked Player and not Triggering Player.
And still not working
So whats the problem?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Dunno, post your triggers again. I reiterate they should look EXACTLY like mine.

This should be a fairly easy system to implement.

You seem to be making small mistakes when copying it over and there's also weird issues with your map (Integer not working at ALL???). All you SHOULD have to do is look at my 4 triggers and recreate them. Look long and hard to see if they're EXACTLY the same. You don't need the "Trains Units" trigger though since we can confirm you're using "Sold Units".

Maybe that Integer bug is happening again? That could be the issue. It's a weird bug because no matter what I set it to to it always came out as 0. Even if I tried "PlayerIncome[1] = 100" -> "Display PlayerIncome[1]" it would say 0 instead of 100. Try testing that out to see if the variable is bugged again.

Also, what's stopping you from updating Warcraft 3 and opening my map?
 
Last edited:
Level 4
Joined
Jan 27, 2020
Messages
51
Dunno, post your triggers again. I reiterate they should look EXACTLY like mine.

This should be a fairly easy system to implement.

You seem to be making small mistakes when copying it over and there's also weird issues with your map (Integer not working at ALL???). All you SHOULD have to do is look at my 4 triggers and recreate them. Look long and hard to see if they're EXACTLY the same. You don't need the "Trains Units" trigger though since we can confirm you're using "Sold Units".

Maybe that Integer bug is happening again? That could be the issue. It's a weird bug because no matter what I set it to to it always came out as 0. Even if I tried "PlayerIncome[1] = 100" -> "Display PlayerIncome[1]" it would say 0 instead of 100. Try testing that out to see if the variable is bugged again.

Also, what's stopping you from updating Warcraft 3 and opening my map?
Hey sir i found a new one more easier
 
Status
Not open for further replies.
Top