Home   Help Search Login Register  

Author Topic: Diver script.  (Read 869 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Diver script.
« 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?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Diver script.
« Reply #1 on: 15 Mar 2005, 18:41:42 »
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...
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Diver script.
« Reply #2 on: 15 Mar 2005, 19:00:16 »
Well, the CoC divers and their spin-offs won't swim with me. I need to drag them kicking and screaming into the water.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Blanco

  • Former Staff
  • ****
Re:Diver script.
« Reply #3 on: 15 Mar 2005, 20:25:40 »
Use this COC script :

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

 
Search or search or search before you ask.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Diver script.
« Reply #4 on: 16 Mar 2005, 03:03:56 »
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.
« Last Edit: 16 Mar 2005, 03:04:41 by The-Architect »
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Blanco

  • Former Staff
  • ****
Re:Diver script.
« Reply #5 on: 16 Mar 2005, 18:01:49 »
Quote
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)

« Last Edit: 16 Mar 2005, 18:02:12 by Blanco »
Search or search or search before you ask.