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:
@@ -272,6 +272,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_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
||||||
#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)
|
||||||
@@ -304,6 +309,10 @@
|
|||||||
#define get_object_ai_data(obj, aiParam) sfall_func2("get_object_ai_data", obj, aiParam)
|
#define get_object_ai_data(obj, aiParam) sfall_func2("get_object_ai_data", obj, aiParam)
|
||||||
#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_string_pointer(text) sfall_func1("get_string_pointer", text)
|
#define get_string_pointer(text) sfall_func1("get_string_pointer", text)
|
||||||
#define get_text_width(text) sfall_func1("get_text_width", text)
|
#define get_text_width(text) sfall_func1("get_text_width", text)
|
||||||
|
|||||||
@@ -480,8 +480,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
|
||||||
@@ -730,6 +730,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 -------
|
||||||
------------------------
|
------------------------
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +66,6 @@ void __declspec(naked) op_get_mouse_x() {
|
|||||||
mov edx, ds:[FO_VAR_mouse_x_];
|
mov edx, ds:[FO_VAR_mouse_x_];
|
||||||
add edx, ds:[FO_VAR_mouse_hotx];
|
add edx, ds:[FO_VAR_mouse_hotx];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +74,6 @@ void __declspec(naked) op_get_mouse_y() {
|
|||||||
mov edx, ds:[FO_VAR_mouse_y_];
|
mov edx, ds:[FO_VAR_mouse_y_];
|
||||||
add edx, ds:[FO_VAR_mouse_hoty];
|
add edx, ds:[FO_VAR_mouse_hoty];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +91,6 @@ void __declspec(naked) op_get_window_under_mouse() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[FO_VAR_last_button_winID];
|
mov edx, ds:[FO_VAR_last_button_winID];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +100,6 @@ void __declspec(naked) op_get_screen_width() {
|
|||||||
sub edx, ds:[FO_VAR_scr_size]; // _scr_size.x
|
sub edx, ds:[FO_VAR_scr_size]; // _scr_size.x
|
||||||
inc edx;
|
inc edx;
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +109,6 @@ void __declspec(naked) op_get_screen_height() {
|
|||||||
sub edx, ds:[FO_VAR_scr_size + 4]; // _scr_size.y
|
sub edx, ds:[FO_VAR_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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +183,6 @@ void __declspec(naked) op_get_viewport_x() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[FO_VAR_wmWorldOffsetX];
|
mov edx, ds:[FO_VAR_wmWorldOffsetX];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +190,6 @@ void __declspec(naked) op_get_viewport_y() {
|
|||||||
__asm {
|
__asm {
|
||||||
mov edx, ds:[FO_VAR_wmWorldOffsetY];
|
mov edx, ds:[FO_VAR_wmWorldOffsetY];
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
// retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,9 +292,27 @@ void mf_set_cursor_mode(OpcodeContext& ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mf_display_stats(OpcodeContext& ctx) {
|
void mf_display_stats(OpcodeContext& ctx) {
|
||||||
// calling the function outside of inventory screen will crash the game
|
unsigned long flags = GetLoopFlags();
|
||||||
if (GetLoopFlags() & INVENTORY) {
|
if (flags & LoopFlag::INVENTORY) {
|
||||||
fo::func::display_stats();
|
fo::func::display_stats(); // calling the function outside of inventory screen will crash the game
|
||||||
|
} else if (flags & LoopFlag::CHARSCREEN) {
|
||||||
|
__asm {
|
||||||
|
mov eax, ds:[FO_VAR_obj_dude];
|
||||||
|
call fo::funcoffs::stat_recalc_derived_;
|
||||||
|
mov eax, ds:[FO_VAR_obj_dude];
|
||||||
|
call fo::funcoffs::critter_adjust_hits_;
|
||||||
|
push edx;
|
||||||
|
push ebx;
|
||||||
|
mov eax, 7;
|
||||||
|
call fo::funcoffs::PrintBasicStat_;
|
||||||
|
xor eax, eax;
|
||||||
|
call fo::funcoffs::ListSkills_;
|
||||||
|
call fo::funcoffs::PrintLevelWin_;
|
||||||
|
call fo::funcoffs::ListDrvdStats_;
|
||||||
|
pop ebx;
|
||||||
|
pop edx;
|
||||||
|
}
|
||||||
|
fo::func::win_draw(fo::var::edit_win);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
#include "Perks.h"
|
#include "Perks.h"
|
||||||
|
#include "Stats.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Worldmap.h"
|
#include "Worldmap.h"
|
||||||
|
|
||||||
@@ -91,6 +92,8 @@ static const SfallMetarule metarules[] = {
|
|||||||
{"get_object_data", mf_get_object_data, 2, 2, 0, {ARG_OBJECT, ARG_INT}},
|
{"get_object_data", mf_get_object_data, 2, 2, 0, {ARG_OBJECT, ARG_INT}},
|
||||||
{"get_outline", mf_get_outline, 1, 1, 0, {ARG_OBJECT}},
|
{"get_outline", mf_get_outline, 1, 1, 0, {ARG_OBJECT}},
|
||||||
{"get_sfall_arg_at", mf_get_sfall_arg_at, 1, 1, 0, {ARG_INT}},
|
{"get_sfall_arg_at", mf_get_sfall_arg_at, 1, 1, 0, {ARG_INT}},
|
||||||
|
{"get_stat_max", mf_get_stat_max, 1, 2, 0, {ARG_INT, ARG_INT}},
|
||||||
|
{"get_stat_min", mf_get_stat_min, 1, 2, 0, {ARG_INT, ARG_INT}},
|
||||||
{"get_string_pointer", mf_get_string_pointer, 1, 1, 0, {ARG_STRING}},
|
{"get_string_pointer", mf_get_string_pointer, 1, 1, 0, {ARG_STRING}},
|
||||||
{"get_text_width", mf_get_text_width, 1, 1, 0, {ARG_STRING}},
|
{"get_text_width", mf_get_text_width, 1, 1, 0, {ARG_STRING}},
|
||||||
{"get_window_attribute", mf_get_window_attribute, 1, 2, -1, {ARG_INT, ARG_INT}},
|
{"get_window_attribute", mf_get_window_attribute, 1, 2, -1, {ARG_INT, ARG_INT}},
|
||||||
|
|||||||
@@ -477,6 +477,20 @@ end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mf_get_stat_max(OpcodeContext& ctx) {
|
||||||
|
int who = (ctx.numArgs() > 1) ? ctx.arg(1).rawValue() : 0;
|
||||||
|
ctx.setReturn(
|
||||||
|
Stats::GetStatMax(ctx.arg(0).rawValue(), who)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mf_get_stat_min(OpcodeContext& ctx) {
|
||||||
|
int who = (ctx.numArgs() > 1) ? ctx.arg(1).rawValue() : 0;
|
||||||
|
ctx.setReturn(
|
||||||
|
Stats::GetStatMin(ctx.arg(0).rawValue(), who)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static void __declspec(naked) statPCAddExperienceCheckPMs_hack() {
|
static void __declspec(naked) statPCAddExperienceCheckPMs_hack() {
|
||||||
static DWORD xpTemp;
|
static DWORD xpTemp;
|
||||||
__asm {
|
__asm {
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ void __declspec() op_set_npc_stat_max();
|
|||||||
|
|
||||||
void __declspec() op_set_npc_stat_min();
|
void __declspec() op_set_npc_stat_min();
|
||||||
|
|
||||||
|
void mf_get_stat_max(OpcodeContext&);
|
||||||
|
|
||||||
|
void mf_get_stat_min(OpcodeContext&);
|
||||||
|
|
||||||
void op_set_xp_mod(OpcodeContext&);
|
void op_set_xp_mod(OpcodeContext&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-13
@@ -46,8 +46,8 @@ static struct StatFormula {
|
|||||||
|
|
||||||
static fo::GameObject* cCritter;
|
static fo::GameObject* 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;
|
||||||
@@ -56,7 +56,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 == fo::var::obj_dude) {
|
if (cCritter == fo::var::obj_dude) {
|
||||||
valLimit = statMinimumsPC[stat];
|
valLimit = statMinimumsPC[stat];
|
||||||
@@ -73,11 +73,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,27 +317,41 @@ void Stats::init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetPCStatMax(int stat, int i) {
|
long Stats::GetStatMax(int stat, int isNPC) {
|
||||||
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
||||||
statMaximumsPC[stat] = i;
|
return (isNPC) ? statMaximumsNPC[stat] : statMaximumsPC[stat];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long Stats::GetStatMin(int stat, int isNPC) {
|
||||||
|
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
||||||
|
return (isNPC) ? statMinimumsNPC[stat] : statMinimumsPC[stat];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __stdcall SetPCStatMax(int stat, int value) {
|
||||||
|
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
||||||
|
statMaximumsPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall SetPCStatMin(int stat, int i) {
|
void __stdcall SetPCStatMin(int stat, int value) {
|
||||||
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
if (stat >= 0 && stat < fo::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 < fo::STAT_max_stat) {
|
if (stat >= 0 && stat < fo::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 < fo::STAT_max_stat) {
|
if (stat >= 0 && stat < fo::STAT_max_stat) {
|
||||||
statMinimumsNPC[stat] = i;
|
statMinimumsNPC[stat] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,14 @@ public:
|
|||||||
static float experienceMod;
|
static float experienceMod;
|
||||||
static DWORD standardApAcBonus;
|
static DWORD standardApAcBonus;
|
||||||
static DWORD extraApAcBonus;
|
static DWORD extraApAcBonus;
|
||||||
|
|
||||||
|
static long GetStatMax(int stat, int isNPC);
|
||||||
|
static long GetStatMin(int stat, int isNPC);
|
||||||
};
|
};
|
||||||
|
|
||||||
void __stdcall SetPCStatMax(int stat, int i);
|
void __stdcall SetPCStatMax(int stat, int value);
|
||||||
void __stdcall SetPCStatMin(int stat, int i);
|
void __stdcall SetPCStatMin(int stat, int value);
|
||||||
void __stdcall SetNPCStatMax(int stat, int i);
|
void __stdcall SetNPCStatMax(int stat, int value);
|
||||||
void __stdcall SetNPCStatMin(int stat, int i);
|
void __stdcall SetNPCStatMin(int stat, int value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user