Home   Help Search Login Register  

Author Topic: Featured OFPEC vehicle respawn scripts.  (Read 2448 times)

0 Members and 1 Guest are viewing this topic.

Baphomet

  • Guest
Featured OFPEC vehicle respawn scripts.
« on: 04 Dec 2002, 02:21:58 »
I want to put a vehicle respawn script into my mission however the two I downloaded off of OFPEC (both made by Doolittle) have critical flaws which if were removed, would be much more useful.

The flaw I see in the first vehicle respawn script is the fact that the vehicle breaks not 10 seconds after you leave it. Of course what it does do that I like, is respawns right after it breaks.

The ultimate vehicle script fixes this by allowing one to specify a time for the vehicle to break if it hasn't been used during that period. The absurd thing is. It doesn't respawn immediately afterward? That negates the usefulness of such a thing. Why have a broken vehicle just sit there not being able to be used if it can't respawn?

If someone would be so good as to, fix? This problem. I'd be very grateful. Since the Ultimate Vehicle respawn seems to run off these two timers. It seems like it'd take a lot of re-scripting to get it to work the way it should.

I was just thinking about lowering the respawn interval from 180 to something shorter. However wouldn't that just cause a significant drain on system performance?
« Last Edit: 04 Dec 2002, 02:27:27 by Baphomet »

Baphomet

  • Guest
Re:Featured OFPEC vehicle respawn scripts.
« Reply #1 on: 04 Dec 2002, 13:03:52 »
Well. I've fiddled around with it. If the respawn time is elimiated there's a bug where the vehicle respawns looking like it's destroyed (yet still usable). Reducing the respawn time to something like 20s. Is an acceptable workaround solution... for the respawning of destroyed vehicles.

I'd personally in this script like to see two things. The getout.sqs perform an action which doesn't simply kill the vehicle so that killed.sqs respawns it.  With the lowered respawn time this is of reduced annoyance, however. I'd still like to see the vehicle just instantaneously disappear and reappear at its place of origin.

Secondly. The getout.sqs script should have some kind of detection that resets the timer if someone gets into the vehicle. To the best of my limited knowledge this is how the beginning of the script script currently works.


Check to see if it's alive,
check to see if it's got more than one passenger.
If not, then wait for 120s.

Right there is the problem. The only way I could see working around that is breaking the intervals of time down and repeatedly checking to see if a passenger is in the vehicle. It's a very crude and perhaps not very efficient way of getting past it. Is there any better way of dealing with this problem?

I really like the idea of having a vehicle reset, especially if it has been left out in the wilderness and forgotten or simply to inconvenient to acquire. However when I drive my vehicle and go to an ammo depot and load it up with supplies for example, that sets the timer in motion say I get back in after about 45 seconds and then drive for another 65, then I get out for a mere 10 seconds... *floof* My vehicle is gone! When I really needed it!

Of course you could crank up the length of time, even still you're just slightly decreasing the odds of that happening. I mean for me, anything above 8 minutes is excessive. Since I'm using this in a deathmatch scenario I want the gameplay to be fluid and therefore wanting vehicles to be available when people need them, unless of course they are already in use.

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:Featured OFPEC vehicle respawn scripts.
« Reply #2 on: 04 Dec 2002, 18:52:05 »
Here's what I've been using for a long time now.  I've recently made adjustments in the hopes that it works better.

Basically it uses the !(CanMove) query to see if the vehicle can move at all.  Sometimes if you go down a steep hill and then flip over a few times, then the game thinks the vcl cannot move, so even though you'd land upright, the vehicle would respawn.  I now have it check again before it respawns it to see if it can move again, and if it can't, if the driver, commander and gunner position is null then it respawns it.  The other thing is that if there is no-one in the vcl, then u could shoot out a tire to send it back to base.  Otherwise it'll wait 2.5 mins before sending it back to base.  If someone gets in during that time, then the timer resets.

I'm working on a better version, but haven't finished testing all the possibilities for it yet.  BTW this one has the ability to do special loadouts for the vcl's just depending on what you want, and this script can also respawn certain Addon vehicles.

To use this, put:

[this]exec "vrs.sqs"

into the on init field of any vehicle u want to respawn.  That way you don't have to do a lot of extra editing in the editor like you might for some scripts that require a lot of info in the array.

