• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Event: unit enters radius of generic unit of player

Level 2
Joined
Dec 20, 2022
Messages
4
Hello. My idea is to make creeps that actually flee when units of other players approach them. Like a deer herd for instance, they don't just stand there awating for an attack, they run away before. I managed to make this work using the event: unit enters radius of specific unit, but I would like a way to do it in a generic manner, so I don't have to pick specific units for the trigger to work.

Also is there a way to do something like "visible" unit enters the radius of generic unit of player. To make the creeps flee only if the other unit is visible to the neutral hostile player.

Thanks in advance.
 
Level 21
Joined
Aug 29, 2012
Messages
882
I think you should be able to do that with the "add event" function

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Neutral Hostile) and (((Matching unit) is A structure) Equal to False))) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Flee Trigger <gen> the event (Unit - A unit comes within XXX of (Picked unit))
This should register all neutral hostile units as events for your trigger

As for the visibility thing, there is this boolean:

  • (Peasant 0000 <gen> is visible to Player 1 (Red).) Equal to True
I've run a mini test by placing an enemy peasant up a cliff without me being able to see it and it returned false, so I think it'll do the trick?
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,714
Here's a simple system I came up with that relies on detecting an Autocast ability.

Basically, the Flee-able units will attempt to cast the ability when another non Flee-able unit gets near them. That will fire this trigger which causes them to run away as a group:
  • Flee Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Level of Flee (System) for (Triggering unit)) Greater than 0
      • (Issued order) Equal to (Order(parasite))
    • Actions
      • -------- Optional special effect: --------
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Set VariableSet Flee_Point[0] = (Position of (Triggering unit))
      • Set VariableSet Flee_Point[1] = (Position of (Target unit of issued order))
      • Set VariableSet Flee_Point[2] = (Flee_Point[0] offset by -512.00 towards (Angle from Flee_Point[0] to Flee_Point[1]) degrees.)
      • Set VariableSet Flee_Group = (Units within 512.00 of Flee_Point[0].)
      • -------- --------
      • Unit Group - Pick every unit in Flee_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Flee_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Flee (System) for Flee_Unit) Greater than 0
              • (Flee_Unit is alive) Equal to True
            • Then - Actions
              • Set VariableSet Flee_Point[3] = (Flee_Point[2] offset by (Random real number between 0.00 and 256.00) towards (Random angle) degrees.)
              • Unit - Order Flee_Unit to Move To Flee_Point[3]
              • Custom script: call RemoveLocation( udg_Flee_Point[3] )
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation( udg_Flee_Point[0] )
      • Custom script: call RemoveLocation( udg_Flee_Point[1] )
      • Custom script: call RemoveLocation( udg_Flee_Point[2] )
      • Custom script: call DestroyGroup( udg_Flee_Group )
Requirements:
1) Your Flee-able units need to have the Flee ability set as their Default Active ability.
2) It requires that Neutral Passive treats your other Players as an Ally. This shouldn't cause any issues as far as I can tell.
3) To prevent the Flee-able units from Fleeing from one another you need to give them a special Classification. In my map I make them Suicidal and setup the Flee ability to target only Non-suicidal units. I imagine this is unlikely to interfere with anything or cause any issues.

Flaws:
1) The flee reaction can be delayed, I guess this has to do with the AI autocasting system and some kind of timer running behind the scenes.
2) Since it relies on an ability it currently can't target Invulnerable, Magic Immune, etc. I think if I change it to a different type of Autocast ability (it's currently using Parasite) then I could fix some of these problems.
3) Since it relies on an ability it won't work if the fleeing unit is silenced.
 

Attachments

  • Flee System 1.w3m
    20 KB · Views: 2
Last edited:
Level 2
Joined
Dec 20, 2022
Messages
4
I think you should be able to do that with the "add event" function...

Here's a simple system I came up with that relies on detecting an Autocast ability....

