From 7057e044d0d036e4e2c27cb9cbb01345d0fae21e Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 11 May 2022 21:55:50 +0800 Subject: [PATCH] Changed Stats::UpdateHPStat() to update the current HP as well Updated German translation file. --- artifacts/translations/german.ini | 2 ++ sfall/Modules/Interface.cpp | 2 +- sfall/Modules/Objects.cpp | 2 +- sfall/Modules/Stats.cpp | 32 +++++++++++++++++-------------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/artifacts/translations/german.ini b/artifacts/translations/german.ini index 69562899..b158536d 100644 --- a/artifacts/translations/german.ini +++ b/artifacts/translations/german.ini @@ -16,6 +16,8 @@ PartyOrderAttackHuman=Ich k PartyOrderAttackCreature=::Grrrr:: PartyOrderAttackRobot=::Piep:: +HiResInfo=Diese Version von Sfall verfügt über einen integrierten High Resolution Patch-Modus, der mit den Einstellungen des Hi-Res-Patch von Mash kompatibel ist.\n\nWenn der Hi-Res Patch von Mash weiterhin verwenden soll, deaktiviere die 'HiResMode'-Option in der ddraw.ini.\nUm die Grafikverbesserungen von Sfall zu erhalten, muss der originale Hi-Res-Patch deaktiviert werden.\n\nSoll der Hi-Res-Patch von Mash deaktiviert werden? + [AppearanceMod] RaceText=Geschlecht StyleText=Stil diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index af71e236..f561b62c 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -1114,7 +1114,7 @@ void Interface::init() { HookCall(0x44C018, gmouse_handle_event_hook); // replaces hack function from HRP by Mash if (HRP::Setting::VersionIsValid) HRP::IFaceBar::IFACE_BAR_MODE = (GetIntHRPValue(HRP_VAR_IFACE_BAR_MODE) != 0); - // Fix crash when the player equips a weapon that is overloaded with ammo + // Fix crash when the player equips a weapon overloaded with ammo (ammo bar overflow) MakeCall(0x45F94F, intface_update_ammo_lights_hack); } diff --git a/sfall/Modules/Objects.cpp b/sfall/Modules/Objects.cpp index c462c775..41b53d9b 100644 --- a/sfall/Modules/Objects.cpp +++ b/sfall/Modules/Objects.cpp @@ -98,7 +98,7 @@ pickNewID: // skip PM range (18000 - 83535) } } -// Reassigns object IDs to all critters upon first loading a map and updates their max HP stat +// Reassigns object IDs to all critters upon first loading a map and updates their HP stats // TODO: for items? static void map_fix_critter_id() { long npcStartID = 4096; // 0x1000 diff --git a/sfall/Modules/Stats.cpp b/sfall/Modules/Stats.cpp index 56482ebb..5b52fa59 100644 --- a/sfall/Modules/Stats.cpp +++ b/sfall/Modules/Stats.cpp @@ -188,26 +188,30 @@ static void __declspec(naked) stat_recalc_derived_hack() { } void Stats::UpdateHPStat(fo::GameObject* critter) { - if (engineDerivedStats) return; - fo::Proto* proto; if (fo::func::proto_ptr(critter->protoId, &proto) == -1) return; - auto getStatFunc = (derivedHPwBonus) ? fo::func::stat_level : fo::func::stat_get_base; + if (!engineDerivedStats) { + auto getStatFunc = (derivedHPwBonus) ? fo::func::stat_level : fo::func::stat_get_base; - double sum = 0; - for (int stat = fo::Stat::STAT_st; stat <= fo::Stat::STAT_lu; stat++) { - sum += (getStatFunc(critter, stat) + statFormulas[fo::Stat::STAT_max_hit_points].shift[stat]) * statFormulas[fo::Stat::STAT_max_hit_points].multi[stat]; + double sum = 0; + for (int stat = fo::Stat::STAT_st; stat <= fo::Stat::STAT_lu; stat++) { + sum += (getStatFunc(critter, stat) + statFormulas[fo::Stat::STAT_max_hit_points].shift[stat]) * statFormulas[fo::Stat::STAT_max_hit_points].multi[stat]; + } + long calcStatValue = statFormulas[fo::Stat::STAT_max_hit_points].base + (int)floor(sum); + if (calcStatValue < statFormulas[fo::Stat::STAT_max_hit_points].min) calcStatValue = statFormulas[fo::Stat::STAT_max_hit_points].min; + + if (proto->critter.base.health != calcStatValue) { + fo::func::debug_printf("\nWarning: critter PID: %d, ID: %d, has an incorrect base value of the max HP stat: %d (must be %d)", + critter->protoId, critter->id, proto->critter.base.health, calcStatValue); + + proto->critter.base.health = calcStatValue; + } } - long calcStatValue = statFormulas[fo::Stat::STAT_max_hit_points].base + (int)floor(sum); - if (calcStatValue < statFormulas[fo::Stat::STAT_max_hit_points].min) calcStatValue = statFormulas[fo::Stat::STAT_max_hit_points].min; - if (proto->critter.base.health != calcStatValue) { - fo::func::debug_printf("\nWarning: critter PID: %d, ID: %d, has an incorrect base value of the max HP stat: %d (must be %d)", - critter->protoId, critter->id, proto->critter.base.health, calcStatValue); - - proto->critter.base.health = calcStatValue; - critter->critter.health = calcStatValue + proto->critter.bonus.health; + // set the current HP to match the maximum HP stat for non-party member critters + if (!fo::util::IsPartyMember(critter)) { // prevent free healing for party members when entering random encounter maps + critter->critter.health = proto->critter.base.health + proto->critter.bonus.health; } }