OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blip 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
-
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
-
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
player addaction ["Form Peremiter","peremiter.sqs"]and name the following: peremiter.sqs
_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
-
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
-
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
-
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:
_movex=_px+(_range*(sin(_deg)))
_movey=_py+(_range*(cos(_deg)))
_pman domove [_movex,_movey,0]
To
_movex=(_range*(sin(_deg)))
_movey=(_range*(cos(_deg)))
_pman domove [_px+_movex,_py+_movey,0]
_pman dowatch [_px+(_movex*2),_py+(_movey*2),0]
-
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
-
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
-
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
-
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.
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"
-
Grendel-
The final Code works! ;D ;D ;D
No bugs. Thank you all very much.
Later, :cheers:
Blip