Thanks! I'm mostly new to using triggers, mostly played with mapping and object editor, so there are many functions I have no idea exist, you gave me new interesting possibilities, I'll test the answers in detail later. I do this for fun, I have some high level language programing skill but don't wish to go deep into coding to be honest, this is just a past time activity, intend to use mostly GUI and perhaps copy paste some few simple lines of code here and there hehe. I do some mapping, play a little creating new objects and abilities, then a little more with the triggers and "AI".

In my case I intend to use both neutral passive and neutral hostile as enemies (prey) to all the other players, which will be custom races simulating different predators, like one huge simulated ecosystem. Kind of like a sandbox ant farm experience. So I'd like to cause both neutrals to flee from players 1-24. I intend to have the computer players actively hunting the creeps like herbivores animals and use the neutral passive as lesser critters to also be hunted on ocasion, that don't cause mini map creep camps to appear, using the custom race meele AI. Any idea how to permanenly hide creep camps in the mini map by the way?

I had done it by just ordering every unit in the "flee radius" around the triggering unit to move to a randon point of region, either as a group or as a individuals, which kind of worked most of the time, save the rare occasions where they ran towards the attacker! It actually made their behaviour quite unpredictable, which was funny to see. I'm doin this just for fun, so I take pleasure testing different options. I also used "is attacked" as event for another similar trigger, but wanted then to flee before it was too late also. Using an autocast does solve the vision problem, will be interesting. Why "non-suicidal" Can't you make the parasite autocast just target enemy units? That would be enough for me, there won't be any neutral unit to flee from.

I have some other ideas but they are subject for another post.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,714
Why "non-suicidal" Can't you make the parasite autocast just target enemy units? That would be enough for me, there won't be any neutral unit to flee from.
Neutral Passive has no Enemies by default so they would never cast the Parasite ability if it only targeted Enemies. However, you can adjust the Neutral Passive player to treat others as an Enemy to fix this issue, but then you've gotten rid of their "Neutral" behavior and they will attempt to attack you and cast other abilities on you. If you're 100% certain that this is fine, for example if Neutral Passive units won't ever have an Attack or offensive ability, then you should be able to ditch the Classification solution and instead rely on the Enemy-only solution.

I had done it by just ordering every unit in the "flee radius" around the triggering unit to move to a randon point of region, either as a group or as a individuals, which kind of worked most of the time, save the rare occasions where they ran towards the attacker!
You can see how I account for this in my Flee Order trigger. I use Point variables and the Point With Polar Offset function to calculate everything. First you store the position of the fleeing unit and the position of unit that scared it in Point variables. Then you get the angle between those two Points to calculate the "final destination" Point, this is where they should all flee to. Think of the angle as the "flee direction". But since I'm making a group of units flee all at once I don't want them to all clump together at the same exact Point. To solve this I order each of them to move to their own Point variable which is set at a random offset from the "final destination". This will ensure that they always run in the same general direction without all being told to go to the same exact spot.


Note that the overall design and outcome of this system (and most systems) will vary based on your map's specifics. With that in mind, Parasite may not be the ideal ability, I used it because it's autocasting AI seemed responsive and it's a rarely used ability so I figured there wouldn't be any interference.

For hiding creep camps:

Edit: Attached a new version of the map that relies on the Flee-From-Enemy design we were talking about. This gets rid of the Classification requirement. I also fixed the Flee ability so that it can now target Invulnerable/Magic Immune units. The trick was to Set it to a Hero ability, Set it's Required Level to 6 (this marks the ability as an Ultimate), then uncheck Hero ability. This works because "Ultimate" abilities will bypass targeting restrictions like Magic Immunity.
 

Attachments

  • Flee System 2.w3m
    20.8 KB · Views: 5
