• 🏆 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] Can Anyone Review this trigger

Status
Not open for further replies.
Level 3
Joined
Nov 21, 2016
Messages
30
i can't say if it is correct that will do what i want i tryied to output but it triggers many times to me say

  • Reapers Scythe
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) is A Hero) Equal to True
      • ((Attacking unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Atacker2[(Player number of (Owner of (Triggering unit)))] Equal to No unit
        • Then - Actions
          • Set Atacker2[(Player number of (Owner of (Triggering unit)))] = (Attacking unit)
        • Else - Actions
          • Set Atacker1[(Player number of (Owner of (Triggering unit)))] = (Attacking unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Atacker1[(Player number of (Owner of (Triggering unit)))] Equal to Atacker2[(Player number of (Owner of (Triggering unit)))]
        • Then - Actions
          • Set Atacker1[(Player number of (Owner of (Triggering unit)))] = No unit
        • Else - Actions
      • Wait 30.00 seconds
      • Set Atacker2[(Player number of (Owner of (Triggering unit)))] = Atacker1[(Player number of (Owner of (Triggering unit)))]
      • Set Atacker1[(Player number of (Owner of (Triggering unit)))] = No unit
i need to set 2 unit one its the first attacker the second is the well the second

but when hit 30s it clear

i'm triyng to do i kynda assist system
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
So you want to store the last two units that attacked each player's hero for 30s? The problem is the trigger runs every time the unit is attacked with the 30 second wait happening for every attack, so Atacker1/2 are getting overwritten all over the place. I think a better solution would be to use a periodic trigger to keep track of how long its been since a unit was attacked and remove its attackers from the list after 30 seconds.
  • Events
    • Unit - A unit is attacked
  • Conditions
    • (Attacking Unit) is a Hero
    • (Triggering Unit) is a Hero
    • -------- So you don't get assists on allies --------
    • (Attacking Unit) belongs to an enemy of (Triggering Unit)
  • Actions
    • Set AssistUnit = (Attacking Unit)
    • Set PlayerIndex = (Player number of (Owner of (Triggering unit)))
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • Attacker1[PlayerIndex] = AssistUnit
      • Then - Actions
        • Set AttackerTime1[PlayerIndex] = 0.00
        • Skip remaining actions
      • Else
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • Attacker2[PlayerIndex] = AssistUnit
      • Then - Actions
        • Set AttackerTime2[PlayerIndex] = 0.00
        • Skip Remaining Actions
      • Else - Actions
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • Or - Any Condition is true
          • Conditions
            • AttackerTime2[PlayerIndex] >= AttackerTime1[PlayerIndex]
            • Attacker2[PlayerIndex] = No Unit
      • Then - Actions
        • Set AttackerTime2[PlayerIndex] = 0.00
        • Set Attacker2[PlayerIndex] = AssistUnit
        • Skip remaining actions
      • Else - Actions
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • Or - Any Condition is true
          • Conditions
            • AttackerTime1[PlayerIndex] >= AttackerTime2[PlayerIndex]
            • Attacker1[PlayerIndex] = No Unit
      • Then - Actions
        • Set AttackerTime1[PlayerIndex] = 0.00
        • Set Attacker1[PlayerIndex] = AssistUnit
      • Else - Actions
  • Events
    • Every 0.50 seconds of game-time
  • Conditions
  • Actions
    • For each integer PLAYER_LOOP from 1 to <MAX NUMBER OF PLAYERS> do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (then actions) else do (else actions)
          • If - Conditions
            • Attacker1[PLAYER_LOOP] not equal to No Unit
          • Then - Actions
            • Set AttackerTime1[PLAYER_LOOP] = AttackerTime1[PLAYER_LOOP] + 0.50
            • If (All conditions are true) then do (then actions) else do (else actions)
              • If - Conditions
                • AttackerTime1[PLAYER_LOOP] > 30.00
              • Then - Actions
                • Set Attacker1[PLAYER_LOOP] = No Unit
                • -------- The below line is probably unnecessary --------
                • Set AttackerTime1[PLAYER_LOOP] = 0.00
              • Else - Actions
          • Else - Actions
        • If (All conditions are true) then do (then actions) else do (else actions)
          • If - Conditions
            • Attacker2[PLAYER_LOOP] not equal to No Unit
          • Then - Actions
            • Set AttackerTime2[PLAYER_LOOP] = AttackerTime2[PLAYER_LOOP] + 0.50
            • If (All conditions are true) then do (then actions) else do (else actions)
              • If - Conditions
                • AttackerTime2[PLAYER_LOOP] > 30.00
              • Then - Actions
                • Set Attacker2[PLAYER_LOOP] = No Unit
                • -------- The below line is probably unnecessary --------
                • Set AttackerTime2[PLAYER_LOOP] = 0.00
              • Else - Actions
          • Else - Actions
As a side note, you would probably be better served using a Damage Detection System for your assist tracking, but you would only have to modify a small part of this code to do so.
 
Status
Not open for further replies.
Top