Home   Help Search Login Register  

Author Topic: One script Vehicle Respawn  (Read 3199 times)

0 Members and 1 Guest are viewing this topic.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
One script Vehicle Respawn
« on: 02 Apr 2003, 23:39:14 »
Howdy...I woke up this morning and said, "hmmmm".  Here's yet another Vehicle Respawn Script...this one, however, is only one script running...the "other" methods I've seen (& made myself) have 1 script running per vehicle, so with 20 vehicles on a map, you would have 20 seperate scripts running.

This is EXTREMELY easy to implement into your map.  It will only work with 1.91 though (as typeOf is used).

1) So, to start.....for each vehicle's Initialization, put vehicles = vehicles + [this].  And then FOR THE FIRST VEHICLE YOU PLACE ON THE MAP you must put vehicles = [this] instead.  But only for that first vehicle placed.

2) Then make a trigger that runs ONCE with:  Condition: local Server OnActivation: [] exec "vehicles.sqs"

3) Then make a GameLogic called Server.

4) Then put this script in your mission's directory:
vehicles.sqs
Code: [Select]
;By Doolittle
_vpos = []
_vdir = []
_vtime = []
_count = count vehicles
_delay = 150

_i = 0
#load
_v = vehicles select _i
_vpos = _vpos + [[getPos _v select 0, getPos _v select 1, 0]]
_vdir = _vdir + [getDir _v]
_vtime = _vtime + [0]
_i = _i + 1
?_i < _count : goto "load"

#init
_i = 0
~3
#alive
_v = vehicles select _i
?fuel _v == 1 : goto "continue"
?alive _v and count crew _v != 0 : _vtime set [_i, 0]; goto "continue"
_vt = _vtime select _i
?_vt != 0 and _vt < _time : goto "notalive"
?_vt == 0 : _vtime set [_i, _time + _delay]
#continue
_i = _i + 1
?_i < _count : goto "alive"
goto "init"

#notalive
_vtype = typeOf _v
deleteVehicle _v
~1
_v = _vtype createVehicle (_vpos select _i)
_v setDir (_vdir select _i)
vehicles set [_i, _v]
_vtime set [_i, 0]
goto "continue"

Vehicles will respawn 150 seconds after being killed and they will also respawn if they are left empty for 150 seconds.

Enjoy!!

Doolittle

P.S. This is done by keeping an array of all vehicles, their start positions, direction facing, and then a timer for each vehicle for the 150 seconds delay.
« Last Edit: 02 Apr 2003, 23:57:10 by Doolittle »

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #1 on: 30 May 2003, 13:14:26 »
Hi, i really want to implement this script into a C&H i am making because of the abandoned vehicle respawn.

Here is the script i am using at the moment which works fine:-

;In init field:  [vehicle,time] exec "VehicleRespawn.sqs"

;VehicleRespawn.sqs
?!(local server) : exit
_vehic = _this select 0
_time = _this select 1
_type = typeof _vehic
_pos = getpos _vehic
_dir = getdir _vehic

#loop
_vehic addEventHandler ["killed", {[[0,0,0],[0,0,0],60,3+random 3,_this select 0] exec "\KEGnoecain_snow\script\destroy.sqs"}]
@!(alive _vehic)
~_time
deletevehicle _vehic
_vehic = _type createvehicle [0,0]
_vehic setpos _pos
_vehic setdir _dir
_vehic setdamage 0
goto "loop"
-----------------------------------------------------------------

Note it has the 'vehicle sets on fire when destroyed' part....is it possible to fit this into your script so i can have my cake and eat it so to speak??

Thanx!

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:One script Vehicle Respawn
« Reply #2 on: 30 May 2003, 17:35:58 »
Does that work in multiplayer, B-2-0?  Only the server is adding the event.  I don't believe the clients will see the smoke event.

Doolittle

beowulf2014

  • Guest
Re:One script Vehicle Respawn
« Reply #3 on: 30 May 2003, 21:18:31 »
Doolittle,

   I like your scripts you have been putting out, (if you remeber talking to me before on the STO server) and I have made a modification to your respawn script to make the smoke a little more realistic and also added a fuel loss system to it as to cause fuel loss when it is damage. So check it out and tell me what you think bro

ftp://ftpserver.stogroup.net/moddoolittlevrs.zip

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #4 on: 31 May 2003, 16:18:55 »
Ok, you were right Doolittle....Now i am stuck :-\

I need a MP compatible Vehicle respawn script that incorporates the 'abandoned vehicle' and the KEG vehicle fire and smoke features (or any other good fire and smoke feature)........Can anyone help me??  Credit will of course be given! :)
« Last Edit: 31 May 2003, 16:23:27 by B-2-0 »

beowulf2014

  • Guest
Re:One script Vehicle Respawn
« Reply #5 on: 31 May 2003, 22:29:24 »
well check this one out by doolittle. It works in multiplayer very well if you follow his intstructions. and I added a different smoke drop to it to make it look cooler (well to me anyways lol).  but you need to do this,

(this is a quote from doolittle and this way it works on MP)

INSTRUCTIONS:

