• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

help with a simple trigger PLZ!!!

Status
Not open for further replies.
Level 3
Joined
Dec 2, 2005
Messages
25
i need help with a trigger. This is the only trigger i cant seem to figure out.

i need a trigger that makes it whenever a player kills 25 units it gets a unit.

it sounds so easy yet i can find any trigger that fits it!! plz help

deso
 
Level 5
Joined
Nov 14, 2004
Messages
159
Only 25 and nothing more? which player? Not enough info.

I'll give you basic - this will work for any players and will happen every 25 units killed (all kind of units). You need to create variable, click on button look like yellow X in trigger screen. Then add new variable by clicking green "+X" button, give it a name lets say "unitkilled" and variable type is "Interger."

Then with trigger.

Code:
    Events
        Unit - A unit Dies
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                unitkilled Less than 25
            Then - Actions
                Set unitkilled = (unitkilled + 1)
            Else - Actions
                Set unitkilled = 0
                Unit - Create 1 ...
 
Level 6
Joined
Feb 18, 2005
Messages
263
i would do it quite like that, but with a small modification:

event:
- a unit dies
cond:
act:

- set Kills[PlayerNumber(OwningPlayer(KillingUnit))] = Kills[...] + 1
- if
- - Kills[...] % 25 = 0 (% means modulo)
- then
- - <do the reward>


modulo is a math operator that returns the rest of a division through a number.
e.g.
3%2 = 1
5%2 = 1
4%2 = 0
16%7 = 2
...


using a module has the advantage of beeing able to grant another reward every larger anount of kills
(simply add another if with an Kills[]%#...)

and by using an array you have the advantage of having the kills stored for all players in only one variable, keeping your code clean ^^

the only disadvantage on the code, as it is above is, that it also works for all the neutral players
(simply add cond: Playernumber(Owner(KillingUnit)) <= 12 - there are only 12 human-player slots)


i hope this helps you ^^
(and no offence to haloboycs - your code is fine, even though it works only for one player ^^)
 
Status
Not open for further replies.
Top