Home   Help Search Login Register  

Author Topic: I have some special respawn questions.  (Read 2120 times)

0 Members and 1 Guest are viewing this topic.

Offline pexmo

  • Members
  • *
  • I'm a llama!
I have some special respawn questions.
« on: 31 Jan 2005, 11:16:17 »
Hello.

I have some respawn questions.

1: Is it possible to make a player respawn when another player executes a action instead of after a set number of seconds? And if so how?

2: I want the respawn zone to always be lets say 1 meter infront of the medic player, lets call him friend. Can this be done and how?


Offline Roni

  • Members
  • *
  • Play the Game !
Re:I have some special respawn questions.
« Reply #1 on: 01 Feb 2005, 05:12:04 »
Hi pexmo

Short answers - yes kind of and yes definitely.

Second one first.  I have a half finished mission in which you have to escape from jail and make your way across the island, steal a plane etc.  You know the routine - work your way across the island making mayhem and solving problems etc.

I wanted to make it so that if you die you start NEAR where you died rather   than way back at the start of the mision, so I created this little trick.  Set respawn to "Instant" and set whatever respawnDelay you want (say, 5 seconds).  Then have a script running on the player that does this -

#loop
@!alive player
<do whatever you want here, such as re-arm, addactions or whatever>
@alive player
player setpos getpos respawnpoint
goto "loop"


Now respawnpoint is the name of some sort of object, in my case a game logic.  So far so good - no matter where the player dies he re-appears at the respawnpoint.  So what big deal - respawn to base does that too, right ?

Now add a buch of triggers on the map with condition West (or East or whatever) Present true.  Name each trigger (eg spawnpoint1, spawnpoint2 etc), and set them so that when they're activated all they do is

respawnpoint setpos getpos spawnpoint1


or whatever.

And there you have it.  As the player moves across the map, moving the storyline along, his spawnpoint follows him so that if he dies, he doesn't have to go right back to the start point.

However, having just thought about it, I just realised that in your case you don't need the triggers.  All you need are the following two lines at the end of your respawn script -

_nearestMedic = nearestObject [player, "SoldierWMedic"]
player setpos getpos _nearestMedic


Your player will now die, respawn and then be imediately teleported to the location of the nearest medic.  If you want to make sure that "the nearest medic" is the nearest to you when you died and not when you reappeared then you will need to move the line "_nearestMedic = nearestObject [player, "SoldierWMedic"]" to the point right after "@!alive player", above.


Now for the first question.

i know that you can't hold back a players respawn but you CAN move him somewhere totally out of the way (via a teleport routine) and keep his screen black with a title cut (or keep his view fixed to that from the corpse with a camcreate) and then wait for the appropriate player to use his action to bring you back (and give you your sight back !).

That should do what you want, the only problem is I've never used camcreate to create camera views.  I'm sure that someone lese can help you here though.

Good luck !

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:I have some special respawn questions.
« Reply #2 on: 01 Feb 2005, 10:39:28 »
well i tryed to use the cam settings from doolitles revive respawn script but i cant get it to work outside of his demo mission. It just lets the player be where he spawns then teleport him back that makes a wierd expirience.


This is a explanation of what i want to create:

We play coop with a forum hosting our characters. We have ranking och points system. We have solved the ways of dying and beeing saved on a off game basis using some simple triggers BUT what i want to create is the following....

When one of our guys gets hit and dies. I have a script that randomly states what damge he got when he fell. Its a 25% chanse of high trauma damage and then we just have to drag his body to the evac halo as usual. BUT if he doesnt get this high trauma message i want me (im the team medic) to be able to get to his body and by issuing a action like: (the fallen player is named friend) Revive friend. When i use this action i want to respawn him infront of me (coz when i do this i am looking at the body so it wont seem that wierd) and in lying mode. The gear of his former self will be lying there waiting for him, or spawn with him as it was before he was killed.

The problem i see with this is:

1: I cant get the doolitles revive respawn to work as i want it and its only set to work with the standard soldier type. I want to spawn the player as the model he was before.

2: I guess as soon as the player spawns, as i now have been told you HAVE to do this with a time delay, the body disaperas. Thus making our dragging inposible if the player gets the no revive message when killed.


Soo is my plan a impossible one or not? (holding a trillion tumbs that you guys wont answer NO!  8) )

EDIT: Perhaps you can spawn a new unit into the group and make reapwn mode group? or something...
« Last Edit: 01 Feb 2005, 10:40:51 by pexmo »

Offline Roni

  • Members
  • *
  • Play the Game !
Re:I have some special respawn questions.
« Reply #3 on: 01 Feb 2005, 23:28:15 »
I'm sure that ANYTHING is possible in OFP !  This game never ceases to amaze me and I've been playing it since 2001 !   :)


I had a similar need in another mission I made.  I wanted to make it seem as if the player had "9 lives" - every time he died I wanted to instantly respawn him and put up a message like "That was close" or whatever.  Of course after 9 deaths the game was supposed to end, at that point something like "That one had your name on it !" was supposed to come up.

In your case I'm certain that it's doable with a combination of instant respawn, a vehicleDelete and an addaction.  Try this (no guarantee of success) -

Set respawn to Instant and respawndelay to (say) 20.  Have the following script run on the player (via his Init field or whatever) -

#loop

revived = 0

