Kills to cash

This article shows various methods of rewarding a player for killing units.
Each of the methods described has uses in certain map making situations.

## Score method 1: reward for killing any unit

When a unit or building is killed, a player earns a fixed amount of kill score points. A list of unit kill scores can be found here.
This score can be detected with the "Score" condition, using "Kills", "Razings", or "Kills and Razings". (When a building is killed, the points go to Razings instead of to Kills.)
The following trigger will reward a player with one mineral when it executes and they have killed at least one unit.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 1.

Actions

* Preserve Trigger.
* Modify score for Current player: Set to 0 Kills.
* Modify resources for Current player: Add 1 Minerals.

This method could potentially work flawlessly if it were used in the right situation, but it does have a few problems.
A player can kill multiple units between trigger cycles (Example: Splash damage kills two units at once) If this happens, the trigger will still only give the player one mineral.
Also, there are many different kinds of units that the player could kill. With this method the player will receive the same reward regardless of what type of unit he kills.

Recommendations for using this method:

* Use Hyper Triggers to increase the accuracy, in case units are killed rapidly, and also to increase the speed that the players are rewarded.
* Try to avoid the possibility of the players killing multiple units at once. (Example: No splash damage)

## Score method 2: reward based on amount of kill score earned

This method will reward the player with one mineral for every 25 kill score points they earn.
Quote

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 25.

Actions

* Preserve Trigger.
* Modify score for Current player: Subtract to 25 Kills.
* Modify resources for Current player: Add 1 Minerals.

Keep in mind that some units will give the player more minerals than others. Killing an Infested Kerrigan will give the player 4000 kill score, whereas killing a Broodling will only give them 25 kills score. Or, from the players perspective, killing Infested Kerrigan is worth 160 minerals while killing a Broodling is worth only 1.
If the players are able to kill many units in a short period of time, the triggers may not be able to reward them fast enough. See below for ways to reduce this possibility.

Recommendations for using this method:

* Use Hyper Triggers to increase the speed that players are rewarded.
* Use higher-value reward triggers to increase the speed that players are rewarded. (Example: Give 4 minerals per 100 kill score)
* Use more reward triggers or binary countoffs to increase the speed that players are rewarded.

## Score method 3: reward based on type of unit killed

In this method you will make one trigger for each unit that can be killed. You will be able to choose the reward amount that each unit gives.
In this example, there are only three types of units that can be killed. Broodlings, Hydralisks, and Infested Kerrigan.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 4000.

Actions

* Preserve Trigger.
* Modify score for Current player: Subtract to 4000 Kills.
* Modify resources for Current player: Add 1 Minerals.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 350.

Actions

* Preserve Trigger.
* Modify score for Current player: Subtract to 350 Kills.
* Modify resources for Current player: Add 5 Minerals.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 25.

Actions

* Preserve Trigger.
* Modify score for Current player: Subtract to 25 Kills.
* Modify resources for Current player: Add 20 Minerals.

This method will not be able to distinguish between units that give the same amount of kill score.
If a player kills multiple units at once they may receive the wrong reward.

Recommendations for using this method:

* Use Hyper Triggers to increase the speed that the players are rewarded.
* Arrange the triggers from highest kill score value to lowest. If you do not, the players may not receive the correct rewards.
* Try to avoid the possibility of the players killing multiple units at once. (Example: No splash damage)
* Use the Deaths and Set Deaths triggers to improve the accuracy:

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current player Kills score is at least 25.
* Foes has suffered at least 1 deaths of Broodling.

Actions

* Preserve Trigger.
* Modify score for Current player: Subtract to 25 Kills.
* Modify resources for Current player: Add 20 Minerals.
* Modify deaths for Foes: Subtract 1 for Broodling.

## Rewards with individual triggers

In this method, the "Kills" condition is used to detect when a player has killed a unit. The kills used by the "Kills" condition are the amount of units killed, rather than the score of the units killed, as was used in the previous method.
This condition makes it very easy to detect exactly what unit the player has killed and reward him for it, but there is a problem. The number of kills cannot be set.
In order for this method to be useful, a large series of triggers will need to be made to detect when a unit is killed.

Imagine a map with 3 zerglings. When a player kills a zergling he should be rewarded with a mineral.
Using this method, the following 3 triggers will be necessary for this to work.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current Player kills at least 1 Zergling.

