Home   Help Search Login Register  

Author Topic: New type of respawn, Have teammate revive  (Read 4811 times)

0 Members and 1 Guest are viewing this topic.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
New type of respawn, Have teammate revive
« on: 13 Feb 2003, 09:12:51 »
Hi, this is a cut & past from the flashpoint1985 forum.
http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3e4b4a7a150cffff;act=ST;f=7;t=27120

Greetings.  Here is a way to make it so that when you die you lay there as a body and if a teammate comes up to your body then you "respawn" at that spot with your old weapons.  This is great for co-op.

description.ext
Code: [Select]
respawn = 3
respawndelay = 20

Make a trigger that runs repeatedly.  Its condition should be "not alive player" and it's OnActivation should be [] exec "respawn.sqs". You will also need to put a Respawn_West marker on the map somewhere far away, like on a small island.

respawn.sqs
Code: [Select]
;by Doolittle
enableRadio false
_body = player
_pos = getPos _body
_magazines = magazines player
_weapons = weapons player

_camera = "CAMERA" camCreate _pos
_camera cameraEffect ["Internal", "BACK"]

cutText ["", "BLACK IN"]

_camera camSetTarget _body
_camera camSetRelPos [0.20, 0.39, 1.86]
_camera camSetFov 0.143
_camera camCommit 0
@camCommitted _camera

_camera camSetRelPos [2.71, 19.55, 12.94]
_camera camSetFov 0.7
_camera camCommit 5
@camCommitted _camera

cutText ["You are ""almost dead"" and waiting to be revived", "PLAIN DOWN"]

_pos = getPos _body
_pos = [_pos select 0, _pos select 1, 0]
_dir = getDir _body

@_body != player and alive player

deleteVehicle _body
_body = "Body" createVehicle _pos
_body setDir _dir

#nearest
~1
_soldier = nearestObject [_body, "SoldierWB"]
? isNull _soldier : goto "nearest"
? not alive _soldier : goto "nearest"
? _soldier distance _body > 5 : goto "nearest"
~1

deleteVehicle _body
"player removeMagazine _x" forEach magazines player
"player removeWeapon _x" forEach weapons player
"player addMagazine _x" forEach _magazines
"player addWeapon _x" forEach _weapons
player selectWeapon primaryWeapon player
player switchMove "LyingToCombat"
player setPos _pos
player setDir _dir
player setCaptive true

_camera camSetTarget player
_camera camSetRelPos [10.49, 0.61, 3.48]
_camera camSetFov 0.7
_camera camCommit 5
@camCommitted _camera

_camera camSetRelPos [-0.82, -3.12, 3.38]
_camera camSetFov 0.044
_camera camCommit 3.5
@camCommitted _camera

player switchCamera "INTERNAL"
player cameraEffect ["Terminate", "BACK"]
camDestroy _camera
enableRadio true
player setCaptive false
 


What this does is when you die it goes into cut scene mode.  Meanwhile your dude is spawning on some island somewhere.  When a SoldierWB is near your fake dead body, it transports your player and cuts out of cut scene mode.  Make sure every player is SoldierWB.

A mission with this in it can be found at http://www10.brinkster.com/dbircsak as co14do_fourshilkas.zip.

If you use this script for your missions please mention "Revive Respawn Script by Doolittle".  I would really appreciate that.  Thanks, as I myself stink/hate making missions but love to code script.

Doolittle

mcnils

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #1 on: 16 Feb 2003, 13:33:11 »
would be ultracool if you could revive only if a medic comes near you,
not the normal soldiers, that would make more sense to use the medic! no medic = no respawn :D :D :D


Hey, does this work also for 2 sides?! if yes, this would be really uber suppa cool...
and medics would get VERY important, in ctf's, tdm's and so on... woah... i ever wanted a respawn system like this......


Plz Plz Plz say me this is possible ^_______________^
« Last Edit: 16 Feb 2003, 13:34:54 by mcnils »

mcnils

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #2 on: 16 Feb 2003, 13:37:47 »

Or also revive if medic m113/bmp is near!!!
woaaaaaah bether i stop posting because this ideas are killing me......
Doolitle plz make it possibleeee if it isnt already... aaaa help :joystick:
« Last Edit: 16 Feb 2003, 13:38:21 by mcnils »

bn880

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #3 on: 16 Feb 2003, 19:41:45 »
Quote
#nearest
~1
_soldier = nearestObject [_body, "SoldierWB"]
? isNull _soldier : goto "nearest"
? not alive _soldier : goto "nearest"
? _soldier distance _body > 5 : goto "nearest"
~1

