ZScript Player Limb System

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Posts: 373
Joined: Mon May 09, 2016 1:38 am
Twitch ID: XLightmingStormL

ZScript Player Limb System

Post by XLightningStormL »

I'm learning ZScript, but still some stuff goes way over my head. So I am a bit confused how to go about doing this.

Simply I wish to add a Limb System for Players a-la Deus Ex, Fallout, Tarkov, where limbs have different health values, and different effects when crippled.

Rough ideas of what I plan to have:
* There are five limbs: right/left arms, right/left legs, and head. For all intents and purposes Torsos are irrelevant.
* When limbs are damaged, the player's health pool will take the damage as well.
* To work around limitations, limb hitbox actors can't die, when they reach 1 hitpoint, it more or less results in them becoming crippled.
* When either leg gets crippled it slows the player down by 25% each (I assume this can be done with Power actors or dummies, the trick is getting the game to register the events for the player to gain the effect) as well as preventing the player from jumping/kicking/etc.
* Falling damage also affects the limb health of legs (I have custom fall damage behaviour in the code, I would assume the damage the player takes from the fall should transfer with a damage children action or whatever)
* When one arm is crippled crippled it would prevent players from using 2H/DW weapons, if both arms are crippled the Player cannot use any weapon (I presume this would work via a dummy token actor which would automatically deselect any held weapon, and jump to either the deselect state when the player switches weapons or a Crippled weapon state sort of like HD's dummy sprintweapon actor)
* Headshots are easy, when they drop down to 1, the player dies instantly. I suppose if the head hitbox health is low enough, it would cause a shaky cam effect for better immersion.
* Stimpacks and the such can heal the player's main health pool, but only all limbs by a small amount, instead the player would be dependent on splints (would restore 50% limb health) or Trauma Packs (restore limbs to full health) [Medikits would make a fine placeholder as an example]
* Limb Hitboxes follow the player, sprinting, jumping, etc.
* A drug item that would ignore the crippled limbs effect as a bonus effect for testing as well, it also protects limbs from damage by 25% for a short time (Berserk Packs would make a fine placeholder)
User avatar
Sir Robin
Posts: 392
Joined: Wed Dec 22, 2021 7:02 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: ZScript Player Limb System

Post by Sir Robin »

bookmarking this, I also want to do a limb hit system
Posts: 1326
Joined: Sun Jul 21, 2019 8:54 am

Re: ZScript Player Limb System

Post by Jarewill »

Okay, I've been chopping away this for 3 hours now and I think I got it done.
Attached will be a player class that spawns limbs (head, torso, arms and legs) that serve as the only way to damage the player (I know you didn't want the torso, but I had no idea how to make it otherwise), the limbs themselves, a limb healing item, a limb powerup item and a custom bullet puff and projectile.

Things I did include:
- The limbs follow the player around and are positioned relatively to the player's angle.
- Limbs take damage and once they reach 1 health, custom logic will happen in the player's class.
- Each broken leg will lower the player's speed by 25%, prevent jumping and give a dummy item that can be checked inside other classes to prevent kicking for example.
- Each broken arm will only give a dummy item that can also be checked to prevent selecting weapons.
- Broken head or broken torso will instantly kill the player.
- Falling damage only damages the legs and the damage itself is split between them both. (Each leg takes 50% falling damage)
- Damaging floors (Doom's Slime) damages legs and the torso. Torso takes 100% while each leg takes 50% of the damage.
- Stimpacks healing 25 health of the head and torso and only 5 health of each limb.
- Splints that heal 50 health of each limb, but don't heal the torso and head.
- A custom powerup that decreases limb damage by 25% and ignores broken limb effects.
- A debug function that prints out the health of each limb to show how to access it.

Things I didn't include:
- Making a custom HUD that would display each limb's health and/or display a collective health of all limbs combined.
- Any effects when certain limbs are low on health, such as the head.

Those things shouldn't be too hard to add, but I wanted to get the system in a basic state out here.
I should note that all monster attacks will need to be adjusted.
I attached an example puff and projectile with all the needed flags to get it working.
Also the vanilla monster melee attacks don't work with this and I have no idea why, however bullet attacks (such as those used by the chaingunners) work.
So you might need to use a bullet attack function for a melee attack.

Also I recommend using Nash's RadiusDebug for editing the positions of each limb.
Hope this serves you well.
You do not have the required permissions to view the files attached to this post.

Return to “Scripting”