Quote
;;BEGIN vrs.sqs
;;By KaRRiLLioN
;;VehicleType Loop by Sefe
;;Original script by Backoff
;;Updated for 1.75 by Jaeger Neo
;;IMPORTANT: ADD A GAMELOGIC NAMED Server
;;to the mission to prevent multispawn

?!(local Server): Goto "end"
_vcl = _this select 0
_respawndelay = 10
_dir=Getdir _vcl
_position=Getpos _vcl
_Vehicles=[]

_Bronco = ["DKMM_OV10_B","DKMM_OV10_FAC","DKMM_OV10_RHB","DKMM_OV10_RES","DKMM_OV10_TR","DKMM_OV10_ATG"]
_TomCat = ["F14TM","F14TMB","F14TMD2","F14TMD"]
_AirAddons = ["bas_ah6mp","bas_ah6j","bas_md500dtow","bas_mh6","bas_mh6a","WDragonfly","EDragonfly"]
_ArmorAddons = ["DKMM_M109_ADATS","DKMM_dtunguska","M109_2","M109"]
_WTrucks=["Truck5tOpen","Truck5tRepair","Truck5tReammo","Truck5tRefuel","Truck5t"]
_ETrucks=["UralRepair","UralReammo","UralReFuel","Ural"]
_CivTrucks=["TruckV3SGCivil","TruckV3SGRefuel","TruckV3SGRepair","TruckV3SGReammo","Bus","TruckV3SG"]
_Jeeps=["JeepMG","GJeep","HMMWV","UAZ","SGUAZG","UAZG","JeepPolice","Jeep"]
_Cars=["Tractor","Rapid","RapidY","Skoda","SkodaBlue","SkodaRed","SkodaGreen","Trabant","Jawa"]
_Helos=["Cobra","AH64","CH47D","OH58","UH60MG","UH60","Kamov","Mi24","Mi17"]
_Planes=["Cessna","A10LGB","A10","SU25"]
_WArmor=["M1Abrams","M60","Bradley","M113Ambul","Vulcan","M2StaticMGE","M2StaticMG","M113","BoatW"]
_GArmor=["T80Res","T72Res"]
_EArmor=["T80","T72","BMP2","BMPAmbul","BMP","BRDM","BoatE","ZSU","T55G"]
_Other=["Mash"]
_OtherAddons = ["sttklr250"]

_Vehicles = _OtherAddons + _TomCat + _Bronco + _AirAddons+_ArmorAddons+_WTrucks+_ETrucks+_CivTrucks+_Jeeps+_Cars+_Helos+_Planes+_WArmor+_GArmor+_EArmor+_Other

_i = 0
#Loop
? (_i > (Count _Vehicles)) : Goto "Skip"
_VehicleType = _Vehicles Select _i
_VehicleTypeDoesMatch = ((_VehicleType CountType _this) == 1)
? _VehicleTypeDoesMatch : _type = _VehicleType
? _VehicleTypeDoesMatch : Goto "Skip"
_i = _i + 1
Goto "Loop"


#start
_wait = 150
~2
@!(Canmove _vcl) OR !(IsNull Driver _vcl) OR !(IsNull Gunner _vcl) OR !(IsNull Commander _vcl)
?!(CanMove _vcl) : Goto "Dead"
@((IsNull Driver _vcl) AND (IsNull Gunner _vcl) AND (IsNull Commander _vcl)) OR !(CanMove _vcl)
?!(CanMove _vcl) : Goto "Dead"
?(IsNull Driver _vcl) : Goto "DriverWait"