You should set up a loop here that runs through an array of vehicle types that are able to revive the body... so create an array like _WestMedicalUnitTypes = ["SoldierWMedic", "M113Ambulance"];  do same for every side, and work with the proper side array to compare to each.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:New type of respawn, Have teammate revive
« Reply #4 on: 17 Feb 2003, 05:44:32 »
One thing I find unfortunate about nearestObject is that you cannot get it to report the NEXT object nearest, like you pick up obj1, ok now tell me what is the next closest object & ignore obj1 when you look.

Doolittle

Commando

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #5 on: 18 Feb 2003, 00:34:15 »
awesome stuff! :D Im going to add your script in tha mission and see if it works...

bn880

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #6 on: 18 Feb 2003, 00:53:44 »
Yep, that's true, you may have to opt for triggers, or do what I do at the CoC:
Keep a list of all units on the map, and run distance checks on each one as you need.

Kind of difficult for you because you want a sort of @ check
One thing I find unfortunate about nearestObject is that you cannot get it to report the NEXT object nearest, like you pick up obj1, ok now tell me what is the next closest object & ignore obj1 when you look.

Doolittle

mcnils

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #7 on: 20 Feb 2003, 16:55:01 »



W00P!

I want to use this in my COOP's or even in TDM's!!!
but since im not a scripting ace, 'ill wait since the script isnt fully complete now O_o

Doolitle you are our last hopeeee (lolz)  :joystick:

Nasty Buttler

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #8 on: 25 Feb 2003, 16:33:18 »
Interesting, i fiddled with this a year or so ack but never got it to work.....but i was trying to do it without respawn "base"....i was solely using camcreate etc....but never managed to get control to go from the old unit and get it to the new unit...
u could also create a 2m trigger for each unit that has a spot over in the middle of the ocean, and then setpos it to the death location when the player dies...

the only thing i could see wrong with this script is if u had a human player as commander due to the fact that dead men wouldnt show up as dead because they had already respawned.
but GL....I hope to strip down your code and maybe see if i cant put my 5c in...

Good work

Nasty Buttler

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #9 on: 27 Feb 2003, 14:44:00 »
Ok lads, here is Version 1.01
in this version the script checks for Officers and Medics.
when an officer or medic is within range it will respawn the player, ive also dabbled with some different playmoves, so it looks abit better and sped up the camera pan and changed the message.
Code: [Select]
;by Doolittle
;modified by DeaDMeaT
;Respawn 1.01

enableRadio false
_body = player
_pos = getPos _body
_magazines = magazines player
_weapons = weapons player

_camera = "CAMERA" camCreate _pos
_camera cameraEffect ["Internal", "BACK"]

cutText ["", "BLACK IN"]

_camera camSetTarget _body
_camera camSetRelPos [0.20, 0.39, 1.86]
_camera camSetFov 0.143
_camera camCommit 0
@camCommitted _camera

_camera camSetRelPos [2.71, 19.55, 12.94]
_camera camSetFov 0.7
_camera camCommit 5
@camCommitted _camera

cutText ["Your Badly injured, MEDIC!!!", "PLAIN DOWN"]

_pos = getPos _body
_pos = [_pos select 0, _pos select 1, 0]
_dir = getDir _body

;// EDIT START
;// EDIT START
_b = "Body" createVehicle [0,0]
@_body != player and alive player

deleteVehicle _body
_body = _b
_body setDir _dir
_body setpos _pos



#nearest
~0.5

_s1 = nearestObject [_body, "OfficerW"]
_s2 = nearestObject [_body, "SoldierWMedic"]
?(_s1 distance _body < _s2 distance _body): _soldier = _s1
?(_s2 distance _body < _s1 distance _body): _soldier = _s2
? isNull _soldier : goto "nearest"
? not alive _soldier : goto "nearest"
? _soldier distance _body > 5 : goto "nearest"
~1
player switchMove "LyingToTreatedLying"
deleteVehicle _body
"player removeMagazine _x" forEach magazines player
"player removeWeapon _x" forEach weapons player
"player addMagazine _x" forEach _magazines
"player addWeapon _x" forEach _weapons
player selectWeapon primaryWeapon player
_soldier playmove "CombatToMedic"
player setPos _pos
player setDir _dir
player setCaptive true
~5
player playmove "TreatedLyingToLying"

_camera camSetTarget player
_camera camSetRelPos [10.49, 0.61, 3.48]
_camera camSetFov 0.7
_camera camCommit 2
@camCommitted _camera

_camera camSetRelPos [-0.82, -3.12, 3.38]
_camera camSetFov 0.044
_camera camCommit 1.5
@camCommitted _camera
;// EDIT END
;// EDIT END
player switchCamera "INTERNAL"
player cameraEffect ["Terminate", "BACK"]
camDestroy _camera
enableRadio true
player setCaptive false

