Home   Help Search Login Register  

Author Topic: Customize respawn amount & delays  (Read 1391 times)

0 Members and 1 Guest are viewing this topic.

MetalG

  • Guest
Customize respawn amount & delays
« on: 04 Apr 2005, 12:49:00 »
Got a question:

in the description.ext file I've got:
respawn=2
respawndelay=20

Now this works fine, however, I would like the host of the MP mission to be able to decide the number of respawns each player gets, and if possible the respawn delay. Is this in any way possible?

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Customize respawn amount & delays
« Reply #1 on: 06 Apr 2005, 18:17:12 »
to achive what you want, you have 2 systems available
In all cases you will need to run a "Killed" eventhandler on each player.

This is easily done by placing the following line in the init.sqs

INIT.SQS
?(local Player):player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

as for the respawn type, you have 2 choices

Group Respawn
Normal pvp respawn eg  respawn = 3

and the best repsawndelay to set in the description.ext is  1 second

For group respawn to work, you need each player in their own group
and at least 1 ai for them to respawn into.
You can place this ai out of harms way and simply setpos yourself back into the game area when you respawn.
Additionally when you respawn you need to create a "Spare" Ai to respawn into when you next die

NB>> you must have an AI alive before you die for this system to work, it wont work by creating the ai that you will spawn into, on your death

The other system is normal respawn, eg respawn = 3 where you simply respawnj into your old self after death



You cannot alter the respawn delay, but what you can do is place the unit/player in a cutscene for a simulated delay, this you can alter as much as you want and also limit the number of respawns by simply not allowing the unit to escape its cutscene.

the following is a very basic example of a simple playerkilled script, run from the Killed eventhandler

firstly initialise some variables in the INIT.sqs

INIT.sqs
;;; following gives the player 5 lives
tx_respawns = 5
;;; following is the amount of time the cutscene will be run for
tx_respawndelay = 20

MISSION EDITOR
1) Create something for the camera to look at, eg a medic tent, name it medic1
2) create your respawn marker and place it somewhere safe and out of harms way
3) create another marker, place it where you want the player to rejoin the game, name this "tx_spawnmarker"


Playerkilled.sqs
Quote
player removeAllEventHandlers "Killed"
;; following saves the units loadout on death, so you can rearm him with the same weapons on spawn
_weapArray = weapons player
_magArray = magazines player
_primarywep = primaryweapon player
Player setcaptive true
enableradio false

#KILLCOUNT
;;; this bit checks how many times the unit has died, and if its too many, stops the player taking any further part
?(tx_respawns <=0): goto "DEAD"
tx_respawns = tx_respawns - 1


@alive player
Player setcaptive true
removeallweapons player
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]

#CUTSCENE
cutText ["","Black out",0.01]
titletext[format["%1\nYou will be returned to the game shortly", name player],"PLAIN"]
_CamPos = getpos medic1
showcinemaborder true
_camera = "camera" camCreate _CamPos
_camera cameraEffect ["internal", "back"]
_camera camSetTarget medic1
_camera camSetRelPos [1,5,3.25]
_camera camCommit 0
@camCommitted _camera
~5

;;; loop for simulated respawn delay
_loopcount = tx_respawndelay
;;;tx_respawndelay = tx_respawndelay + 20
#Loop
titletext[format["Respawning in %1 secs", _loopcount],"PLAIN"]
_loopcount =_loopcount - 1
?(_loopcount <= 0):goto "SPAWN"
goto "Loop"

#SPAWN
player switchCamera "INTERNAL"
player cameraeffect ["terminate","back"]
camDestroy _camera
showcinemaborder false
cutText ["","Black in",2]
enableradio true
#REARM
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray

;;;;;;;;;; BIS Standard
?(_primarywep == "M16GrenadeLauncher"): _primarywep = "M16Muzzle"
?(_primarywep == "Ak74GrenadeLauncher"): _primarywep = "AK74Muzzle"
?(_primarywep == "Ak47GrenadeLauncher"): _primarywep = "AK47Muzzle"

#SETPOS
player setpos (getmarkerpos "tx_spawnmarker")
~1
Player setcaptive false
exit

#DEAD
cutText ["","Black out",1]
~1
titletext[format["%1\nYou are K.I.A\n\nWars Over Dude!", name player],"PLAIN"]
[player] join grpnull
Player setcaptive true
removeallweapons player
player removeAllEventHandlers "Killed"
_CamPos = getpos medic1
showcinemaborder true
_camera = "camera" camCreate _RsCamPos
_camera cameraEffect ["internal", "back"]
_camera camSetTarget medic1
_camera camSetRelPos [1,5,3.25]
_camera camCommit 0
@camCommitted _camera
exit

Rather than have a boring camera cutscene, you can initiate kegety's spectator script, this however rerquires more work, as you need to update the spectate script deathcamarray, every time you respawn a player.

other things you can do, is dynamically increase the respawn delay time, by adding the line highlighted in red

The above system would be the same for group respawn, apart freom that you would add a "createunit" command after the @ alive condiotion
« Last Edit: 06 Apr 2005, 18:21:56 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Customize respawn amount & delays
« Reply #2 on: 06 Apr 2005, 18:26:13 »
oops forgot something, if you want the admin to be able to select the number of respawns or the delay, you can add these lines

DESCRIPTION.EXT
titleParam1 = "No of Lives";
valuesParam1[] = {1,2,3,4,5};
defValueParam1 = 4;
textsParam1[] = {"1", "2", "3", "4", "5"};

titleParam2 = "RESPAWN DELAY";
valuesParam2[] = {20,40,60};
defValueParam2 = 20;
textsParam2[] = {"20 secs","40 secs", "60 secs"};



INIT.SQS
tx_respawns = Param1
tx_respawndelay = Param2
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123