Actions

* Modify resources for Current Player: Add 1 Ore.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current Player kills at least 2 Zerglings.

Actions

* Modify resources for Current Player: Add 1 Ore.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Current Player kills at least 3 Zerglings.

Actions

* Modify resources for Current Player: Add 1 Ore.

Should you use "Preserve Trigger" on these triggers, it will constantly fire, since no trigger action can modify the fact that the player killed 1 Zergling.
If there is no limit on how many kills the player can make in the map, using this method may not be the best way to do kills to cash.
There are trigger duplication programs available to speed up the creation of large sets of these type of kills to cash triggers. See the files page for trigger duplicators.

Recommendations for using this method:

* Use larger numbers in order to reduce the total amount of triggers necessary. (Example: Give 10 minerals every 10 kills, instead of 1 mineral every kill)

## Rewards based on opponent deaths

When a player kills a unit, their opponent gains one death counter point of the type of the unit killed. For example, if the player kills Zerglings owned by player 8, player 8 will get Zergling death counter points.
The "Deaths" condition can be used to detect when a player has killed an enemy unit, and reward him for doing so.
The following trigger rewards the player for each player 8 Zergling that is killed.

*StarCraft* Trigger [template]
Players

* [Force]

Conditions

* Player 8 has suffered at least 1 deaths of Zerg Zergling.

Actions

* Preserve trigger.
* Modify death counts for Player 8: Subtract 1 for Zerg Zergling.
* Modify resources for Current Player: Add 1 ore.

Make sure to use the "Set Deaths" action to remove the death counter point.

Recommendations for using this method:

* Remember that this detection method cannot tell you what player killed the unit.
* Use this method for a single player game, or for a game where all players are rewarded equally when a kill is made.

## Unit count method

This method allows for precise individual tracking of kills against the same player, so long as they are separated by location. You need an arena (or several) where units can only enter and exit via triggers, and can only be killed by 1 player. To implement this system, create and constantly maintain a count of actual and expected units in the arena, then award cash whenever the actual unit count is lower than expected. Put the number of actual number of units into a DC, and compare it to the number of expected units using binary countoffs.

## "Perfect" kills to cash version 1

This method is called perfect because it can be used to accurately track kills with relatively few trade-offs.
It essentially combines Score Method 3 and Rewards based on opponent deaths. The downside of Score Method 3 is that you can't accurately track which units have been killed, so killing four Marines in the same frame will give you the same result as killing one Goliath. So, to fix that, we also track opponent deaths.

*StarCraft* Trigger [template]
Players

* Computer Player 8

Conditions

* Player 8 has suffered at least 1 deaths of Terran Goliath
* Player 1 has at least 400 Killscore.

Actions

* Modify death counts for Player 8: Subtract 1 for Terran Goliath
* Modify Player 1 Killscore: Subtract 400
* (Do whatever, add minerals or experience points)

Now, in order to correctly track everything, including splash damage, we need to make sure that sufficient killscore and deaths are subtracted in the same trigger cycle. To do so, we need to order our triggers correctly and use a binary system of subtracting killscore. So we would first place at the top of our triggers the highest killscore unit: the Overmind. We can scale our system for however much splash kills we think may happen. So for example, if you think that at most only 15 units will ever be killed in the same frame, then you would have a trigger sequence like this:

*StarCraft* Trigger [template]
Players

* Computer Player 8

Conditions

* Player 8 has suffered at least 8 deaths of Zerg Overmind
* Player 1 has at least 80,000 Killscore.

Actions

* Modify death counts for Player 8: Subtract 8 for Zerg Overmind
* Modify Player 1 Killscore: Subtract 80,000
* (Do whatever, add minerals or experience points)

*StarCraft* Trigger [template]
Players

* Computer Player 8

Conditions

* Player 8 has suffered at least 4 deaths of Zerg Overmind
* Player 1 has at least 40,000 Killscore.

Actions

* Modify death counts for Player 8: Subtract 4 for Zerg Overmind
* Modify Player 1 Killscore: Subtract 40,000
* (Do whatever, add minerals or experience points)

*StarCraft* Trigger [template]
Players

* Computer Player 8

Conditions

* Player 8 has suffered at least 2 deaths of Zerg Overmind
* Player 1 has at least 20,000 Killscore.

