Home   Help Search Login Register  

Author Topic: Respawn script  (Read 2636 times)

0 Members and 1 Guest are viewing this topic.

pazuzu

  • Guest
Respawn script
« on: 31 Dec 2005, 04:18:38 »
Hi, I'm using a script I got from the editors depot (AI vehicle respawn by Doolittle).

The problem I have is there is no limit to how many times the vehicles respawn and I was wondering if any of you knew how to modify it to have a limited number of respawns?

Also I wanted to use it for planes too so that the planes would respawn in the air if possible. How would I do this?

Here is the script:

Code: [Select]
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 = 150; goto "notalive"

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

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

Offline Pilot

  • Contributing Member
  • **
Re:Respawn script
« Reply #1 on: 31 Dec 2005, 06:04:52 »
For a limited number of respawns, simply add a counter:
Code: [Select]
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
_counter = 5

#clear
?_counter <= 0 : exit
_t = 0

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

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

? _t == 0 : _t = _time + 110
? _t > _time : goto "alive"

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

#notalive
~_delay
_counter = _counter - 1

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"
To change the number of times the object spawns, simply adjust the:
_counter = 5
at the beginning of the script to whatever number of respawns you want.

To spawn a flying airplane is a bit more difficult.  You will have to create the airplane in the air and then give is speed.  I have one question, first, what direction do you want the plane spawned?

-Pilot
« Last Edit: 31 Dec 2005, 06:09:14 by Pilot »

pazuzu

  • Guest
Re:Respawn script
« Reply #2 on: 31 Dec 2005, 07:52:51 »
Thank you. You make it sound so simple...

I've got the plane facing south right now and it has a "Guard" waypoint.

The plane respawns in the taxiway of the airport on Afghanistan island (cat intro) then takes off again and follows the wp every time, which is nice, but I was hoping I could get it to respawn in the air so I't doesn't need a runway.

Thanks for the help.

Edit: I was also wondering about naming the plane. I named the plane "su1" and just for a test I made a Radio alpha trigger that has this in the on activation field:

su1 setpos [getpos su1 select 0,getpos su1 select 1, (getpos su1 select 2)+1000]

But it doesn't get the plane in the air.

Why wouldn't this work?

Thanks again.
« Last Edit: 31 Dec 2005, 08:45:35 by pazuzu »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Respawn script
« Reply #3 on: 31 Dec 2005, 11:52:36 »
after you have created the new aircraft and placed crew in it, then add the following line

where _plane refers to the newly created vehicle

_plane flyinheight 200
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Respawn script
« Reply #4 on: 31 Dec 2005, 11:56:46 »
I suppose a plane might build up flying speed by the time it falls 200m. I have not done that with a plane but  I have created a fully crewed chopper in the air and I found I needed to insert something like:
Code: [Select]
_startTime = _time
#loopStart
~0.01
_ch setPos [getPos _ch select 0,getPos _ch select 1,300]
if (_time < _startTime +20) then {goto"loopStart"}
To keep it in the air while its engines get up to speed.
« Last Edit: 31 Dec 2005, 11:57:11 by THobson »

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Respawn script
« Reply #5 on: 31 Dec 2005, 15:18:17 »
There's some relevant stuff in this script.
I couldn't be arsed to pick the right bits out. Here's the whole dirty mess of a thing.

;Spawn A10LGB in flight script by The-Architect.


Me1 sidechat "This is Alpha. We've taken out all the MANPADS we know about. We're ready to take on the AAA systems. Over."
playsound "Alpha1"
~7
PapaBear sidechat "Roger Alpha. November 1 is inbound. ETA 60 seconds. Out."
playsound "pap1"
~6
strikePlane = "a10lgb" camCreate (getMarkerPos "spawn")
strikePlane setPos [(getPos strikePlane select 0),(getPos strikePlane select 1),(getPos strikePlane select 2)+800]
strikePlane setDir 0
strikePlane setvelocity [0,200,10]
strikeplane flyinheight 200
strikeplane setGroupId ["November", "GroupColor0"]
strikeplane exec "destroyednobang.sqs"

strikePilot assignAsDriver strikePlane
strikePilot moveInDriver strikePlane
strikePilot doMove getpos me1
~30
[strikepilot] join mygrp
StrikePilot sidechat "This is November. Start painting those AA guns. Out."
playsound "Pt3"


#DistanceLoop
? Strikepilot distance me1 >= 1000 : Goto "DistanceLoop"

[] exec "Pilotcheck.sqs"
#Altitude
Strikeplane flyinheight 100


#Check
? Strikeplane ammo "Laserguidedbomblauncher" >=1 : goto "Check"


Strikepilot sidechat "I'm out of ammo here. I'm heading home. Out."
playsound "pt2"
~1
removeallweapons strikeplane
Strikepilot setbehaviour "careless"
~5
[Strikepilot] join Grpnull
Strikepilot Land "Land"

exit

James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

pazuzu

  • Guest
Re:Respawn script
« Reply #6 on: 31 Dec 2005, 20:19:20 »
Quote
after you have created the new aircraft and placed crew in it, then add the following line

where _plane refers to the newly created vehicle

_plane flyinheight 200
I don't need the plane to fly at 200 I just want it teleported up 1000m or more so it has time to get its engines going and gets to flying speed. I've done this before using triggers and it works great if you dont have a runway for the enemy to use. I just hoped this method could be used by modifying this script.

If I named the original plane "su1" will that name still be valid after it respawns?

Thanks for the replies.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Respawn script
« Reply #7 on: 02 Jan 2006, 14:36:54 »
the newly created plane will not be known as SU1 unless you state that in the createvehicle line

as in the following example


SU1 = "Su25" createvehicle (getpos server)
_Pilot moveindriver SU1
SU1 setpos [getpos this select 0, getpos this select 1,1000]
SU1 flyinheight 1000


the script will setpos the plane 1000 above its created position
you dont need to setpos it so high, 200 works fine on the desert island, it may need to be increased for rougher terrain islands
edit the flyinheight value to the height you want the plane to fly at,
at 1000m you will hardly see it

i've had them flyinheight 20 for some really nice close air support flybys

you will have to edit the _Pilot and createvehicle line to suit your script
« Last Edit: 02 Jan 2006, 14:53:08 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123