Killing Value (gas)

MissKerrigan

Active Member
Reaction score
23
Hello,

I want players earn 1 gas every 10 units they killed
Which trigger do I need to make for this?
Can it be one without variables?

I know I already asked this but I can't find my old post anymore

MissKerrigan
 

MissKerrigan

Active Member
Reaction score
23
I watched some older posts and saw the usage of an 'integer' so I tried this
Creating a variable called 'gas bonus player 1' and set it to 'integer'

Now I made a trigger that adds +1 in the integer when a player kills a unit

The only thing which I am not understanding is how to make the trigger-event when the integer is on 10

Somebody help pls?


(I really am starting to learn about variables !!)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
this is an example trigger, it is typed not copied/pasted so dont get mad at me if there are things wrong with it...

Create the global variable <integer> PlayerKills
Check the array box, and set size to the ammount of players in the game

at map init do something like this:

Trigger:
  • Init
    • Events
      • Map Initialization
    • Conditions
    • Local Variables
      • &lt;Integer&gt; x = 0
    • Actions
      • For each integer x from 0 to [Max player number] do actions
        • Loop - Actions
          • Set PlayerKills[x] = 0


then do this:

Trigger:
  • 1 Gas per 10 kills
    • Events
      • A unit dies
    • Conditions
      • Owner of (Killing unit) is an enemy of Owner of (Triggering unit) == true
    • Local Variables
    • Actions
      • Set PlayerKills[Owner of (Killing unit)] = PlayerKills[Owner of (Killing unit)] + 1
      • If, Else if multiple
        • Else If (Conditions)
          • PlayerKills[Owner of (Killing unit)] == 10
        • Then (Actions)
          • Set PlayerKills[Owner of (Killing unit)] = 0
          • Player - Add 1 vespene to Owner of (Killing unit)


As far as variables go just think of a variables like a box, a wierd shaped box, that only fits one type of object because of its shape, for instance an integer variable holds a whole number (no decimals) while a real variable is a number that can have decimals or a floating point number... but because of these awkward shapes that variables holding them have you cant just set a real variable to an integer, but there are conversions allowing you to convert an integer to a real and visa-versa...

There are a few types of variables, but the most commonly used are the following:
  • Units - holds a reference to a unit in the game
  • Integer - a whole number with no decimal
  • Real - a decimal number
  • String - a word or sentence, identified via " symbols
  • Ability - holds a reference to an ability that a unit has
  • Unit Group - a group of units, these are useful for doing 1 thing to many units
  • And many more, generally a variable's type sort of describes it
An example of a variable describing itself would be a String, think of it like a string of yarn, where every inch there is a sticker of a letter, and when put together, it creates a sentence or word or series of characters.
Arrays are just like variables, but unlike normal variables these are a group of variables, where every member of that group is identified by a number, starting at zero, for instance, an array of size 5 has numbers 0-4 in it. Each of these members of this group of variables can be accessed via the bracket operator ([ ]), like so:

<Integer> SomeArrayVariable is an integer variable with 1 dimension of size 5
SomeArrayVariable[0] can be used like a normal integer variable, as can SomeArrayVariable[1 through 4], however, if you actually use the number 5 (the size) it will create an error.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
So basically MissKerrigan, you don't have a trigger event that fires when the variable reaches 10. You check if it's 10 every time that a unit dies.

As for GFreak's explanation, it's good and you should really try to read through it all and understand it.

@GFreak: Is it really necessary to initialize the integer array? If you create a global integer array, it's going to have 0 as its default value anyway. Also, you could use modulo in the second trigger to reduce the amount of actions with 1. It also has the advantage of keeping track of the total amount of kills, which you might want for a scoreboard or something.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
i wasnt sure whether the arrays in sc2 are initialized automatically, in Wc3 if you did not initialize them yourself the thread would crash when it used that specific variable, I forget if it was just local variables that did that or globals too.
 

MissKerrigan

Active Member
Reaction score
23
1. how create a global valuable instead of a normal one?

2. a trigger contains events/variables/conditions/actions, are the variables also a kind of condition?

3. again, where can I set in the event, that if the intereg is on 10, the trigger will run?


I must say that I already found out how to give players income every 10 seconds and increase this by a variable, but it's just a trigger then which increase the integer number + text tag number
 

MissKerrigan

Active Member
Reaction score
23
btw Siretu, if you say that GFreaks his explanations is good, I believe you and will have a few looks on his threat till I get it
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Well there is an event for variables being set to a certain value, but that isnt need, if you look through that trigger, it does 2 things, on an even that a unit dies. If the owner of the killing unit is an enemy of the owner of the dying unit, it adds 1 to the variable, but then after that it checks the variable if it is 10, if it is, it sets the variable back to 0 and gives them the 1 vespene gas, combining the 2 actions into one trigger, if you have any other questions with this just reply here and ill try to clear them up, but please do take the time to go over the large post ^ up there

&@Siretu is there a modulus operator in sc2's language, due to my severe disappointment with the trigger editor I have avoided it at my own peril :p

If there isnt a mod operator you could make a relatively simple mod function:
Trigger:
  • Name: Mod
    • Parameters
      • Value &lt;Integer&gt;
      • Mod &lt;Integer&gt;
    • Return: Integer
    • Hint: Gets the remained of the given integer
    • Text: Mod(Value, Mod)
    • Actions
      • return Value - ((Value/Mod) * Mod)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
read each node 1 by 1, for example, add the event first, then the first action, then the second... there is a search function in the trigger editor that lets you search by name, use it, it will make your life much easier.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I think the mod function confused her. There is a built-in modulo operator in the trigger editor though.

@MissKerrigan: Don't worry about the trigger shown in #8. It's not actually a trigger, but a custom function. You don't need it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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