mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "get_stat_max/min" script functions (#307)
Added updating player's stats on the char screen to "display_stats" script function (#314)
This commit is contained in:
@@ -244,6 +244,11 @@
|
|||||||
use_obj_on_obj(item, dude_obj); \
|
use_obj_on_obj(item, dude_obj); \
|
||||||
set_self(0)
|
set_self(0)
|
||||||
|
|
||||||
|
// returns the corrected tile distance between two objects to the distance variable (return value >= 9996 is an error when getting the distance)
|
||||||
|
#define distance_objs(distance, obj1, obj2) distance := tile_distance_objs(obj1, obj2) - 1; \
|
||||||
|
if (get_flags(obj1) bwand FLAG_MULTIHEX) distance--; \
|
||||||
|
if (get_flags(obj2) bwand FLAG_MULTIHEX) distance--
|
||||||
|
|
||||||
// sfall_funcX macros
|
// sfall_funcX macros
|
||||||
#define add_global_timer_event(time, fixedParam) sfall_func2("add_g_timer_event", time, fixedParam)
|
#define add_global_timer_event(time, fixedParam) sfall_func2("add_g_timer_event", time, fixedParam)
|
||||||
#define add_iface_tag sfall_func0("add_iface_tag")
|
#define add_iface_tag sfall_func0("add_iface_tag")
|
||||||
@@ -269,6 +274,10 @@
|
|||||||
#define get_metarule_table sfall_func0("get_metarule_table")
|
#define get_metarule_table sfall_func0("get_metarule_table")
|
||||||
#define get_object_data(obj, offset) sfall_func2("get_object_data", obj, offset)
|
#define get_object_data(obj, offset) sfall_func2("get_object_data", obj, offset)
|
||||||
#define get_outline(obj) sfall_func1("get_outline", obj)
|
#define get_outline(obj) sfall_func1("get_outline", obj)
|
||||||
|
#define get_pc_stat_max(stat) sfall_func1("get_stat_max", stat)
|
||||||
|
#define get_pc_stat_min(stat) sfall_func1("get_stat_min", stat)
|
||||||
|
#define get_npc_stat_max(stat) sfall_func2("get_stat_max", stat, 1)
|
||||||
|
#define get_npc_stat_min(stat) sfall_func2("get_stat_mix", stat, 1)
|
||||||
#define get_sfall_arg_at(argNum) sfall_func1("get_sfall_arg_at", argNum)
|
#define get_sfall_arg_at(argNum) sfall_func1("get_sfall_arg_at", argNum)
|
||||||
#define get_text_width(text) sfall_func1("get_text_width", text)
|
#define get_text_width(text) sfall_func1("get_text_width", text)
|
||||||
#define hide_window(winName) sfall_func1("hide_window", winName)
|
#define hide_window(winName) sfall_func1("hide_window", winName)
|
||||||
|
|||||||
@@ -445,8 +445,8 @@ Some utility/math functions are available:
|
|||||||
- sets the current cursor mode
|
- sets the current cursor mode
|
||||||
|
|
||||||
> void sfall_func0("display_stats")
|
> void sfall_func0("display_stats")
|
||||||
- displays player stats in the inventory screen display window
|
- updates player's stats in the inventory display window or on the character screen
|
||||||
- works only in opened inventory
|
- NOTE: works only when the interface window is opened
|
||||||
|
|
||||||
> int sfall_func1("lock_is_jammed", object)
|
> int sfall_func1("lock_is_jammed", object)
|
||||||
- returns 1 if the lock (container or scenery) is currently jammed, 0 otherwise
|
- returns 1 if the lock (container or scenery) is currently jammed, 0 otherwise
|
||||||
@@ -636,6 +636,13 @@ optional arguments:
|
|||||||
- flags: mode flags (see MSGBOX_* constants in define_extra.h). Pass -1 to skip setting the flags (default flags are NORMAL and YESNO)
|
- flags: mode flags (see MSGBOX_* constants in define_extra.h). Pass -1 to skip setting the flags (default flags are NORMAL and YESNO)
|
||||||
- color1/2: the color index in Fallout palette. color1 sets the text color for the first line, and color2 for all subsequent lines of text (default color is 145)
|
- color1/2: the color index in Fallout palette. color1 sets the text color for the first line, and color2 for all subsequent lines of text (default color is 145)
|
||||||
|
|
||||||
|
> int sfall_func1("get_stat_min", stat)
|
||||||
|
> int sfall_func1("get_stat_max", stat)
|
||||||
|
> int sfall_func2("get_stat_min", stat, bool who)
|
||||||
|
> int sfall_func2("get_stat_max", stat, bool who)
|
||||||
|
- returns the maximum or minimum set value of the specified stat (see set_stat_max/min functions)
|
||||||
|
- who: 0 (false) or omitting the argument - returns the value of the player, 1 (true) - returns the value set for other critters
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
------ MORE INFO -------
|
------ MORE INFO -------
|
||||||
------------------------
|
------------------------
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ const DWORD correctFidForRemovedItem_ = 0x45409C;
|
|||||||
const DWORD createWindow_ = 0x4B7F3C;
|
const DWORD createWindow_ = 0x4B7F3C;
|
||||||
const DWORD credits_ = 0x42C860;
|
const DWORD credits_ = 0x42C860;
|
||||||
const DWORD credits_get_next_line_ = 0x42CE6C;
|
const DWORD credits_get_next_line_ = 0x42CE6C;
|
||||||
|
const DWORD critter_adjust_hits_ = 0x42D1A4;
|
||||||
const DWORD critter_body_type_ = 0x42DDC4;
|
const DWORD critter_body_type_ = 0x42DDC4;
|
||||||
const DWORD critter_can_obj_dude_rest_ = 0x42E564;
|
const DWORD critter_can_obj_dude_rest_ = 0x42E564;
|
||||||
const DWORD critter_compute_ap_from_distance_ = 0x42E62C;
|
const DWORD critter_compute_ap_from_distance_ = 0x42E62C;
|
||||||
@@ -697,6 +698,7 @@ const DWORD stat_level_ = 0x4AEF48; // &GetCurrentStat(void* critter, int statID
|
|||||||
const DWORD stat_pc_add_experience_ = 0x4AFAA8;
|
const DWORD stat_pc_add_experience_ = 0x4AFAA8;
|
||||||
const DWORD stat_pc_get_ = 0x4AF8FC;
|
const DWORD stat_pc_get_ = 0x4AF8FC;
|
||||||
const DWORD stat_pc_set_ = 0x4AF910;
|
const DWORD stat_pc_set_ = 0x4AF910;
|
||||||
|
const DWORD stat_recalc_derived_ = 0x4AF6FC;
|
||||||
const DWORD stat_set_bonus_ = 0x4AF63C;
|
const DWORD stat_set_bonus_ = 0x4AF63C;
|
||||||
const DWORD stat_set_defaults_ = 0x4AF6CC;
|
const DWORD stat_set_defaults_ = 0x4AF6CC;
|
||||||
const DWORD stricmp_ = 0x4DECE6;
|
const DWORD stricmp_ = 0x4DECE6;
|
||||||
|
|||||||
@@ -580,6 +580,7 @@ extern const DWORD correctFidForRemovedItem_; // (int critter@<eax>, int oldArmo
|
|||||||
extern const DWORD createWindow_;
|
extern const DWORD createWindow_;
|
||||||
extern const DWORD credits_;
|
extern const DWORD credits_;
|
||||||
extern const DWORD credits_get_next_line_;
|
extern const DWORD credits_get_next_line_;
|
||||||
|
extern const DWORD critter_adjust_hits_;
|
||||||
extern const DWORD critter_body_type_;
|
extern const DWORD critter_body_type_;
|
||||||
extern const DWORD critter_can_obj_dude_rest_;
|
extern const DWORD critter_can_obj_dude_rest_;
|
||||||
extern const DWORD critter_compute_ap_from_distance_;
|
extern const DWORD critter_compute_ap_from_distance_;
|
||||||
@@ -971,6 +972,7 @@ extern const DWORD stat_level_;
|
|||||||
extern const DWORD stat_pc_add_experience_; // eax - amount to add
|
extern const DWORD stat_pc_add_experience_; // eax - amount to add
|
||||||
extern const DWORD stat_pc_get_;
|
extern const DWORD stat_pc_get_;
|
||||||
extern const DWORD stat_pc_set_;
|
extern const DWORD stat_pc_set_;
|
||||||
|
extern const DWORD stat_recalc_derived_;
|
||||||
extern const DWORD stat_set_bonus_;
|
extern const DWORD stat_set_bonus_;
|
||||||
extern const DWORD stat_set_defaults_;
|
extern const DWORD stat_set_defaults_;
|
||||||
extern const DWORD stricmp_;
|
extern const DWORD stricmp_;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ static void __declspec(naked) op_input_funcs_available() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, 1; // They're always available from 2.9 on
|
mov edx, 1; // They're always available from 2.9 on
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +85,6 @@ static void __declspec(naked) op_get_mouse_x() {
|
|||||||
mov edx, ds:[_mouse_x_];
|
mov edx, ds:[_mouse_x_];
|
||||||
add edx, ds:[_mouse_hotx];
|
add edx, ds:[_mouse_hotx];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +94,6 @@ static void __declspec(naked) op_get_mouse_y() {
|
|||||||
mov edx, ds:[_mouse_y_];
|
mov edx, ds:[_mouse_y_];
|
||||||
add edx, ds:[_mouse_hoty];
|
add edx, ds:[_mouse_hoty];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +125,6 @@ static void __declspec(naked) op_get_window_under_mouse() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[_last_button_winID];
|
mov edx, ds:[_last_button_winID];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +135,6 @@ static void __declspec(naked) op_get_screen_width() {
|
|||||||
sub edx, ds:[_scr_size]; // _scr_size.x
|
sub edx, ds:[_scr_size]; // _scr_size.x
|
||||||
inc edx;
|
inc edx;
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +145,6 @@ static void __declspec(naked) op_get_screen_height() {
|
|||||||
sub edx, ds:[_scr_size + 4]; // _scr_size.y
|
sub edx, ds:[_scr_size + 4]; // _scr_size.y
|
||||||
inc edx;
|
inc edx;
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +230,6 @@ static void __declspec(naked) op_get_viewport_x() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[_wmWorldOffsetX];
|
mov edx, ds:[_wmWorldOffsetX];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +237,6 @@ static void __declspec(naked) op_get_viewport_y() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[_wmWorldOffsetY];
|
mov edx, ds:[_wmWorldOffsetY];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,9 +367,27 @@ static void mf_set_cursor_mode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mf_display_stats() {
|
static void mf_display_stats() {
|
||||||
// calling the function outside of inventory screen will crash the game
|
unsigned long flags = GetLoopFlags();
|
||||||
if (GetLoopFlags() & INVENTORY) {
|
if (flags & INVENTORY) {
|
||||||
DisplayStats();
|
DisplayStats(); // calling the function outside of inventory screen will crash the game
|
||||||
|
} else if (flags & CHARSCREEN) {
|
||||||
|
__asm {
|
||||||
|
mov eax, ds:[_obj_dude];
|
||||||
|
call stat_recalc_derived_;
|
||||||
|
mov eax, ds:[_obj_dude];
|
||||||
|
call critter_adjust_hits_;
|
||||||
|
push edx;
|
||||||
|
push ebx;
|
||||||
|
mov eax, 7;
|
||||||
|
call PrintBasicStat_;
|
||||||
|
xor eax, eax;
|
||||||
|
call ListSkills_;
|
||||||
|
call PrintLevelWin_;
|
||||||
|
call ListDrvdStats_;
|
||||||
|
pop ebx;
|
||||||
|
pop edx;
|
||||||
|
}
|
||||||
|
WinDraw(*ptr_edit_win);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ static const SfallMetarule metaruleArray[] = {
|
|||||||
{"get_object_data", mf_get_object_data, 2, 2},
|
{"get_object_data", mf_get_object_data, 2, 2},
|
||||||
{"get_outline", mf_get_outline, 1, 1},
|
{"get_outline", mf_get_outline, 1, 1},
|
||||||
{"get_sfall_arg_at", mf_get_sfall_arg_at, 1, 1},
|
{"get_sfall_arg_at", mf_get_sfall_arg_at, 1, 1},
|
||||||
|
{"get_stat_max", mf_get_stat_max, 1, 2},
|
||||||
|
{"get_stat_min", mf_get_stat_min, 1, 2},
|
||||||
{"get_text_width", mf_get_text_width, 1, 1},
|
{"get_text_width", mf_get_text_width, 1, 1},
|
||||||
{"get_window_attribute", mf_get_window_attribute, 1, 2},
|
{"get_window_attribute", mf_get_window_attribute, 1, 2},
|
||||||
{"hide_window", mf_hide_window, 0, 1},
|
{"hide_window", mf_hide_window, 0, 1},
|
||||||
|
|||||||
@@ -666,6 +666,46 @@ end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mf_get_stat_max() {
|
||||||
|
const ScriptValue &statArg = opHandler.arg(0);
|
||||||
|
|
||||||
|
if (statArg.isInt()) {
|
||||||
|
int who = 0;
|
||||||
|
if (opHandler.numArgs() > 1) {
|
||||||
|
const ScriptValue &whoArg = opHandler.arg(1);
|
||||||
|
if (!whoArg.isInt()) goto invalidArgs;
|
||||||
|
who = whoArg.rawValue();
|
||||||
|
}
|
||||||
|
opHandler.setReturn(
|
||||||
|
GetStatMax(statArg.rawValue(), who)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
invalidArgs:
|
||||||
|
OpcodeInvalidArgs("get_stat_max");
|
||||||
|
opHandler.setReturn(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mf_get_stat_min() {
|
||||||
|
const ScriptValue &statArg = opHandler.arg(0);
|
||||||
|
|
||||||
|
if (statArg.isInt()) {
|
||||||
|
int who = 0;
|
||||||
|
if (opHandler.numArgs() > 1) {
|
||||||
|
const ScriptValue &whoArg = opHandler.arg(1);
|
||||||
|
if (!whoArg.isInt()) goto invalidArgs;
|
||||||
|
who = whoArg.rawValue();
|
||||||
|
}
|
||||||
|
opHandler.setReturn(
|
||||||
|
GetStatMin(statArg.rawValue(), who)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
invalidArgs:
|
||||||
|
OpcodeInvalidArgs("get_stat_min");
|
||||||
|
opHandler.setReturn(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void __declspec(naked) statPCAddExperienceCheckPMs_hack() {
|
static void __declspec(naked) statPCAddExperienceCheckPMs_hack() {
|
||||||
static DWORD xpTemp;
|
static DWORD xpTemp;
|
||||||
__asm {
|
__asm {
|
||||||
|
|||||||
+26
-13
@@ -38,8 +38,8 @@ static double StatMulti[33 * 7] = {0};
|
|||||||
|
|
||||||
static TGameObj* cCritter;
|
static TGameObj* cCritter;
|
||||||
|
|
||||||
static const DWORD StatLevelHack_Ret = 0x4AEF52;
|
|
||||||
static void __declspec(naked) stat_level_hack() {
|
static void __declspec(naked) stat_level_hack() {
|
||||||
|
static const DWORD StatLevelHack_Ret = 0x4AEF52;
|
||||||
__asm {
|
__asm {
|
||||||
mov cCritter, eax;
|
mov cCritter, eax;
|
||||||
sub esp, 8;
|
sub esp, 8;
|
||||||
@@ -48,7 +48,7 @@ static void __declspec(naked) stat_level_hack() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __fastcall check_stat_level(register int value, DWORD stat) {
|
static int __fastcall check_stat_level(int value, DWORD stat) {
|
||||||
int valLimit;
|
int valLimit;
|
||||||
if (cCritter == *ptr_obj_dude) {
|
if (cCritter == *ptr_obj_dude) {
|
||||||
valLimit = StatMinimumsPC[stat];
|
valLimit = StatMinimumsPC[stat];
|
||||||
@@ -65,11 +65,10 @@ static int __fastcall check_stat_level(register int value, DWORD stat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void __declspec(naked) stat_level_hack_check() {
|
static void __declspec(naked) stat_level_hack_check() {
|
||||||
static const DWORD StatLevelHackCheck_Ret = 0x4AF3D7;
|
|
||||||
__asm {
|
__asm {
|
||||||
mov edx, esi; // stat
|
mov edx, esi; // stat
|
||||||
call check_stat_level; // ecx - value
|
push 0x4AF3D7; // return address
|
||||||
jmp StatLevelHackCheck_Ret;
|
jmp check_stat_level; // ecx - value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,26 +309,40 @@ void StatsInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetPCStatMax(int stat, int i) {
|
long __stdcall GetStatMax(int stat, int isNPC) {
|
||||||
if (stat >= 0 && stat < STAT_max_stat) {
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
StatMaximumsPC[stat] = i;
|
return (isNPC) ? StatMaximumsNPC[stat] : StatMaximumsPC[stat];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long __stdcall GetStatMin(int stat, int isNPC) {
|
||||||
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
|
return (isNPC) ? StatMinimumsNPC[stat] : StatMinimumsPC[stat];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __stdcall SetPCStatMax(int stat, int value) {
|
||||||
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
|
StatMaximumsPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetPCStatMin(int stat, int i) {
|
void __stdcall SetPCStatMin(int stat, int value) {
|
||||||
if (stat >= 0 && stat < STAT_max_stat) {
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
StatMinimumsPC[stat] = i;
|
StatMinimumsPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetNPCStatMax(int stat, int i) {
|
void __stdcall SetNPCStatMax(int stat, int value) {
|
||||||
if (stat >= 0 && stat < STAT_max_stat) {
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
StatMaximumsNPC[stat] = i;
|
StatMaximumsNPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetNPCStatMin(int stat, int i) {
|
void __stdcall SetNPCStatMin(int stat, int value) {
|
||||||
if (stat >= 0 && stat < STAT_max_stat) {
|
if (stat >= 0 && stat < STAT_max_stat) {
|
||||||
StatMinimumsNPC[stat] = i;
|
StatMinimumsNPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -20,10 +20,14 @@
|
|||||||
|
|
||||||
void Stats_OnGameLoad();
|
void Stats_OnGameLoad();
|
||||||
void StatsInit();
|
void StatsInit();
|
||||||
void __stdcall SetPCStatMax(int stat, int i);
|
|
||||||
void __stdcall SetPCStatMin(int stat, int i);
|
long __stdcall GetStatMax(int stat, int isNPC);
|
||||||
void __stdcall SetNPCStatMax(int stat, int i);
|
long __stdcall GetStatMin(int stat, int isNPC);
|
||||||
void __stdcall SetNPCStatMin(int stat, int i);
|
|
||||||
|
void __stdcall SetPCStatMax(int stat, int value);
|
||||||
|
void __stdcall SetPCStatMin(int stat, int value);
|
||||||
|
void __stdcall SetNPCStatMax(int stat, int value);
|
||||||
|
void __stdcall SetNPCStatMin(int stat, int value);
|
||||||
|
|
||||||
extern float ExperienceMod;
|
extern float ExperienceMod;
|
||||||
extern DWORD StandardApAcBonus;
|
extern DWORD StandardApAcBonus;
|
||||||
|
|||||||
Reference in New Issue
Block a user