Resurrecting a player in coop

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Resurrecting a player in coop

Post by GleasSpty »

The functionality I would like is as follows. During a coop game, a player cannot resurrect oneself with +use, and if all players die, they lose and must restart the level (or load from a saved game); however, as long as a single player remains alive, their dead teammates can be resurrected by having one of the surviving players go to the corpse of the dead teammate and press the "+use" key. In such a case, the previously dead player would be revived in place with inventory just as it was before death and at X health (I currently haven't decided on a value for the health they should be revived at---suggestions?).

I've never done any Doom modding before, and I just spent the past several hours researching the subject. I tried a couple of things, but nothing has worked. Hopefully someone with more experience than me knows of a way to implement this?
User avatar
UnTrustable
Posts: 758
Joined: Wed Jan 31, 2007 11:34 am
Location: The Netherlands
Contact:

Re: Resurrecting a player in coop

Post by UnTrustable »

This is the same thing i need soon.
Im making a BridgeCrossing map (idea stolen America's Army game) where it would be cool if players who 'died' can be revived again.
I HAVE an idea to pull this off, but i have not began to make it ...yet....

The idea is: to have the player have more than 100% health, and makes it invulnerable and immobilize at the same time (prentend it is dead) when it come lower than ..lets say 10% (which could be a tricky number to work with).
When you work with the 10% number, the player must have 110% HP, which is then basicly his 100% HP....if you still can follow me?
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

For what it's worth, I have begun work on this at the moment. I have uploaded a (pre)beta version of this if you want to test it out.

From a player's/end-use perspective, everything is as normal, except (in mutliplayer), instead of dying, you are "incapacitated", being frozen in place, only able to shoot. If another player comes over and "+uses" the incapacitated player, they are "revived" and given 10 health.

From a development perspective, they key idea was to give each player the property APROP_BUDDHA and then manually implement incapacitation upon having their health reach 1.

Right now I am working on making a Project Brutality/UDV compatible version. This is turning-out to be quite a bit more complicated (for example, for some reason, if you "kick" in PB, this seems to unfreeze the player (try loading Revive-Vanilla.pk3 with PB to see what I mean), and in any case, I would need to write code to disallow the player from kicking when incapacitated anyways). Upon working on this version, I have made some tweaks that I would like to put in the vanilla version but have not yet. (One example that comes into mind: currently, in the vanilla version, if two players happen to become incapacitated right next to each other, they can revive each other---that shouldn't be allowed.) There are also a couple of features I would like to add to both, perhaps the chief of which is to forbid players from using anything else besides a pistol when incapacitated (somehow, it doesn't quite make sense that a marine weakened to the point of immobility could wield a BFG . . .). (I actually just asked a question (http://forum.zdoom.org/viewtopic.php?f=3&t=51770) related to this. If the feature I asked about there existed, achieving this would be a lot easier.)

Disclaimer: I shamelessly just plain outright stole a couple of assets (sprites and sound effects) from PB. I was planning on using this only for personal use and not distributing, and so I'm not actually sure if I was supposed to ask permission (I haven't yet!) to use these assets before uploading my code here. In any case, obviously all credits for these assets to go pa1nki113r and Sergeant_Mark_IV (and maybe others?).
Attachments
Revive-Vanilla.pk3
(121.83 KiB) Downloaded 252 times
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Resurrecting a player in coop

Post by Nash »

It's possible to do it without exploiting the BUDDHA flag (in case you need the deaths to actually happen). I don't have time to write code, but you'd basically setup a way to keep track if a player has "died". There are several ways, you can keep track of this info in a map array, or give a dummy inventory item to a player to mark him as "has just died".

With that info, what you'd do next is, when the player's health <= 0 (or via a DEATH script, you store the last location of the player's death. You can then write a RESPAWN script to check if the player has been flagged for death. If he has, immediately move him to the last known location of death, set him to frozen or whatever, and force him to start with 10 health.

From then on, you should be able to figure out the mechanics to remove the death flag when other players click on him.

Of course the downside is that there will be a brief moment where you see the respawn fog FX but that's unavoidable when death actually happens to players.
User avatar
nakkemake
Posts: 237
Joined: Fri Apr 24, 2015 3:31 am
Location: ┌П┐(▀̿Ĺ̯▀̿ ̿)

Re: Resurrecting a player in coop

Post by nakkemake »

I'm wondering about how to make playable arch vile who resurrects dead players in coop mode? Same procedure what nash said?
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

@Nash. When I first started, I definitely wanted the player to 'actually' die, but I was never able to figure out how to simply bring a player back to life. I Googled to try to find ACS functions that could achieve on an arbitrary player (given their TID, say) the same effect as the console command "resurrect" does, but I was unable to find any. In fact, I think I briefly tried "ConsoleCommand("resurrect")" in Zandronum, but it didn't work as expected (though I didn't really debug/troubleshoot this because I want to play in GZDoom anyways).

How do you bring a dead player back to life?
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Resurrecting a player in coop

Post by Nash »

Ah that's not possible then, engine-wise, when a player dies, he really dies, you can't intercept that. The BUDDHA workaround seems to the cleanest course of action here.
User avatar
NGX
Posts: 123
Joined: Sat Jun 14, 2014 12:17 pm

Re: Resurrecting a player in coop

Post by NGX »

Hey. I am also looking to utilize "resurrect" in only co-op games, and I also heard that utlizing "buddha" was the best approach.

Are any of you making any advancements towards this goal?

It's out of my field but I'd love to hear somebody accomplishing this.

Personally I'd opt for 20-40% resurrection health to avoid players dying again immediately, but it would a good balance to include something like a ~5 second penalty.
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

Yes, I have made some advancements working towards this. I have attached two versions, one for vanilla Doom and the other to be loaded with Project Brutality.

While the vanilla version was designed to be run alone, you can certainly try to run the vanilla version with other mods. Depending on the mod, things should range from "Working perfectly" to "Meh a couple of things seem not to be working right but it's still playable.". (For example, if you run the vanilla version with PB, the "incapacitated" and "reviving" sprites don't work, you can kick when you're incapacitated, but you can't shoot at all, etc., though the main mechanic still works (i.e. you can still revive your teammates).) I should also mention that as I plan to play myself mostly with PB, I spent most of the time testing the PB version---I would imagine there are still some bugs to be worked out in the vanilla version.

For the PB version, just load Revive.pk3 after PB (and probably also after UDV if you're using it, though I'm not sure this will make a difference). One thing to note is that, if you want the pistol (and melee) names to display properly in UDV, you will have to change a couple of strings in your UDV_v1.84_B_MOD_ProjectBrutality.pk3---I have uploaded mine with the strings premodified (of course all credit goes to saegiru for this mod). (If someone knows a way to fix these strings without modifying the UDV code directly, please let me know---I tried a couple of things myself, and with no success I decided to message saegiru to ask if there was a convenient way to fix custom weapon names without touching UDV itself, though I haven't yet heard back.) Note that I did write a Classic Brutal Doom v20 and Traditional version was well, but I did not test them at all (though the only code that is different is the weapon code, so if anything is broken, it will only be the pistol/rifle and melee.)

In both versions, you can tweak the amount of health revival gets by opening up SOURCE/Revive.acs and changing the 10 in "#define REVIVE_HEALTH 10" to whatever number you like.

I am aware of one minor (though probably time-consuming to fix) bug. To see this, first run PB by itself, switch to melee, and hold down the alt+fire---Doomguy should punch once, and that's it---if you want to punch further, you have to release and press punch again. Now run PB with Revive.pk3, and hold down the alt-fire again---Doomguy should repeatedly keep punching. It' doesn't break the game or anything because you can't actually punch faster than you can in PB alone (or if you can, you would have to go out of our way to measure such a difference), but it's a shame that it's not exactly like in PB.

The reason this bug is arising is as follows. By default, a player is forced to use a pistol when incapacitated---if they don't have a pistol, they will be forced to use melee. Because the player is PROP_TOTALLYFROZEN when incapacitated, I needed to change how the pistol and fists fire by manually checking for player input so that they can still fire the pistol (and punch) while incapacitated. My understanding is that there are times ZDoom will jump to the "Fire" state, even if there is nothing explicit (e.g. "goto Fire") in the code (I think A_WeaponReady might do this). As as beginner, I don't have a complete understanding of exactly how/when ZDoom will fire when the player is not PROP_TOTALLYFROZEN, and evidently I didn't get it quite right when trying to manually reimplement the same thing checking for player input on my own. It also doesn't help that, right now, the code for this (in ACTORS/WEAPONS/RevivablePistol.txt and similar files) is a god-awful mess. Because of the issue I describe in http://forum.zdoom.org/viewtopic.php?f=3&t=51772, I wound-up having to copy and paste nearly the entirety of the BDPIstol and Melee_Attacks classes from PB and modify them accordingly---simply inheriting and tweaking just a couple of states didn't work.

There are a couple of things that would be nice to add, but I probably won't have time for. The first one is extra player sprites for players shooting when incapacitated. Right now I'm just using a couple of death animation sprites I stole from PB to show that the player is incapacitated, and the sprite doesn't change even if the player is shooting from the ground. The second (and definitely more important thing) that would be nice is to have it autoload the most recent save, or if there is none, just restart the level, when all players are incapacitated (or really after they all have pressed +use at this point to indicate they are ready to restart). My guess is that this is just not possible because you can't even normally load games in ZDoom itself when in multiplayer, but if someone has an idea of how to get this to work, I would love to hear it. Finally, it would be nice if there were a better option to have monsters not attack incapacitated players than SetPlayerProperty(0,1,PROP_NOTARGET)---with only this, monsters will still attack any players they had already seen or if a new player attacks them. This could easily be abused, say, by deliberately having one teammate be incapacitated and distract the monsters to make something much easier for their teammates.

Anyways, let me know what you think, in particular if you find any bugs or have any feature suggestions. I wasn't planning on releasing this, but if there is enough interest and it matures enough, I may upload it to moddb or something.
Attachments
Revive-Vanilla.pk3
(120.5 KiB) Downloaded 261 times
Revive.pk3
(140.36 KiB) Downloaded 231 times
UDV_v1.84_B_MOD_ProjectBrutality.pk3
(46.06 KiB) Downloaded 125 times
User avatar
NGX
Posts: 123
Joined: Sat Jun 14, 2014 12:17 pm

Re: Resurrecting a player in coop

Post by NGX »

I get this error when running "Revive.PK3";
Script error, "Revive.pk3:actors/weapons/revivablepistol.txt" line 1:
Parent type 'BDPistol' not found in RevivablePistol
Script error, "Revive.pk3:actors/weapons/revivablepistol.txt" line 1:
Replaced type 'BDPistol' not found for RevivablePistol

Execution could not continue.

Script error, "Revive.pk3:actors/weapons/revivablepistol.txt" line 38:
Invalid state parameter a_weaponready
"Revive-vanilla.PK3" runs but I didn't see any behavioral changes in-game -- yes, I did try it in co-op.

Any chance you could make a variation that simply revives the player after ~5 seconds without needing a team-mate to do that for you?
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

The error you get is exactly the one I get if I don't load PB. Are you sure you are loading Project Brutality 2.03 *before* Revive.pk3?

Well, there shouldn't be any behavioral changes at all, with the sole exception that you don't die but instead become incapacitated. In coop, when a player reaches 1 health, they didn't die, did they?

I could do that, but I don't see the point. If you have players automatically get resurrected, then you can't lose. Why not just have them not die in the first place (which is super easy to do: just give all the players PROP_BUDDHA)?

The thing I personally didn't like was that playing coop effectively made things harder, because as soon as one of the players dies, you all have to restart (which is particularly annoying because you all have to quit, load, and reconnect, a process that can take up to half a minute, and with PB max difficulty on things like Maps of Chaos this means spending a lot of time reloading and not actually playing). The same level with more players should be easier, and I felt that the revival mechanic was a natural way to make more players beneficial, but to write the mod in such a way that you can't lose seems to defeat the purpose. Why not just iddqd and be done with it?
User avatar
NGX
Posts: 123
Joined: Sat Jun 14, 2014 12:17 pm

Re: Resurrecting a player in coop

Post by NGX »

Oh, I thought it was the third download "UDV_v1.84_B_MOD_ProjectBrutality" that was meant for PB --- no, I don't even have PB.

I tried "Revive-vanilla" in co-op with just myself playing, and it did die as normal rather than being incapacitated..

You have a point, and I would be mighty grateful if you did make a variant of this.

In response to your question, a traditional "co-op" game as opposed to "survival" grants endless respawning for the players, so my suggestion wouldn't be any different in that regard, although it would solve the problem of respawning way back at the initial starting area and having to catch up to the other players again - this is what my biggest concern was with how my own mod will play in co-op as I'd rather avoid subjecting players to such an unnecessary journey every time they fall in battle.

That said and considering your response, I think a "life limit" could be a good complement -- and hey, I just didn't have the courage to venture into this type of stuff earlier but seeing as I'm kind of forced to now as I'm looking to balance the co-op in my mod, I have for a long time now had the desire to include a "life system" on all of my current and future mods; player starts with 1 extra life by default, and they can be found and picked up for further extra lives throughout the map.
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

Coop by yourself? I'm not sure what you mean by that. In any case, the script looks at the number of players in the game, not the "mode", and so (unless there is a bug), the game should play identically as usual if you play by yourself. To test it myself, I had to start two instances of gzdoom and connect just as if I were connecting to another player.

I believe ZDoom might already have what you're looking for. If you go to the "Gameplay options" menu, take a look at the "NO RESPAWN" setting. If this is off, then players die like normal and can respawn indefinitely by pressing +use after they die. On the other hand, if it is on, then when one player dies, everyone has to restart (once again, assuming you actually want to continue playing with your friends . . .). Also check out the "SPAWN WHERE DIED" option under "Cooperative settings" on the same page. If on, then when you respawn, you respawn where you died, and otherwise you respawn at the beginning of the level.

I'm not sure about ZDoom itself, but PB has a coop life limit determined by the CVAR bd_cooplives (1 for on and 0 for off) and bd_numcooplives (the number of lives). (This is described in the manual.) This is actually not too bad---the problem I had with it is that the life pool is shared. I play with someone who tends to be, shall we say, "overagressive", and I wasn't too excited about the idea of him taking up all our lives =P

On the other hand, I am not aware of a life system for singleplayer or even just coop ZDoom. This is my first mod and so I'm not experienced enough to say how to do this or even how difficult it might be off the top of my head, but if you're interested, the first thing I would do is check out the PB source and see how he implements the bd_numcooplives. (Actually, in general I found the source code of other mods, PB in particular, to be a great source of learning.)
User avatar
NGX
Posts: 123
Joined: Sat Jun 14, 2014 12:17 pm

Re: Resurrecting a player in coop

Post by NGX »

Okay, I didn't know that about your script. I played co-op alone by the command line and "gzdoom -host 1 -warp 1".

No, unfortunately the existing options are not what I'm looking for, and so far I'm afraid the scenario where everybody has to restart if somebody dies sounds the best, because it'll solve players having to make their way from spawn point and back to place of death, and it would also encourage team-play.

The existing "spawn at place of death" option could work, but I have areas that are instant-kill such as a lava lake, so I can't have players respawning right into a death trap.

A life system for both single-player but more importantly co-op is honestly what I'm really looking for, but coding is just not my preferred field of work and I've already spent more than plenty of time with my mod to the point of actually wearing out my right hand --- it's taken a ~2 week vacation but I hope it's back on duty soon :wink:
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Resurrecting a player in coop

Post by GleasSpty »

"where everybody has to restart if somebody dies sounds the best" ---- Turning on "NO RESPAWN" doesn't achieve what you want? No one can respawn, so if someone dies and you want them to live, everyone has to restart.
Locked

Return to “Editing (Archive)”