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. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. 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.

[Trigger] Following pets

Discussion in 'Triggers & Scripts' started by Hargoth, May 1, 2009.

  1. Hargoth

    Hargoth

    Joined:
    Oct 23, 2006
    Messages:
    140
    Resources:
    5
    Maps:
    5
    Resources:
    5
    In my RPG i need a trigger which keeps a pet (or just unit) close to a hero, in other words so it does not walk to far away or get left behind. Now i know your thinking the owner of the unit could simply keep them together but if an owner so chooses he could mess up other triggers in the game. Thank you for reading!
     
  2. The_Nyne

    The_Nyne

    Joined:
    Apr 28, 2009
    Messages:
    18
    Resources:
    0
    Resources:
    0
    Maybe just do something like.

    Every 0.3 seconds of the game
    If (pet) is not in within range(350) of (petOwner)
    then move (pet) to a random point within range(300) of (petOwner)
    else
    do nothing

    Maybe instead of a move instantly, do an issue move? That way it doesn't jump around the place and it doesn't look so bad. If that case, I'd make the pet's movement speed the same(maybe a little faster) than the petOwner.
     
  3. Hargoth

    Hargoth

    Joined:
    Oct 23, 2006
    Messages:
    140
    Resources:
    5
    Maps:
    5
    Resources:
    5
    That helps alot mate, thx
     
  4. Guishiu

    Guishiu

    Joined:
    Apr 7, 2008
    Messages:
    160
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Is it a non-combat pet or combat pet? If it is then constantly ordering it to move to your Hero wont really work....
    Also. is it a summonable pet? Is it created through a trigger? Feel free to PM me.
     
  5. Reaper2008

    Reaper2008

    Joined:
    Jul 27, 2008
    Messages:
    1,117
    Resources:
    1
    Spells:
    1
    Resources:
    1
    You could create an order for the pet to guard the hero and make it unselectable:
    • Trigger
    • Events
      • Player - Player 1 (Red) - Selects a unit
      • Player - Player 2 (Red) - Selects a unit
      • Player - Player 3 (Red) - Selects a unit
      • Player - Player 4 (Red) - Selects a unit
      • Player - Player 5 (Red) - Selects a unit
      • ... etc
    • Conditions
      • Unit-Type of (Triggering Unit) Equal to <PET>
    • Actions
      • Player - Clear Selection for (Triggering Player)

    And maybe add commands too, such as attack, stay close etc.
     
    Last edited: May 1, 2009
  6. Toilet Maker

    Toilet Maker

    Joined:
    Apr 25, 2008
    Messages:
    75
    Resources:
    0
    Resources:
    0
    In my map (Creature Island) I have a similar system. There is a minor problem though and that is that if one unit is faster than the other they will get further apart and also if they select the following unit and order it to stop it will stop following (until either issues a new order). With some simple triggers I guess you could fix these problems (teleport back if they get too far away)

    • Auto Follow Creature
      • Events
        • Unit - A unit Is issued an order targeting a point
      • Conditions
        • (Ordered unit) Equal to Active[(Player number of (Owner of (Ordered unit)))]
      • Actions
        • Unit - Order CreatureTamer[(Player number of (Owner of (Ordered unit)))] to Follow (Ordered unit)

    • Auto Follow Tamer
      • Events
        • Unit - A unit Is issued an order targeting a point
      • Conditions
        • (Ordered unit) Equal to CreatureTamer[(Player number of (Owner of (Ordered unit)))]
      • Actions
        • Unit - Order Active[(Player number of (Owner of (Ordered unit)))] to Follow (Ordered unit)
     
  7. Wolfhelm

    Wolfhelm

    Joined:
    Jan 28, 2009
    Messages:
    393
    Resources:
    0
    Resources:
    0
    There is really simple and effective way to do this - that is if you dont want the player to have much control over the pet and rather want the pet to just fallow a single unit.

    Edit Locus Swarm so its only 1 unit - your pet. Hide it in a spell book, set the duration to 999999 and use a trigger to make the unit cast it.
     
  8. Toilet Maker

    Toilet Maker

    Joined:
    Apr 25, 2008
    Messages:
    75
    Resources:
    0
    Resources:
    0
    I guess that would work too. But difference between my one and your one is that in my map players have max control over the pet as well as the main character.
     
  9. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    If you want your pet to basically always be within X range of your hero, just do what The_Nyne said. To prevent players from spamming stop on the pet, just make a trigger that detects when it receives any order. Check to see if the pet is farther than X from its hero, and if it is, just reissue the move order. (Of course you can see that this way the pet will literally do nothing except try to get back to its hero if it's too far away...which may be a problem.)
     
  10. Wolfhelm

    Wolfhelm

    Joined:
    Jan 28, 2009
    Messages:
    393
    Resources:
    0
    Resources:
    0
    Uhh is this thread to help you or Hargoth? It looks like he doesnt want the player to have much control over the pet.. but i have been wrong b4.
     
  11. ShadowMan

    ShadowMan

    Joined:
    Jul 25, 2005
    Messages:
    219
    Resources:
    0
    Resources:
    0
    Here's a simple Pet AI map I just made for you
    (Haven't added leak removes because I don't find it necessary if its only for show)
    This is how you should design your pet's commands
    Note that this also comes with a command where you can turn on/off the AI, so you let the player decide whether or not the pet should be automated or controlled
    Adding to these triggers, you can use a trigger that teleports the pet back to the caster if the pet is too far away (and if AI is on)
    I feel dirty allover, I don't like triggering in GUI :cute:

    Let's see, what can be improved?
    1) If you have more than one pet, you can create an array of points (each one representing a point around the master) and then position each pet for each point.
    2) You can add a better follow system, where if the degree to the targeted offset point is bigger than the masters degree to the targeted point then assign a new point that doesn't interfere with the masters point (not creating an X pattern where they cross paths with eachother), or something...

    And here are the triggers for those who are lazy:

    Pet AI Triggers

    Pet Initiation
    • PetInit
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Summon Flame Seeker
      • Actions
        • Set intPlayerNumber = (Player number of (Triggering player))
        • Set pointSpawnLocation = ((Position of (Triggering unit)) offset by 150.00 towards ((Facing of (Triggering unit)) + 90.00) degrees)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • isFlameSeekerActive[intPlayerNumber] Equal to True
          • Then - Actions
            • Unit - Kill uFlameSeeker[intPlayerNumber]
          • Else - Actions
        • Unit - Create 1 Flame Seeker for (Owner of (Triggering unit)) at pointSpawnLocation facing (Facing of (Triggering unit)) degrees
        • Set uFlameSeeker[intPlayerNumber] = (Last created unit)
        • Set uFlameMaster[intPlayerNumber] = (Triggering unit)
        • Set isFlameSeekerActive[intPlayerNumber] = True
        • Unit - Order uFlameSeeker[intPlayerNumber] to Night Elf Demon Hunter - Activate Immolation
    Pet AI
    • PetAI
      • Events
        • Unit - A unit Is issued an order targeting an object
        • Unit - A unit Is issued an order targeting a point
        • Unit - A unit Is issued an order with no target
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Master
      • Actions
        • Set intPlayerNumber = (Player number of (Triggering player))
        • Game - Display to (All players) the text: (String((Issued order)))
        • -------- If there is no flame seeker, or if the AI is turned off, this trigger will end here --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • isFlameSeekerActive[intPlayerNumber] Equal to False
                • isAIOn[intPlayerNumber] Equal to False
          • Then - Actions
            • Skip remaining actions
          • Else - Actions
        • -------- if the event was an order --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Issued order) Equal to (Order(smart))
                • (Issued order) Equal to (Order(stop))
                • (Issued order) Equal to (Order(holdposition))
                • (Issued order) Equal to (Order(attack))
                • (Issued order) Equal to (Order(move))
          • Then - Actions
            • -------- Smart Move --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Issued order) Equal to (Order(smart))
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Or - Any (Conditions) are true
                      • Conditions
                        • ((Target unit of issued order) is A structure) Equal to True
                        • ((Target unit of issued order) is A Hero) Equal to True
                        • ((Target unit of issued order) is A ground unit) Equal to True
                        • ((Target unit of issued order) is A flying unit) Equal to True
                  • Then - Actions
                    • Unit - Order uFlameSeeker[intPlayerNumber] to Attack (Target unit of issued order)
                  • Else - Actions
                    • Set pointMove = ((Target point of issued order) offset by 150.00 towards ((Angle from (Position of uFlameMaster[intPlayerNumber]) to (Target point of issued order)) + 90.00) degrees)
                    • Unit - Order uFlameSeeker[intPlayerNumber] to Move To pointMove
              • Else - Actions
            • -------- Stop --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Issued order) Equal to (Order(stop))
              • Then - Actions
                • Unit - Order uFlameSeeker[intPlayerNumber] to Stop
              • Else - Actions
            • -------- Hold Position --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Issued order) Equal to (Order(holdposition))
              • Then - Actions
                • Unit - Order uFlameSeeker[intPlayerNumber] to Hold Position
              • Else - Actions
            • -------- Attack --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Issued order) Equal to (Order(attack))
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Or - Any (Conditions) are true
                      • Conditions
                        • ((Target unit of issued order) is A structure) Equal to True
                        • ((Target unit of issued order) is A Hero) Equal to True
                        • ((Target unit of issued order) is A ground unit) Equal to True
                        • ((Target unit of issued order) is A flying unit) Equal to True
                  • Then - Actions
                    • Unit - Order uFlameSeeker[intPlayerNumber] to Attack (Target unit of issued order)
                  • Else - Actions
                    • Set pointMove = ((Target point of issued order) offset by 150.00 towards ((Angle from (Position of uFlameMaster[intPlayerNumber]) to (Target point of issued order)) + 90.00) degrees)
                    • Unit - Order uFlameSeeker[intPlayerNumber] to Attack-Move To pointMove
              • Else - Actions
            • -------- Move --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Issued order) Equal to (Order(move))
              • Then - Actions
                • Set pointMove = ((Target point of issued order) offset by 150.00 towards ((Angle from (Position of uFlameMaster[intPlayerNumber]) to (Target point of issued order)) + 90.00) degrees)
                • Unit - Order uFlameSeeker[intPlayerNumber] to Move To pointMove
              • Else - Actions
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Or - Any (Conditions) are true
                  • Conditions
                    • ((Target unit of issued order) is A structure) Equal to True
                    • ((Target unit of issued order) is A Hero) Equal to True
                    • ((Target unit of issued order) is A ground unit) Equal to True
                    • ((Target unit of issued order) is A flying unit) Equal to True
              • Then - Actions
                • Unit - Order uFlameSeeker[intPlayerNumber] to Attack (Target unit of issued order)
              • Else - Actions
    Pet State (AI on or off)
    • PetManagement
      • Events
        • Unit - A unit Is issued an order with no target
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Issued order) Equal to (Order(immolation))
                • (Issued order) Equal to (Order(unimmolation))
            • (Unit-type of (Triggering unit)) Equal to Flame Seeker
      • Actions
        • Set intPlayerNumber = (Player number of (Triggering player))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Issued order) Equal to (Order(immolation))
          • Then - Actions
            • Set isAIOn[intPlayerNumber] = True
          • Else - Actions
            • Set isAIOn[intPlayerNumber] = False
    Pet Dies
    • PetDeath
      • Events
        • Unit - A unit Dies
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Flame Seeker
      • Actions
        • Set intPlayerNumber = (Player number of (Triggering player))
        • Set isFlameSeekerActive[intPlayerNumber] = False
        • Set isAIOn[intPlayerNumber] = False
    Pet is out of range
    • PetRange
      • Events
        • Unit - A unit Is attacked
      • Conditions
        • (Unit-type of (Attacking unit)) Equal to Flame Seeker
      • Actions
        • Set intPlayerNumber = (Player number of (Owner of (Attacking unit)))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • And - All (Conditions) are true
              • Conditions
                • (Distance between (Position of uFlameMaster[intPlayerNumber]) and (Position of uFlameSeeker[intPlayerNumber])) Greater than 1000.00
                • isAIOn[intPlayerNumber] Equal to True
          • Then - Actions
            • Set pointMove = ((Position of uFlameMaster[intPlayerNumber]) offset by 150.00 towards ((Angle from (Position of uFlameMaster[intPlayerNumber]) to (Target point of issued order)) + 90.00) degrees)
            • Unit - Move uFlameSeeker[intPlayerNumber] instantly to pointMove, facing (Facing of uFlameMaster[intPlayerNumber]) degrees
          • Else - Actions
     

    Attached Files:

    Last edited: May 2, 2009