Skip to content

Commit

Permalink
fixing a bug where dismemberment code was not being read in from json…
Browse files Browse the repository at this point in the history
… files correctly, also adding a brief test for dismemberment for players, mostly works unless players are wearing armor then it gets trippy.
  • Loading branch information
DarthFutuza committed May 2, 2024
1 parent c4d0aa6 commit 86f774e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions codemp/game/bg_damage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ static void JKG_ParseSingleMeansOfDamage(const char* name, cJSON* json) {
mod.modifiers.droid = 1.0f;
mod.modifiers.organic = 1.0f;
mod.modifiers.shield = 1.0f;

mod.modifiers.ignoreArmor = qfalse;
mod.modifiers.ignoreShield = qfalse;
mod.modifiers.shieldBlocks = qfalse;
mod.modifiers.dodgeable = qfalse;
mod.modifiers.isEMP = qfalse;
}

jsonNode = cJSON_GetObjectItem(json, "dismemberment");
if (jsonNode) {
child = cJSON_GetObjectItem(json, "canDismember");
child = cJSON_GetObjectItem(jsonNode, "canDismember");
mod.dismemberment.canDismember = cJSON_ToBooleanOpt(child, qfalse);

child = cJSON_GetObjectItem(json, "blowChunks");
child = cJSON_GetObjectItem(jsonNode, "blowChunks");
mod.dismemberment.blowChunks = cJSON_ToBooleanOpt(child, qfalse);
}

Expand Down
19 changes: 19 additions & 0 deletions codemp/game/g_combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5194,6 +5194,23 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
trap->SendServerCommand(attacker - g_entities, va("notify 1 \"Head blow!\""));
}
}

//check for dismemberment for players --futuza: todo, check wtf is going on with armor when dismemberment happens
if (targ->s.eType == ET_PLAYER || targ->s.eType == ET_BODY)
{
if ((means->dismemberment.canDismember || means->dismemberment.blowChunks)
&& take > 2 && !(dflags & DAMAGE_NO_DISMEMBER))
{
if (means->dismemberment.canDismember)
{
G_CheckForDismemberment(targ, attacker, targ->pos1, take, targ->client->ps.torsoAnim, qtrue);
}
if (means->dismemberment.blowChunks)
{
G_CheckForBlowingUp(targ, attacker, targ->pos1, take, targ->client->ps.torsoAnim, qtrue);
}
}
}
}
else if (targ->s.eType == ET_NPC)
{ //g2animent
Expand Down Expand Up @@ -5229,6 +5246,8 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
}
}



targ->enemy = attacker;
targ->die (targ, inflictor, attacker, take, mod);
G_ActivateBehavior( targ, BSET_DEATH );
Expand Down

0 comments on commit 86f774e

Please sign in to comment.