Home   Help Search Login Register  

Author Topic: Vehicle Respawn  (Read 1675 times)

0 Members and 1 Guest are viewing this topic.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Vehicle Respawn
« on: 21 May 2005, 10:42:23 »
Quote
_obj = _this select 0
_pos = getpos (_this select 1)
_stime = _this select 2
_dir = _this select 3
~5
_weapons = weapons _obj

#waitdeath
? (getdammage _obj >= 1) : goto "spawn"
~10
goto "waitdeath"

#spawn
_obj setFuel 0
~_stime
_obj setVelocity [0, 0, 0]
_obj setPos [(_pos select 0),(_pos select 1), (_pos select 2)+0.1]
_obj setDir _dir
_obj setDammage 0.3
~0.5
_obj setDammage 0.1
~0.5
_obj setDammage 0
_obj setFuel 1

removeAllWeapons _obj
"_obj addMagazine _x" forEach _weapons

goto "waitdeath"

that is a vehicle respawn I'm using. The problem is, for some reason the vehicles blow up when they respawn. Like, a vehicle is destroyed, when it respawns, it first gets moved to where it spawns to, then it blows, then it's setdamaged to 0. So, whats wrong? :-\

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Vehicle Respawn
« Reply #1 on: 21 May 2005, 13:05:42 »
use a createvehicle command for the new undamaged version and deletevehicle the old
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Vehicle Respawn
« Reply #2 on: 21 May 2005, 13:53:40 »
I can't do that, cause I got lots of scripts running for some of the vehicles, and creating a new one will cause a lot of problems with the scripts, and I have to change like 30 scripts...if it's even possible to make all the scripts work for a new vehicle.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Vehicle Respawn
« Reply #3 on: 22 May 2005, 10:01:59 »
well whatever scripts you have running on the old vehicle can be passed to the new vehicle

eg
_veh =

[_veh] exec "myscript.sqs"

and then use
_veh = _this select 0

at the start of these scripts so that you can refer to the vehicle you created

********************************************************************************
********************************************************************************
following script initiated by the following line in the init field of the vehicle

[this, "vehicle class name"] exec "common\vehrespawn.sqs";

Quote
?!(local Server): exit
~3
_vcl = _this select 0
_vclclass = _this select 1
_vclpos = getpos _vcl
_vcldir = getdir _vcl
_vclweapArray = weapons _vcl
_vclmagArray = magazines _vcl

[_vcl] exec "myscriptA.sqs"
[_vcl] exec "myscriptB.sqs"
[_vcl] exec "myscriptC.sqs"


#DEFAULT_DELAY
;;;;Delay before an abandoned vehicle is respawned
_i = 60


#START0
_vcl lock False
?(getdammage _vcl > .01):goto "LOST"
?(count crew _vcl > 0):goto "START1"
~2
goto "START0"
 
#START1
?!(Alive _vcl):goto "END"
?(count crew _vcl <= 0): goto "LOST"
~1
goto "START1"
 
#LOST
_counter = 0
#LOOP
~1
_counter = _counter + 1
?!(Alive _vcl): goto "END"
?(getdammage _vcl >= 0.7) && (count crew _vcl <= 0): goto "END"
?(count crew _vcl > 0): goto "START1"
? _counter >= _i: goto "NEWVEHICLE"
goto "LOOP"

#END
_vcl setdammage 1
;; following is how long to wait before you start the createvehicle process after deleting the old version
~ 60
goto "NEWVEHICLE"


#NEWVEHICLE
_vcl setfuel 0
~1
_vcl setdammage 0.7
~0.1
_vcl setdammage 0.5
~0.1
_vcl setdammage 0.2
~0.1
_vcl setdammage 0.1
~0.1
deleteVehicle _vcl
~0.1
_vcl = _vclclass createVehicle _vclpos
_vcl setdir _vcldir
removeallweapons _vcl
{_vcl addMagazine _x} forEach _vclmagArray
{_vcl addWeapon _x} forEach _vclweapArray
_vcl setdammage _vcldamage

goto "START0"

the blue lines are where you want your additional vehicle scripts to start
« Last Edit: 22 May 2005, 10:02:38 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Vehicle Respawn
« Reply #4 on: 22 May 2005, 20:32:42 »
you don't get it...the scripts for the vehicles are tied to their name to work...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Vehicle Respawn
« Reply #5 on: 22 May 2005, 22:03:47 »
Garcia, you need to give us more information.    At the moment what you're saying doesn't make sense.    How are the scripts tied to the name of the vehicle?   And why?  

I'm not a scripting expert but Terox's solution seems to be reasonable.   If it won't work, why not?    

Also, please give you give us an example of how the script is called.

Tell us in more detail what exactly is going wrong.    Vehicles often blow up shortly after they are destroyed - is that was is happening here?    The difference here being that they are moved to the new position between (for example) the LAW hitting them and the final explosion ocurring.
« Last Edit: 22 May 2005, 22:08:14 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Vehicle Respawn
« Reply #6 on: 22 May 2005, 22:30:46 »
execution: [vehicle name,respawn point,respawn delay,direction] exec "MIFVR.sqs"

