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

[Solved] Hostile behavior

Level 7
Joined
Oct 6, 2022
Messages
135
Is it possible to make a hostile fight each other if they are not the same type of unit?
For example:
Hostile Wildkin vs Hostile Spider
Hostile Trolls vs Hostile Wildkin
Hostile Spider vs Hostile Trolls
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,542
That's pretty difficult, if you give them different owners maybe but then you're limited to how many Player slots you have available. Plus you may not get the same Neutral Hostile perks.

First idea that comes to mind:
  • All of the Units are owned by Neutral Hostile.
  • You contain them in a Unit Group and periodically check around them for non-self threats.
  • If a unit finds a threat, order the two units to attack one another.
  • When a Player's units are nearby they will prioritize that over one another.
Potential issues:
  • They won't cast any spells on one another.
  • Weird unit behavior from time to time.
  • Inefficient if a lot of units.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,542
Here's what I came up with, it seems to work but I didn't test it too thoroughly:
  • NTS Init
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set NTS_Source_Group = (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is alive) Equal to True)))
  • NTS Attack Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in NTS_Source_Group and do (Actions)
        • Loop - Actions
          • Set NTS_Source = (Picked unit)
          • Set NTS_CV = (Custom value of NTS_Source)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (NTS_Battle_Target[NTS_CV] is alive) Equal to False
            • Then - Actions
              • Set NTS_Source_Type = (Unit-type of NTS_Source)
              • -------- --------
              • -------- Get nearby neutral hostile units: --------
              • Set NTS_Point = (Position of NTS_Source)
              • Set NTS_Target_Group = (Units within 600.00 of NTS_Point matching ((((Unit-type of (Matching unit)) Not equal to NTS_Source_Type) and ((Owner of (Matching unit)) Equal to Neutral Hostile)) and (((Matching unit) is alive) Equal to True)).)
              • -------- --------
              • -------- Get a random one of these units to attack: --------
              • Set NTS_Target = (Random unit from NTS_Target_Group)
              • Set NTS_CVT = (Custom value of NTS_Target)
              • -------- --------
              • -------- Link them together: --------
              • Set NTS_Battle_Target[NTS_CV] = NTS_Target
              • Set NTS_Last_Owner[NTS_CV] = Neutral Hostile
              • Set NTS_Battle_Target[NTS_CVT] = NTS_Source
              • Set NTS_Last_Owner[NTS_CVT] = Neutral Hostile
              • -------- --------
              • -------- Literally make them attack one another: --------
              • Unit - Order NTS_Source to Attack NTS_Target
              • Unit - Order NTS_Target to Attack NTS_Source
              • -------- --------
              • -------- Prevent the two from being picked in this same loop again: --------
              • Unit Group - Add NTS_Source to NTS_Source_Backup_Group
              • Unit Group - Add NTS_Target to NTS_Source_Backup_Group
              • Unit Group - Remove NTS_Source from NTS_Source_Group.
              • Unit Group - Remove NTS_Target from NTS_Source_Group.
              • -------- --------
              • Custom script: call RemoveLocation (udg_NTS_Point)
              • Custom script: call DestroyGroup( udg_NTS_Target_Group )
            • Else - Actions
              • -------- This will make a neutral unit revert back to attacking other neutrals after enough time has passed: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • NTS_Reset_Counter[NTS_CV] Greater than 0
                • Then - Actions
                  • Set NTS_Reset_Counter[NTS_CV] = (NTS_Reset_Counter[NTS_CV] - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • NTS_Reset_Counter[NTS_CV] Equal to 0
                    • Then - Actions
                      • Set NTS_Battle_Target[NTS_CV] = No unit
                    • Else - Actions
                • Else - Actions
      • -------- --------
      • -------- Add the units back to the source group: --------
      • Unit Group - Pick every unit in NTS_Source_Backup_Group and do (Actions)
        • Loop - Actions
          • Set NTS_Source = (Picked unit)
          • Unit Group - Remove NTS_Source from NTS_Source_Backup_Group.
          • Unit Group - Add NTS_Source to NTS_Source_Group
  • NTS Attack Priority
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacked unit)) Equal to Neutral Hostile
      • (Owner of (Attacking unit)) Not equal to Neutral Hostile
    • Actions
      • Set NTS_Source = (Attacking unit)
      • Set NTS_Target = (Attacked unit)
      • Set NTS_CV = (Custom value of NTS_Target)
      • -------- --------
      • -------- This makes the neutral unit focus the Player units instead: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • NTS_Last_Owner[NTS_CV] Equal to Neutral Hostile
          • (NTS_Battle_Target[NTS_CV] is alive) Equal to True
        • Then - Actions
          • Unit - Order NTS_Target to Stop.
          • Set NTS_Last_Owner[NTS_CV] = (Owner of NTS_Source)
          • -------- --------
          • -------- (Optional) Make the target of this unit also stop: --------
          • Unit - Order NTS_Battle_Target[NTS_CV] to Stop.
          • Set NTS_CVT = (Custom value of NTS_Battle_Target[NTS_CV])
          • Set NTS_Last_Owner[NTS_CVT] = (Owner of NTS_Source)
          • Set NTS_Battle_Target[NTS_CVT] = NTS_Source
          • Set NTS_Reset_Counter[NTS_CVT] = 3
        • Else - Actions
      • Set NTS_Battle_Target[NTS_CV] = NTS_Source
      • -------- --------
      • -------- This is how many seconds the unit will focus players after being attacked by a player (assuming your loop runs once per second): --------
      • Set NTS_Reset_Counter[NTS_CV] = 3
  • NTS Remove Dead
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Unit Group - Remove (Triggering unit) from NTS_Source_Group.
      • Set NTS_Battle_Target[(Custom value of (Triggering unit))] = No unit
I'm sure it could be made more efficient but I'm not really in the mood to make a whole robust system.

The triggers require a Unit Indexer system to function properly and the map requires the latest patch to open.
 

Attachments

  • Neutral Tribe System 1.w3m
    25.9 KB · Views: 0
Last edited:
Top