Random Award

MissKerrigan

Active Member
Reaction score
23
Hello it's me again,

I have a simpel question about a value for killing units
When killed a unit, you must earn a random number of minerals between 25 and 50. ( 25-30-35-40-45 or 50)

Does anyone know how I trigger or data this?

MissKerrigan
 

Dave312

Censored for your safe viewing
Reaction score
269
Triggering this should be fairly simple, but it is also possible via data.

In terms of triggers, I assume you're unsure as to how to get the random sequence which is a multiple of 5? To do this, you need to generate a random value and multiply it by your increment, then add your minimum value. You random minimum value needs to be 0 because 0 x 5 + 25 = 25. Your maximum random value should be 5 because 5 x 5 + 25 = 50. As such your code should look like (Random Integer between 0 and 5) x 5 + 25. In the end, your trigger should look like this:
Trigger:
  • Kill Bonus
    • Events
      • Unit - Any Unit dies
    • Local Variables
    • Conditions
    • Actions
      • Player - Modify player (Owner of (Killing unit)) Minerals: Add (((Random integer between 0 and 5) * 5) + 25)


If you or someone else requires a data solution, then let me know and I'll post one.
 

MissKerrigan

Active Member
Reaction score
23
At first, I don't understand how you create that action

As second, I wan't also create a text tag at the place of the killing unit which shows howmuch minerals you earned by killing the unit

I can't create a text tag because I don't howmuch mineral I earn for killing the unit
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
At first, I don't understand how you create that action

As second, I wan't also create a text tag at the place of the killing unit which shows howmuch minerals you earned by killing the unit

I can't create a text tag because I don't howmuch mineral I earn for killing the unit

Create a local integer variable called "Bonus minerals".

Use the action called "Set variable" to set the "Bonus minerals" variable to "(((Random integer between 0 and 5) * 5) + 25)". To do this, use the "arithmetic" function and as value 1, use the arithmetic function again.

You will now have the amount of bonus minerals in the variable "Bonus minerals" so you can use text tags to display it properly. You can then use "Modify player property" action to add "Bonus minerals" to the Killing Player's minerals
 

MissKerrigan

Active Member
Reaction score
23
Is there maybe a way to create 6 trigger actions:

1. modify player resources add 25 ore
2. modify player resources add 30 ore
3. modify player resources add 35 ore
4. modify player resources add 40 ore
5. modify player resources add 45 ore
6. modify player resources add 50 ore

and select 1 random action of these 6?
I really hate this variables, it seems quitte easy to create them but how use them?

I created a variable 'integer' and set the number to 5 but I have really no idea where I can set the quantity of resourses to them and even how to trigger them into a bonus sigh...
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Is there maybe a way to create 6 trigger actions:

1. modify player resources add 25 ore
2. modify player resources add 30 ore
3. modify player resources add 35 ore
4. modify player resources add 40 ore
5. modify player resources add 45 ore
6. modify player resources add 50 ore

and select 1 random action of these 6?
I really hate this variables, it seems quitte easy to create them but how use them?

I created a variable 'integer' and set the number to 5 but I have really no idea where I can set the quantity of resourses to them and even how to trigger them into a bonus sigh...

Right now, it feels like one of the biggest problems you're having is with understanding how variables work. In this post, I'll try to do my best to explain that. It wont be completely relevant to this problem, but hopefully you'll find it useful. Don't try to find work-arounds that allow you to skip learning about variables. They are VITAL. You will most likely have to learn them at some point. Math uses them, programming uses them and the editor uses them.

What is a variable? A variable is just a place to store things that you might not have access to later otherwise. If you create a unit with triggers, you can use the function "Last created unit" to get the newly created unit. This only works as long as this is the last created unit so if we want to save it, we'll have a problem. You can think of it as a box where you put stuff you want to save.

Let's do some basic testing with a variable and how to use one. Create a new trigger called "Variables". Let's skip the event since we're only interested in learning about variables. Right-click>New>New variable(or just Ctrl+B). You now have a new variable. The editor asks for the name and it already has "Untitled 001" as default. Name it "Bonus". There should be a box below it with some information. It should look like this:
1CRTu.jpg

