Home   Help Search Login Register  

Author Topic: Limited Respawning An idea  (Read 1769 times)

0 Members and 1 Guest are viewing this topic.

ClayPigeon

  • Guest
Limited Respawning An idea
« on: 16 Nov 2004, 13:02:49 »
What do I want: to limit Respawning in a MP mission. In other words, I want the player of my MPmission to be able to die once an Respawn but when the player dies again it's over. I don't want the mission to end, because other players may still be alive and I don't want the player to Respawn somewhere else, even if it means he can participate in the mission.
I know this is no new problem but after checking the forums/tutorials/intelligence depot etc. I realised nobody actually cracked this problem. Suggestions were done but no solutions were provided. Of course I could be wrong, I may have missed something, if so then please accept my appologies.
I have an idea though but I am no good scripter, so if you are please help me out.
Like this. The player respawns in its squad/group (groupname Red) with a delay of five seconds. But initially the player is the only squad member. The moment the player dies a groupmember (AI) spawns on Respawn location and after five seconds the player Respawns. Put the code in the init field of the player and he will only respawn once, right?
All comment/suggestions/help is/are welcome.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Limited Respawning An idea
« Reply #1 on: 16 Nov 2004, 22:16:21 »
This is untested, so i don't know what will happen for sure when you use it, but it should work for what you said...
to use this, you need to setup the respawn as group, and give it a bit of delay.

arguments (this is easiest to use in the init line of the unit):
[name, Unit type, init line] exec "whatyounamethis.sqs"
name: units name, if you put it in the init line you only need "this" (w/out quotes)

unit type: look in any list of vehicle names or anything like that, its also in the comref. if not entered it will make a basic unit for the side of the person.

init line:obvious. but it needs to be a string. put it in quotes "" or it won't work. you can use this to give the unit more respawns by execing the script through their init.

Code: [Select]
_player = _this select 0
_UnitType = _this select 1
_init = _this select 2
_group = group _player
?_init = null:_init = ""
?_UnitType = null:goto "default"

#CheckDead
@!(alive _player):_UnitType createUnit [getpos _player, _group, _init]
exit

#default
?side _player = west:_UnitType = "SoldierWB";goto "CheckDead"
?side _player = east:_UnitType = "SoldierEB";goto "CheckDead"
?side _player = resistance:_UnitType = "SoldierGB";goto "CheckDead"

;just put this here to insure that it goes back
goto "CheckDead"

ClayPigeon

  • Guest
Re:Limited Respawning An idea
« Reply #2 on: 18 Nov 2004, 11:19:31 »
Thanx for the quick reply, Triggerhappy!
I tried it right away but unfortunatly it didn't work. The next message appeared:

@!(alive _player):_UnitType createUnit [getpos _player, _group, _init] = error unknown operator

So obviously I did something wrong. So what did I do? I put the next line in the initfield of my player: [white1, SoldierLAW, "init line"] exec "LimitedRespawn.sqs" and copied the rest of the code in "LimitedRespawn.sqs".
I noticed that with this script the player respawns at the place of his death. I would like to have the player respawn at a marker because if the player died there once he 's bound to be killed there again. Therefor I rather have him spawn at a save location.
Forgive me my ignorance but I really would like it to work so any suggestions would be more than welcome.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Limited Respawning An idea
« Reply #3 on: 19 Nov 2004, 01:05:35 »
you are not supposed to use "init line" you put for that what you would want their int line to be:
ex. you could call the script again from the new unit to give him a respawn:
[white1, SoldierLAW, {[white1, SoldierLAW, ""] exec "LimitedRespawn.sqs"} ] exec "LimitedRespawn.sqs"
that will give him a second respawn
you'll notice i use {} instead of "". that is so the game doesn't get confused about which quote is for what
and the unit will respawn as many times as you put that into the next units init line, like so:
[white1, SoldierLAW, {[white1, SoldierLAW, {[white1, SoldierLAW, {[white1, SoldierLAW, ""] exec "LimitedRespawn.sqs"}] exec "LimitedRespawn.sqs"}] exec "LimitedRespawn.sqs"} ] exec "LimitedRespawn.sqs"
that would give him 4 respawns
if you want nothing in their init line just leave it blank

yes its very confusing, and it would work a lot better if i made the number of respawns defined by the editor through the arguments, but that would take a while, and i don't think you will be giving them many respawns

as for the marker thing, the script needs to be changed for that:
Code: [Select]
_player = _this select 0
_marker = _this select 1
_UnitType = _this select 2
_init = _this select 3
_group = group _player
?_init = null:_init = ""
?_UnitType = null:goto "default"

#CheckDead
@!(alive _player):_UnitType createUnit [getmarkerpos _marker, _group, _init]
exit

#default
?side _player = west:_UnitType = "SoldierWB";goto "CheckDead"
?side _player = east:_UnitType = "SoldierEB";goto "CheckDead"
?side _player = resistance:_UnitType = "SoldierGB";goto "CheckDead"

;just put this here to insure that it goes back
goto "CheckDead"
now you need to call the script with:
[unitname,markername,unit type, init line] exec "limitedrespawn.sqs"

Offline CrashDome

  • Members
  • *
Re:Limited Respawning An idea
« Reply #4 on: 24 Nov 2004, 08:45:12 »
Actually, here is a method I use
in init line of any unit (such as a logic or leader or truck --- any unit but only in one of em --- best method is to put it into the init.sqs instead if you have one)

Code: [Select]
MyRespawn = 0
Make a trigger anywhere and make it of type "none". In condition line put:
Code: [Select]
alive playerin activation line put
Code: [Select]
[player] exec "respawn.sqs"
Respawn.sqs (You can change 10 to whatever you want)
Code: [Select]

? (_this select 0 != player):exit

? (MyRespawns==10):goto "Spectate"

#Respawn
MyRespawns=MyRespawns+1
exit

#Spectate
;Add spectate code here
exit

Keep in mind this will execute the first time at mission start - then once again for every death so for two lives make it
? (MyRespawn == 2) : goto "spectate"  
in above script.

For spectate code, even a simple flying camera will do, but can be as elaborate as you wish. I would usually send the unit to a remote location nobody would find him, then force a camera mode on him.

EDIT: please note this uses regular respawn settings in the description.ext for where to respawn and how (i.e. at base marker, in squad, in last place of death, etc...)

EDIT AGAIN: forgot about some issue and changed code.. anyway.. enjoy!
« Last Edit: 24 Nov 2004, 09:09:14 by CrashDome »