Changed "obj_under_cursor" for the movement cursor

* the function is not designed for use with it.

Code correction in Stats.cpp.
This commit is contained in:
NovaRain
2021-01-25 11:34:03 +08:00
parent 15564dc0ab
commit 16843956b5
9 changed files with 63 additions and 58 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
[Main]
;Set to 1 to take the bonus values of SPECIAL stats into account when calculating maximum hit points
;Set to 0 for the original behavior (bonus stats do not affect maximum hit points)
;Set to 0 for the Fallout original behavior (bonus stats do not affect maximum hit points)
HPDependOnBonusStats=0
;max hp
@@ -578,6 +578,7 @@ Some utility/math functions are available:
- onlyCritter: True - only checks critters and ignores their cover (roof tiles, walls, scenery, etc.)
False - checks all objects (can't check critters under objects)
- passing False to the includeDude argument will ignore dude_obj
- NOTE: the function will always return 0 if the cursor is in movement mode (hexagon cursor)
> object sfall_func0("loot_obj")
- returns a pointer to the target object (container or critter) of the loot screen
+1 -1
View File
@@ -1455,7 +1455,7 @@ FUNC(gmouse_3d_disable_modes_, 0x44CA04)
FUNC(gmouse_3d_enable_modes_, 0x44C9F8)
FUNC(gmouse_3d_exit_, 0x44DB34)
FUNC(gmouse_3d_get_fid_, 0x44CCF4)
FUNC(gmouse_3d_get_mode_, 0x44CB6C)
//FUNC(gmouse_3d_get_mode_, 0x44CB6C)
FUNC(gmouse_3d_highlight_menu_frame_, 0x44D630)
FUNC(gmouse_3d_init_, 0x44D984)
FUNC(gmouse_3d_is_on_, 0x44CEB0)
-1
View File
@@ -120,7 +120,6 @@ WRAP_WATCOM_FUNC0(long, get_input)
// Searches for message ID in given message file and places result in result argument
WRAP_WATCOM_FUNC3(const char*, getmsg, const MessageList*, fileAddr, MessageNode*, result, long, messageId)
WRAP_WATCOM_FUNC1(void, gdialogDisplayMsg, const char*, message)
WRAP_WATCOM_FUNC0(long, gmouse_3d_get_mode)
WRAP_WATCOM_FUNC1(void, gmouse_3d_set_mode, long, mode)
WRAP_WATCOM_FUNC1(long, gmouse_set_cursor, long, picNum)
WRAP_WATCOM_FUNC1(long, gsound_background_volume_get_set, long, setVolume)
+1
View File
@@ -69,6 +69,7 @@ VAR_(gdBarterMod, DWORD)
VAR_(gdNumOptions, DWORD)
VAR_(gIsSteal, DWORD)
VAR_(glblmode, DWORD)
VAR_(gmouse_3d_current_mode, long)
VAR_(gmouse_current_cursor, long)
VARA(gmovie_played_list, BYTE, 17)
VAR_(GoodColor, BYTE)
+1 -1
View File
@@ -94,7 +94,7 @@ pickNewID: // skip PM range (18000 - 83535)
}
}
// Reassigns object IDs to all critters upon first loading a map and updates HP stats
// Reassigns object IDs to all critters upon first loading a map and updates their max HP stat
static void map_fix_critter_id() {
long npcStartID = 4096;
fo::GameObject* obj = fo::func::obj_find_first();
@@ -299,7 +299,7 @@ void mf_tile_refresh_display(OpcodeContext& ctx) {
}
void mf_get_cursor_mode(OpcodeContext& ctx) {
ctx.setReturn(fo::func::gmouse_3d_get_mode());
ctx.setReturn(fo::var::gmouse_3d_current_mode);
}
void mf_set_cursor_mode(OpcodeContext& ctx) {
+3 -1
View File
@@ -373,7 +373,9 @@ void mf_get_dialog_object(OpcodeContext& ctx) {
}
void mf_obj_under_cursor(OpcodeContext& ctx) {
ctx.setReturn(fo::func::object_under_mouse(ctx.arg(0).asBool() ? 1 : -1, ctx.arg(1).rawValue(), fo::var::map_elevation));
ctx.setReturn((fo::var::gmouse_3d_current_mode != 0)
? fo::func::object_under_mouse(ctx.arg(0).asBool() ? 1 : -1, ctx.arg(1).rawValue(), fo::var::map_elevation)
: 0);
}
void mf_get_loot_object(OpcodeContext& ctx) {
+54 -52
View File
@@ -26,8 +26,8 @@
namespace sfall
{
bool engineDerivedStats = true;
bool derivedHPwBonus = false; // recalculate the hit points with bonus stat values
static bool engineDerivedStats = true;
static bool derivedHPwBonus = false; // recalculate the hit points with bonus stat values
static DWORD statMaximumsPC[fo::STAT_max_stat];
static DWORD statMinimumsPC[fo::STAT_max_stat];
@@ -203,11 +203,12 @@ void Stats::UpdateHPStat(fo::GameObject* critter) {
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 %d (must be %d) of the max HP stat.",
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;
}
proto->critter.base.health = calcStatValue;
critter->critter.health = calcStatValue + proto->critter.bonus.health;
}
static void __declspec(naked) stat_set_base_hack_allow() {
@@ -297,61 +298,62 @@ void Stats::init() {
auto statsFile = GetConfigString("Misc", "DerivedStats", "", MAX_PATH);
if (!statsFile.empty()) {
engineDerivedStats = false;
MakeJump(0x4AF6FC, stat_recalc_derived_hack); // overrides function
// STAT_st + STAT_en * 2 + 15
statFormulas[STAT_max_hit_points].base = 15; // max hp
statFormulas[STAT_max_hit_points].multi[STAT_st] = 1;
statFormulas[STAT_max_hit_points].multi[STAT_en] = 2;
// STAT_ag / 2 + 5
statFormulas[STAT_max_move_points].base = 5; // max ap
statFormulas[STAT_max_move_points].multi[STAT_ag] = 0.5;
statFormulas[STAT_ac].multi[STAT_ag] = 1; // ac
// STAT_st - 5
statFormulas[STAT_melee_dmg].min = 1; // melee damage
statFormulas[STAT_melee_dmg].shift[STAT_st] = -5;
statFormulas[STAT_melee_dmg].multi[STAT_st] = 1;
// STAT_st * 25 + 25
statFormulas[STAT_carry_amt].base = 25; // carry weight
statFormulas[STAT_carry_amt].multi[STAT_st] = 25;
// STAT_pe * 2
statFormulas[STAT_sequence].multi[STAT_pe] = 2; // sequence
// STAT_en / 3
statFormulas[STAT_heal_rate].min = 1; // heal rate
statFormulas[STAT_heal_rate].multi[STAT_en] = 1.0 / 3.0;
statFormulas[STAT_crit_chance].multi[STAT_lu] = 1; // critical chance
// STAT_en * 2
statFormulas[STAT_rad_resist].multi[STAT_en] = 2; // rad resist
// STAT_en * 5
statFormulas[STAT_poison_resist].multi[STAT_en] = 5; // poison resist
const char* statFile = statsFile.insert(0, ".\\").c_str();
if (GetFileAttributes(statFile) == INVALID_FILE_ATTRIBUTES) return;
if (GetFileAttributes(statFile) != INVALID_FILE_ATTRIBUTES) { // check if file exists
derivedHPwBonus = (iniGetInt("Main", "HPDependOnBonusStats", 0, statFile) != 0);
engineDerivedStats = false;
derivedHPwBonus = (iniGetInt("Main", "HPDependOnBonusStats", 0, statFile) != 0);
// STAT_st + STAT_en * 2 + 15
statFormulas[STAT_max_hit_points].base = 15; // max hp
statFormulas[STAT_max_hit_points].multi[STAT_st] = 1;
statFormulas[STAT_max_hit_points].multi[STAT_en] = 2;
// STAT_ag / 2 + 5
statFormulas[STAT_max_move_points].base = 5; // max ap
statFormulas[STAT_max_move_points].multi[STAT_ag] = 0.5;
char key[6], buf2[256], buf3[256];
statFormulas[STAT_ac].multi[STAT_ag] = 1; // ac
// STAT_st - 5
statFormulas[STAT_melee_dmg].min = 1; // melee damage
statFormulas[STAT_melee_dmg].shift[STAT_st] = -5;
statFormulas[STAT_melee_dmg].multi[STAT_st] = 1;
// STAT_st * 25 + 25
statFormulas[STAT_carry_amt].base = 25; // carry weight
statFormulas[STAT_carry_amt].multi[STAT_st] = 25;
// STAT_pe * 2
statFormulas[STAT_sequence].multi[STAT_pe] = 2; // sequence
// STAT_en / 3
statFormulas[STAT_heal_rate].min = 1; // heal rate
statFormulas[STAT_heal_rate].multi[STAT_en] = 1.0 / 3.0;
for (int i = fo::Stat::STAT_max_hit_points; i <= fo::Stat::STAT_poison_resist; i++) {
if (i >= fo::Stat::STAT_dmg_thresh && i <= fo::Stat::STAT_dmg_resist_explosion) continue;
statFormulas[STAT_crit_chance].multi[STAT_lu] = 1; // critical chance
// STAT_en * 2
statFormulas[STAT_rad_resist].multi[STAT_en] = 2; // rad resist
// STAT_en * 5
statFormulas[STAT_poison_resist].multi[STAT_en] = 5; // poison resist
_itoa(i, key, 10);
statFormulas[i].base = iniGetInt(key, "base", statFormulas[i].base, statFile);
statFormulas[i].min = iniGetInt(key, "min", statFormulas[i].min, statFile);
for (int j = 0; j < fo::Stat::STAT_max_hit_points; j++) {
sprintf(buf2, "shift%d", j);
statFormulas[i].shift[j] = iniGetInt(key, buf2, statFormulas[i].shift[j], statFile);
sprintf(buf2, "multi%d", j);
_gcvt(statFormulas[i].multi[j], 16, buf3);
iniGetString(key, buf2, buf3, buf2, 256, statFile);
statFormulas[i].multi[j] = atof(buf2);
char key[6], buf2[256], buf3[256];
for (int i = fo::Stat::STAT_max_hit_points; i <= fo::Stat::STAT_poison_resist; i++) {
if (i >= fo::Stat::STAT_dmg_thresh && i <= fo::Stat::STAT_dmg_resist_explosion) continue;
_itoa(i, key, 10);
statFormulas[i].base = iniGetInt(key, "base", statFormulas[i].base, statFile);
statFormulas[i].min = iniGetInt(key, "min", statFormulas[i].min, statFile);
for (int j = 0; j < fo::Stat::STAT_max_hit_points; j++) {
sprintf(buf2, "shift%d", j);
statFormulas[i].shift[j] = iniGetInt(key, buf2, statFormulas[i].shift[j], statFile);
sprintf(buf2, "multi%d", j);
_gcvt(statFormulas[i].multi[j], 16, buf3);
iniGetString(key, buf2, buf3, buf2, 256, statFile);
statFormulas[i].multi[j] = atof(buf2);
}
}
}
} else {
}
if (engineDerivedStats) {
CritterStats::RecalcDerivedHook();
} else {
MakeJump(0x4AF6FC, stat_recalc_derived_hack); // overrides function
}
}