Kill to Cash

From HIVE
Revision as of 23:59, 25 November 2010 by DevliN (talk | contribs) (Addded Data Editor category)
Jump to navigation Jump to search

Kill to Cash systems are used to award resources to a player for killing an enemy unit. In StarCraft 1, this was primarily done through the use of Triggers and "Kill Score." In StarCraft II, we have the option to do this easily through the Data Editor as well. Examples of both methods are below.

Kills to Cash with the Data Editor

Go into the Data Editor (F7) and under "Data Type:" select "Units." Select the unit that you want to award resources for killing.

  • In the box on the right, find "Combat - Kill Resource" and double-click the space on the right to open an Object Values window.
  • Select any of the resources and change the value to what you want the reward to be for killing this unit.
  • Click "OK" to close the window.

Congratulations, you will now resources when you kill this unit.


Kills to Cash with Triggers

Basic Theory

Basically, what we want is to detect whenever a Unit Dies, and make sure it's an enemy for the player we run the trigger for. This requires two things:

  • Event: Any Unit Dies
  • Condition: Triggering Unit's Owner == Player from Unit Group "Enemies"


Then, while there are multiple ways to obtain such a system, this tutorial will use two different Variables:

  • Local Variable: Currency = 12 <Integer>
Please take note that this value (12) has been chosen arbitrary.
  • Global Variable: Score = 0 <Integer[5]>
To know why there are 5 arrays while there are only 4 players, see General_Mapping_Tips#The_Array_Trick.


For the rest of the trigger (actions), the different "sections" will be highlighted (and you can see the final result in the "Trigger Reference" section).


Changing the Currency value based on the difficulty

In this case, the difficulty value will be determinated by the number of players that are in-game.

Basically, we want to use the "Modify Variable (Integer)" action to multiply the "Currency" variable by an arbitrary number. We'll also use an "If-Then-Else": "Ifs" will use a Comparison of the "Number of Player in Player Group", using the "Active Players" Player Group.

Store Kill Score into a Variable

For each player, you'll want to use a "Set Variable" to store their individual "Kill Score" in an array corresponding to each player. This requires you to use the "Player Score Value (Integer)" Function and set the Score value to be "Total Unit Score".

Rewarding players

You can decide to reward players based on different conditions. See the Trigger Reference section just below and read the comments inside the last "Pick Each Integer" loop: they explain pretty well how this part of the trigger works.


Trigger Reference

This commented trigger has been taken from the Open Source project "Swarmed Heroes".

Kill to Cash trig.png


Adjustments

If you want to adjust the number of Score points the death of a unit gives to a player, you'll want to modify the "Stats - Score - Kill" field value to whatever you want. This field can be found in the Data Editor under the "Units" tab. Each different unit has its own Kill Score.