Guide to make an Easy kill counter
| ===================== |
1. IntroductionA few months ago, I developed two trigger members* (1 condition and 1 effect) to make a Stat Value counter using only one trigger. (You hear that? One!) The two trigger members came with the SNXT2 (Some New X Triggers 2), composed by Reyk. I explained how to use it dozens of times in various threads, but my posts about this feature were mostly ignored. That's why all of you can now read about this amazing solution in a new guide.*Trigger members: a term I created that covers both conditions and effects.
2. Requirements
- AoM:TT (Chocolate).
- A little Quest Var knowledge. (Try this good guide by DrNick.)
- Some New X Triggers 2.
- QV Set Stat Value (effect) and QV Stat Value (condition). These come with SNXT2, but some people may have got it from me personal.
3. TheoryLet's say you want to grant a player something if he has killed a certain amount of units. No problem, you can use Stat Value -> kills. That's simple.Let's say you want to grant a player something every 10 kills that he makes. That's tricky, and it requires a complex solution with lots of OR-red conditions. If you want to start counting at a certain point in the gameplay (and not from the start), you certainly have a problem.
But not anymore! The solution to this problem lies in the combination of Stat Values and Quest Vars.(The following information is not fool-proof and is only useful if you can fully understand the way a trigger works.)This is the simplified* code of the normal Stat Value condition:
IF stat equals x THEN [effects]
stat is the current stat of the player (e.g. Kills). x is the count you fill in in the condition. If you want something to happen if the player's kill count equals 200, the trigger will work if stat equals 200.The problem is that you have to give an absolute value as x (a number that is defined during designing and not during gameplay). But what we want is this: the trigger must work if x is 10 more than the previous kill count.I found a way to accomplish that. It would make the code like this:
IF stat - p is-equal-or-greater-than x
THEN
[effects]
[update p]
stat is again the current stat value count (Kills in our example, x is the repetitive value ("every x kills...") and p is the previous kill count! And in my solution, it is a Quest Var. Before the counter is started, the Quest Var will be updated so that it contains the number of kills at that point of the gameplay. The special condition in the looping trigger will constantly check if the actual kill count minus the previous registered kill count is the value that the designer filled in (it's 10 in our example). Of course, a higher value will be counted too (if the player kills 2 guys at once and the kill count doesn't 'hit' 10). (Remember: actual kill count - previous registered kill count = kill count since registration!) In the same trigger is an effect that updates the Quest Var to the current kill count.
QV Stat Value is the condition that checks the stat as described before. It uses a Quest Var (that I like to call Point Zero) as p, the previous kill count.
QV Set Stat Value** is the effect that can update the Point Zero Quest Var. In general, it gives a Quest Var the value of a Stat Value.Let's get practical - if you don't get the theory, don't worry, the actual trigger is very easy.
*Of course, the real code is much more complicated.
**A better name is QV Set as Stat Value; the effect doesn't actually set the Stat Value or something.
4. Let's make the triggerIf you didn't read the theory (or just scanned it over) but are good at triggers, please read and try to understand it now.
This is the trigger scheme. NOTE: The first trigger is optional: use it only if you start the counter "somewhere in the game" and not from the start of the game.
TRIGGER 1 (Optional)Conditions[What you like - the conditions to start the counter, for example]Effects
- QV Set Stat Value
- QVName: The name for your Quest Var that will remember the previous kill count. I suggest "PointZero", but the name is free, of course.
- Player: The player you want.
- Stat Type: Any type you want, but most common Kills.
- Fire Event
Trigger 2
TRIGGER 2
LoopConditions
- QV Stat Value
- Player: The player you want.
- Stat Type: Any type you want, but most common Kills.
- Operator: Use >=.
(If you've read the theory: >= stands for is-equal-or-greater-than. You can use other operators too: that could give things like "IF stat - p is lower than x THEN".)
- QV Point Zero: The Quest Var that you use to remember the previous kill count (same as in Trigger 1).
(The p in the theory.)
- Value: The kill count you want the condition to check ("Every x kills...").
(The x in the theory.)
- Timer
(I suggest 1 second.)
Effects
- [All the effects you want]
- QV Set Stat Value
- QVName: Same Quest Var as used in the QV Stat Value condition.
- Player: Same player as used in the QV Stat Value condition.
- Stat Type: Same stat as used in the QV Stat Value condition.
The effects of the trigger could e.g. modify a protounit or grant other units. Remember, these effects are executed every x kills that the player makes.
5. AdvancedThere are various other things you can do using this technique besides a kill counter.
Examples:
- You can count other stats as well.
- You can use a different operator than >=.
- You can make something random happen using a random Quest Var.
6. ConclusionThe theory behind the easy kill counter is a bit complicated. The practical use, however, is quite simple. If you just use the trigger scheme, your counter is ready. Remember: it's only one trigger! If you have any additions, please post it.
Happy designing,
Oddy.
A condition is not a trigger.
An effect is not a trigger.
A trigger is a combination of one or more conditions and effects.
It causes effects to happen if and when conditions are met.
Period.
[This message has been edited by oddy (edited 08-16-2004 @ 04:01 AM).]