Home   Help Search Login Register  

Author Topic: Respawning vehicles with AI in the AIR  (Read 628 times)

0 Members and 1 Guest are viewing this topic.

Mox2002

  • Guest
Respawning vehicles with AI in the AIR
« on: 25 Jul 2003, 22:05:35 »
Hi, currently I'm using this script to respawn AI driven vehicles in a MP-map.
All works fine except for the Air-units, when they get killed they respawn
on the ground.
It would be great if someone could crack this problem since it would
be sooo cool to have a everlasting airbattle.

Here's the script:
=====================================================
requiredVersion "1.91"
? not local Server : exit
_obj = _this select 0

_pos = getPos _obj
_dir = getDir _obj
_type = typeOf _obj
_group = group _obj
_crew = []
"_crew = _crew + [typeOf _x]" forEach crew _obj
"_x addEventHandler [""Killed"", {(_this select 0) removeAllEventHandlers ""Killed""; deleteVehicle (_this select 0)}]" forEach crew _obj

#clear
_t = 0

#alive
~3
? not alive _obj : _delay = 60; goto "notalive"

? fuel _obj == 1 : goto "clear"
? count crew _obj != 0 : goto "clear"

? _t == 0 : _t = _time + 60
? _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

? count _crew < 1 : goto "clear"
Soldier = []
_crew select 0 createUnit [_pos, _group, "Soldier = this"]
Soldier moveInDriver _obj
Soldier doMove getWPPos [_group, 1]
Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

? count _crew < 2 : goto "clear"
Soldier = []
_crew select 1 createUnit [_pos, _group, "Soldier = this"]
Soldier moveInGunner _obj
Soldier doMove getWPPos [_group, 1]
Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

? count _crew < 3 : goto "clear"
Soldier = []
_crew select 2 createUnit [_pos, _group, "Soldier = this"]
Soldier moveInCommander _obj
Soldier doMove getWPPos [_group, 1]
Soldier addEventHandler ["Killed", {(_this select 0) removeAllEventHandlers "Killed"; deleteVehicle (_this select 0)}]

goto "clear"
======================================================

Thanks in advance!

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:Respawning vehicles with AI in the AIR
« Reply #1 on: 25 Jul 2003, 22:41:07 »
im not sure if there is a way to respawn a plane flying, but you could try spawning it in the air with a velocity and hope the ai takes over from there...

Quote
_dir = getdir player
_type = "A10"
_pos = getpos player
_group = group player

_obj = _type createVehicle [_pos select 0, _pos select 1, _pos select 2]
_obj setDir _dir
_obj setpos [_pos select 0, _pos select 1, (_pos select 2) + 60]
~.01
_x = 100 * sin _dir
_y = 100 * cos _dir
_obj setvelocity [_x, _y, 0]
~.01
"SoldierWCaptive" createUnit [_pos, _group, "Soldier = this"]
Soldier moveInDriver _obj

exit

i just tried this out and it works, just take what u need from it to make ur script work

Offline KTottE

  • Former Staff
  • ****
Re:Respawning vehicles with AI in the AIR
« Reply #2 on: 25 Jul 2003, 22:52:03 »
You could download the BIS_Camel addon, in the sample MP mission that came with it you start in the air, so a safe bet is that there's a script in there that shows how to do it.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Mox2002

  • Guest
Re:Respawning vehicles with AI in the AIR
« Reply #3 on: 26 Jul 2003, 01:59:55 »
Pablo youre the best, its works beautifully.
Thanks many times  :D

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:Respawning vehicles with AI in the AIR
« Reply #4 on: 26 Jul 2003, 02:30:50 »
well being God does have its perks

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Respawning vehicles with AI in the AIR
« Reply #5 on: 26 Jul 2003, 08:11:11 »
hey god :wave:

u did it again :P- forgot ur smilies  :-X

it shud b

well being God does have its perks ::)

 ;)  :P

(so dat meens dat im on higher class dan god ? or a god ? or somin ??? ::) alwayz knew dat atheisem wil work :P) ::)

@ Mox2002 - proby solved right ? click da solve tpoic thingy somwere down dere ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Mox2002

  • Guest
Re:Respawning vehicles with AI in the AIR
« Reply #6 on: 26 Jul 2003, 14:49:42 »
Pablo >  ;)

LCD> done!