Home   Help Search Login Register  

Author Topic: defencive postition mark 2  (Read 632 times)

0 Members and 1 Guest are viewing this topic.

Piraneous

  • Guest
defencive postition mark 2
« 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

deaddog

  • Guest
Re:defencive postition mark 2
« Reply #1 on: 31 Jan 2004, 08:42:34 »
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
« Last Edit: 31 Jan 2004, 08:45:15 by deaddog »

Piraneous

  • Guest
Re:defencive postition mark 2
« Reply #2 on: 31 Jan 2004, 11:27:20 »
oh, thanks mate.

love your work.

Piraneous

  • Guest
Re:defencive postition mark 2
« Reply #3 on: 31 Jan 2004, 11:47:14 »
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

deaddog

  • Guest
Re:defencive postition mark 2
« Reply #4 on: 31 Jan 2004, 15:48:14 »
You're right :)  It's the stop command.  I made a couple of changes.  Here are the two scripts again:

Code: [Select]
;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

Code: [Select]
;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)

deaddog

  • Guest
Re:defencive postition mark 2
« Reply #5 on: 31 Jan 2004, 16:13:11 »
i made another version to have your units form a 180 degree arc in front of the group leader.

Code: [Select]
;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:
Code: [Select]
;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"]


Code: [Select]
;defcir.sqs

[group player,10] exec "formation_circle.sqs"

exit
Code: [Select]
;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  :)

Piraneous

  • Guest
Re:defencive postition mark 2
« Reply #6 on: 01 Feb 2004, 00:39:27 »
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

Piraneous

  • Guest
Re:defencive postition mark 2
« Reply #7 on: 01 Feb 2004, 00:44:57 »
next trick is to come up with new unit formations :)

dont know how possible that is though.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:defencive postition mark 2
« Reply #8 on: 01 Feb 2004, 11:55:35 »
There's a script for that in the Ed Depot.
Plenty of reviewed ArmA missions for you to play