#Dead
~_respawndelay
?(CanMove _vcl) AND ((!IsNull Driver _vcl) OR !(IsNull Gunner _vcl) OR (!(IsNull Commander _vcl) : Goto "start"
#Respawn
deleteVehicle _vcl
_vcl = _type createVehicle _position
_vcl setdir _dir
Goto "Skip"

#DriverWait
~1
?(IsNull Driver _vcl) AND (IsNull Gunner _vcl) AND (IsNull Commander _vcl) AND (_wait == 0) : Goto "Respawn"
?!(IsNull Driver _vcl) OR !(IsNull Gunner _vcl) OR !(IsNull Commander _vcl) : Goto "start"
?!(CanMove _vcl) : Goto "Respawn"
_wait = _wait - 1
Goto "DriverWait"

#Skip

#CustomArming

?(_type=="cessna"):goto "cessna"
?(_type=="Mi17"):goto "Mi17"
?(_type=="OH58"):goto "OH58"
?(_type=="CH47D") OR (_type=="UH60MG"):Goto "UH60MG"
?(_type=="M2StaticMG"):goto "M2"
?(_type=="M2StaticMGE"):goto "M2"
Goto "start"

#Mi17
_vcl removemagazines "Rocket57x192"
_vcl removeweapon "Rocket57x192"
_vcl addweapon "MachineGun30"
_vcl addmagazine "MachineGun30"
goto "start"

#cessna
_vcl addmagazine "MachineGun30"
_vcl addweapon "MachineGun30"
_vcl addmagazine "MaverickLauncher"
_vcl addweapon "MaverickLauncher"
_vcl addmagazine "ZuniLauncher38"
_vcl addweapon "ZuniLauncher38"
Goto "start"


#OH58
_vcl removemagazine "LaserDesignatorOH"
_vcl removeweapon "LaserDesignatorOH"
_vcl addmagazine "Browning"
_vcl addweapon "Browning"
Goto "start"

#UH60MG
_vcl removemagazine "Browning"
_vcl removeweapon "Browning"
_vcl addmagazine "MachineGun30"
_vcl addweapon "MachineGun30"
goto "start"

#M2
_vcl removemagazine "Browning"
_vcl removeweapon "Browning"
_vcl addmagazine "MachineGun30"
_vcl addweapon "MachineGun30"
_vcl addmagazine "Rocket57x64"
_vcl addweapon "Rocket57x64"
_vcl addmagazine "SHELL120"
_vcl addweapon "SHELL120"
Goto "start"


goto "start"


#end
Exit
;;END vrs.sqs
« Last Edit: 05 Dec 2002, 02:43:49 by KaRRiLLioN »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #3 on: 04 Dec 2002, 22:45:07 »
This is what I tend to use
(Its not my script, and i forget who made it) so apologies

Each vehicle requires a gamelogic to be placed where you want it to respawn and a gamelogic called "server"

Type the following into the init field of the vehicle
[this "oh58", "oh58spawn", 70] exec "veh_respawn.sqs"

where

"oh58" is the class_name of the vehicle
"oh58spawn" is the name you gave the gamelogic that marks the respawn location
"70" is the angle you want the vehicle to face

This is basically how it works
1) It checks to see if the vehicle is damaged
2) If it is, it then checks to see if there are any crew
3) When the crew has dismounted it removes all the fuel to stop it, sets damage to full then deletes the vehicle

The respawning vehicle looks perfect, basically because it creates a new one

An advantage of this is, the respawning vehicle does not have to be in the same location as the original

The example i use is for a couple of choppers
As you can see its easy to remove weapons, ammo etc
if yopu want unarmed choppers or limited ammo etc
-------------------------------------------------------------------------------------
;veh_respawn.sqs
;Chopper respawn no ammo
 ~1
 ?!(local Server): exit  
 _vcl = _this select 0
 _class = _this select 1
 _rspn = _this select 2
 _azimut = _this select 3  
 #start0
 _vcl lock False
 ~5
 ?(getdammage _vcl > .01):goto "Lost"
 ~2
 ?(count crew _vcl > 0):goto "start1"  
 ~5
 goto "start0"
 ;*************************************************************
 #start1
 ?!(Alive _vcl):goto "end"
 ?(count crew _vcl == 0):goto "Lost"
 ~10
 goto "start1"
 ;*************************************************************
 #Lost  
 ~5
 ?!(Alive _vcl):goto "end"
 ~30
 ?!(Alive _vcl):goto "end"  
 ~30
 ?!(Alive _vcl):goto "end"
 ?(count crew _vcl == 0):goto "end"
 ?(count crew _vcl > 0):goto "start1"
 ;goto "start0"
 ;*************************************************************
 #end
~30
 _vcl setfuel 0
 ~1
 _vcl setdammage 1
 deleteVehicle _vcl
 ~10
 _vcl = _class createVehicle getpos _rspn
 _vcl setdir _azimut
 _vcl lock False  
?(_class == "Kamov"): _vcl removemagazines "Rocket57x40Kamov"
?(_class == "Kamov"): _vcl removemagazines "Cannon30AP"
?(_class == "Kamov"): _vcl removemagazines "Cannon30HE"
?(_class == "Kamov"): _vcl removemagazines "HellfireLauncherKamov"
?(_class == "OH58"): _vcl removemagazines "ZuniLauncherOH"

 goto "start0"
