Home   Help Search Login Register  

Author Topic: Respawning Vehicles & Aircraft  (Read 3083 times)

0 Members and 2 Guests are viewing this topic.

Offline satexas69

  • Members
  • *
Respawning Vehicles & Aircraft
« on: 26 Feb 2007, 23:56:12 »
In OPF, respawn was always "shaky", with various scripts and stuff having odd effects like stuff multiplying, etc.

Does anyone have (or is it built in ArmA yet?) a way to successfully RESPAWN a vehicle after it's destroyed - and maybe with a nice "timer" on it so it's not "instant"?

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Respawning Vehicles & Aircraft
« Reply #1 on: 27 Feb 2007, 00:06:51 »
yep, i got this one working nicely:

vehirespawn.sqs
Code: [Select]
?! (local server): exit
~3
_vehicle = _this select 0
_delay = _this select 1
_empty = true
_disabled = false
_moved = false

_startpos = getpos _vehicle
_startdir = getdir _vehicle
_type = typeof _vehicle

#waiting
~2
_newpos = getpos _vehicle
?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false
? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true

?! (canmove _vehicle) or (canfire _vehicle): _disabled = true
? (canmove _vehicle) and (canfire _vehicle): _disabled = false
? (_disabled) and (_empty): goto "spawn"
? (_moved) and (_empty): goto "spawn"
goto "waiting"

#spawn
~_delay
?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false
?! (_empty): goto "waiting"
deletevehicle _vehicle
~0.5
_newveh = _type createvehicle _startpos
_newveh setpos _startpos
_newveh setdir _startdir
[_newveh, _delay] exec "vehirespawn.sqs"
exit

It also checks if there are some guys left in the vehicle and will break respawn routine unless vehicle is empty for sure. This will avoid to get you kicked out on a unsecure point, being shot at from all sides.

God am i lazy today....the script takes 2 arguments: vehicle and respawndelay.

Code: [Select]
[this, 120] exec "vehirespawn.sqs"
in the initline of a vehicle will respawn the vehicle after 2 minutes.

Please do not remove the 3 seconds wait at the beginning. This is for Choppers which are always a little "bumpy" when placed. Without the delay the script would recognize the bumps as "moved" and therefor instantly start the respawn routine.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Respawning Vehicles & Aircraft
« Reply #2 on: 27 Feb 2007, 00:25:14 »
There is also an ArmA command for this sort of thing:

respawnVehicle....


vehiclename respawnVehicle [delay, count]


Planck
I know a little about a lot, and a lot about a little.

Offline satexas69

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #3 on: 01 Mar 2007, 21:39:37 »
UPDATE:

The VEHIRESPAWN.sqs script below technically works - but it's got the SAME problem the OpFlash ones had - it spawns and spawns multi vehicles like your stuff is mating. Not good.... 10 choppers on respawn in a field end up a pile of 100.

Also, I can't get Planck's ArmA command to work... I tried various times, no respawn ever...

Help? Ideas?

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Respawning Vehicles & Aircraft
« Reply #4 on: 01 Mar 2007, 21:56:18 »
did you set a GameLogic named "server"? It sounds to me that you didn't had placed this, ending up the script running on each client.

My mistake not clearly telling you that you have to set such a Gamelogic. Actually, this script is in use in seeveral missions and i never had the problem you're telling.

Offline satexas69

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #5 on: 02 Mar 2007, 07:23:45 »
Ah, that must be my mistake, I had not used any gamelogic.

The whole "GameLogic" advancement has always confuse me - in addition to the script, how exactly do I had the gamelogic? (IE, what exactly needs to be set in the options??)

Thanks in advance Myke..

Russ

Offline WhisperOFP

  • Members
  • *
  • I'm a llama!
Re: Respawning Vehicles & Aircraft
« Reply #6 on: 02 Mar 2007, 13:29:08 »
Just add a gamelogic on the map (it's a unit of side "LOGIC", and then you won't have much choice in unit type, it's "LOGIC"), and give it the name : server. That is all

Offline satexas69

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #7 on: 02 Mar 2007, 13:44:07 »
I've added a game logic with the name "Server" in the NAME field - I assume that's what you mean.

But I still don't totally understand...

1. How does that respawn script know to use it?

2. Wouldn't MANY scripts need to use that? Why isn't it included in default in the game.

3. I've seen game logic "AI" in the name field too... is that for other scripts that require it also?

I know this is "dumb" for some of you vets, but I'm trying to understand "basic concepts" so I can move forward on my learning :)

Offline FreeBird

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #8 on: 03 Mar 2007, 21:46:51 »
Quote
1. How does that respawn script know to use it?
In combination with the "Local" command.
?(local server):exit --->it means exit to all who/what is local to the GameLogic named server (it is a bit confusing,
name your GameLogic "Alpha" and your script looks now:?(local Alpha):exit
By Default only Dedicated server is local to GameLogic
?(local player):code --->this code will only run on the players machine,as he and only he is local to player

Quote
2. Wouldn't MANY scripts need to use that? Why isn't it included in default in the game.
Yes,many needs it.It probably is included in BIS MP maps.


Quote
3. I've seen game logic "AI" in the name field too... is that for other scripts that require it also?

Yes,U can do many things with GameLogics,like pinpoint a position for a sound...

Code: [Select]
_relPos = [random 1,random 1,random 1]
_rico = player modelToWorld _relPos
_logic = "logic" createVehicle (_rico)
_logic say "bulletricochet1"
~0.1
deletevehicle _logic


PS:There is nothing "dumb" when trying to understand something
Call [This,Birth,School,Work,Death]execVM "Storyofmylife.sqf"
(_this select 1)ObjStatus "DONE";(_this select 2)ObjStatus "DONE";(_this select 3)ObjStatus "ACTIVE";(_this select 4)ObjStatus "HIDDEN";
if not((_this select 0) IsKindOf "Human")ExitWith{PlayMusic"Goodbye Cruel World"}

Offline satexas69

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #9 on: 03 Mar 2007, 22:05:10 »
Excellent help, and I *really* appreciate it. Very, very kind of you.

In naming, does CaPiTaLiZaTiOn matter in the NAME field?

IE, does a game logic "SERVER" differ from "Server" or "server"?

Offline FreeBird

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #10 on: 03 Mar 2007, 22:09:58 »
Nope,but dont forget,the fun in scripting is trying to find out as much as you can yourself. ;)
Call [This,Birth,School,Work,Death]execVM "Storyofmylife.sqf"
(_this select 1)ObjStatus "DONE";(_this select 2)ObjStatus "DONE";(_this select 3)ObjStatus "ACTIVE";(_this select 4)ObjStatus "HIDDEN";
if not((_this select 0) IsKindOf "Human")ExitWith{PlayMusic"Goodbye Cruel World"}

Offline satexas69

  • Members
  • *
Re: Respawning Vehicles & Aircraft
« Reply #11 on: 04 Mar 2007, 00:44:13 »
Absolutely, and that's what I've been doing, pulling apart scripts, learning how they work, etc.

The only thing I wish Script writers would do, would put "how to use" syntax as comments at the top of the script...

Each script I've learned how to use, I've been doing that - that way when people pull apart MY missions, I'll save them some time and learning curve  :)