Actions

* Modify death counts for Player 8: Subtract 2 for Zerg Overmind
* Modify Player 1 Killscore: Subtract 20,000
* (Do whatever, add minerals or experience points)

*StarCraft* Trigger [template]
Players

* Computer Player 8

Conditions

* Player 8 has suffered at least 1 deaths of Zerg Overmind
* Player 1 has at least 10,000 Killscore.

Actions

* Modify death counts for Player 8: Subtract 1 for Zerg Overmind
* Modify Player 1 Killscore: Subtract 10,000
* (Do whatever, add minerals or experience points)

Then you would have a trigger for Overmind (with shell), and so on and so forth through the different kill scores down to the lowest amount of kill score.

Cons:
The only one I can think of is the rare occurrence of two players killing different amounts of units with the same resultant killscore (Player 1 kills 4 marines, Player 2 kills 1 Goliath, in the same frame, Player 1 would be given the experience from killing a Goliath even though he didn't kill a Goliath, and Player 2 would be given the experience from killing 4 marines, even though he didn't kill 4 marines).

## "Perfect" kills to cash version 2

The basic idea behind the entire is system is as follows:
There is a computer player, which is the "score keeper", used to detect when a player kills a unit. The Most Kills condition is used to make this work.
When the map starts the score keeper is allowed to kill one unit so he has the "most kills".
Later, when a player kills a unit, their kills goes up one. When this happens the player now has the "most kills" status as well. (When two players have the same amount of kills they both have the "most kills")
A trigger executes for the player with the "most kills" that gives him a reward, and then gives all the other players who didn't get one mineral one kill. This includes the score keeper.
(To give the players a kill, an actual unit must be created for them to kill. This is usually done by creating a weak enemy unit near a Photon Cannon that the player controls)
Since all of the other players have been given a kill, they should all be even again, except the score keeper who has one more than the players.

The computer score keeper needs to have one more kill than the other players.
This trigger simply sets a death counter for the computer score keeper. We will use this counter to create units for the players and score keeper to kill.

*StarCraft* Trigger [template]
Players

* Computer Player

Conditions

* Always

Actions

* Modify death counts for Score Keeper: Set to 1 for CreateUnit

This trigger uses the death counter to create units that will be killed by the players.
In your map, you will need an area set aside for your players to kill the units you create. In this example, we have a Photon Cannon for each player which we create an enemy unit beside of. The player's cannons should kill these unit automatically.

*StarCraft* Trigger [template]
Players

* All Players

Conditions

* Current player has suffered at least 1 deaths of CreateUnit

Actions

* Preserve trigger
* Modify death counts for Current player: Subtract 1 for CreateUnit
* Center location labeled 'UpdateKills' on 'Photon Cannon' owned by Current Player at 'Anywhere'
* Create 1 Zergling at 'UpdateKills' for (enemy player)

This is the trigger that detects when a player kills a unit and rewards them for it.
The CreateUnit counter is set for all of the other players in order to re-balance the kill amounts.

*StarCraft* Trigger [template]
Players

* Human Player

Conditions

* Elapsed scenario time is at least 1 game seconds.
* Current player has most kills of any unit.
* All Players has suffered exactly 0 deaths of CreateUnit.
* (enemy player) brings exactly 0 units to (area where the cannons are).

Actions

* Preserve trigger.
* Modify death counts for All Players: Add 1 for CreateUnit.
* Modify death counts for Current player: Subtract 1 for CreateUnit.
* Modify resources for Current player: Add 1 Minerals.

Minerals will only be added as fast as the Most Kills counter is updated, which could be a long time if large numbers of units are killed.

Recommendations for using this method:

* Use Hyper Triggers to increase the speed that the players are rewarded.
* Instead of cannons, use a unit that can kill faster (e.g. Archon), to speed up the kills-updating process.
* Try new things. Despite its name, this system can be improved easily.

Sample Maps
http://www.staredit.net/maplantis/index.php?map=723
Possible Improvements
This alternative method does not use Death Counts, and will give a different amount of minerals or other types of rewards for each separate unit type killed. Its fundamental core is the exact same as the one listed above, but since there are several different rewards to be given, a Move Unit trigger replaces the Death Counts. The main benefit of this alternative method is the need for less triggers to achieve the same objective than using Death Counts.

