Help with income !!

Apelsinsaft

New Member
Reaction score
0
Ive searched to forums and i cannot understand how to make a working "income".

I dont know what a integer is, and i cant figure it out.. :/

anyway what i want to do is when i send 1 bandit, my basic income (20 gold), should be income + 5 gold = 25gold. And also i want it to work for all players on the map, 8 st.

Can someone please help me with this and explain very carefully? =)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
1). Go into the trigger editor (F4)

2). now you look in the toolbar at the top of the window for a yellow X button and click it

3). This is the variable editor where you create new global variables. Create a new variable (The green "+X" button)

4). give the new variable any name you like, i will call it "Income".

5). click the field "Variable Type" and search for "Integer". Integers are whole numbers.

6). Click the check box which says "Array [ ]" and then click okay.

7). click okay to close the variable editor. Voila we got a global income variable with array.

8). create a new Trigger, call it however you like, it should look like this:
Trigger:
  • First Trigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Income[(Player number of (Picked player))] = 20

because the variable "Income" is an array of Integer variables it is as if we got many variables of the same name. Just imagine you have several variables all called "Income" and you just put a number at the end to specify which one you use.
In this trigger we set the variables "Income + PlayerNumber" for each player.

9). Now create another trigger to add gold to the players periodically, somewhat like this:
Trigger:
  • Second Trigger
    • Events
      • Time - Every 2.00 seconds of game time
    • 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

Again we pick all players and add gold to the picked player. the amount of gold added is equal to our integer variable "Income + PlayerNumber".
The event "Every 2.00 seconds of game time" can be changed to whatever you want.

10). And now a third trigger to change the income when you train a unit.
Trigger:
  • Third Trigger
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to Bandit
        • Then - Actions
          • Set Income[(Player number of (Owner of (Triggering unit)))] = (Income[(Player number of (Owner of (Triggering unit)))] + 5)
        • Else - Actions

This trigger will fire each time a structure finishes training a unit, no matter which player, no matter which unit.
Then an if-statement will check whether the unit type of the trained unit is a Bandit, if it is not nothing will happen.
If it is a Bandit-type unit it will set the variabe "Income + PlayerNumber" to itself + 5 (means it adds 5 to the income).

Please pay full attention to this line:
Trigger:
  • Set Income[(Player number of (Owner of (Triggering unit)))] = (Income[(Player number of (Owner of (Triggering unit)))] + 5)

dont mix up the player number part, what we need now is the player number of the Owner of the triggering unit.


Good luck.
Accname.
 

Apelsinsaft

New Member
Reaction score
0
Ive done everything right now,but i cant figure out how to get the last "+5" .

Set Income[(Player number of (Owner of (Triggering unit)))] = (Income[(Player number of (Owner of (Triggering unit)))] + 5) <-- i mean that one.

:/
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
its an arithmetic, should be somewhere at the top of the function list.
arithmetics are used in GUI as math operations.
 

Moridin

Snow Leopard
Reaction score
144
There's a drop down menu of functions. It should be pretty easy to find. It's in the same action window :).
 

Apelsinsaft

New Member
Reaction score
0
IT dosent work.. have been trying for 4 hours in a row now.. what could be wrong?

My last trigger goes like this.

Events
Unit - A unit Finishes training a unit
Conditions ->

Actions
If(All conditons are True) then do (Then Action) else do (Else Actions)

If - Conditions
(Unit-type of (Trained unit)) Equal to Bandit

Then - Actions
Set Income[(Player number of (Owner of (Triggering unit)))] = Income[((Player number of (Owner of (Triggering unit))) + 5)]

Else - Actions




What happens when i build a Bandit is that all income stops.
 

Tyman2007

Ya Rly >.
Reaction score
74
this line
Income[((Player number of (Owner of (Triggering unit))) + 5)]


you accidentally added +5 to the player number instead of the variable.

try doing the set variable all over again, but when you're at "Set Income[XXXX] = " and it's not = to anything, click to set it, then on the first "1" you see at the top. follow the instructions in the posts above.
 

Apelsinsaft