exit

Hope it works...  :D
enjoy

Nasty Buttler

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #10 on: 27 Feb 2003, 17:50:32 »
well i dont know how much testing doolittle did on the original script in multiplayer but hell, BUGGIE!.....i have been working out the bugs for the last 5 hours and there is still a way to go...ill post the final script when its finished

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:New type of respawn, Have teammate revive
« Reply #11 on: 28 Feb 2003, 03:28:32 »
What the HEY are you talking about?  It's not buggy.  And I have improved upon my original code a lot.

Code: [Select]
;by Doolittle
enableRadio false
_body = player
_pos = getPos _body

_camera = "CAMERA" camCreate _pos
_camera cameraEffect ["Internal", "BACK"]

cutText ["", "BLACK IN"]

_camera camSetTarget _body
_camera camSetRelPos [0.20, 0.39, 1.86]
_camera camSetFov 0.143
_camera camCommit 0
@camCommitted _camera

_camera camSetRelPos [2.71, 19.55, 12.94]
_camera camSetFov 0.7
_camera camCommit 5
@camCommitted _camera

cutText ["You are ""almost dead"" and waiting to be revived", "PLAIN DOWN"]

_pos = getPos _body
_pos = [_pos select 0, _pos select 1, 0]
_dir = getDir _body

@_body != player and alive player

_magazines = magazines _body
_weapons = weapons _body
deleteVehicle _body
_body = "Body" createVehicle _pos
_body setDir _dir

_camera camSetTarget _body
_camera camCommit 0
_camera camCommand "manual on"
@camCommitted _camera

#nearest
~1
_soldier = nearestObject [_body, "SoldierWSaboteurDay"]
?isNull _soldier : goto "nearest"
?not alive _soldier : goto "nearest"
?_soldier distance _body > 5 : goto "nearest"
~1

_soldier playMove "CombatToMedic"
cutText [format ["%1 revived you", name _soldier], "PLAIN DOWN"]

deleteVehicle _body
"player removeMagazine _x" forEach magazines player
"player removeWeapon _x" forEach weapons player
"player addMagazine _x" forEach _magazines
"player addWeapon _x" forEach _weapons
player selectWeapon primaryWeapon player
player switchMove "LyingToCombat"
player setPos _pos
player setDir _dir
player setCaptive true
enableRadio true

_camera camSetTarget player
_camera camSetRelPos [10.49, 0.61, 3.48]
_camera camSetFov 0.7
_camera camCommit 5
_camera camCommand "manual off"
@camCommitted _camera

_camera camSetRelPos [-0.82, -3.12, 3.38]
_camera camSetFov 0.044
_camera camCommit 3.5
@camCommitted _camera

player switchCamera "INTERNAL"
player cameraEffect ["Terminate", "BACK"]
camDestroy _camera
player setCaptive false

In this one you can move around while you are dead.  This also says who saved you and makes them do the treat animation.  Also it remembers what weapons were on the player at the last second....this way you can loot the body before it turns into a blanket and they won't respawn with whatever you took.

I didn't want to do too many nearestObject calls because I think that is a CPU intensive function.

Also I have decided not to use this code at all!  I will post more about this later.

Doolittle
« Last Edit: 28 Feb 2003, 03:35:43 by Doolittle »

bn880

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #12 on: 28 Feb 2003, 06:33:27 »
How about adding an action to the dead players.  ;D  

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:New type of respawn, Have teammate revive
« Reply #13 on: 02 Mar 2003, 03:58:28 »
This is a cut and paste post:

I rewrote the script.  I am trying to do client/server model.  This allows the AI to be "revived" too now.

This is called whenever someone dies.  The name of that person is passed, like "Soldier1".
respawn.sqs
Code: [Select]
;by Doolittle
_string = _this select 0

_body = call format ["%1", _string]
_string setMarkerPos getPos _body

?not local _body : exit
?_body == player : [] exec "cam.sqs"

#notalive
~1
_obj = call format ["%1", _string]
?not alive _obj : goto "notalive"

"_obj removeMagazine _x" forEach magazines _obj
"_obj removeWeapon _x" forEach weapons _obj
"_obj addMagazine _x" forEach magazines _body
"_obj addWeapon _x" forEach weapons _body
_obj selectWeapon primaryWeapon _obj

_pos = getPos _body
_pos = [_pos select 0, _pos select 1, 0]
_dir = getDir _body
_dir = _dir - 90

deleteVehicle _body
_body = "Body" createVehicle _pos
_body setDir _dir