Just like the existing Perfect method, this system uses a computer player as the "Leader", who will always have 1 more kill in every type of enemy unit (for simplicity, "Monster") that the human players (for simplicity, "Heroes") will need to kill. Whenever a Hero kills a certain type of Monster, he will have the same number of Kills (not to be confused with Kill Score, which is entirely different) as the Leader does. This is detected through the Most Kills condition (not to be confused with the Score: Kills condition), and we will award that Hero some gold, experience, etc. Now we reset the state of the Perfect KTC system by letting all the Heroes and the Leader -- EXCEPT the Hero who was just awarded -- kill that same Monster unit. The non-trigger parts of this system are also important, since you need to isolate an area to let the Kill Update process be completed. In addition, when the game starts, the Leader will immediately kill 1 of every unit so it will have that +1 Kill advantage.

Preparation:
Players: Let the Leader be P8 and a Computer, the Monsters are P7 and another Computer, and P1-P4 are Heroes and Human controlled. P1-4 and P8 are unallied with P7.

Terrain + Units: all Heroes and the Leader each owns a Photon Cannon. Another damage-dealing unit will also work, but Photon Cannons are an obvious choice because they are stationary, attack both Air and Ground, and are Detectors (in other words, they will kill everything). These Cannons need to be spread apart far enough so that one Cannon cannot be within attacking range of another. Lastly, place 1 of each type of Monster (1 Zergling, 1 Hydralisk, etc.) within range of the Photon Cannon owned by the Leader and set their HP to 1%.

Locations: "Moveto" (any size) and "Movefrom" (needs to be big enough to cover many units). "Moveto" can be placed anywhere. "Movefrom" needs to be in an isolated area that also has to be quite big. "Update" is a location that covers all the Photon Cannons mentioned above.

Step-by-step Triggers & Explanations:
1) After the map starts for a few seconds and before any trigger runs, the kills are as follows: Leader- 1 Zergling, 1 Hydralisk, etc.; Heroes- 0 Zergling, 0 Hydralisk, etc. Of course, you don't need to use Zerglings or Hydralisks, this is just an example.

2) A Hero kills a Zergling. We'll say it's P3, though this trigger will take care of all of them. Now the kills are as follows: Leader- 1 Zergling, 1 Hydralisk, etc.; P3- 1 Zergling, 0 Hydralisk, etc.; All Heroes except P3- 0 Zergling, 0 Hydralisk, etc.

*StarCraft* Trigger [template]
Players

* Heroes (all of them)

Conditions

* Current Player has Most Kills for: Zergling
* All players bring exactly 0 Men to "Update"

Actions

* Set resources/score or whatever reward you want. You can also play a Wav sound to enhance the map
* Create 1 Zergling for Heroes at "Movefrom"
* Create 1 Zergling for Leader at "Movefrom"
* Remove 1 Zergling for Current Player at "Movefrom" (in this example, for P3)

3) Now we move the newly created Zerglings so they go to each person's Cannon. Each player's kills are still the same as Step 2 until the Cannons attack and kill the Zerglings.

*StarCraft* Trigger [template]
Players

* Heroes (all of them - in this example, it won't run for P3) and the Leader

Conditions

* Current player brings at least 1 men to "Movefrom"

Actions

* Preserve Trigger.
* Move location "Moveto" on Photon Cannon owned by Current Player at "Update"
* Move all men for Current Player at "Movefrom" to "Moveto"
* Give all men owned by Current Player at "Moveto" to P7
* Modify unit HP for all men owned by P7 at "Update": set to 1%

4) After a few seconds, the Kills change to this: Leader- 2 Zergling, 1 Hydralisk, etc.; All Heroes including P3- 1 Zergling, 0 Hydralisk, etc. As you can see, Leader regains his lead, and P1-P4 have the same number of Kills again

5) Repeat the trigger from Step 2) for all other Monster types

Recommendations for using this method:

* To conserve space, use the Leader's own Photon Cannon space to serve the function as "Movefrom". Make sure that P8 allies the other players so he won't kill their Monsters with his Photon Cannon before those Monsters are moved to each player's own space.
* Use Hyper Triggers to increase the speed that the players are rewarded.
* Instead of cannons, use a unit that can kill faster (e.g. Archon), to speed up the kills-updating process.