Home   Help Search Login Register  

Author Topic: Have your men setup a perimeter  (Read 1440 times)

0 Members and 2 Guests are viewing this topic.

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Have your men setup a perimeter
« on: 11 May 2004, 01:24:52 »
I was wondering if somebody could write up a script to make your units setup a perimeter around the area when it is called.

Basically, something were they form a circle about 15-20 meters from a you and then point out in all directions.

Thanks-

Blip
...NIGHT WALKER....

Dubieman

  • Guest
Re:Have your men setup a perimeter
« Reply #1 on: 11 May 2004, 01:40:49 »
I would have many uses for a script like that.
Maybe a new formation, Perimeter, there was a program thingy that could make formations but I'm not sure where it went...

1 ALL form perimeter!
2 Roger
3 Roger
4 Moving on

Grendel

  • Guest
Re:Have your men setup a perimeter
« Reply #2 on: 11 May 2004, 17:45:21 »
I can do this up pretty quick, I already have somthing very similar to this.  Give me a few hours to take care of some work... ;)

-Grendel

******EDIT UDATED CODE*******

Heres a snippet that should work (untested).  Use an addaction in the init.sqs or the editor init field

Code: [Select]
player addaction ["Form Peremiter","peremiter.sqs"]and name the following: peremiter.sqs
Code: [Select]
_pgroup = group player
_groupnum=(count units _pgroup)
_grouparray=units _pgroup

_deg=0
_splitdeg=360/(_groupnum-1)
_range=15
_pos=getpos player
_px=_pos select 0
_py=_pos select 1

#top
_groupnum=_groupnum-1
_pman=_grouparray select _groupnum
;skip player
?(_pman==player):goto "top"

_deg=_deg+_splitdeg
_movex=_px+(_range*(sin(_deg)))
_movey=_py+(_range*(cos(_deg)))

_watchx=_px+((_range*2)*(sin(_deg)))
_watchy=_py+((_range*2)*(cos(_deg)))


_pman domove [_movex,_movey,0]
_pman dowatch [_watchx,_watchy,1]

?(_groupnum!=0):goto "top"

exit

« Last Edit: 12 May 2004, 20:40:32 by Grendel »

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Have your men setup a perimeter
« Reply #3 on: 11 May 2004, 23:26:06 »
Grendel

The script works nicely as far as getting the guys into postion.  Thanks-

Although it doesn't appear to effect the guys setting up the perimeter, there is an error showing up.  It looks like this:

'_pman=_grouparray select _groupnum|#|': Error zero divisor

So there's alittle bug.

Thanks for the script.  This one will come in handy.

Blip
...NIGHT WALKER....

Grendel

  • Guest
Re:Have your men setup a perimeter
« Reply #4 on: 12 May 2004, 00:10:36 »
sorry about that, I did this pretty much out of my head at work...Easy to fix though:

Change the next to last line to read like so:

?(_groupnum!=0):goto "top"

this should fix it.  I'll work on something for the facing thing...

-Grendel

Unnamed

  • Guest
Re:Have your men setup a perimeter
« Reply #5 on: 12 May 2004, 15:10:23 »
Quote
as far as making them continue to face out, this will take a little more scripting...

Not much more as you have done the main bit, just change:

Code: [Select]
_movex=_px+(_range*(sin(_deg)))
_movey=_py+(_range*(cos(_deg)))


_pman domove [_movex,_movey,0]

To

Code: [Select]
_movex=(_range*(sin(_deg)))
_movey=(_range*(cos(_deg)))


_pman domove [_px+_movex,_py+_movey,0]
_pman dowatch [_px+(_movex*2),_py+(_movey*2),0]

DBR_ONIX

  • Guest
Re:Have your men setup a perimeter
« Reply #6 on: 12 May 2004, 17:06:08 »
For making them face out
What about another version of that script, that makes/moves a few gamelogics out further, and dotarget's them?
- Ben

Grendel

  • Guest
Re:Have your men setup a perimeter
« Reply #7 on: 12 May 2004, 19:45:59 »
I updated the snippet I posted above to correct the zero divisor error and put in the dowatch code (so all you have to do is cut and paste).  It should work fine now (although I still can't run it myself yet :'().

-Grendel

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Have your men setup a perimeter
« Reply #8 on: 12 May 2004, 19:54:55 »
Nicely done Grendel, they units setup the perimeter and face out.  My thanks to you. ;D

I'm still getting the divisor error though.  ???

Can somebody else test Grendels script and see if they get it as well?

Later-

Blip
...NIGHT WALKER....

Grendel

  • Guest
Re:Have your men setup a perimeter
« Reply #9 on: 12 May 2004, 20:49:52 »
It is very hard for me to bugtest without being able to run OFP, but I think I know what is going on...I think it has to do with the skip player loop; if the player is the first element in the array, this could cause the script to loop and try to select the -1  element from the array (which is impossible, and would give the zero divisor error I think).  Try this out and let me know if it worked.

Code: [Select]
pgroup = group player
_groupnum=(count units _pgroup)
_grouparray=units _pgroup

_deg=0
_splitdeg=360/(_groupnum-1)
_range=15
_pos=getpos player
_px=_pos select 0
_py=_pos select 1

#top
_groupnum=_groupnum-1
?(_groupnum<0):exit
_pman=_grouparray select _groupnum
;skip player
?(_pman==player):goto "top"

_deg=_deg+_splitdeg
_movex=_px+(_range*(sin(_deg)))
_movey=_py+(_range*(cos(_deg)))

_watchx=_px+((_range*2)*(sin(_deg)))
_watchy=_py+((_range*2)*(cos(_deg)))


_pman domove [_movex,_movey,0]
_pman dowatch [_watchx,_watchy,1]

goto "top"

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Have your men setup a perimeter
« Reply #10 on: 12 May 2004, 23:33:37 »
Grendel-

The final Code works! ;D ;D ;D

No bugs.  Thank you all very much.

Later,  :cheers:

Blip
...NIGHT WALKER....