• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Animal Awareness Trigger

Status
Not open for further replies.
Level 3
Joined
May 17, 2008
Messages
45
Hi. I'm currently working on a Map that is in RPG style, just hunting-based.
What I would like to do:
First, I want that whenever a Hero(Hunter) approaches an animal, the Animal should first take notice. When it takes Notice, it stands still. If the hero proceeds and comes even closer, the Animal should, depending on whether it's a carnivore or a peaceful animal, attack or flee. The two Steps should be: Aware when in 800 Range; Attack/Flee in 400 Range.

The Second Question is..
I make a region, where randomly deers are being spawned, capped at max 20.
Since they move in free will, I would like them to periodically return to a trough that is placed on the left side of the region. The intervals would have to be random and not effect all deers at once, since it would look weird if all the deers were to drink at the same time.

The Third Question would be..

I want to make doodads constellations, f.E. 4 Rocks and 7 bushes, that give good cover from being spotted. Now, when a Hunter enters those Doodad constellations, he no longer aggravates animals, unless they are in 200 Range or less. What would be the most effective way to create those special places?


The Fourth Question most certainly is...

Does it make a big difference if I use 9 Integer arrays with 4 Values each, or 4 Integers with 9 each? Thanks! :)

If anyone has just one answer, that would be SO much appreciated.
 
Level 4
Joined
Jan 28, 2013
Messages
74
For the first one:

You need to create a periodic event to check if the unit is in range of the hunter. From there you can pause the unit by removing wander and then you need a way to add wander back to the unit when it leaves, which you could use another trigger for or you can add the unit to a unit group and then check if the unit in that unit group is still in range of the hero it was first in range of. You repeat a similar process for the 400 range trip.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Hero[1] = Footman 0001 <gen>
      • Set FleeDistance = 800.00
      • Set RangeAwareness = 800.00
      • Set RangeFlee = 400.00
  • Untitled Trigger 001
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units within RangeAwareness of (Position of Hero[(Player number of (Picked player))])) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • ((Triggering unit) is in NonWander[(Player number of (Picked player))]) Equal to False
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of (Picked unit)) Equal to Stag
                          • (Unit-type of (Picked unit)) Equal to Timber Wolf
                • Then - Actions
                  • Unit - Remove Wander (Neutral) from (Picked unit)
                  • Unit Group - Add (Picked unit) to NonWander[(Player number of (Picked player))]
                • Else - Actions
          • Unit Group - Pick every unit in (Units within RangeFlee of (Position of Hero[(Player number of (Picked player))])) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Stag
                • Then - Actions
                  • Set TempPoint = ((Position of (Picked unit)) offset by FleeDistance towards (Facing of Hero[(Player number of (Picked player))]) degrees)
                  • Unit - Order (Picked unit) to Move To TempPoint
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Timber Wolf
                • Then - Actions
                  • Unit - Order (Picked unit) to Attack Hero[(Player number of (Picked player))]
                • Else - Actions
          • Unit Group - Pick every unit in NonWander[(Player number of (Picked player))] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) is in (Units within RangeAwareness of (Position of Hero[(Player number of (Picked player))]))) Equal to False
                • Then - Actions
                  • Unit - Add Wander (Neutral) to (Picked unit)
                  • Unit Group - Remove (Picked unit) from NonWander[(Player number of (Picked player))]
                • Else - Actions


For the second one you can use mana as a simple solution just do a periodic event to pick all deer and check if their mana is x number and if it is set it to 0 and order them to go to the trough.

Number 3: make the cover doodads have a dummy unit inside of them with no model and add conditions to the first solution to check if hero is in range of unit of type dummy unit by picking all units in x range of hero matching unit type of dummy and if there is a unit in that group make the trigger act accordingly.

Number 4: Not really.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
First thing: is this map single-player ?

What I would like to do:
First, I want that whenever a Hero(Hunter) approaches an animal, the Animal should first take notice. When it takes Notice, it stands still. If the hero proceeds and comes even closer, the Animal should, depending on whether it's a carnivore or a peaceful animal, attack or flee. The two Steps should be: Aware when in 800 Range; Attack/Flee in 400 Range.
Once the Hunter enters Notice/Attack/Flee state, what do you intend to do ?

The Third Question would be..

I want to make doodads constellations, f.E. 4 Rocks and 7 bushes, that give good cover from being spotted. Now, when a Hunter enters those Doodad constellations, he no longer aggravates animals, unless they are in 200 Range or less. What would be the most effective way to create those special places?
You mean the condition should be, 4 rocks and 7 bushes for the Hunter to enter this state ?
The Hunter won't be able to enter this state if the condition is not enough - such as 3 rocks and 7 bushes ?
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
for doodad constellation you could use region.
either make a region for each of them, or create a wandering region that you move to your hero position to check if all the doodads are in the wandering region (meaning he is inside the constellation).

about the order to drink...
you should put all the deer into an unit array and maybe add custom value to deer equal to the number of the array they are archived in...
this way you have an individual variable for each deer, and can make something like this.
create a deer, set integer MaxDeer = MaxDeer +1, set deer custom value = MaxDeer
Drink[MaxDeer] = false
X = random number from 1 to MaxDeer
if Drink[x] = false
order unit[x] to go to water area, set Drink[x] = true
or you can add a timer to every deer (Timer[MaxDeer] is expired order deer to go to area)
 
Level 3
Joined
May 17, 2008
Messages
45
This might seem really dumb, but I'm having problems with your awesome trigger...
First: What kind of variable does it have to be in order to be accessible as a range variable? Integer doesn't work.

I defined the hero variable ((Position of Hero[(Player number of (Picked player))])) as a Unit group array. Can't be picked in this trigger constellation... I tried to change it all, but I simply can't wrap my head around it..
 
Level 3
Joined
May 17, 2008
Messages
45
@Defskull sorry, didn't mean to be disrespectful! Since I'm kinda going with Sick's version, I'm not really sure how to respond to your efforts.. thanks, I guess?
To clarify my question: The hunter doesn't enter Attack/Notice/Flee status, the animal does it when the hunter approaches it. I think I explained that in my question.. Or I just don't get what you're asking.
And yes, that's exactly what I mean by the doodad constellation!
@ABM: Thanks, haven't thought about it that way! Could be helpful.

Edit @ Sick:
I think I know what the problem is. I should use a Unit variable instead of a Unit Group variable. Trying it right now, let's see if I can do it!

Next Edit@Sick:
Ha, figured it out and it works perfectly fine! I just had to insert a condition before the "Order unit to move to TempPoint", since the deer was stuck in an endless loop of being flooded with "MOVE THERE, THERE, THERE, THERE.." Orders. I simply inserted the condition "current order not equal to order "move"" :) Thanks so much, you were of incredible help.
Although I think of inserting a little nugget there, that the movespeed of the unit is increased by 300% and it runs much further. So it acutally looks believable.
ha, love you! You're awesome.
 
Last edited:
Status
Not open for further replies.
Top