Last edited:
Level 2
Joined
Dec 20, 2022
Messages
4
Edit: Attached a new version of the map that relies on the Flee-From-Enemy design we were talking about. This gets rid of the Classification requirement. I also fixed the Flee ability so that it can now target Invulnerable/Magic Immune units. The trick was to Set it to a Hero ability, Set it's Required Level to 6 (this marks the ability as an Ultimate), then uncheck Hero ability. This works because "Ultimate" abilities will bypass targeting restrictions like Magic Immunity.
Is this for reforged only? I forgot to mention I'm using the old Warcraft 3 in an old PC. Couldn't open the map "-Level Info data missing or invalid."
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,714
Is this for reforged only? I forgot to mention I'm using the old Warcraft 3 in an old PC. Couldn't open the map "-Level Info data missing or invalid."
The map was made using the latest patch so it requires the latest patch to open, but the system is compatible with just about any version of Warcraft 3. Most people that help on here are going to be on the latest patch, so in the future please let people know which version you're on (my mistake for forgetting to ask).

Anyway, it's not a lot to recreate yourself:
  • Flee Alliance Settings
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Required: --------
      • -------- Neutral Passive won't cast abilities on you unless you're an Ally or Enemy with them. --------
      • -------- [ Warning: This may have unforeseen consequences since they will now be enemies. ] --------
      • -------- --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make Neutral Passive treat (Picked player) as an Enemy
  • Flee Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Level of Flee (System) for (Triggering unit)) Greater than 0
      • (Issued order) Equal to (Order(parasite))
    • Actions
      • -------- Optional special effect: --------
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Set VariableSet Flee_Point[0] = (Position of (Triggering unit))
      • Set VariableSet Flee_Point[1] = (Position of (Target unit of issued order))
      • Set VariableSet Flee_Point[2] = (Flee_Point[0] offset by -512.00 towards (Angle from Flee_Point[0] to Flee_Point[1]) degrees.)
      • Set VariableSet Flee_Group = (Units within 512.00 of Flee_Point[0].)
      • -------- --------
      • -------- Order all nearby flee-able units to run away from the unit that scared them: --------
      • Unit Group - Pick every unit in Flee_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Flee_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Flee (System) for Flee_Unit) Greater than 0
              • (Flee_Unit is alive) Equal to True
            • Then - Actions
              • Set VariableSet Flee_Point[3] = (Flee_Point[2] offset by (Random real number between 0.00 and 256.00) towards (Random angle) degrees.)
              • Unit - Order Flee_Unit to Move To Flee_Point[3]
              • Custom script: call RemoveLocation( udg_Flee_Point[3] )
            • Else - Actions
      • -------- --------
      • -------- Real values explained: --------
      • -------- In Flee_Point[2]: -512.00 = Flee total distance traveled. --------
      • -------- In Flee_Group: 512.00 = Area of effect surrounding the fleeing unit to tell other flee-able units to flee as well. --------
      • -------- In Flee_Point[3]: 0.00 to 256.00 = Extra offset to help prevent the fleeing units from all traveling to the same exact spot. --------
      • -------- --------
      • -------- Clean up memory leaks (helps with map performance over time): --------
      • Custom script: call RemoveLocation( udg_Flee_Point[0] )
      • Custom script: call RemoveLocation( udg_Flee_Point[1] )
      • Custom script: call RemoveLocation( udg_Flee_Point[2] )
      • Custom script: call DestroyGroup( udg_Flee_Group )
  • Flee Cancel
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Flee (System)
    • Actions
      • -------- Just in case they somehow begin to cast the ability, cancel it: --------
      • Unit - Order (Triggering unit) to Stop.
The Flee (System) ability used throughout the triggers, set this as the Default Active Ability for your Neutral critters:
1715382914495.png

^ The only thing that actually needs to change is the Targets Allowed, Cast Range, and that you mark it as an "Ultimate" using the trick I described before. Also, you likely want to adjust the Cast Range to be shorter. You could probably set this to your desired "Scare distance" + an extra 128.00.

The Variables needed:
1715382838712.png
 
Last edited:
Top