OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: The-Architect on 15 Mar 2005, 18:15:04
-
I need a script which will detect whether I am in the diver vehicle (CoC), and if I get more than 10m from any of my team members, it will setpos them into the water with me. As I swim, it will keep checking to see if I am more than 10m from my team and if so, it will keep setposing them back to me, thus creating the illusion of them swimming with me.
I think that getting out of the water could be a problem but I won't know until I get to that part.
Anyone give me some pointers on how to achieve this?
-
first whatever the name of the vehicle is simple put this to find if your in it or not:
?(Player in VehicleName):Hint"Your in one spiffy car!"
as for the distance thing I cant remember the exzact usage of moving only one unit without making a script that really is unnessacary...
-
Well, the CoC divers and their spin-offs won't swim with me. I need to drag them kicking and screaming into the water.
-
Use this COC script :
; AI helper
; As AI can't handle swimming, this script will help them out a bit.
#START
;set variables
LAR7speed=12
ENDHELPER=FALSE
_Group = _this
_listunits = units _Group
_A = 0
_B = count _listunits
_counter=1
#UNITCYCLE
~0.1
_ActUnit = vehicle (_listunits select _A)
? ((_ActUnit == vehicle Player) || ((_ActUnit distance (vehicle Player)) < (1+_A*3)) || (getpos _ActUnit select 2 > -1)): goto "SKIP"
_vectorX = (getpos (vehicle player) select 0)-(getpos _ActUnit select 0)
_vectorY = (getpos (vehicle player) select 1)-(getpos _ActUnit select 1)
(_listunits select _A) dowatch (getpos player)
? ((_ActUnit distance (vehicle Player)) > (1+_A*3)) : _ActUnit setvelocity [_vectorX/(1+_A*3), _vectorY/(1+_A*3), velocity _ActUnit select 2]
;? ((_ActUnit distance (vehicle Player)) < (1+_A*3)) : _ActUnit setvelocity [0,0,0]
goto "SKIP"
#SKIP
;hint format ["SKIPPED %1",_A]
_A=_A+1
?_B >_A:goto "UNITCYCLE"
? !ENDHELPER :goto "START"
#END
Run it in the init of a member of your diversgroup.
group this exec "AI_helper.sqs"
It uses the smoother setvelocity commands instead of the abrupt setpos commands. There are no big problems with getting out of the water, but there could be some with getting into the water again.
AI units avoid water (collision detection) you know...
You can see the script in action in this COCmission named COC sabotage (http://www.downloads.thechainofcommand.net/zips/CoCSabotage.Noe.zip)
-
Cheers Blanco.
I tried it out and they won't follow me back into the water.
Is there a way to setpos them into the water if I get in?
Granted there may be problems if I want to go swimming on my own, they would be forced in after me. Not good If I've set them to watch something a few hundred metres away, then suddenly once I take a dip, they appear alongside me in the water.
Perhaps it would work if once I got into the water, I had the option of calling them via a radio command or something. Maybe a dialog? Jeez I don't know. Any ideas on how I can sort this would be greatly appreciated.
-
Granted there may be problems if I want to go swimming on my own, they would be forced in after me.
You can exit the script by putting endhelper = true in a another script or trigger, it will stop the following.
After that you have to run the script a second time if you want them to follow you again (it not a switch if you know what i mean)