Hi all. Im making an map with an income system. it works like this, You build an income tower and you get 1 mineral every 10 seconds. If you build 2 towers you get 2 minerals. Etc. Etc.
How do you make this in triggers? I know i need to make an variable but what type of variable?
ive build a income system myself recently in my first project, so im relativly new and can (hopefully) explain my system:
in my case i need an integer variable for each player (integers are just numbers), i use an array of 12 integers (array=many variables of one type in one listlike object).
also u need one timer that hits every 10 sec
and then 3 triggers
the first :
on mapintialization:
timer - start timer (the timer u should have created first) with 10 seconds runtime in loop (im german so im sorry if the actual function is called something other)
variable - set variable income[0]= 100 (or whatever u want as startingincome)
...
...
...
variable - set variable income[11]=100
u have to do this for eachpart of the income variable. it has 12 parts and starts at 0, so you have to set all from 0 to 11. if u start with 0 income u dont have to do that (the integer starts as 0 by default)
the second trigger is when u add income for any player who builds the building:
unit - unit gets build (german again, sry, but something like this should work)
condition: unittype of triggering unit== the unti type u want to check - this whole condition is only needed if u should only get income from special buildings, not everyone
action:
variable - Edit variable Income[player-1]+1 - the player -1 is needed cause the playercount starts at 1, but the array starts at 0.
and one final trigger to actually add the income to the player
timer - timer runs out
condition none
action
player edit player 1 minerals: income[0] add
...
...
player edit player 12 minerals: income[11] add
again for each player adding the income
and that should do it
in my case it works perfectly.
i know there are many options like doing a while loop sothat u dont have to respnde each arrayfeeld on its own, but i think for beginner its better if u do it that way.
if u dont understand how arrays work u can also create one integer variable for each player but then u have to write one trigger for each player to add income after he built a building.
does the "increase income on build" trigger fires?
is the income added to the players minerals?
u can check that by adding a textmassage to the trigger (just for debugging, like "trigger xxx has fired")
or "xxx income was added to player ... incomevariable"
with such debugg messages u can find errors in triggers much better cause u see maybe where the error is
Pick each unit in (Income towers in region entire map owned by player any player) and do actions.
Actions:
Modify player (picked player) minerals + 10
That will take each tower and add 10 minerals for each tower it finds to the owner of the tower. Also, code is probably a bit off. Don't have the GE open right now.
Hi all. Im making an map with an income system. it works like this, You build an income tower and you get 1 mineral every 10 seconds. If you build 2 towers you get 2 minerals. Etc. Etc.
How do you make this in triggers? I know i need to make an variable but what type of variable?
Ty
You can look at my supply depot income map.
ive build a income system myself recently in my first project, so im relativly new and can (hopefully) explain my system:
in my case i need an integer variable for each player (integers are just numbers), i use an array of 12 integers (array=many variables of one type in one listlike object). also u need one timer that hits every 10 sec and then 3 triggers
the first : on mapintialization: timer - start timer (the timer u should have created first) with 10 seconds runtime in loop (im german so im sorry if the actual function is called something other) variable - set variable income[0]= 100 (or whatever u want as startingincome) ... ... ... variable - set variable income[11]=100
u have to do this for eachpart of the income variable. it has 12 parts and starts at 0, so you have to set all from 0 to 11. if u start with 0 income u dont have to do that (the integer starts as 0 by default)
the second trigger is when u add income for any player who builds the building: unit - unit gets build (german again, sry, but something like this should work) condition: unittype of triggering unit== the unti type u want to check - this whole condition is only needed if u should only get income from special buildings, not everyone action: variable - Edit variable Income[player-1]+1 - the player -1 is needed cause the playercount starts at 1, but the array starts at 0.
and one final trigger to actually add the income to the player
timer - timer runs out condition none action player edit player 1 minerals: income[0] add ... ...
player edit player 12 minerals: income[11] add again for each player adding the income
and that should do it in my case it works perfectly. i know there are many options like doing a while loop sothat u dont have to respnde each arrayfeeld on its own, but i think for beginner its better if u do it that way. if u dont understand how arrays work u can also create one integer variable for each player but then u have to write one trigger for each player to add income after he built a building.
hope i helped and didnt confused u too much =)
cu, syl3r
sorry but nothing worked :( and if i use your map kanaru he starts adding minerals at the start but not when i build an pod.
@thommiej: Go
have u tested where the error is?
does the "increase income on build" trigger fires? is the income added to the players minerals?
u can check that by adding a textmassage to the trigger (just for debugging, like "trigger xxx has fired") or "xxx income was added to player ... incomevariable" with such debugg messages u can find errors in triggers much better cause u see maybe where the error is
try this:
That will take each tower and add 10 minerals for each tower it finds to the owner of the tower. Also, code is probably a bit off. Don't have the GE open right now.