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

[General] Following unit problem

Status
Not open for further replies.
Level 5
Joined
Jan 13, 2008
Messages
96
Hi!... I have a little question about an trigger or problem...Ok so, after starting map, i choose my hero. After this i will buy an scrool... That scrool will summon a horse like a pet...With it i will travel map from town to towm for trading...Like silkroad trader if anyone know(old version)...Ok, now my problem is about following my hero...Always follow my choosed hero...If i am player 1 my horse follow only me...If a player 2 is active...His horse following only his hero...And like this for all players...And i i select the horse and i right clicked on the other way, horse will follow my hero...I mean whereever i give him move comand he will always follow my hero like pet in world of warcraft...Can anyone help me, please!
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Add your hero to a unit array variable
  • Set Hero[Player Number of (Owner of (Unit))] = Unit
When the horse is created order the horse to follow your hero (or right click your hero).

Another trigger:
Events
A unit is issued an order targeting a unit
A unit is issued an order targeting a point
A unit is issued an order with no target
Conditions
Unit type of triggering unit = Horse/Pet
Actions
Unit -Order (Triggering Unit) Right Click / Move Hero[Player Number of (Owner of (Triggering Unit))]

Add your hero to a unit array variable
  • Set Hero[Player Number of (Owner of (Unit))] = Unit
When the horse is created order the horse to follow your hero (or right click your hero).

Another trigger:
  • Events
    • A unit is issued an order targeting a unit
    • A unit is issued an order targeting a point
    • A unit is issued an order with no target
  • Conditions
    • Unit type of triggering unit = Horse/Pet
  • Actions
    • Unit -Order (Triggering Unit) Right Click / Move Hero[Player Number of (Owner of (Triggering Unit))]
With this (or something similar) your horse will follow your unit. Every time you give the horse an order, the system will order the horse to follow the hero. You have to solve the issue of your hero dying and moving the pet to the hero position.

If you don't want the unit to walk directly to your position then:

  • Actions
    • Set Point = Position of Hero[Player number... bla bla]
    • Set Point2 = Point 1 offset by (random integer between 100 and 300) towards (random angle)
    • Unit -Order (Triggering Unit) Move to Point2
    • Custom script: call RemoveLocation(udg_Point1)
    • Custom script: call RemoveLocation(udg_Point2)
 
Last edited by a moderator:
Level 5
Joined
Jan 13, 2008
Messages
96
no...it doesn„t work..take my map and i explain all you need to do:)
 

Attachments

  • please help.w3x
    17.9 KB · Views: 47
Level 5
Joined
Jan 13, 2008
Messages
96
ok maybe it doesn„t work...or i dont know how exactly do this trigger...can anyone make me a little map with trigger? in my map...after hero dies, horse will die too...please help me ...i realy need this :(
 
Level 5
Joined
Jan 13, 2008
Messages
96
i did what you said to other map...and i post that map here for eiditing it by you...with exactly trigger...couse i have a real problem with variables...make the trigger on it and post again...this is what i want...!
 
Level 5
Joined
Jan 13, 2008
Messages
96
when i do variable with Set Hero[Player Number of (Owner of (Unit))] = Unit
i cant select unit to follow...i mean here (owner of (unit(cant select))) and i have a random unit which my horse need to follow...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
You need to create a timer which will fire 0 seconds after the event (yes, 0 seconds is enough delay). Be aware that during this time many such orders could be issued so you will probably need to use hashtables to attach the appropiate values so the timer thread can access them.
 
Level 5
Joined
Jan 13, 2008
Messages
96
so..super good can you help me with exactly trigger? and please do the trigger on that map...i want to teach about how you did it...not post it here...i can„t use variables...
i dont know how...!:)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
I really do not have the time at the moment to do something like that. I advise eithor finding and using a ready made follower system or you improvise.

Adding a wait to the trigger before issuing the order should resolve the problem although you will have latency before the cancellation order is issued.
 
Spartipilo a more officiant way of using the point to set it into a variable would be
  • Set Point = Set Point = ((Position of Hero[Player number... bla bla]) offset by (Random real number between 100.00 and 300.00) towards (Random angle) degrees)
not
  • Set Point = Position of Hero[Player number... bla bla]
  • Set Point2 = Point 1 offset by (random integer between 100 and 300) towards (random angle)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
DeathChef... Point with offset uses the Base Point and creates the Offset Point. Point with Offset = 2 points... If you just create the Point with Offset in the variable, you would be leaking the base point.
 
Status
Not open for further replies.
Top