Home   Help Search Login Register  

Author Topic: Ultimate Vehicle Respawn Script  (Read 3264 times)

0 Members and 2 Guests are viewing this topic.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Ultimate Vehicle Respawn Script
« on: 10 Oct 2002, 03:17:58 »
Hey guys.  I just wrote this & I thought I'd share it.

respawn.sqs

;Ultimate Vehicle Respawn
;by Doolittle

;This script will respawn any vehicle if it has been dead for a while
;It will also respawn a vehicle if it has been abandoned somewhere for too long!

;Set the Initialization for whatever vehicles you want to respawn to
;[this] exec "respawn.sqs"
;That's it!

_obj = _this select 0
_pos = getPos _obj
_dir = getDir _obj

_magazines = magazines _obj
_j = count _magazines

#begin
? "m2staticmg" counttype [_obj] == 1 : goto "alive"

@count crew _obj != 0 || !alive _obj
? !alive _obj : goto "alive"
@count crew _obj == 0 || !alive _obj
? !alive _obj : goto "alive"

_oldtime = _time + 55

@_time > _oldtime || count crew _obj != 0 || !alive _obj
? !alive _obj : goto "alive"
? count crew _obj != 0 : goto "begin"
_obj setFuel 0
_obj setDammage 1

#alive
@!alive _obj

~40

_i = 0
#rearm
_mag = _magazines select _i
_obj removeMagazine _mag
_obj addMagazine _mag
_i = _i + 1
? _i < _j : goto "rearm"

_obj setPos _pos
_obj setDir _dir
_obj setDammage 0.3
~0.1
_obj setDammage 0.1
~0.1
_obj setDammage 0
_obj setFuel 1

goto "begin"

« Last Edit: 10 Oct 2002, 03:22:11 by Doolittle »

mcnils

  • Guest
Re:Ultimate Vehicle Respawn Script
« Reply #1 on: 11 Oct 2002, 05:15:20 »

Very interesting script but, a litle more info of
"what does what" would be appreciated from a scripting noob like me..

For example,
can i set a different respawn time if a vehicle is destroyed or without crew, or is there only one universal "timer" for both the situations? Where do i set the respawning time? How to make respawn east stuff on east side and west stuff on west side?



*feels noob*  :-\ ::)
« Last Edit: 11 Oct 2002, 05:21:49 by mcnils »

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Ultimate Vehicle Respawn Script
« Reply #2 on: 11 Oct 2002, 20:47:15 »
Ok...let me comment.

;Ultimate Vehicle Respawn
;by Doolittle

;This script will respawn any vehicle if it has been dead for a while
;It will also respawn a vehicle if it has been abandoned somewhere for too long!

;Set the Initialization for whatever vehicles you want to respawn to
;[this] exec "respawn.sqs"
;That's it!

;Notice here I am getting a vehicle's position and direction
;What this does is that when the mission starts we will remember where every vehicle started
;Where the vehicle starts is where it will respawn, whether it is East or West doesn't matter
_obj = _this select 0
_pos = getPos _obj
_dir = getDir _obj

;Get weapon info for #rearm loop
_magazines = magazines _obj
_j = count _magazines

;Here is where that EMPTY VEHICLE code starts
;We check to see if a vehicle has been left empty
#begin
;Don't want to do this for M2 spots (they never move)
? "m2staticmg" counttype [_obj] == 1 : goto "alive"

@count crew _obj != 0 || !alive _obj
? !alive _obj : goto "alive"
@count crew _obj == 0 || !alive _obj
? !alive _obj : goto "alive"

;If a vehicle is left for 55 seconds then respawn it
;Change this number if you want
_oldtime = _time + 55

@_time > _oldtime || count crew _obj != 0 || !alive _obj
? !alive _obj : goto "alive"
? count crew _obj != 0 : goto "begin"
;Here we blow it up so that it will automatically respawn
;With fuel at 0 the vehicle will not explode w/ as much damage
_obj setFuel 0
_obj setDammage 1