I am creating a vehicle list via an ARRAY.  The very first VEHICLE placed on the map should have this in its Initialization:

vehicles = [this]

From then on, any other vehicle you want to be respawning, put this in instead:

vehicles = vehicles + [this]

THEN make a GameLogic and call it Server.  THEN make a trigger that runs Once and have its Condition be: local Server OnActivation: [] exec "vehicles.sqs"

Then make another trigger and have it run Once.  Its Condition should be: >>> local player <<<  and set OnActivation to: >>> [] exec "player.sqs" <<<

Then place the player.sqs, vehicles.sqs, and smoke.sqs in your mission directory.  That should be it!

IN VEHICLES.SQS the line at the top that says _delay = 3 ....this is how long it takes before a vehicle respawns.  You should probably change this to something like 300 (seconds).  Right now it is set to three seconds, which is rather fast.

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #6 on: 01 Jun 2003, 20:13:37 »
Ok, i have started to implement this into the map but am un-sure about a couple of things;
Quote
Its Condition should be: >>> local player <<<  and set OnActivation to: >>> [] exec "player.sqs" <<<


Do i need to include the arrows and do the triggers have to cover the map or is no radius needed?

Also is there a way i can use the KEG fire with this?

Thanx :)
« Last Edit: 01 Jun 2003, 20:32:28 by B-2-0 »

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #7 on: 01 Jun 2003, 22:34:00 »
Ok, i have figured it out and realised this does have fire ;D

But...i am getting a missing fuel-loss script error and although the fire and smoke look very nice, imo the fire extends too far from the vehicle and it doesn't burn when totally destroyed :-\

I know this is asking a lot but could one of you guys have a go at this for me as i am not as gifted in the scripting department as you :-[

As i said before could the KEG fire be incorporated into this, as that only burns when the vehicle is destroyed.

Credit will be given of course 8)

Hope so....thanx in advance
« Last Edit: 01 Jun 2003, 22:46:08 by B-2-0 »

beowulf2014

  • Guest
Re:One script Vehicle Respawn
« Reply #8 on: 02 Jun 2003, 02:34:04 »
yes i dont have the keg fire and it doesnt explode on dammage....i can do that but it will take some time for me to do. i run another editing team so my time is short. as far as the fuel loss ill post it here.
ftp://ftpserver.stogroup.net/fuel.zip
just put the file in with the others.
the other problem with burning after destroyed is that it respawns so that will stop the fire.
« Last Edit: 02 Jun 2003, 03:12:55 by beowulf2014 »

deaddog

  • Guest
Re:One script Vehicle Respawn
« Reply #9 on: 02 Jun 2003, 03:06:55 »
Hey Doolittle,

You could also populate the vehicle array like this:

place trigger covering entire map
type:anybody, present
condition:true
on activation:vehicles=[];{if ("tank" counttype [_x]>0 or "car" counttype [_x]>0 ) then {vehicles=vehicles+[_x]}} foreach thislist

This will place all tank and car types in the array and save you from having to worry about the init line of every vehicle.

It will also place any M2 machine guns in the list, since they are of type "tank".  You could remove those manually if you'd like.

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #10 on: 02 Jun 2003, 03:28:20 »
Thanx again Beowulf....don't get me wrong, the smoke is great and the fire 'looks' sweet but it just extends too far from the vehicle....looks cool on planes and choppers, or if the vehicle is still moving, but not when stood still.

Quote
the other problem with burning after destroyed is that it respawns so that will stop the fire.


Keg's fire gradually decreases (takes about 60secs to go out) which works well as i have my vehicle respawn time set to 60secs so as the fire goes out the wreck disappears.

Thanx!

Commando

  • Guest
Re:One script Vehicle Respawn
« Reply #11 on: 10 Jun 2003, 01:26:18 »
hi Doolittle i put your script in my mission but all the regular ofp stuff i have tried it works fine, but the ammo crate wont respawn..and when you say that the first vehilce placed on the map should contain this line vehicles = [this]  does it mean that my bus that drives around have to have that line in it or do you mean the first empty vehicle?
and btw i discovered a fun thing, I put a house from the editor addon and put in vehicles = vehicles + [this] code in the initfield of the house and it respawned after i destroyed it with a rocket! Really cool.
But why doesn't the ammo crate respawn?   :P

beowulf2014

  • Guest
Re:One script Vehicle Respawn
« Reply #12 on: 11 Jun 2003, 03:30:40 »
very odd, i have had success in respawning ammo crates with this scritp

B-2-0

  • Guest
Re:One script Vehicle Respawn
« Reply #13 on: 12 Jun 2003, 07:58:25 »
I use this script for repairing ammo crates....

;Autorepair.sqs
_crate = _this select 0
#start
@(getdammage _object > 0.9)
~10
_object setdammage 0
goto "start"


.....and put [name of crate] exec "AutoRepair.sqs" in your init.sqs file  :)

Commando

  • Guest
Re:One script Vehicle Respawn
« Reply #14 on: 12 Jun 2003, 15:57:21 »
Thx for the help. I'll try the script later today when I get home.
 :) this sript is really going to help me outbecause a friend of mine is a pain in the ass on destryoing stuff..