Now, by default this variable is of the "Integer" type. This just means it's a number. It also has a initial value of 0. This means the value stored in this "box" starts as 0. Now, later on I might want to save my height in centimeters(for example). I would set this variable to 200 and now suddenly the value stored in the "box" is 200. I can use the value in the box for different things. I could print out "My height is (Bonus)" (Remember, we named it Bonus) and it would print out "My height is 200".

There's a lot of different options here. I wont talk much about them since they're not important now.

Here are some information that can be good to know but it's not necessary to understand variables right now:
Checking the "Constant" value means the variable will NEVER change. It will be the default value throughout the game , without changing. You sometimes do this so other people reading your code knows that the variable isn't supposed to change. Don't mind this button.

Checking the array makes the variable into the array. This is basically a list with several values. Think of a box with several drawers. You might access the box's first drawer or the second or so on and you can store different values in them.

"Defines default value" just makes sure every other variable starts with the same default value as the one this variable has.
Now let's get into the important stuff. The type explains what kind of data is stored in the box. You can store units, numbers(integers), timers and all kinds of stuff. We'll keep this at "integer".

Now let's first set it to a new value in game(NOT through the initial value) and then we'll use it. Create a new action called "Set Variable". It asks you two things: What box(variable) do you want to put something in? and what do you want to put in it?

We want to use the "Bonus" variable we just created so in the "Variable" parameter, we pick "Bonus". If you don't have any other variables, it should be the only one.

In the "Value" parameter, we'll make it simple. If you open the value parameter, it will have "Value" selected as source.(See below)
Au8K4.jpg


You see, the editor knows you want to store a number since the variable has the "integer" type. There's several ways it can get integer values from. It can just take a normal value like 25 or 10, this is done in the Value source(which is currently selected). It can also take it from another box(variable) or it can take it from a function. We'll get back to this when we want to use our value, but right now we'll make it easy, so input 25 as the value(make sure "Value" is the selected source).

It should now look something like this:
hDRSO.jpg

Now we want to give player 1 the amount of minerals stored in the "Bonus" box. This means Player 1 will receive 25 minerals since we used "Set variable" to set it to 25.

Add the "Modify Player Property" action. It looks pretty good already. Change "Set to" to "Add". The value is 1000 by default by we want it to use the value in our variable "Bonus". Edit the value by clicking on the "1000".

Yet again, we're greeted by the different sources and again it is on the "Value" source initially. Now, do we want to get the value from a function, a variable or just a normal value? The answer is: "Variable", so click the "Variable" source. There'll be a list of all the variables in your map that are either global or local in this trigger. It should at least have the "Bonus" variable that you created earlier. Select it and press "Okay".

It should look something like this:
8j7dc.jpg


That's it. You just learned how to create a variable, set a variable and use the variable. Read through this until you understand it.
 

MissKerrigan

Active Member
Reaction score
23
Thx Siretu! I really learned from this

So if I understand it well, I can use the trigger action 'set variable bonus' every time I want to add a player 25 minerals?

X
 

MissKerrigan

Active Member
Reaction score
23
Pls can you also make a 'step by step' how to create a leaderboard of kills because the way Dave did it confused me a little :)
But I want the leaderboard only for the kills 'nova' does and not the other units

It's importain is this game players can see their kills, it's the only thing in the game what's missing 'Farm Destroyer'
Maybe you can open starcraft II and try this game and tell me what you like of it

MissKerrigan
 

Kyuft

Member
Reaction score
11
So if I understand it well, I can use the trigger action 'set variable bonus' every time I want to add a player 25 minerals?

Actually, every time you want to give a player 25 minerals, you have to use the trigger action "modify player properties" set the type to minerals and the amount to Add Bonus (the variable we made).

-Kyuft:shades:
 

Kyuft

Member
Reaction score
11
Pls can you also make a 'step by step' how to create a leaderboard of kills because the way Dave did it confused me a little :)
But I want the leaderboard only for the kills 'nova' does and not the other units

It's importain is this game players can see their kills, it's the only thing in the game what's missing 'Farm Destroyer'
Maybe you can open starcraft II and try this game and tell me what you like of it

MissKerrigan

Please don't pose more questions after your first is answered. Reply to your leaderboard thread or make a new thread. I'm sorry, but I just want to try and keep this forum organized, especially since it is in the forum rules. Good luck with your maps!

-Kyuft:shades:
 
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