1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Animal Awareness Trigger

Discussion in 'World Editor Help Zone' started by sanitoeter, Jan 29, 2013.

  1. sanitoeter

    sanitoeter

    Joined:
    May 17, 2008
    Messages:
    46
    Resources:
    0
    Resources:
    0
    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.
     
  2. Sick

    Sick

    Joined:
    Jan 28, 2013
    Messages:
    69
    Resources:
    0
    Resources:
    0
    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.
    Trigger Example

    • 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.
     
  3. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    First thing: is this map single-player ?

    Once the Hunter enters Notice/Attack/Flee state, what do you intend to do ?

    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 ?
     
  4. ABM

    ABM

    Joined:
    Jul 13, 2005
    Messages:
    279
    Resources:
    0
    Resources:
    0
    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)
     
  5. sanitoeter

    sanitoeter

    Joined:
    May 17, 2008
    Messages:
    46
    Resources:
    0
    Resources:
    0
    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..
     
  6. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,979
    Resources:
    17
    Spells:
    17
    Resources:
    17
    You should also respond to others' comment instead of one person only.

    If you tell me the exact details, I will create a test map for you.
     
  7. sanitoeter

    sanitoeter

    Joined:
    May 17, 2008
    Messages:
    46
    Resources:
    0
    Resources:
    0
    @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: Jan 30, 2013