@!alive player
_body = player
_bodyaddaction ["Revive", revivePlayer.sqs"]
~19
@alive player

deleteVehicle _body
if revived == 0 then hint "You didn't make it !", deleteVehicle player
hint "That was close, but you made it !"

goto "loop"


Make another script called "revivePlayer.sqs" as follows

if revivingPlayer == 1 then exit
revivingPlayer = 1
player playMove "CombatToPutDown"
if random 1 < 0.2 then revived = 1, publicVariable "revived"
~3
revivingPlayer == 0


What the first script SHOULD do is create an addaction on your corpse while you lay there, floating over it.  If someone can get to your body and successfully activate the addaction script within 20 seconds then you will come back, otherwise you will be removed from the game.  In either case your body will be removed at the same time.

The second script runs when another player or AI unit runs the addaction.  It only has a 1 in 5 chance of success, but if it works then it sets the "revived" flag to 1 so that you don't get wiped from the game after the respawn period has lapsed.

Notice that the 1 in 5 chance of success with each attempt taking 3 seconds means that you SHOULD survive if your buds can get to you quickly.  Note also this variable is not "public'ed" so multiple players can work on you at the same time.

The part I can't vouch for is the deleteVehicle player.  I've never actually tried to delete a player in game so I don't know if it will work (it should, fingers crossed !).  I DO know that you the player are the living unit or your corpse, right up until you respawn.  After that, you become the new unit and your corpse becomes a different (non-player) unit.

Finally, please note that the above routines have no provision for restocking your new persona with the weapons from the old body.  Check out that revive respawn script by VB and see if you can cut and paste the relevant bits.

Good luck with it !



Roni



Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:I have some special respawn questions.
« Reply #4 on: 02 Feb 2005, 08:51:52 »
thx Roni!

It sounds realy promising! Ill test it as soon as i get one of my fellow coopers to try it out with me  :D

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:I have some special respawn questions.
« Reply #5 on: 02 Feb 2005, 11:06:55 »
well hmmm i didnt get this to work. I got the revive action on the old corpse after my pal respawned beside it etc. And he always respawned at 20 sec. I fixed some small errors like a missing " and a space between body and addaction. but still no luck.

Dunno whats wrong

Guess adding the action to the a player named lets say friend4 when he gets within 2 meters of the body might work better. but how to fix the rest i dont know

Offline Roni

  • Members
  • *
  • Play the Game !
Re:I have some special respawn questions.
« Reply #6 on: 02 Feb 2005, 23:58:01 »
Hi pexmo

Okay, now now you got me interested.  I'm sure it's doable, it's just working out how.  How's this for an alternative solution ?

Rather than setting respawn to Instant you set respawn to Group.  You keep the same 20 second respawndelay and addaction, but now rather than having the revive flag detemine whether or not you delete the character, you make it detemine whether or not you create a new group member to respawn into.

Again the above solution SHOULD work, but note that it won't work if the player is already part of a big group.  In this case the player will respawn in to the next existing member no matter what you do, which is not what you want.

(BTW - I have made a number of misions that use a variation of that last routine - respawn to group with some sort of group respawn on.  This gives you a great incentive to keep all your team mates alive !)

I'll test the above suggestion tonight and get back to you with the result.

Cheers !

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:I have some special respawn questions.
« Reply #7 on: 03 Feb 2005, 07:16:15 »
That sounds good. The thing you want is to spawn in a new group member with the same gear as the fallen soldier and the same model, or have the dead guy drop all of his gear on the ground before the body is deleted.

Offline OFPWiZard

  • Members
  • *
Re:I have some special respawn questions.
« Reply #8 on: 03 Feb 2005, 08:17:04 »
could a person have their own respawn point... such as my friend and i...

* were on the same team... hmmm

me
friend

(we both have our own base that we would like to respawn at... how would that be done?)

if possible

Offline Roni

  • Members
  • *
  • Play the Game !
Re:I have some special respawn questions.
« Reply #9 on: 04 Feb 2005, 01:38:43 »
Hi Pexmo

I'm working on my OFP missions tonight - I'll mock up a respawn script as above and get back to you.


Wiz - I don't see why each person can't have their own spawn point.  All you have to do is put this on each players Init field -

[spawnpoint] exec "respawnscript.sqs]

where spawnpoint is the name of the object that you want your man to appear at.  Then you simply make a script that looks like this -

; respawnscript.sqs

#spawnloop

@!alive player
@alive player

; put in anything you want here, such as re-arm routines, addactions etc
player setpos getpos _this select 0

goto "spawnloop"



What this should do is wait until you're dead, then do the re-arm etc routines, then move you to your spawn point, which you specify in the bit that goes in the player's Init field.

Of course, don't forget to name the object that you want to be the loons spawn point.  If you want this to be an empty space you can make the object something inocuous like a bush or a watch (check out the Empty objects !) or even a game logic.

Cheers

roni


EDIT - Don't foget that "player" is local to each machine so the above script should interpret true for each player.
« Last Edit: 04 Feb 2005, 01:42:12 by Roni »

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:I have some special respawn questions.
« Reply #10 on: 04 Feb 2005, 18:38:25 »
any luck Roni?

Offline Roni

  • Members
  • *
  • Play the Game !
Re:I have some special respawn questions.
« Reply #11 on: 07 Feb 2005, 06:46:49 »
Hi Pexmo

I finally got my nscript working and guess what - it doesn't work !  It sems that if you have respawn set to group then the engine checks for a valid respawn host as soon as you die, NOT when you're ready to come back.  So if your group doesn't have any other members at the point that you die then you're dead for good.

On the plus side - I HAVE created a script that DOES work in creating new group members when you die.  So long as you have one other group member when you die then you will come back and bring a new member with you.  This means that so you can ensure that you always have the to same number of members no matter how often you die (unless you all die at once !).

My next idea  ::)  :P is to use an eventHandler and create the new groupie as soon as you get hit.  My hope is that if you spawn the new groupie AFTER you're hit but BEFORE you're recorded as dead then you should respawn okay.  We'll see.

If it works then the posibilities are endless !

I'll check toinight and get back to you (again !).

Cheers



Roni