---------------------------------------------------------------------------------
It uses older commands, i am sure that folks can do a better job with the newer commands available
« Last Edit: 04 Dec 2002, 22:50:04 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Baphomet

  • Guest
Re:Featured OFPEC vehicle respawn scripts.
« Reply #4 on: 05 Dec 2002, 09:58:01 »
Thanks for the input. I'll look into them.  :)

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Featured OFPEC vehicle respawn scripts.
« Reply #5 on: 05 Dec 2002, 19:14:24 »
I'm working on fixing my respawn scripts.  The thing where they respawn "broken" is hard to fix.  The new getout.sqs has this in it:

_x = 0
#crew
~3
? count crew _obj != 0 : exit
? not alive _obj : exit
_x = _x + 1
? _x < 50 : goto "crew"

So that every three seconds it sees if anyone re-entered vehicle...to reset timer.

Doolittle

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #6 on: 05 Dec 2002, 20:49:04 »
Quote
Here's what I've been using for a long time now.  I've recently made adjustments in the hopes that it works better.
....

@KaRRiLLioN -  Now that is a proper vehicle respawn script - one that uses createvehicle. The type that are in the ed depot still use setdammage to fix the vehicles, which causes AI to ignore them. and for them to appear crushed even after they are fixed.

One tiny bug I see though....

The type for the OH58(Kiowa) is "JetRanger", not "OH58". I don't thing your respawn script would work on the Kiowa.

@Doolittle
The reason they respawn broken is because you need to use deletvehicle and createvehicle, instead of setdammage. Objects are not meant to be ressurected in OFP - thats why BIS gave us the createunit/creatvehicle/delectvehicle commands.

---------------------------
EDIT: Maybe im wring about the kiowa type thing, as I see that both of you use "oh58" as it's type. You should check it though.
« Last Edit: 05 Dec 2002, 21:00:36 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:Featured OFPEC vehicle respawn scripts.
« Reply #7 on: 05 Dec 2002, 22:44:04 »
JetRanger?  I haven't heard of that one before.  Are you sure you're not thinking about an addon?  Anyway, I've been using that respawn for a long time and it respawns Kiowa's with no probs.

BTW I got a PM from Suma on the official forums saying that they were "considering" a GetType command, but no promises.  It would be awesome though because that would cut many, many lines of code from my vehicle respawn.

The main reason some ppl  like to use the SetDammage respawn method is to keep the same "Name" for the vehicle, i.e. whatever they name it in the editor.  There are, however much better methods if you need to identify certain vehicles with certain names.  Simply using :

MyCar = _vcl
PublicVariable "MyCar"

Works much better than naming it in the editor and then simply setting damage to 0 whenever it dies.  The reason it still looks broken by using this method is because the server considers the vehicle dead and gone.  Using createvehicle spawns a new one that the server recognizes as dead.

If you took a soldier and had it exec a script to setdammage 0 whenever it died and played it locally on your machine, then it would look like it works perfectly.  If you did the same thing on a dedicated server, you would see the soldier's corpse sliding along on the ground, mainly because the server doesn't seem to broadcast the fact that it is alive again.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #8 on: 05 Dec 2002, 23:57:26 »
Your right karr..I was looking at an config.cpp of an addon - thought it was the official config.cpp :P  Oopsie!

Gettype would be a great command to have. There are a couple of vehcles who's class does not corrospond to their name, like the LST is actually "CarrierW". I have no clue what the M2A2's class is.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:Featured OFPEC vehicle respawn scripts.
« Reply #9 on: 06 Dec 2002, 02:19:57 »
The M2A2 is referred to as "Bradley".  I'm not entirely sure why they decided upon some names, like the M1A1 is the "M1Abrams", etc.  I don't know why they didn't just keep it "M1A1".

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Featured OFPEC vehicle respawn scripts.
« Reply #10 on: 06 Dec 2002, 03:52:38 »
toadlife I use event "Killed" to see when something's dead.  If I delete the vehicle object then I'd need to remove the event for it and add an event to the new object.  This is a pain.

Doolittle

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Featured OFPEC vehicle respawn scripts.
« Reply #11 on: 06 Dec 2002, 08:07:31 »
Ok, stick [this] exec "vehicle.sqs" in a vehicle's Init string.  This script will respawn a new vehicle if that vehicle was killed and also has the feature of respawning a vehicle right away if you leave the vehicle "unattended" for two minutes!

