OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: scorpi0x on 23 Feb 2005, 07:48:09

Title: is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: scorpi0x on 23 Feb 2005, 07:48:09
hi guys,
i have this question.
there are 2 groups with 1 player and 5 AI.
after putting "respawn=4" in description.ext, players respawn to replace AI soldier in thier group when they die.
What if i wanna set a limit to the number of of respawns to 3 (and not the default 5)?

All help will be much appreciated. Thank You  :)
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: nominesine on 23 Feb 2005, 09:56:37
If there are 6 soldiers in the group and you want to limit respawn to 3 rebirths you can:

1) End the mission when the group contains < 3 units

2) Break up the group with a join grpNull command when the number of soldiers < 3. Then there will be no more units around to respawn into.

3) Make two triggers
Condition: unitName == player
Activation: unitName setDamage 1
unitName is the name of the last two units in the group. When a player dies and respawns he will kill the unit he respawns into. The group will be decimated, but any players who are still alive can continue the game.
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: Terox on 23 Feb 2005, 14:21:46
other systems that can be used


killed eventhandler executes a respawn script

this respawn script has a global variable counter, which increments every time it is run



when the player has reached  the specified number of respawns
a) setpos the player to a non playable part of the island
b) place the unit in a cutscene, possibly the spectate script
c) remove their weapons "removeallweapons unit"
d) remove them from their group "[player] join grpnull"
e) turn the radio system off  "enableradio false"
f) set the unit captive, just incase a helicopter strays its path "unit setcaptive true"

then it shouldnt cause any further problems in the mission

you can also create a progressive respawn doing this system, eg 1st time they die, they wait 30 secs to rejoin the game, second time a minute etc
this would be done with a death cutscene, a respawn delay of say 1 second and simply keep them in a cutscene during a "counting loop"
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: scorpi0x on 23 Feb 2005, 19:09:19
thanks nominesine. ur idea will be good if i have only 1 player in the group. :)
sorry i didnt make it clear enough earlier.
i am actually going to have 4 players and 10 AI per group in the real thing.
so having a count for the group

thanks terox too. i am gonna try your method. hope it works well for me :)
but is it possible to spawn the player into a bird on 4th spawn in the respawn script?
if possible, can anyone guide me with the syntax?
couldnt find a relevant variable in the command reference  :-\
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: nominesine on 23 Feb 2005, 21:53:29
If there are no more respawn units left in the group, player will be reborn as bird automatically.
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: scorpi0x on 24 Feb 2005, 15:16:19
thx nomineshine but i still need to limit the respawns/player to 3.

what i am thinking now is having a script with (what Terox mentioned) 16 global viarables as counters.
and adding some codes
Code: [Select]
?(counterA>3) : {soldierA join grpNull}
?(counterB>3) : {soldierB join grpNull}
...
...
(doing a 16-players (4-players/group of the same side) MPmission )
Hoping this works.
Thank You All :)
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: Terox on 27 Feb 2005, 22:50:36
using an addeventhandler killed
have the eventhandler run a respawn script
that
.....a) increments a deathcount
..... b) if the deatcount is lower than the limit that you impose (eg ?(tx_death > 3): exit)
then createunit a unit of whatever soldier class you want
have this unit join your player's group
(NB>>> During mission setup, make sure all the playable units are in solo groups)

that way, when your respawn limit is up, there wont be any more units in the players group to respawn too, and therefore he will become a seagull

DESCRIPTION
Quote
respawn = 4
respawndelay = 20

INIT.sqs
Quote
player addEventHandler ["killed", {_this exec "myrespawn.sqs"}]
tx_death = 0
[Player] join grpnull

myrespawn.sqs
Quote
;;;.....before respawn
_weapArray = weapons player
_magArray = magazines player
_primary = primaryweapon player
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
tx_death = tx_death + 1
?(tx_death > 3): exit
?(side player == west):_unit = "soldierclass" createunit [(getmarkerpos "respawn_west"),(group player),""]
?(side player == east):_unit = "soldierclass" createunit [(getmarkerpos "respawn_east"),(group player),""]


@ alive player
player addEventHandler ["killed", {_this exec "myrespawn.sqs"}]
~0.1
removeallweapons Player
{Player addMagazine _x} forEach _magArray
{Player addWeapon _x} forEach _weapArray
Player selectWeapon _primary
exit


I added some additional lines for ya, so that when you respawn into the _unit, you get the weapon loadout you died with
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: scorpi0x on 28 Feb 2005, 10:33:31
apparently, this method doesn't seems to work  :-\
tried exactly the same codes of terox and didnt work out.
change around some codes here and there, and result to a few weird situations like having the player died and respawn into the same "corpse"
or respawn without being limited. :-\
Title: Re:is it possible to limit respawns if "respawn=GROUP" in description.ext??
Post by: Terox on 02 Mar 2005, 01:44:46
i read yesterday, that someone had done testing on this, and apparently the respawn into group, looks for a group member to respawn into ON DEATH, not on respawn.

So you could do 1 of 2 things.


a) Start with an additional unit in your group at the start of the mission, place the unit somewhere safe, and then when you die, setpos this unit to your respawn location
Use the above system to create another ai on your death at the safe location, and you will always have an ai to spawn into
Until you stop creating ai on your respawn count.


or

b) add a "Hit" event handler to your player, have tyhis create an ai for you, incorporate a check, so that you only have one created ai at any one time

hit eventhandler should be triggered before you die and therefore there will be an ai in your group prior to your death.

I would run with the first option