Home   Help Search Login Register  

Author Topic: RE-ORG!!!  (Read 488 times)

0 Members and 1 Guest are viewing this topic.

Piraneous

  • Guest
RE-ORG!!!
« on: 27 Mar 2003, 16:51:14 »
ok,  i'm trying to come up with some way of  scripting something that allows the leader of a squad to order his troops into a defensive position.

what i need to know is, is it possable to order a unit to move to a position at X degrees from the squad leader at X distance?

e.g.,  order the first soldier to move 10 meters from the leader at 0 degrees,  the 2nd soldier to move to 10 meters at 10 degrees and so on untill all the troops are in a circle with a 10 meter radius around the leader all facing outwards (with use of the setdir command)

its mainly for cosmetics really,  and to add a bit more realistic tactics to the game


HuNtA

  • Guest
Re:RE-ORG!!!
« Reply #1 on: 27 Mar 2003, 17:28:21 »
I guess it could be done using the setDir and doMove commands. Check the[shadow=red,left,500] Official command reference [/shadow]

deaddog

  • Guest
Re:RE-ORG!!!
« Reply #2 on: 31 Mar 2003, 05:10:21 »
Try this script:

group = _this select 0
_dis = _this select 1

_units = units(_group)
_count = count(_units)-1
?_count<=0:goto "end"

_spokespacing=360/_count
_dir=0

_i=0

_center=getpos leader (_this select 0)
_cx = _center select 0
_cy = _center select 1


#fanout

_unit = (_units select _i)
_;unitpos = getpos _unit
_ux = _center select 0
_uy = _center select 1
_vx = _ux+(_dis * sin(_dir))
_vy = _uy+(_dis * cos(_dir))


?_unit == (leader _group):goto "next"

_unit domove [_vx,_vy]
@unitready _unit
_unit stop true
_unit setdir _dir

#next
_unit setunitpos "down"
_dir=_dir+_spokespacing

_i=_i+1
?_i<count(units _group):goto "fanout"

exit



I called it "radial.sqs".  You can call it anything you want.  To execute the script use:

 [groupname, distance] exec "radial.sqs"

or, if called from the init field of one of the units

[group this, distance] exec "radial.sqs"

groupname is the name of the group to spread out
distance is from the leader.

You can place this in the activation field of a waypoint or the init field of your unit

I made the group spread out in a 360 degree circle and lie down.  They move one at a time until all are positioned.  I could also make them move all at once if you'd like.

If you'd like to see a short sample mission, just let me know.

Hope this helps  :)

Piraneous

  • Guest
Re:RE-ORG!!!
« Reply #3 on: 01 Apr 2003, 05:29:46 »
That works quite well.

it'de be nice if they all did it together though :)  and position the machine guns at 12 and 6 o'clock. something for me to have a play around with i guess

thanks

deaddog

  • Guest
Re:RE-ORG!!!
« Reply #4 on: 01 Apr 2003, 06:02:29 »
I just noticed I have a couple of extra lines in there that could be taken out.  I modified a more complicated script to get this one.  

You could change which soldiers are carrying the machine guns until they move where you want them.

To make all the soldiers move at once would require another script which actually contains the domove command.

Try this,  make another script called radialmove.sqs (or whatever) :

_u=_this select 0
_x=_this select 1
_y=_this select 2

_u domove [_x,_y]
@unitready _u
_u stop true
_u setdir _dir
_u setunitpos "down"

exit


Then replace the four lines starting with the domove command in the original script with :

[_unit,_vx,_vy] exec "radialmove.sqs"

and also remove the _unit setunitpos "down" line from the original script.


You'll end up with the radial.sqs script looking like this:

_group = _this select 0
_dis = _this select 1

_units = units(_group)
_count = count(_units)-1
?_count<=0:goto "end"

_spokespacing=360/_count
_dir=0

_i=0

_center=getpos leader (_this select 0)

#fanout

_unit = (_units select _i)
_ux = _center select 0
_uy = _center select 1
_vx = _ux+(_dis * sin(_dir))
_vy = _uy+(_dis * cos(_dir))

?_unit == (leader _group):goto "next"

[_unit,_vx,_vy] exec "radialmove.sqs"

#next
_dir=_dir+_spokespacing

_i=_i+1
?_i<count(units _group):goto "fanout"

exit