• 🏆 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 an Trigger (Killing count system)

Status
Not open for further replies.
Level 3
Joined
Nov 25, 2013
Messages
31
Hey! so i have this idea for a feature in a map i'm working on and i decided to try to copy an old trigger i got from another project some years ago but it dosen't work quit as i want it to at the moment and i have very little experience when it comes to this type of triggers.

How i want it to work:
- When a player kills a unit it starts counting them, one kill= one sacrefice in this case. When the player has killed let's say 25 units they get a message they can research a research that requires 25 kills and then it goes on to 50, 75 100


At the moment it works somewhat, but it's not correct on the kills and after it reaches it's first research it dosen't require 25 more kills in this case for next research but only 1.

Here is the trigger that i was given a few years back and tried to replicate somewhat
count.png
 
Level 22
Joined
Feb 26, 2008
Messages
891
Based on what you've described, you shouldn't need this many variables or a hashtable involved. Really all you need is an integer to count the kills. See if this makes sense:

  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Killing unit)) Equal to Player 7 (Green)
    • Actions
      • Set VariableSet killCount_Green = (killCount_Green + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • killCount_Green Equal to 25
        • Then - Actions
          • -------- Cool Stuff --------
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • killCount_Green Equal to 50
        • Then - Actions
          • -------- More Cool Stuff --------
        • Else - Actions
 
Level 3
Joined
Nov 25, 2013
Messages
31
Based on what you've described, you shouldn't need this many variables or a hashtable involved. Really all you need is an integer to count the kills. See if this makes sense:

  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Killing unit)) Equal to Player 7 (Green)
    • Actions
      • Set VariableSet killCount_Green = (killCount_Green + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • killCount_Green Equal to 25
        • Then - Actions
          • -------- Cool Stuff --------
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • killCount_Green Equal to 50
        • Then - Actions
          • -------- More Cool Stuff --------
        • Else - Actions
That did it! thank you very much
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,517
If you're going to implement Ghan's example into your map then you should definitely use Arrays.
  • Example
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Owner of (Killing unit)))
      • Set VariableSet KillCount[PN] = (KillCount[PN] + 1)
In most cases you can replace variables like "RedVariable" or "BlueVariable" with an Array, using that Player's Number as the Index.

KillCount[1] = Player 1's Kills
KillCount[2] = Player 2's Kills
KillCount[3] = Player 3's Kills
etc...
 
Status
Not open for further replies.
Top