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

Reposition Unit Within Range

Status
Not open for further replies.
Level 9
Joined
May 21, 2014
Messages
580
I came up with a problem once again, and this time it's about keeping a unit in the range around another unit.

Let me cite an example:

I have a, let's say, pet unit for a hero. The pet unit cannot go out from the hero up to 300 range around the hero. Whenever the pet unit goes out, the pet unit will be redirected to the point where the hero is positioned.

Anyone who has ideas? If there is an alternative way for this, the idea is welcome. Please help me. :ogre_kawaii:
 
Level 12
Joined
May 20, 2009
Messages
822
Okay, so. I'm gonna call the unit you want to follow the Leader, and the other unit that is following the Follower. So basically,

You make a trigger, with arrays, and you check if the Followers leader is within range, and if not order them to move to their Leader. Simple as that.

Basically:

(Not doing Trigger Code because this is messy as shit anyway, so that'd really not make it look any better)

Every 1.00 game seconds,
For each (FollowInit) Do:
Pick all units within 300 of FollowerUnit[FollowInit] and do:
If
Picked unit is not equal to LeaderUnit[FollowInit]
Then
Order FollowerUnit[FollowInit] to (Move, Follow, Right-Click, whatever) LeaderUnit[FollowInit]



Now, to set these units up you do this:

A unit enters (Playable map area)
If Triggering unit is equal to Follower
Then
Set LeaderSystemMaxIndex to LeaderSystemMaxIndes + 1
Set FollowerUnit[LeaderSystemMaxIndex] = Triggering Unit

//

Not sure how to Index the Leader unit, though...
 
Level 9
Joined
May 21, 2014
Messages
580
Okay, so. I'm gonna call the unit you want to follow the Leader, and the other unit that is following the Follower. So basically,

You make a trigger, with arrays, and you check if the Followers leader is within range, and if not order them to move to their Leader. Simple as that.

Basically:

(Not doing Trigger Code because this is messy as shit anyway, so that'd really not make it look any better)

Every 1.00 game seconds,
For each (FollowInit) Do:
Pick all units within 300 of FollowerUnit[FollowInit] and do:
If
Picked unit is not equal to LeaderUnit[FollowInit]
Then
Order FollowerUnit[FollowInit] to (Move, Follow, Right-Click, whatever) LeaderUnit[FollowInit]



Now, to set these units up you do this:

A unit enters (Playable map area)
If Triggering unit is equal to Follower
Then
Set LeaderSystemMaxIndex to LeaderSystemMaxIndes + 1
Set FollowerUnit[LeaderSystemMaxIndex] = Triggering Unit

//

Not sure how to Index the Leader unit, though...

Many thanks for taking you time!

So there is no actual way to detect it, but by just checking every second?
I'll try to do it your way if there isn't any way.

I'm just afraid keeping it on every second for the whole duration of the rpg would make it lag (or no?)
 
Level 9
Joined
May 21, 2014
Messages
580
Nah, it wouldn't cause a lot of lag. There's leaks in my thing, but it'd only cause noticeable lag after 30-40 minutes, maybe an hour of straight play. (NOT including everything else on the map)

What kind of leaks are there? I am going to start triggering it while also removing leaks, since this is an RPG map, it will be necessary XD.

+Rep though if I managed to finish this.

EDIT: Works! But I hope there was a better way to do this. :(
 
Last edited:
Status
Not open for further replies.
Top