_ai = objNull
#nearest
~1
_soldier = nearestObject [_body, soldierType]
?isNull _soldier : goto "nearest"
?not alive _soldier : goto "nearest"
?_ai != _soldier : _ai = _soldier; _ai doMove _pos
?_soldier distance _body > 5 : goto "nearest"

~1
deleteVehicle _body
_obj = call format ["%1", _string]
?not alive _obj : exit

_soldier doWatch _obj
_soldier playMove "MedicToCombat"
_obj switchMove "LyingToCombat"
_obj setPos _pos
_obj setDir _dir

_obj setCaptive true
~5
~3.5
_obj setCaptive false

cam.sqs
Code: [Select]
;by Doolittle
enableRadio false
_camera = "CAMERA" camCreate getPos player
_camera cameraEffect ["Internal", "BACK"]

cutText ["", "BLACK IN"]

_body = player
_camera camSetTarget _body
_camera camSetRelPos [0.20, 0.39, 1.86]
_camera camSetFov 0.143
_camera camCommit 0
@camCommitted _camera

_camera camSetRelPos [2.71, 19.55, 12.94]
_camera camSetFov 0.7
_camera camCommit 5
@camCommitted _camera

cutText ["You are ""almost dead"" and waiting to be revived", "PLAIN DOWN"]

@alive player

~1
_camera camCommit 0
_camera camCommand "manual on"
@camCommitted _camera

#list
~1
?not (player in list playeralive) : goto "list"

enableRadio true

_pos = getPos player
_pos = [_pos select 0, _pos select 1, 1]

_camera camSetTarget _pos
_camera camSetRelPos [10.49, 0.61, 3.48]
_camera camSetFov 0.7
_camera camCommit 5
_camera camCommand "manual off"
@camCommitted _camera

_camera camSetRelPos [-0.82, -3.12, 3.38]
_camera camSetFov 0.044
_camera camCommit 3.5
@camCommitted _camera

player switchCamera "INTERNAL"
player cameraEffect ["Terminate", "BACK"]
camDestroy _camera

I wanted to seperate all client side effects into it's own file and then have it "react" to whatever the respawn.sqs file was doing.

Again, there is a new version of my example mission up called co12do_fourshilkas that implements this code.

I also have markers being placed where someone dies so it is easy to find their body to revive them AND when you are dead you can fly around like a seagull while you wait to be revived.  The AI can be revived AND it revives other people.  It is cool seeing the AI run over to you and save you and also run to and save eachother.

Doolittle

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:New type of respawn, Have teammate revive
« Reply #14 on: 16 Mar 2003, 06:15:04 »
NEW NEW

Okay, I'm trashing co12do_fourshilkas.  It was just a map to test my scripts.  Now testing is done & we have a finished product!

NOTICE, there are now three missions at my little webpage called co12do_noe.zip.  This zip has these three missions I made: :) co12do_takevalley, co12do_citydefense, and co12do_interimbase. :)

These missions show off the REVIVE RESPAWN thingy.

Revive Respawn
- When you die a teammate can come over and "revive" you
- You decide at setup how many times you can be revived (0..infinite)
- The AI can be revived if they are killed AND they also run around and revive eachother & you
- When someone is dead a big X will appear on the map, when they come back, the X will be removed
- When you are dead you can fly around like a seagull to watch the action until someone saves you

I am not a fan of team respawn, the guy that dies the most uses up the AI soldiers.  Or the constant respawn, where you go running in shooting at everything, die & then respawn again with no worries, repeat.  However I hated playing without respawn because you could teamkill someone by backing up over them, or you shoot the mountain with a LAW accidentally killing yourself or some lone AI sniper picks you off, or you sneak up to the enemy base, crawling along for 30 minutes & then you get shot without even shooting at them...frustrating!  SO hopefully Revive Respawn will be a compromise.  Fear being killed, yet it's not game over necessarily if you do die...IF you can convince a teammate to come over to your body & rescue you.  This also encourages people to STICK TOGETHER.

Doolittle

Josef

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #15 on: 17 Mar 2003, 19:26:01 »
how do I call this version?

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:New type of respawn, Have teammate revive
« Reply #16 on: 21 Mar 2003, 07:31:30 »
Awesome stuff, man, this is just the kind of thing that a lot of MP missions need... I wish I had had this code when I wrote my Homeland Security mod...

This would be awesome in some Vietnam team vs. team missions :)

I'd say your next step should be to add a timer, and if the person doesn' get treated within 30 seconds to a minute, they respawn at a 'base' or are dead for the duration...

Would be cool also in a round based game... Keep up the work. :)
The Captain

Nasty Buttler

  • Guest
Re:New type of respawn, Have teammate revive
« Reply #17 on: 12 Jun 2003, 05:37:41 »
Your a true master Doolittle