This script will work when 1.91 comes out because I use the typeOf command.

Code: [Select]
_obj = _this select 0

_pos = getPos _obj
_dir = getDir _obj
_type = "UAZ"
;_type = typeOf _obj

~random 5
? not alive _obj : exit

_crew = 0
#alive
~3
? fuel _obj != 1 : _crew = _crew + 1
? count crew _obj != 0 : _crew = 0
? alive _obj and _crew < 50 : goto "alive"

_delay = 150
? fuel _obj != 0 : _delay = 10
"_obj removeMagazine _x" forEach magazines _obj
_obj setFuel 0
_obj setDamage 1

~_delay

deleteVehicle _obj
~1
_obj = _type createVehicle _pos
_obj setDir _dir

_crew = 0
goto "alive"

If you use this code in your mission you must mention "Vehicle Respawn script by Doolittle" in your mission briefing notes!  Thanks.

Doolittle

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:Featured OFPEC vehicle respawn scripts.
« Reply #12 on: 06 Dec 2002, 20:33:04 »
Well I sure hope they release the english 1.91 version soon.  We've been begging for a GetType command for some time now.

Then I'll do a lot of re-writing in RTS-3 as well to account for the fact that I don't have to loop some things anymore.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Featured OFPEC vehicle respawn scripts.
« Reply #13 on: 06 Dec 2002, 20:43:10 »
Here's another (more logical?) way to write that script:

Code: [Select]
_obj = _this select 0

_pos = getPos _obj
_dir = getDir _obj
_type = "UAZ"

_t = 0
#alive
~3
? not alive _obj : _delay = 150; goto "notalive"
? fuel _obj == 1 : _t = 0; goto "alive"
? count crew _obj != 0 : _t = 0; goto "alive"
? _t == 0 : _t = _time + 150; goto "alive"
? _t > _time : goto "alive"

"_obj removeMagazine _x" forEach magazines _obj
_obj setFuel 0
_obj setDamage 1
_delay = 10

#notalive
~_delay

deleteVehicle _obj
~1
_obj = _type createVehicle _pos
_obj setDir _dir

_t = 0
goto "alive"

If you use this script you must include "Goats are mean." in your mission's briefing.

Doolittle

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #14 on: 06 Dec 2002, 22:40:06 »
This is what I wrote the other day just messing around. You initialize the script with the vehicle, type,limit of respawns, and delay. The script respawns the vehicle on the position the vehicle starts at. I havn't tested it on a dedicated server, nor added any weapons code but it works like a charm.

Code: [Select]
; Untested on ded servers!
; Vehicle being respawned
_vehicle = _this select 0

; Type of vehicle - See official command ref for types
_type = _this select 1

; Respawn limit - 0 for unlimited
_limit = _this select 2

;Delay before respawning
_delay = _this select 3

; Starting direction of the vehicle
_dir = getdir _vehicle

; Starting position of the vehicle
_pos = getpos _vehicle

; Initialize the variable that keeps track of vehicle respawn count
_number = 0

; Default respawn delay (in case it's not specified by the mission maker)
_delay = 15

; Select respawn delay via script init - to use mission parameters, leave blank
_delay = _this select 3

; Select respawn delay from mission parameters
?param1 == 1:_delay = 5
?param1 == 2:_delay = 10
?param1 == 3:_delay = 20
?param1 == 4:_delay = 40
?param1 == 5:_delay = 80
?param1 == 6:_delay = 160


#respawnloop
@getdammage _vehicle == 1
_number = _number + 1
~(_delay / 2)
_vehicle setpos [0,0,0]
deletevehicle _vehicle
~(_delay / 2)
?(( _number > _limit) && !(_limit == 0)):exit
_vehicle = _type createvehicle _pos
_vehicle setdir _dir

;;; ATTENTION: insert any weapon cargo code here!

goto "respawnloop"
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #15 on: 06 Dec 2002, 22:59:16 »
Quote
If you use this script you must include "Goats are mean." in your mission's briefing.

Doolittle

LMAO!

That script is very similar to the last one I posted. One suggestion is to use the canfire and canmove commands when checking vehicles. They are very usefull commands.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Featured OFPEC vehicle respawn scripts.
« Reply #16 on: 07 Dec 2002, 20:42:44 »
If you want to use it on a dedicated server you have to "Server Side" script it to be assured of the clients all getting the same results


« Last Edit: 07 Dec 2002, 20:43:32 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123