From 92e602894bf8197a7808c034962c5bf2479db3cf Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 19 Dec 2020 11:02:09 -0600 Subject: [PATCH] Merged https://github.com/coelckers/gzdoom/pull/1239 (More DamageMobj flags) --- src/playsim/p_interaction.cpp | 34 ++++++++++++------- src/playsim/p_local.h | 3 ++ src/playsim/p_map.cpp | 8 ++--- src/playsim/p_mobj.cpp | 8 ++--- src/playsim/p_spec.cpp | 5 +-- src/playsim/po_man.cpp | 2 +- wadsrc/static/zscript/actors/player/player.zs | 4 +-- wadsrc/static/zscript/constants.zs | 3 ++ 8 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index a9fae573d..87c732fd9 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -1110,20 +1110,28 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da if (!telefragDamage || (target->flags7 & MF7_LAXTELEFRAGDMG)) // TELEFRAG_DAMAGE may only be reduced with LAXTELEFRAGDMG or it may not guarantee its effect. { - if (player && damage > 1) + if (damage > 1) { - // Take half damage in trainer mode - damage = int(damage * G_SkillProperty(SKILLP_DamageFactor) * sv_damagefactorplayer); - } - else if (!player && damage > 1 && !(target->flags & MF_FRIENDLY)) - { - // inflict scaled damage to non-players - damage = int(damage * sv_damagefactormobj); - } - else if (!player && damage > 1 && (target->flags & MF_FRIENDLY)) - { - // inflict scaled damage to non-player friends - damage = int(damage * sv_damagefactorfriendly); + if (player) + { + // Take half damage in trainer mode + damage = int(damage + * ((flags & DMG_NO_CVAR) ? 1. : sv_damagefactorplayer) + * ((flags & DMG_NO_SKILL) ? 1. : G_SkillProperty(SKILLP_DamageFactor))); + } + else if (!(flags & DMG_NO_CVAR)) + { + if (target->flags & MF_FRIENDLY) + { + // inflict scaled damage to non-player friends + damage = int(damage * sv_damagefactorfriendly); + } + else + { + // inflict scaled damage to non-players + damage = int(damage * sv_damagefactormobj); + } + } } // Special damage types if (inflictor) diff --git a/src/playsim/p_local.h b/src/playsim/p_local.h index 594a3f0b5..fa2ee6bcc 100644 --- a/src/playsim/p_local.h +++ b/src/playsim/p_local.h @@ -447,6 +447,9 @@ enum EDmgFlags DMG_NO_PAIN = 1024, DMG_EXPLOSION = 2048, DMG_NO_ENHANCE = 4096, + DMG_NO_CVAR = 8192, + DMG_NO_SKILL = 16384, + DMG_SECTOR = 32768, }; diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index 151953d07..7275124f3 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -869,7 +869,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee, DMG_SECTOR); } if (wasfit) { @@ -946,7 +946,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec { if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee, DMG_SECTOR); } if (wasfit) { @@ -2711,7 +2711,7 @@ pushline: if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee, DMG_SECTOR); } numSpecHitTemp = (int)spechit.Size(); while (numSpecHitTemp > 0) @@ -6306,7 +6306,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) if ((cpos->crushchange > 0) && !(thing->Level->maptime & 3)) { - int newdam = P_DamageMobj(thing, NULL, NULL, cpos->crushchange, NAME_Crush); + int newdam = P_DamageMobj(thing, NULL, NULL, cpos->crushchange, NAME_Crush, DMG_SECTOR); // spray blood in a random direction if (!(thing->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 308c58144..d988e96a3 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -1271,7 +1271,7 @@ bool AActor::Grind(bool items) if (flags6 & MF6_TOUCHY && (flags6 & MF6_ARMED || IsSentient())) { flags6 &= ~MF6_ARMED; // Disarm - P_DamageMobj (this, NULL, NULL, health, NAME_Crush, DMG_FORCED); // kill object + P_DamageMobj (this, NULL, NULL, health, NAME_Crush, DMG_FORCED|DMG_SECTOR); // kill object return true; // keep checking } @@ -2364,7 +2364,7 @@ void P_MonsterFallingDamage (AActor *mo) damage = int((vel - 23)*6); } if (!(mo->Level->flags3 & LEVEL3_PROPERMONSTERFALLINGDAMAGE)) damage = TELEFRAG_DAMAGE; - P_DamageMobj (mo, NULL, NULL, damage, NAME_Falling); + P_DamageMobj (mo, NULL, NULL, damage, NAME_Falling, DMG_SECTOR); } // @@ -6231,7 +6231,7 @@ foundone: && Terrains[terrainnum].DamageAmount && (thing->Level->time & Terrains[terrainnum].DamageTimeMask); if (dealDamageOnLand) - P_DamageMobj(thing, nullptr, nullptr, Terrains[terrainnum].DamageAmount, Terrains[terrainnum].DamageMOD); + P_DamageMobj(thing, nullptr, nullptr, Terrains[terrainnum].DamageAmount, Terrains[terrainnum].DamageMOD, DMG_SECTOR); // don't splash when touching an underwater floor if (thing->waterlevel >= 1 && pos.Z <= thing->floorz) return Terrains[terrainnum].IsLiquid; @@ -6329,7 +6329,7 @@ bool P_HitFloor (AActor *thing) if (thing->flags6 & MF6_TOUCHY && ((thing->flags6 & MF6_ARMED) || thing->IsSentient()) && thing->Vel.Z < -5) { thing->flags6 &= ~MF6_ARMED; // Disarm - P_DamageMobj (thing, NULL, NULL, thing->health, NAME_Crush, DMG_FORCED); // kill object + P_DamageMobj (thing, NULL, NULL, thing->health, NAME_Crush, DMG_FORCED|DMG_SECTOR); // kill object return false; } diff --git a/src/playsim/p_spec.cpp b/src/playsim/p_spec.cpp index 2a156373d..b881f47db 100644 --- a/src/playsim/p_spec.cpp +++ b/src/playsim/p_spec.cpp @@ -461,7 +461,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { if (!(player->cheats & (CF_GODMODE | CF_GODMODE2))) { - P_DamageMobj(player->mo, NULL, NULL, sector->damageamount, sector->damagetype); + P_DamageMobj(player->mo, NULL, NULL, sector->damageamount, sector->damagetype, DMG_SECTOR); } if ((sector->Flags & SECF_ENDLEVEL) && player->health <= 10 && (!deathmatch || !(dmflags & DF_NO_EXIT))) { @@ -516,6 +516,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type, } int dflags = (flags & DAMAGE_NO_ARMOR) ? DMG_NO_ARMOR : 0; + dflags |= DMG_SECTOR; P_DamageMobj (actor, NULL, NULL, amount, type, dflags); } @@ -651,7 +652,7 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType) if (ironfeet == NULL) { damage = P_DamageMobj (player->mo, NULL, NULL, Terrains[floorType].DamageAmount, - Terrains[floorType].DamageMOD); + Terrains[floorType].DamageMOD, DMG_SECTOR); } if (damage > 0 && Terrains[floorType].Splash != -1) { diff --git a/src/playsim/po_man.cpp b/src/playsim/po_man.cpp index 8bbf80142..c73102e4c 100644 --- a/src/playsim/po_man.cpp +++ b/src/playsim/po_man.cpp @@ -790,7 +790,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) DVector2 pos = actor->Vec2Offset(thrust.X, thrust.Y); if (bHurtOnTouch || !P_CheckMove (actor, pos)) { - int newdam = P_DamageMobj (actor, nullptr, nullptr, crush, NAME_Crush); + int newdam = P_DamageMobj (actor, nullptr, nullptr, crush, NAME_Crush, DMG_SECTOR); P_TraceBleed (newdam > 0 ? newdam : crush, actor); } } diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 95c8db40a..2147a36cf 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -1559,7 +1559,7 @@ class PlayerPawn : Actor } else if (player.air_finished <= Level.maptime && !(Level.maptime & 31)) { - DamageMobj(NULL, NULL, 2 + ((Level.maptime - player.air_finished) / TICRATE), 'Drowning'); + DamageMobj(NULL, NULL, 2 + ((Level.maptime - player.air_finished) / TICRATE), 'Drowning', DMG_SECTOR); } } } @@ -1638,7 +1638,7 @@ class PlayerPawn : Actor if (player.hazardinterval <= 0) player.hazardinterval = 32; // repair invalid hazardinterval if (!(Level.maptime % player.hazardinterval) && player.hazardcount > 16*TICRATE) - player.mo.DamageMobj (NULL, NULL, 5, player.hazardtype); + player.mo.DamageMobj (NULL, NULL, 5, player.hazardtype, DMG_SECTOR); } player.mo.CheckPoison(); player.mo.CheckDegeneration(); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 4cfff28a9..8db6c495f 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -912,6 +912,9 @@ enum EDmgFlags DMG_NO_PAIN = 1024, DMG_EXPLOSION = 2048, DMG_NO_ENHANCE = 4096, + DMG_NO_CVAR = 8192, + DMG_NO_SKILL = 16384, + DMG_SECTOR = 32768, } enum EReplace