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

[Trigger] Killing units by clicking bug

Status
Not open for further replies.
Level 4
Joined
Jun 22, 2009
Messages
63
Hey, im working on a fun little minigame where you defend the computer from viruses by clicking on them to deal damage. I have a multiboard showing level, kills and clicks. But sometimes when i kill a unit, it won't give me any kills or even 2 kills. It's realy annoying and i don't know how to fix it. Please help. +rep

  • Damage System
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
    • Conditions
    • Actions
      • Set Clicks = (Clicks + 1)
      • Multiboard - Set the text for Multiboard item in column 3, row 2 to (String(Clicks))
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - 1.00)
  • Kills
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Kills = (Kills + 1)
      • Multiboard - Set the text for Multiboard item in column 2, row 2 to (String(Kills))
 
First of all, that's not MPI. You need it to support Player's 1 and 2 actions at the same time. So, go to the Variable Editor and for the Clicks and Kills variables tick the "Array".
Then, do it like
Set Clicks[Player Number of (Triggering player)] = (Clicks[Player Number of (Triggering player)] + 1)
and
Set Kills[Player Number of (Owner of (Killing unit))] = (Kills[Player Number of (Owner of (Triggering unit))] + 1).

I would also change the first trigger to this:
  • Damage System
  • Events
    • Player - Player 1 (Red) Selects a unit
    • Player - Player 2 (Blue) Selects a unit
  • Conditions
  • Actions
    • Custom script: local unit u = GetTriggerUnit()
    • Set Clicks[Player number of (Triggering player)] = (Clicks[Player number of (Triggering player)] + 1)
    • Custom script: call SetWidgetLife (u, GetWidgetLife(u) - 1)
    • Custom script: set u = null
 
Status
Not open for further replies.
Top