From 1c073fab89736852bab9a9654ad52c40d60c1603 Mon Sep 17 00:00:00 2001 From: thokkat Date: Thu, 16 May 2024 19:49:37 +0200 Subject: [PATCH] changeAttribute: don't reduce hitpoints of immortal npcs --- game/game/damagecalculator.cpp | 4 +--- game/world/objects/npc.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/game/game/damagecalculator.cpp b/game/game/damagecalculator.cpp index f1a555db8..70f24de17 100644 --- a/game/game/damagecalculator.cpp +++ b/game/game/damagecalculator.cpp @@ -27,8 +27,6 @@ DamageCalculator::Val DamageCalculator::damageValue(Npc& src, Npc& other, const if(ret.hasHit && !ret.invincible && Gothic::inst().version().game==2) ret.value = std::max(ret.value,MinDamage); - if(other.isImmortal()) - ret.value = 0; return ret; } @@ -44,7 +42,7 @@ DamageCalculator::Val DamageCalculator::damageFall(Npc& npc, float speed) { int32_t prot = npc.protection(::PROT_FALL); Val ret; - ret.invincible = (prot<0 || npc.isImmortal()); + ret.invincible = (prot<0); ret.value = int32_t(dmgPerMeter*(height-h0)/100.f - float(prot)); if(ret.value<=0 || ret.invincible) { ret.value = 0; diff --git a/game/world/objects/npc.cpp b/game/world/objects/npc.cpp index 97afd7314..bb0e780c0 100644 --- a/game/world/objects/npc.cpp +++ b/game/world/objects/npc.cpp @@ -1154,8 +1154,12 @@ int32_t Npc::attribute(Attribute a) const { void Npc::changeAttribute(Attribute a, int32_t val, bool allowUnconscious) { if(a>=ATR_MAX || val==0) return; - if(isPlayer() && Gothic::inst().isGodMode() && val<0 && a==ATR_HITPOINTS) - return; + if(val<0 && a==ATR_HITPOINTS) { + if(isPlayer() && Gothic::inst().isGodMode()) + return; + if(isImmortal()) + return; + } hnpc->attribute[a]+=val; if(hnpc->attribute[a]<0)