OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Piraneous on 31 Jan 2004, 07:18:35
-
ok, last year some time, someone on this forum made me 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
it basically makes your troops move one by one into a defencive harbour. the problem i'm having with it now it that i want the men to move into position pretty much similtaniously rather than one by one.
if anyone can see a way to achieve the desired effect but with all troops moving at once, let me know.
cheers
-
I was that someone. Go back to the original post and you'll will see that I already answered that for you.
http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=7842;start=0
-
oh, thanks mate.
love your work.
-
ok, got it going so they move into position correctly, only now, i cant get them to move OUT of their postion when done.
i think its got somethign to do with the stop command. just wondring how to get the moving again.
i tried commenting out the stop line, but then their directions were all screwy
-
You're right :) It's the stop command. I made a couple of changes. Here are the two scripts again:
;radial.sqs
_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,_dir] exec "radialmove.sqs"
#next
_dir=_dir+_spokespacing
_i=_i+1
?_i<count(units _group):goto "fanout"
exit
;radialmove.sqs
_u=_this select 0
_x=_this select 1
_y=_this select 2
_d=_this select 3
_u domove [_x,_y]
@unitready _u
_vx = _x+(50 * sin(_d))
_vy = _y+(50 * cos(_d))
_u setunitpos "down"
_u dowatch [_vx,_vy,0]
dostop _u
exit
I also noticed they weren't watching the direction i wanted so i made a small change there as well.
Hope that works out better 8)
-
i made another version to have your units form a 180 degree arc in front of the group leader.
;formation_arc.sqs
_group = _this select 0
_dis = _this select 1
_units = units(_group)
?"alive _x" count _units >0:_units=_units-[leader _group]
_count = count(_units)
?_count<=1:goto "end"
_spokespacing=180/(_count-1)
_dir=(getdir player)-90
_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,_vx,_vy,_dir] exec "radialmove.sqs"
_dir=_dir+_spokespacing
#next
_i=_i+1
?_i<count(units _group):goto "fanout"
exit
And then renamed the first one:
;formation_circle.sqs
_group = _this select 0
_dis = _this select 1
_units = units(_group)
?"alive _x" count _units >0:_units=_units-[leader _group]
_count = count(_units)
?_count<=1:goto "end"
_spokespacing=360/_count
_dir=getdir player
_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,_vx,_vy,_dir] exec "radialmove.sqs"
_dir=_dir+_spokespacing
#next
_i=_i+1
?_i<count(units _group):goto "fanout"
exit
In my test mission I called these from the action menu
player addaction ["Defense - Arc","defarc.sqs"]
player addaction ["Defense - Circle","defcir.sqs"]
;defcir.sqs
[group player,10] exec "formation_circle.sqs"
exit;defarc.sqs
[group player,10] exec "formation_arc.sqs"
exit
You could also call these from the radio menu just as easily.
I'm glad you brought this up. I'm going to use these in a mission :)
-
yeah that works perfectly now, thanks.
the arc one will come in handy too no doubt.
i wanted a script to do this as its more realistic to the training i've had in the australian army
-
next trick is to come up with new unit formations :)
dont know how possible that is though.
-
There's a script for that in the Ed Depot.