New Member
Reaction score
0
I cant get it work. no matter how i try i end up with

Then - Actions
Set Income[(Player number of (Owner of (Triggering unit)))] = Income[((Player number of (Owner of (Triggering unit))) + 5)]

Can you make a step by step explenation.. this is really driving me crazy :)
 

Okay

New Member
Reaction score
2
This is what u need to do for the action

1. use the set variable action

2. set the variable to your "income Variable"

3. set the array number to player number of owner of triggering unit

4. set what the variable equals to arithmetic(it is one of the first choices for the formula dropdown menu)

5. Set the value to Your "Income variable"

6. Set its array to player number of owner of triggering unit

7. Change the 1 to a 5 back in the arithmetic menu

This should work.
Here are a few other things you could try

a. Make sure that the array size of your income variable is the number of players you have, otherwise none of the incomes will work

b. If you are not using lumber as a resource, you could instead give a player 5 lumber each time they build a bandit, and either use lumber as income, or make a simple trigger that checks every few seconds to see if you have lumber, and then adds the amount of gained lumber to their income THEN takes away their lumber

c. instead of an array variable just have a separate variable for each player and do something like
If player 3 trains a bandit, add 5 to player 3's income

That one will probably take a little longer, but it should be easier to solve any problems that come up

d. one last thing, you could set some value for each unit that you dont need (for example unit level would work great but only if no unit gave an income higher than 100) to how much income you want them to give and compress everything in to a few variables (for example if you used point value, the point value of a bandit is 5). This could probably work with any of the other ideas, just dont specify a certain unit and do "whatever value you are using" of trained unit instead of a 5.
That didnt really answer your question but it seemed like it would help a lot so i added it on.

If you have any question on how to do any of these, just ask me and I will post a reply ASAP.

Hope this helped
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
a. Make sure that the array size of your income variable is the number of players you have, otherwise none of the incomes will work
thats just wrong.

c. instead of an array variable just have a separate variable for each player and do something like
If player 3 trains a bandit, add 5 to player 3's income
this would be rediculously dump, i would not advice anyboy on earth to do it this way.

d. one last thing, you could set some value for each unit that you dont need (for example unit level would work great but only if no unit gave an income higher than 100) to how much income you want them to give and compress everything in to a few variables (for example if you used point value, the point value of a bandit is 5). This could probably work with any of the other ideas, just dont specify a certain unit and do "whatever value you are using" of trained unit instead of a 5.
That didnt really answer your question but it seemed like it would help a lot so i added it on.
point value would be the best solution because the level of the unit determines how much exp they give to heroes if killed.
and please note that you can set a units level to whatever value you like, there is no limit of 100. (you just have to hod down shift)
 

gloradow

New Member
Reaction score
0
ok I found out what to do... before selecting the Income variable in the second part of the Set Variable, go to the bar below and select the Arithmetic and then do the rest. I had the same problem till I did this.
 

Moridin

Snow Leopard
Reaction score
144
Step by step instructions:
*All lines after "=>" is what you should see.

1) Action: Set Variable

=> Set _______ = _______

2) Click the first blank.
3) Select your Integer Array variable.

=> Set Income_Integer[ ___ ] = _____

4) Select the blank in the [ ] brackets.
5) Open the drop down menu of functions.
6) Select Player - Player Number
7) You should automatically have "Player - Player number of (Triggering Player)" *.

=> Set Income_Integer[Player number of (Triggering Player)] = ________

8) Select the second blank (the only one left).
9) Open the drop down menu of functions.
10) Select Arithmetic.
11) You will get something like:

=> 1 + 1

...in another box.

12) Click the first 1.
13) Select the Income_Integer array variable.
14) Repeat steps 4 to 7.
15) Click the second "1".
16) Type in 5 in the blank space given at the bottom of the box that pops up.
17) Keep clicking ok / tapping enter until you get to here:

=> Set Income_Integer[Player number of (Triggering Player)] = ((Income_Integer[Player number of (Triggering Player)]) + 5)

Hope that helps.

Edit: Woops, a little too late :p. Ah well.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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