Vehcile name: the name of the vehicle which the script runs for (:P)
Respawn point: the name of a object that is at the position where the vehicle should respawn (because not all vehicles are respawning to the point they are at when the script is executed)
respawn delay: delay from the vehicle is destroyed until they respawn
direction: direction the vehicle should face when respawned.

Reason why the other scripts are tied to the name of the vehicle is because I've made some scripts adding actions to the different choppers, like drop flares and drop ammo, and some scripts to cause fuel leaks and stuff like that...and since I'm a crappy scripter, it all gets kinda messy to script this in MP, since I gotta PV lots of things and stuff like that.

Example: player1 gets in a slick and drops some flares using the drop flare action. The script executed from the action only runs for him, so I gotta set i.e dropflare = true and then PV it. And then I got another script running in a loop checking when dropflare is true...when it is, it drops the flares, then sets dropflares to false and goes back to the loop. Now, I'm sure it would work some way or another to create new choppers and execute these scripts for the new chopper, but I don't know how, and I really don't wana start doing it.

Before I added all these scripts for the choppers, I tried making another respawn script which created a new chopper which was taken to base by AI, to make it all a bit more realistic. Problem was that the creation line could only run for server, or else I would get 1 chopper for the server + every client. And since the line only ran on server, only the server knew the choppers name, so when I executed a script for the chopper, only the server noticed the effect, so I ended up with dust script only for the server and stuff like that.

Anyway, I've tried moving the chopper to a island where the player ain't supposed to be (:P) and setdamage it to 0 there, then wait 20 seconds before moving it to base. Because the vehicles usually waits about 15-40 mins before getting respawned, but they for some reason blow up. Like, v1 (jeep) gets destroyed by VC. After 15 mins it gets moved to base, then it blows up, and then it's setdamaged to 0. And I really doubt that the final explosion occurs after 15 mins ;)
« Last Edit: 22 May 2005, 22:31:36 by Garcia »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Vehicle Respawn
« Reply #7 on: 23 May 2005, 16:17:08 »
As long as you want the spawned (newly created vehicle) to have the same attributes of its predecessor, then my above example will work

The script is a looping script, so any newly created vehicle will have the same spawnpoint info passed to the script when it was originally executed



eg

_a = _this select 0
_b = _this select 1

value _A and value _B will be the same for the newly created vehicle and the old one


you can add query's on the class type of the vehicle and then start scripts for that


eg,  after the createvehicle line, before the script jumps back to its starting point, you can add lines like

?("tank" countType [_vcl] > 0): [_vcl] exec "smokegrenade.sqs"


any local variable can be passed as part of the array that is starting a script
therefore you can use your
[_vcl, _a,_b] exec "anothervehiclerespawnscript.sqs"


but because the script is looping, the newly created vehicle will have the same attributes as the old one


the old vehicle was referred to as _vcl, all u simply do is start referring the newly created vehicle as _vcl


The script i posted wasn't meant to be a replacement for yours, i was merely trying to explain how to implement what you want in a similar system
« Last Edit: 23 May 2005, 16:18:49 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Vehicle Respawn
« Reply #8 on: 23 May 2005, 16:39:17 »
Well, problem with your script is that the script is only running on the server, and that will cause the scripts executed in the vehicle respawn script to only be executed on the server, right? I could get it all working if I it was possible to, in one way or another, send the name of the vehicle to every other computer :-\

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Vehicle Respawn
« Reply #9 on: 23 May 2005, 18:41:41 »
How are you executing this script?
The way I read it is that it should be started with something like
[chopper1, 30, 180] exec "vehiclerespawn.sqs"

However, that doesn't seem to be. You're getting four values and I only see three that need to be passed.
So with the above exec you could have

_obj = _this select 0
_pos = getpos _obj
_stime = _this select 1
_dir = _this select 2

Instead of

_obj = _this select 0
_pos = getpos (_this select 1)
_stime = _this select 2
_dir = _this select 3
Not all is lost.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Vehicle Respawn
« Reply #10 on: 23 May 2005, 18:46:54 »
ah, the beta tester :P

nono...since the gunships ain't where they are supposed to be spawned to when the respawn script starts, it should be executed (as I wrote in my reply to mac) like this: [v1,h1,800,0] exec "script.sqs"

v1=vehicle
h1=spawn point (usually the vehicle name, but for gunships, name of H they are supposed to spawn to)
800=respawn delay
0=direction on spawn...

Quote
execution: [vehicle name,respawn point,respawn delay,direction] exec "MIFVR.sqs"

Vehcile name: the name of the vehicle which the script runs for (:P)
Respawn point: the name of a object that is at the position where the vehicle should respawn (because not all vehicles are respawning to the point they are at when the script is executed)
respawn delay: delay from the vehicle is destroyed until they respawn
direction: direction the vehicle should face when respawned.