Browse Source

Fix Stat Adjustment (#3898)

This fixes a problem related to shrines. When a player with a base Magic or Vitality stat of 0 has their respective stat reduced below 0, they lose Mana/Life, and their stat is corrected to 0 without refunding them the lost Mana/Life. This will prevent stats from being modified to a value less than 0 in the first place.
pull/4047/head
KPhoenix 4 years ago committed by GitHub
parent
commit
32d39c6524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      Source/player.cpp

20
Source/player.cpp

@ -3792,10 +3792,7 @@ void ModifyPlrStr(int p, int l)
}
auto &player = Players[p];
int max = player.GetMaximumAttributeValue(CharacterAttribute::Strength);
if (player._pBaseStr + l > max) {
l = max - player._pBaseStr;
}
l = clamp(l, 0 - player._pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Strength) - player._pBaseStr);
player._pStrength += l;
player._pBaseStr += l;
@ -3814,10 +3811,7 @@ void ModifyPlrMag(int p, int l)
}
auto &player = Players[p];
int max = player.GetMaximumAttributeValue(CharacterAttribute::Magic);
if (player._pBaseMag + l > max) {
l = max - player._pBaseMag;
}
l = clamp(l, 0 - player._pBaseStr, player.GetMaximumAttributeValue(CharacterAttribute::Magic) - player._pBaseMag);
player._pMagic += l;
player._pBaseMag += l;
@ -3850,10 +3844,7 @@ void ModifyPlrDex(int p, int l)
}
auto &player = Players[p];
int max = player.GetMaximumAttributeValue(CharacterAttribute::Dexterity);
if (player._pBaseDex + l > max) {
l = max - player._pBaseDex;
}
l = clamp(l, 0 - player._pBaseDex, player.GetMaximumAttributeValue(CharacterAttribute::Dexterity) - player._pBaseDex);
player._pDexterity += l;
player._pBaseDex += l;
@ -3871,10 +3862,7 @@ void ModifyPlrVit(int p, int l)
}
auto &player = Players[p];
int max = player.GetMaximumAttributeValue(CharacterAttribute::Vitality);
if (player._pBaseVit + l > max) {
l = max - player._pBaseVit;
}
l = clamp(l, 0 - player._pBaseVit, player.GetMaximumAttributeValue(CharacterAttribute::Vitality) - player._pBaseVit);
player._pVitality += l;
player._pBaseVit += l;

Loading…
Cancel
Save