Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement cut stock game gibbing feature #294

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

GooberRF
Copy link
Contributor

@GooberRF GooberRF commented Oct 22, 2024

This PR reimplements the cut gibbing feature that at one point existed in Red Faction, and as seen in the Technochunk bonus video.

When enabled, this feature causes entities and corpses to explode into meat chunks when they are destroyed by explosive damage (and some specific conditions). Other damage types do not trigger gibbing. I have tried to replicate this feature as close to the spirit of the original code as possible, though a handful of changes have been made:

  • With this PR, gibbing will only happen at gore level 2. Original code had it happening at gore level 1 (which is the default for 1.2 NA).

The functionality is controlled through the built-in gore level feature which I have tied to the new gore_level console command. It would be ideal at some point to have this as an option in the launcher, but I'm not worrying about that right now.

Here's a video of (an older version of) this feature in action: https://youtu.be/tgunFnn-lx0

The gibbing function fires under the following conditions for entities:

  • Life < -100
  • Explosive damage
  • Doesn't have flag for custom_corpse, dying, in_water, or eye_under_water

If those conditions are not met, the entity dies normally. If the entity has the flag ambient it disappears but doesn't explode into gibs. (Not totally sure if this is necessary - I don't know what the ambient flag does for certain, but this logic was in the original code. Perhaps it can be removed?)

The gibbing function fires under the following conditions for corpses:

  • Explosive damage

If that condition is not met, the corpse remains. If the corpse has flags for drools_slime or custom_state_anim it disappears but doesn't explode into gibs

Additional notes:

  • Original code used 7 chunks on PS2 - probably for performance reasons. I've doubled that count to 14. In the future I'd like to expose this to mod devs to customize the amount, but for now I think 14 is good.
  • The 5 meatchunk v3ms are direct from Volition (extracted from ps2 demo). Unfortunately the original texture as far as I know has been lost, so I made a replacement (gore1.tga)
  • I have also added the new gib texture to the RED texture browser under the Gore category - not strictly necessary but may as well let mappers use it if they want.
  • This PR adds the global g_rng for mt19937 RNG, and uses it for revamped rand_quick functions inside Vector3 and Matrix3.
  • This PR removes the bare definition for the ImpactSoundSet struct from weapon.h and properly defines it in sound.h
  • Originally I was worried about compatibility with mods, but with the shift to using the built-in gore level setting (which is saved to players.cfg, and is specific to each mod, as opposed to a registry key), which is far less of a concern. If a mod doesn't work quite right with gibs, the player should just not enable gore level 2 in that mod.

game_patch/rf/object.h Outdated Show resolved Hide resolved
game_patch/rf/entity.h Outdated Show resolved Hide resolved
game_patch/rf/entity.h Outdated Show resolved Hide resolved
game_patch/misc/player.cpp Outdated Show resolved Hide resolved
game_patch/misc/player.cpp Outdated Show resolved Hide resolved
game_patch/rf/ai.h Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
@GooberRF GooberRF requested a review from rafalh October 29, 2024 18:50
if (g_game_config.gibbing && !rf::is_multi && ep) {
int damage_type = regs.ebp;
ep->ai.explosive_last_damage = (damage_type == 3);
if (ep->ai.explosive_last_damage && ep->info->body_temp >= 90.0f) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it's not sensical to depend on some magic number that happens to work for stock game entities and has no other explanation. If what you want is to exclude entities with custom death animations or enormous one why not specify it directly? Body temp field was added with the intention to define color in IR scanners (e.g. railgun), not to determine how entity dies.
You also repeated that condition twice... Please follow DRY principle.

game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/misc/player.cpp Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
@GooberRF
Copy link
Contributor Author

GooberRF commented Dec 5, 2024

Revamped this to:

  • Use entity flag 0x80 to track "should gib"
  • Use built-in gore level feature to control gibs (also allows players to set gore level to 0 to disable blood decals if they wish - which was previously inaccessible)
  • Gibs are used at gore level 2. Default gore level is 1, so gibbing still defaults to off.
  • Gibbing flag is not added unless the entity should have it, and gibbing is not allowed for corpses that should remain (like rock snake, etc.)

@GooberRF GooberRF requested a review from rafalh December 5, 2024 00:49
game_patch/object/entity.cpp Outdated Show resolved Hide resolved
game_patch/rf/object.h Outdated Show resolved Hide resolved
game_patch/rf/player/player.h Show resolved Hide resolved
resources/CMakeLists.txt Outdated Show resolved Hide resolved
resources/licensing-info.txt Outdated Show resolved Hide resolved
@GooberRF GooberRF marked this pull request as draft December 12, 2024 04:23
@GooberRF GooberRF requested a review from rafalh December 15, 2024 15:55
@GooberRF GooberRF marked this pull request as ready for review December 15, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants