• 🏆 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!

Add up how many units....

Status
Not open for further replies.
Level 9
Joined
Aug 11, 2007
Messages
429
Hey guys, I'm looking for 2 triggers.

When a player types "-kills" and the game will display how many enemy units they have killed.
And when a player types "-losses" it will tell them how many units they have lost.

Can anyone help? +rep for help
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This updates kills and deaths:

  • Untitled Trigger 005
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
      • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
This displays kills:

  • Untitled Trigger 006
    • Events
      • Player - Player 1 (Red) types a chat message containing -kills as An exact match
      • Player - Player 2 (Blue) types a chat message containing -kills as An exact match
      • Player - Player 3 (Teal) types a chat message containing -kills as An exact match
      • ...
    • Conditions
    • Actions
      • Set Temp_Player_Group = (Player group((Triggering player)))
      • Game - Display to Temp_Player_Group the text: (String(Kills[(Player number of (Triggering player))]))
      • Custom script: call DestroyForce(udg_Temp_Player_Group)
Displaying deaths is similar.

You can use concatenate string to print more than the number on the sccreen.
 
Level 9
Joined
Aug 11, 2007
Messages
429
I can't get Deaths to work. Could you post that trigger for me? And then what type of condition do I need to prevent players from killing their own units to boost the stats?
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
I can't get Deaths to work. Could you post that trigger for me? And then what type of condition do I need to prevent players from killing their own units to boost the stats?

Deaths display would be:

  • Untitled Trigger 006
    • Events
      • Player - Player 1 (Red) types a chat message containing -losses as An exact match
      • Player - Player 2 (Blue) types a chat message containing -losses as An exact match
      • Player - Player 3 (Teal) types a chat message containing -losses as An exact match
      • ...
    • Conditions
    • Actions
      • Set Temp_Player_Group = (Player group((Triggering player)))
      • Game - Display to Temp_Player_Group the text: (String(Deaths[(Player number of (Triggering player))]))
      • Custom script: call DestroyForce(udg_Temp_Player_Group)
Preventing killing own units:

  • Blah
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • ((Owner of (Triggering unit)) is an ally of (Owner of (Attacked unit))) Equal to True
          • (Owner of (Triggering unit)) Equal to (Owner of (Triggering unit))
    • Actions
      • Unit - Order (Triggering unit) to Stop
Also prevents player to attack/kill their allies.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^Check the condition ;)

You could do it like this, if you don't want to prevent units from attacking allies:

  • Untitled Trigger 005
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
        • Then - Actions
          • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
        • Else - Actions
      • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
 
Level 9
Joined
Aug 11, 2007
Messages
429
Events
Unit - A unit Dies
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
Then - Actions
Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
Else - Actions
Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)


That's what I have to adding up the Killed units, and deaths still remain at 0. Here is the function to display the deaths:
Events
Player - Player 1 (Red) types a chat message containing -deaths as An exact match
Actions
Set Tally_Group = (Player group((Triggering player)))
Game - Display to Tally_Group the text: (Units Lost: + (String(Deaths[(Player number of (Triggering player))])))
Custom script: call DestroyForce(udg_Tally_Group)
 
Level 5
Joined
May 3, 2009
Messages
129
well look at the trigger he posted
  • Events
  • Unit - A unit Dies
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
  • Then - Actions
  • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
  • Else - Actions
  • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
when it should be
  • Events
  • Unit - A unit Dies
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
  • Then - Actions
  • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
  • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
  • Else - Actions
 
Level 9
Joined
Aug 11, 2007
Messages
429
  • Events
    • Unit - A unit Dies
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
      • Then - Actions
        • Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + 1)
      • Else - Actions
        • Set Deaths[(Player number of (Owner of (Triggering unit)))] = (Deaths[(Player number of (Owner of (Triggering unit)))] + 1)
That's what I have to adding up the Killed units, and deaths still remain at 0. Here is the function to display the deaths:
  • Events
    • Player - Player 1 (Red) types a chat message containing -deaths as An exact match
  • Actions
    • Set Tally_Group = (Player group((Triggering player)))
    • Game - Display to Tally_Group the text: (Units Lost: + (String(Deaths[(Player number of (Triggering player))])))
    • Custom script: call DestroyForce(udg_Tally_Group)
Here is it in trigger form. So what should I do?

Edit: Nevermind, misread an earlier post. Fixing it now.
 
Status
Not open for further replies.
Top