mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Reverted the previous commit and added "obj_is_openable" function
* the previous commit conflicts with BIS document.
This commit is contained in:
@@ -365,6 +365,7 @@
|
|||||||
#define message_box(text) sfall_func1("message_box", text)
|
#define message_box(text) sfall_func1("message_box", text)
|
||||||
#define metarule_exist(metaruleName) sfall_func1("metarule_exist", metaruleName)
|
#define metarule_exist(metaruleName) sfall_func1("metarule_exist", metaruleName)
|
||||||
#define npc_engine_level_up(toggle) sfall_func1("npc_engine_level_up", toggle)
|
#define npc_engine_level_up(toggle) sfall_func1("npc_engine_level_up", toggle)
|
||||||
|
#define obj_is_openable(obj) sfall_func1("obj_is_openable", obj)
|
||||||
#define obj_under_cursor(onlyCritter, includeDude) sfall_func2("obj_under_cursor", onlyCritter, includeDude)
|
#define obj_under_cursor(onlyCritter, includeDude) sfall_func2("obj_under_cursor", onlyCritter, includeDude)
|
||||||
#define objects_in_radius(tile, radius, elev, type) sfall_func4("objects_in_radius", tile, radius, elev, type)
|
#define objects_in_radius(tile, radius, elev, type) sfall_func4("objects_in_radius", tile, radius, elev, type)
|
||||||
#define outlined_object sfall_func0("outlined_object")
|
#define outlined_object sfall_func0("outlined_object")
|
||||||
|
|||||||
@@ -1048,6 +1048,11 @@ sfall_funcX metarule functions
|
|||||||
- Passing an empty string ("") to the `name` argument or omitting it will allow the game to get the name for the object from pro_*.msg files
|
- Passing an empty string ("") to the `name` argument or omitting it will allow the game to get the name for the object from pro_*.msg files
|
||||||
- __NOTE:__ this function is intended for use in normal game scripts and overrides the name only once for the same object until reset
|
- __NOTE:__ this function is intended for use in normal game scripts and overrides the name only once for the same object until reset
|
||||||
|
|
||||||
|
----
|
||||||
|
#### obj_is_openable
|
||||||
|
`bool sfall_func1("obj_is_openable", object obj)`
|
||||||
|
- Returns True if the object is openable (i.e. has an opening/closing animation)
|
||||||
|
|
||||||
|
|
||||||
****
|
****
|
||||||
_See other documentation files (arrays.md, hookscripts.md) for related functions reference._
|
_See other documentation files (arrays.md, hookscripts.md) for related functions reference._
|
||||||
|
|||||||
@@ -210,6 +210,19 @@ fo::AttackSubType GetWeaponType(DWORD weaponFlag) {
|
|||||||
return (type < 9) ? weapon_types[type] : fo::AttackSubType::NONE;
|
return (type < 9) ? weapon_types[type] : fo::AttackSubType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long ObjIsOpenable(fo::GameObject* object) {
|
||||||
|
long result = 0;
|
||||||
|
if (fo::func::obj_is_openable(object)) {
|
||||||
|
DWORD lock;
|
||||||
|
fo::FrmHeaderData* frm = fo::func::art_ptr_lock(object->artFid, &lock);
|
||||||
|
if (frm) {
|
||||||
|
if (frm->numFrames > 1) result = 1;
|
||||||
|
fo::func::art_ptr_unlock(lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool HeroIsFemale() {
|
bool HeroIsFemale() {
|
||||||
return (fo::func::stat_level(fo::var::obj_dude, fo::Stat::STAT_gender) == fo::Gender::GENDER_FEMALE);
|
return (fo::func::stat_level(fo::var::obj_dude, fo::Stat::STAT_gender) == fo::Gender::GENDER_FEMALE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ long GetCurrentAttackMode();
|
|||||||
|
|
||||||
fo::AttackSubType GetWeaponType(DWORD weaponFlag);
|
fo::AttackSubType GetWeaponType(DWORD weaponFlag);
|
||||||
|
|
||||||
|
long ObjIsOpenable(fo::GameObject* object);
|
||||||
|
|
||||||
bool HeroIsFemale();
|
bool HeroIsFemale();
|
||||||
|
|
||||||
long CheckAddictByPid(fo::GameObject* critter, long pid);
|
long CheckAddictByPid(fo::GameObject* critter, long pid);
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_first)
|
|||||||
WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_next)
|
WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_next)
|
||||||
WRAP_WATCOM_FUNC2(fo::GameObject*, obj_find_first_at_tile, long, elevation, long, tileNum)
|
WRAP_WATCOM_FUNC2(fo::GameObject*, obj_find_first_at_tile, long, elevation, long, tileNum)
|
||||||
WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_next_at_tile)
|
WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_next_at_tile)
|
||||||
|
WRAP_WATCOM_FUNC1(bool, obj_is_openable, fo::GameObject*, object)
|
||||||
WRAP_WATCOM_FUNC2(long, obj_pid_new, fo::GameObject*, object, long, pid)
|
WRAP_WATCOM_FUNC2(long, obj_pid_new, fo::GameObject*, object, long, pid)
|
||||||
WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, fo::GameObject*, object) // Checks/unjams jammed locks
|
WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, fo::GameObject*, object) // Checks/unjams jammed locks
|
||||||
WRAP_WATCOM_FUNC1(void, obj_unjam_lock, fo::GameObject*, object)
|
WRAP_WATCOM_FUNC1(void, obj_unjam_lock, fo::GameObject*, object)
|
||||||
|
|||||||
@@ -3150,28 +3150,6 @@ noObject:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __declspec(naked) obj_is_open_hack() {
|
|
||||||
__asm {
|
|
||||||
je checkMaxFrames; // curr.frame == 0
|
|
||||||
setnz al;
|
|
||||||
and eax, 0xFF;
|
|
||||||
retn;
|
|
||||||
checkMaxFrames:
|
|
||||||
push edx;
|
|
||||||
sub esp, 4;
|
|
||||||
mov eax, [eax + artFid];
|
|
||||||
mov edx, esp;
|
|
||||||
call fo::funcoffs::art_ptr_lock_;
|
|
||||||
call fo::funcoffs::art_frame_max_frame_;
|
|
||||||
add esp, 4;
|
|
||||||
cmp eax, 1;
|
|
||||||
pop edx;
|
|
||||||
setle al; // 1 - is open if frames == 1
|
|
||||||
and eax, 0xFF;
|
|
||||||
retn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BugFixes::init()
|
void BugFixes::init()
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -3983,9 +3961,6 @@ void BugFixes::init()
|
|||||||
|
|
||||||
// Fix to prevent the main menu music from stopping when entering the load game screen
|
// Fix to prevent the main menu music from stopping when entering the load game screen
|
||||||
BlockCall(0x480B25);
|
BlockCall(0x480B25);
|
||||||
|
|
||||||
// Fix the return value of obj_is_open function for containers with only one frame (e.g. shelves)
|
|
||||||
MakeJump(0x49D2E8, obj_is_open_hack, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ static const SfallMetarule metarules[] = {
|
|||||||
{"message_box", mf_message_box, 1, 4, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT}},
|
{"message_box", mf_message_box, 1, 4, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT}},
|
||||||
{"metarule_exist", mf_metarule_exist, 1, 1}, // no arg check
|
{"metarule_exist", mf_metarule_exist, 1, 1}, // no arg check
|
||||||
{"npc_engine_level_up", mf_npc_engine_level_up, 1, 1},
|
{"npc_engine_level_up", mf_npc_engine_level_up, 1, 1},
|
||||||
|
{"obj_is_openable", mf_obj_is_openable, 1, 1, 0, {ARG_OBJECT}},
|
||||||
{"obj_under_cursor", mf_obj_under_cursor, 2, 2, 0, {ARG_INT, ARG_INT}},
|
{"obj_under_cursor", mf_obj_under_cursor, 2, 2, 0, {ARG_INT, ARG_INT}},
|
||||||
{"objects_in_radius", mf_objects_in_radius, 3, 4, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
|
{"objects_in_radius", mf_objects_in_radius, 3, 4, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
|
||||||
{"outlined_object", mf_outlined_object, 0, 0},
|
{"outlined_object", mf_outlined_object, 0, 0},
|
||||||
|
|||||||
@@ -603,5 +603,9 @@ void mf_npc_engine_level_up(OpcodeContext& ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mf_obj_is_openable(OpcodeContext& ctx) {
|
||||||
|
ctx.setReturn(fo::util::ObjIsOpenable(ctx.arg(0).object()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,5 +107,7 @@ void mf_objects_in_radius(OpcodeContext&);
|
|||||||
|
|
||||||
void mf_npc_engine_level_up(OpcodeContext&);
|
void mf_npc_engine_level_up(OpcodeContext&);
|
||||||
|
|
||||||
|
void mf_obj_is_openable(OpcodeContext&);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user