Home   Help Search Login Register  

Author Topic: My follow script.  (Read 679 times)

0 Members and 1 Guest are viewing this topic.

Bad Maniac

  • Guest
My follow script.
« on: 25 Apr 2003, 23:07:16 »
Code: [Select]
;Unit Follow Script

_obj1 = _this select 0
_obj2 = _this select 1

#Start
_obj1 DoMove GetPos _obj2;
~1
? (alive _obj1) : goto "Start"
exit


Usage:
[Unit1, Unit2] exec "follow.sqs";

This will make unit1 follow unit2.

Is this a good script? I have no idea since it is my first one. Is there anything I could improve, or is there an alltogether better way of getting the same result?

Iwesshome

  • Guest
Re:My follow script.
« Reply #1 on: 25 Apr 2003, 23:14:45 »
Shouldn't be set up this way?

Code: [Select]
;[Unit1,Unit2] exec "follow.sqs"
;Unit Follow Script

_obj1 = _this select 0
_obj2 = _this select 1

#Start
_obj2 DoFollow _obj1;
~1
goto "start"

I think you could just say loon2 DoFollow loon1 in loon2's activation feild.

IW
« Last Edit: 25 Apr 2003, 23:16:19 by IW »

Bad Maniac

  • Guest
Re:My follow script.
« Reply #2 on: 25 Apr 2003, 23:17:46 »
Quote from the Ofpec command reference:

DoFollow:
Causes selected unit to follow a unit. Effectively makes him return to formation. This command will not cause him to follow anyone but his leader. Use the Join command to do that.


and since join will make the unit join the other units group, it's no good.
if that command worked, I wouldn't need to make a script of it now would I?

Iwesshome

  • Guest
Re:My follow script.
« Reply #3 on: 25 Apr 2003, 23:25:34 »
Well.... this is not my week   :(

Quote
doMove position
Operand types:
    position: Array
Type of returned value:
    Nothing
Description:
Order unit to move to given position (format Position) (silent).

Example:
    soldierOne doMove getMarkerPos "MarkerMoveOne"

Don't think that will work either.... When I looked up the Official Command Ref. this is what I found.

Quote
doFollow position
Operand types:
    position: Object
Type of returned value:
    Nothing
Description:
    Order unit follow given unit (silent).

Example:
    soldierOne doFollow player

I could be wrong but this is the 1.85 version of the command ref. I am just trying to help m8  ::)

IW
« Last Edit: 25 Apr 2003, 23:34:42 by IW »

Bad Maniac

  • Guest
Re:My follow script.
« Reply #4 on: 25 Apr 2003, 23:50:08 »
My script works fine, Im just wondering if it is a good script, or if its horribly inneficient in any way.
and CommandMove works great, because it will not make the unit move exactly to my position, but somewhere near around me (unit2) so it looks like unit2 is following.

DoFollow only works to get a unit to follow his group leader. I need a unit to follow another unit, not grouped.

My sarcastic comment was a bit over the top. I didn't mean to sound nasty, I know you are helping, and I apreciate it. It was just a sarcastic remark with a smile, not anything else. I'm sorry.

Iwesshome

  • Guest
Re:My follow script.
« Reply #5 on: 26 Apr 2003, 01:19:25 »
No need to apologize... if the script works then great. Can you do exactly what you are looking to do without using an external script?

What I meant on my reply is that I am having a bad week of giving the wrong answers to good questions... Help is here anytime  ;D

IW

Bad Maniac

  • Guest
Re:My follow script.
« Reply #6 on: 26 Apr 2003, 02:02:57 »
No, I have found no way of getting a unit to follow another. ther just isn't a way internally.

Why I am asking is, this is the first and only script I have ever written for OP:F and I want to know if it is a good script or if it stinks  :D

CrashnBurn

  • Guest
Re:My follow script.
« Reply #7 on: 26 Apr 2003, 16:01:24 »
You may not need to update it every second unless the follower is really close to the followee. For example, if they're 25-50 meters or more apart, you could give it a longer wait time like 5 to 10 seconds or randomize it like -
~random(5) + 5
As a rule you should only update your loops as fast as is necessary, in order to leave headroom for other scripts to run. If they're close together, then you'd update the loop faster so the follower doesn't pause or stop between loops.

Bad Maniac

  • Guest
Re:My follow script.
« Reply #8 on: 27 Apr 2003, 12:54:46 »
Right, this script doesn't work properly at all, it just makes one unit follow another, I want a script that I can exec in a group leaders init field, that will make the whole group follow, can anyone help?
Right now when I exec it on the group leader, only he will move, the others will stay put and look stupid...

CrashnBurn

  • Guest
Re:My follow script.
« Reply #9 on: 27 Apr 2003, 15:54:51 »
You should have said group in the first place...you said unit.  ::)
The syntax is- groupname move getpos postionname
example:

Alpha move getpos loon1

The whole group will move with the leader.

example script-

#LOOP
? !(alive loon1): exit
Alpha move getpos loon1
~random(5) + 5
goto "LOOP"