'wait' trigger

MissKerrigan

Active Member
Reaction score
23
hello there,

this question might be too hard but never trying is never get a chance :)

alright, what I wanna do is creating a 'income trigger' that gives a certain income to the players every 30 seconds

now the standard income is 10 minerals and this can be upgraded with +1 in diffirent moments of the game
now here is my situation:

every unit you kill brings you +1 income, but NOT for always just the moment you killed them

example 1: if you killed 7 units in the first 30 seconds, your income should be 17
example 2: if you killed 12 units between 30-60 seconds, your income should be 22
example 3: if you killed 0 units between 150-180 seconds, your income should be 10 (if no upgrades were done)

Now there are several upgrades which increase your 'standard income' and also upgrades for the 'killing income' (every killed unit brings 2 minerals, 3 mineral, 4 minerals etc..)


problem 1: the computer must give only minerals to players every 30 seconds (30-60-90 etc...)

Problem 2: when a player kills 8 units, the computer must give 8 minerals to this player

Problem 3: every 10 kills gives 1 gas to a player (gas can be used to buy upgrades which increase weapon strenght or income)

Problem 4: a 'text message' in the subtitle area must appears every 30 seconds which shows the income (this depents on howmany units this player has killed)

Problem 5: I tried to create a trigger that gives resources when the timer has finished but this seems impossible because you never know what the income number will be! :(

do I really have to make 100 triggers for this?

Please help me,

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I can change the title if you tell me what you want it to be. The trigger is not impossible. It is not even that hard as long as you understand how variables (and arrays) work.

You need two new global variables. Call them ExtraIncome(This is the amount of units that the player has killed since the last income) and TotalExtraIncome(This is the amount of units that the player has killed total) and make sure both of them are of the integer type. Set the first array size of both of them to 15(you could set it to the amount of players instead but setting it to 15 will make sure it works even if you increase the amount of players.

(For the rest of my post, I assume that kills for the gas are saved between levels. So if you kill 5 units, get your income and kill 5 more, you still get the gas. If this is the case, continue as normal. Otherwise, replace all mentions of TotalExtraIncome with ExtraIncome and delete TotalExtraIncome.)

You might want to read through this post again to refresh your memory on variables. Arrays are just like a lot of variables with the same name. So MyArray[0] is one place where I can store stuff and MyArray[5] is another place where I can store stuff. However, for this we have the array ExtraIncome and TotalExtraIncome. We're going to store each player's income in those arrays. This means that ExtraIncome[3] will be the extra income for player 3.

First of all you need a repeating 30-second timer that gives income. Add a new timer variable, use the "Start timer" action at the start of the map to start it as a repeating timer. Have another trigger that looks something like this:

(I assumed you have an income upgrade that gives 5 additional income. You can copy the "if" below and modify it to make it work for several upgrades)
Code:
Event:
  IncomeTimer expires.
Conditions:
Local Variables:
  amount(integer) = 0
Actions:
  Pick Every Player in (Active Players):
    Set amount = 10+ExtraIncome[(Picked Player)]
    If:
        (Level of (IncomeUpgrade) for player (Picked Player)) == 1
    Then:
        Set amount = amount + 5
    Set ExtraIncome[(Picked Player)] = 0
    Modify (Picked Player)'s minerals: add amount
    Display (Text(amount)) in the subtitle text area for Player Group((Picked Player))


What does this do? We go through all the players that are currently playing. We set the amount variable to 10(the starting income) + the player's extra income(Again, this is the amount of units that the player has killed since the last income). If the player has the IncomeUpgrade upgrade, we add 5 to the amount. Finally, we add the amount to the player's minerals. We then start over with the next player.

You also need another trigger that starts when a unit is killed.
Code:
Event:
  Any unit dies
Conditions:
Local Variables:
Actions:
  Set ExtraIncome[(Killing Player)] = ExtraIncome[(Killing Player)] + 1
  Set TotalExtraIncome[(Killing Player)] = TotalExtraIncome[(Killing Player)] + 1 ([I]If you don't want to save the kills for gas between income, delete this row. Do not just replace TotalExtraIncome with ExtraIncome)[/I]
  If:
      (TotalExtraIncome[(Killing Player)] % 10) == 0
  Then:
      Modify (Killing Player)'s Vespene Gas: add 1
(I apologize for the inexact triggers. No trigger editor available right now. Hopefully you'll figure it out with what I wrote)
 

X-maul

AKA: Demtrod
Reaction score
201
As far as I can see- you you will do this by having a Global Integer variable with 12 arrays and every time a unit gets killed it increases the Integer variable by 1. Then you will have a periodic trigger that runs every 30 seconds, and gives each player Integer minerals.
 

MissKerrigan

Active Member
Reaction score
23
Hey,

Yes, would be nice if you can change the title to 'income by kills'
I red all your explanations in the second thread, thanks for that !!
But I got a few questions about this if you don't mind :)


Variable - Integer

- I know this variable is about numbers but I don't know exactly how it works. Why do I must set the integer to 15? Does this mean I can kill 15 unit maximum?

- Do I have to make a 'set variable' trigger at integers? if yes, then in a new trigger or in existing one?

Income

-Can I change TotalIncome to 'StandardIncome' and ExtraIncome to 'KillingIncome'?

-Yes, if a player kills 7 units in a 'level' then this player has only to kill 3 units in the next 'level' for earning a gas, this just adds level to level

- The standard income is always 10 at least, unless upgrades were done, so every new round players starting with 10 minerals + the number of kills they did in the round before (7 kills = 17 income)

Upgrades

- one of the upgrades is 'upgrade standard income 1', so this gives 15 minerals now instead of 10 in start of a level, next upgrade is 'upgrade standard income 2', so now players get 20 minerals instead of 15 in start of a level. This part reaches 10 upgrades, so finally players reach 60 stardard income

- another upgrade is 'killing upgrade 1', this increase the size of minerals a player get's when killed a unit. So when upgrade 1 is complete, players must get 2 minerals for every kill. Upgrade 2 gives 3 minerals for every kill. This continues to 10 upgrades where players get a killing income of 25 (+1, +1, +1, +2, +2, +2, +3, +3, +3, +6)

- Actually I also want an upgrade about the gas: every 25 kills brings a player a gas, but I want create 3 upgrades which increase this to '20 kills' - '15 kills' - '10 kills'

(so when 'upgrade gas income 1' is done, the player gets +1 gas every 20 kills, up to a total of 3 gas upgrades)

Triggers

- I don't understand this, if you killed 6 units and gets an income of 16, how does the computer knows he must start counting from '0' again when a new 'level' starts?

- How do I program that when 'killing upgrade 1' is done, players get's 2 minerals for every kill? (total of 10 upgrades)

- The 'if, then else' trigger. If the conditions of the 'if, then else' are not egual, does the trigger runs anyway then? Please explain me more about this 'if, then else'. I mean, a normal basic trigger is already an 'if, then else' am I right?

- How do I create a 'text amount' in a text message which shows the income of players?


I think I can do it when getting this anwsers :)

MissKerrigan
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I messed up a little in my triggers. I edited my previous post. Check it out again.
Variable - Integer

- I know this variable is about numbers but I don't know exactly how it works. Why do I must set the integer to 15? Does this mean I can kill 15 unit maximum?
No, it means that a maximum of 15 players can play your game at the same time. Since 15 is the max amount of players, you wont have to worry about this at all.
- Do I have to make a 'set variable' trigger at integers? if yes, then in a new trigger or in existing one?
You need to use the "Set variable" _Action_. It's not a trigger. You use the action in all the places where it says something like for example: "Set amount = amount + 5". That means you use the "Set variable" action and set the variable parameter to amount and the value to Arithmetic(Integer) with first value to amount and second to 5.
Income

-Can I change TotalIncome to 'StandardIncome' and ExtraIncome to 'KillingIncome'?
Yes, as long as you use the new name in all the places I used the old one.
-Yes, if a player kills 7 units in a 'level' then this player has only to kill 3 units in the next 'level' for earning a gas, this just adds level to level
Okay, if you just create the triggers like I showed you, it'll work like that.

- The standard income is always 10 at least, unless upgrades were done, so every new round players starting with 10 minerals + the number of kills they did in the round before (7 kills = 17 income)

That's how my triggers work
Upgrades

- one of the upgrades is 'upgrade standard income 1', so this gives 15 minerals now instead of 10 in start of a level, next upgrade is 'upgrade standard income 2', so now players get 20 minerals instead of 15 in start of a level. This part reaches 10 upgrades, so finally players reach 60 stardard income

Okay, if it's the same upgrade but with 10 levels, you can just change this part:

Code:
If
  (Level of (IncomeUpgrade) for player (Picked Player)) == 1
Then:
  Set amount = amount + 5
to
Code:
Set amount = amount + (IncomeUpgrade count for player (Picked Player) counting Complete)
If it's not the same upgrade with several levels, you should make it so it is.
- another upgrade is 'killing upgrade 1', this increase the size of minerals a player get's when killed a unit. So when upgrade 1 is complete, players must get 2 minerals for every kill. Upgrade 2 gives 3 minerals for every kill. This continues to 10 upgrades where players get a killing income of 25 (+1, +1, +1, +2, +2, +2, +3, +3, +3, +6)


Change
Code:
Set ExtraIncome[(Killing Player)] = ExtraIncome[(Killing Player)] + 1
Set TotalExtraIncome[(Killing Player)] = TotalExtraIncome[(Killing Player)] + 1
to
Code:
Set ExtraIncome[(Killing Player)] = ExtraIncome[(Killing Player)] + (1 + (KillingUpgrade count for player (Killing Player) counting Complete))
Set TotalExtraIncome[(Killing Player)] = TotalExtraIncome[(Killing Player)] + (1 +(KillingUpgrade count for player (Killing Player) counting Complete))

- Actually I also want an upgrade about the gas: every 25 kills brings a player a gas, but I want create 3 upgrades which increase this to '20 kills' - '15 kills' - '10 kills'

(so when 'upgrade gas income 1' is done, the player gets +1 gas every 20 kills, up to a total of 3 gas upgrades)
Change
Code:
(TotalExtraIncome[(Killing Player)] % 10) == 0
into
Code:
(TotalExtraIncome[(Killing Player)] % (25 - (5 * (GasUpgrade count for player (Killing Player) counting Complete)))) == 0
So for each level of gasupgrade, it subtracts 5 from 25.

Triggers

- I don't understand this, if you killed 6 units and gets an income of 16, how does the computer knows he must start counting from '0' again when a new 'level' starts?
It didn't. My mistake. I fixed it now. It now knows it since it sets the ExtraIncome variable to 0 when the timer expires.
- How do I program that when 'killing upgrade 1' is done, players get's 2 minerals for every kill? (total of 10 upgrades)
Already answered above.

- The 'if, then else' trigger. If the conditions of the 'if, then else' are not egual, does the trigger runs anyway then? Please explain me more about this 'if, then else'. I mean, a normal basic trigger is already an 'if, then else' am I right?
The if then else action has three parts. The if part, the then part and the else part. You can put other actions inside each part and you'll see that they become a little moved to the left. They're indented.

Now in the if part you can put a condition. This condition is either true or false. If it's true it runs all the actions in the "then" part and it then continues to run all the actions after the if then else action. If the condition is false, it'll run the actions in the else part and then continue to run everything after the if then else.
- How do I create a 'text amount' in a text message which shows the income of players?
I showed this in my trigger.
Code:
Display (Text(amount)) in the subtitle text area for Player Group((Picked Player))
 

MissKerrigan

Active Member
Reaction score
23
grr so hard, I'll try to read this a couple of times and I hope I understand it then

thx anyway for your help !! x
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top