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

Status
Not open for further replies.
Level 6
Joined
Oct 25, 2018
Messages
108
How can I make that when an enemy unit dies, those close to 500 radius, come closer to look at the corpse, but when they are fighting and a unit close to them dies while fighting, do not stop to look, and continue fighting? It happens that I manage to get them to approach the corpse, but when they are in combat every time one of their units dies, they stop to look at the corpse instead of continuing to fight. What I want is that they only see the corpse if they are not fighting.
 
Level 14
Joined
Feb 7, 2020
Messages
387
You will need to post the triggers to get the best help.

upload_2020-4-29_5-31-21.png


Copy as text then wrap in [trigger][/trigger]
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
You need a system that marks units as "fighting" and "not fighting". This way you can differentiate between units in combat and units out of combat.

I threw this together real quick using a Unit Indexer. Replace all instances of Player 2 with your Computer Player.
  • IF Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacking unit)) Equal to Player 2 (Blue)
    • Actions
      • Set VariableSet UDex = (Custom value of (Attacking unit))
      • Set VariableSet IsFighting[UDex] = True
      • Set VariableSet FightDuration[UDex] = 5.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) is in FightingGroup.) Equal to False
        • Then - Actions
          • Unit Group - Add (Attacking unit) to FightingGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (IF Timer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on IF Timer <gen>
        • Else - Actions
  • IF Timer
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in FightingGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • Set VariableSet FightDuration[UDex] = (FightDuration[UDex] - 0.50)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • FightDuration[UDex] Less than or equal to 0.00
                  • ((Picked unit) is alive) Equal to False
            • Then - Actions
              • Set VariableSet IsFighting[UDex] = False
              • Set VariableSet FightDuration[UDex] = 0.00
              • Unit Group - Remove (Picked unit) from FightingGroup.
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FightingGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Look At Corpse
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set VariableSet TempPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 500.00 of TempPoint.) and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 2 (Blue)
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • IsFighting[UDex] Equal to False
            • Then - Actions
              • Unit - Order (Picked unit) to Move To TempPoint
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
 

Attachments

  • Is Fighting.w3m
    24.2 KB · Views: 17
Last edited:
Level 6
Joined
Oct 25, 2018
Messages
108
You need a system that marks units as "fighting" and "not fighting". This way you can differentiate between units in combat and units out of combat.

I threw this together real quick using a Unit Indexer. Replace all instances of Player 2 with your Computer Player.
  • IF Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacking unit)) Equal to Player 2 (Blue)
    • Actions
      • Set VariableSet UDex = (Custom value of (Attacking unit))
      • Set VariableSet IsFighting[UDex] = True
      • Set VariableSet FightDuration[UDex] = 5.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in FightingGroup.) Equal to False
        • Then - Actions
          • Unit Group - Add (Attacking unit) to FightingGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (IF Timer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on IF Timer <gen>
        • Else - Actions
  • IF Timer
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in FightingGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • Set VariableSet FightDuration[UDex] = (FightDuration[UDex] - 0.50)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • FightDuration[UDex] Less than or equal to 0.00
                  • ((Picked unit) is alive) Equal to False
            • Then - Actions
              • Set VariableSet IsFighting[UDex] = False
              • Set VariableSet FightDuration[UDex] = 0.00
              • Unit Group - Remove (Picked unit) from FightingGroup.
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FightingGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Look At Corpse
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set VariableSet TempPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 500.00 of TempPoint.) and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 2 (Blue)
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • IsFighting[UDex] Equal to False
            • Then - Actions
              • Unit - Order (Picked unit) to Move To TempPoint
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
won't let me open the file
upload_2020-4-29_17-31-12.png
 

Attachments

  • upload_2020-4-29_17-30-30.png
    upload_2020-4-29_17-30-30.png
    312 bytes · Views: 22
  • upload_2020-4-29_17-30-33.png
    upload_2020-4-29_17-30-33.png
    312 bytes · Views: 18

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
I use the latest version of the standard World Editor, so you'll need to be up to date to open the map.

You'll need to import this into your map: GUI Unit Indexer 1.4.0.0
UDex = Integer <-- This comes with the Unit Indexer so you don't need to create it yourself
IsFighting = Boolean (Array)
FightDuration = Real (Array)
FightingGroup = Unit Group

Edit:
IMPORTANT!
I made a mistake in the IF Attack trigger.

Instead of "If triggering unit is in FightingGroup equal to False" it should say "if ATTACKING unit is in FightingGroup equal to False". I fixed it in my post above.
 
Status
Not open for further replies.
Top