Skip to content

Commit

Permalink
changeAttribute: don't reduce hitpoints of immortal npcs (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
thokkat authored May 17, 2024
1 parent f7b86ee commit ad66816
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions game/game/damagecalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(ret.value,MinDamage);
if(other.isImmortal())
ret.value = 0;
return ret;
}

Expand All @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions game/world/objects/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ad66816

Please sign in to comment.