#alive
@!alive _obj

;If a vehicle is not alive then it will respawn in 40 seconds
;Change this if you want
~40

;Rearm the vehicle
_i = 0
#rearm
_mag = _magazines select _i
_obj removeMagazine _mag
_obj addMagazine _mag
_i = _i + 1
? _i < _j : goto "rearm"

;Move the vehicle back to its original position
_obj setPos _pos
_obj setDir _dir
_obj setDammage 0.3
~0.1
_obj setDammage 0.1
~0.1
;If you change damage too fast it blows up again, so ease into 0 (perfect health)
_obj setDammage 0
_obj setFuel 1

;Now that vehicle has respawned, go back to check and see if it has been driven & left behind or if it is dead again
goto "begin"


I hope this helps!

I-RZ#

  • Guest
Re:Ultimate Vehicle Respawn Script
« Reply #3 on: 22 Oct 2002, 13:51:22 »
Do you put the script in a seperate SQS file or do you just copy & paste it into the bottom of an init.sqs script or what? :-\

chill

  • Guest
Re:Ultimate Vehicle Respawn Script
« Reply #4 on: 23 Oct 2002, 02:39:06 »
The Ai does not attack any vehicle that is made by this script. Any ideas around this as I building a massive dynamic battle in multiplayer.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Ultimate Vehicle Respawn Script
« Reply #5 on: 24 Oct 2002, 03:27:32 »
Well I haven't figured out the AI stuff yet but I did update the script.  New version at http://www10.brinkster.com/dbircsak and I will post it here too.

Doolittle

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Ultimate Vehicle Respawn Script
« Reply #6 on: 10 Nov 2002, 07:53:01 »
I noticed just recently that the your set dir doesn't seem to work once the vehicle is respawned. I set a motor cycle one direction (not default) then go do my thing and when i come back the motorcycle is facing another direction and not in the direction i got off the vehicle.

hoz
Xbox Rocks

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Ultimate Vehicle Respawn Script
« Reply #7 on: 14 Nov 2002, 18:50:41 »
This doesnt use the Local command or a game logic, so when mplaying across the internet, different effects will occur on different clients.
It needs to be server side scripted.


If you want to really create the Ultimate script, then
Create a looping script that only has 1 instance of it running no matter how many vehicles are on the map, and is written in template form.
also
1) It has the option within it of disarming, or arming each vehicle types individual weapons
2) Respawning if damaged (Optionally switched)
3) Respawning if unnocupied (Time limit variable)
4) (For real coolness, you could have it not respawn, if the last driver of the vehicle was within a trigger area of the vehicle, this would allow it to remain in position, if the driver had loaded it with weapons and was usingm it as an ammo crate)

Ie do it for vehicle classes, and have each vehicle named within a list.

So if there was 20 vehicles on the map, and 5 different types of vehicle, there wouldnt be 20 versions of the script running, or even 4 (1 for each version type).

Just 1 almighty script.


I know your script does some of this already, but to become reliable and totally versatile, it needs more work!

Please keep at it
« Last Edit: 14 Nov 2002, 18:57:01 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Nasty Buttler

  • Guest
Re:Ultimate Vehicle Respawn Script
« Reply #8 on: 25 Feb 2003, 16:17:31 »
the AI attacking bus has been in flashpoint since 1.30....there is no cure as far as my BIS contacts tell me. Basically what happens is the AI dont concider dead units a threat so once they have been destroyed they are moved off the possible threat list and onto the dont worry about anymore list....they only true way to respawn a vehicle in Multiplayer is by using the createvehicle command.....yes you can assign a variable to it, BUT the variable will only be local to the machine it was created on and the server.....so AI can still use it but say if you order another client machine to moveindriver or something you will get weird things happening like u will be in the vehicle but in the middle of the ocean etc.....(usually point 0,0,0)

Anyway i hope that clarifies some things about vehicle respawn