mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "proto_exists" script function
Updated gl_auto_closebox example script.
This commit is contained in:
Binary file not shown.
@@ -28,9 +28,10 @@ procedure start begin
|
||||
lootObject := loot_obj;
|
||||
if (obj_type(lootObject) != OBJ_TYPE_ITEM) then lootObject = 0;
|
||||
end else if (lootObject andAlso get_sfall_arg_at(1) == INTFACELOOT) then begin
|
||||
if (get_object_data(lootObject, OBJ_DATA_CUR_FRM) > 1) then call close in 1;
|
||||
closeObject = lootObject;
|
||||
lootObject = 0;
|
||||
if (get_object_data(lootObject, OBJ_DATA_CUR_FRM) > 1) then begin
|
||||
closeObject = lootObject;
|
||||
call close in 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -332,6 +332,7 @@
|
||||
#define overlay_clear(winType) sfall_func2("interface_overlay", winType, 2)
|
||||
#define overlay_clear_rectangle(winType, x, y, w, h) sfall_func6("interface_overlay", winType, 2, x, y, w, h)
|
||||
#define overlay_destroy(winType) sfall_func2("interface_overlay", winType, 0)
|
||||
#define proto_exists(pid) sfall_func1("proto_exists", pid)
|
||||
#define real_dude_obj sfall_func0("real_dude_obj")
|
||||
#define remove_all_timer_events sfall_func0("remove_timer_event")
|
||||
#define remove_timer_event(fixedParam) sfall_func1("remove_timer_event", fixedParam)
|
||||
|
||||
@@ -742,6 +742,9 @@ optional arguments:
|
||||
- gvarNumber: the number of the global variable controlling the quest
|
||||
- thresholdValue: the value of the global variable at which the quest is counted as a failure
|
||||
|
||||
> bool sfall_func1("proto_exists", int pid)
|
||||
- returns True if the specified PID number exists in the list of registered protos
|
||||
|
||||
------------------------
|
||||
------ MORE INFO -------
|
||||
------------------------
|
||||
|
||||
@@ -576,6 +576,14 @@ long AnimCodeByWeapon(TGameObj* weapon) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CheckProtoID(DWORD pid) {
|
||||
if (pid == 0) return false;
|
||||
long type = pid >> 24;
|
||||
if (type > OBJ_TYPE_MISC) return false;
|
||||
|
||||
return (static_cast<long>(pid & 0xFFFF) < ptr_protoLists[type].totalCount);
|
||||
}
|
||||
|
||||
bool GetProto(long pid, sProto** outProto) {
|
||||
return (fo_proto_ptr(pid, outProto) != -1);
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
#define FO_VAR_procTableStrs 0x51C758 // table of procId (from define.h) => procName map
|
||||
#define FO_VAR_proto_main_msg_file 0x6647FC
|
||||
#define FO_VAR_proto_msg_files 0x6647AC
|
||||
#define FO_VAR_protoLists 0x51C290
|
||||
#define FO_VAR_ptable 0x59E934
|
||||
#define FO_VAR_pud 0x59E960
|
||||
#define FO_VAR_quest_count 0x51C12C
|
||||
@@ -522,6 +523,8 @@ Queue* QueueFind(TGameObj* object, long type);
|
||||
// returns weapon animation code
|
||||
long AnimCodeByWeapon(TGameObj* weapon);
|
||||
|
||||
bool CheckProtoID(DWORD pid);
|
||||
|
||||
// returns False if the prototype does not exist, or pointer to prototype by PID in the outProto argument
|
||||
bool GetProto(long pid, sProto** outProto);
|
||||
|
||||
|
||||
@@ -476,6 +476,7 @@ FUNC(protinst_use_item_on_, 0x49C3CC)
|
||||
FUNC(proto_dude_init_, 0x49FA64)
|
||||
FUNC(proto_dude_update_gender_, 0x49F984)
|
||||
FUNC(proto_list_str_, 0x49E758)
|
||||
FUNC(proto_make_path_, 0x49E270)
|
||||
FUNC(proto_ptr_, 0x4A2108) // eax - PID, edx - int** - pointer to a pointer to a proto struct
|
||||
FUNC(pushLongStack_, 0x46736C)
|
||||
FUNC(qsort_, 0x4F05B6)
|
||||
|
||||
@@ -168,6 +168,7 @@ WRAP_WATCOM_FUNC2(long, perk_level, TGameObj*, critter, long, perkId)
|
||||
WRAP_WATCOM_FUNC6(long, pick_death, TGameObj*, attacker, TGameObj*, target, TGameObj*, weapon, long, amount, long, anim, long, hitFromBack)
|
||||
WRAP_WATCOM_FUNC0(void, process_bk)
|
||||
WRAP_WATCOM_FUNC0(void, proto_dude_update_gender)
|
||||
WRAP_WATCOM_FUNC2(void, proto_make_path, char*, buffer, long, pid)
|
||||
// Places pointer to a prototype structure into ptrPtr and returns 0 on success or -1 on failure
|
||||
WRAP_WATCOM_FUNC2(long, proto_ptr, long, pid, sProto**, ptrPtr)
|
||||
WRAP_WATCOM_FUNC2(void, queue_clear_type, long, qType, void*, func) // removes all events of the given type and performs func before removal
|
||||
|
||||
@@ -593,6 +593,19 @@ struct PremadeChar {
|
||||
char unknown[20];
|
||||
};
|
||||
|
||||
struct ProtoListBlock {
|
||||
long* protoMem[16];
|
||||
long count;
|
||||
ProtoListBlock* next;
|
||||
};
|
||||
|
||||
struct ProtoList {
|
||||
ProtoListBlock* block;
|
||||
ProtoListBlock* lastBlock;
|
||||
long countBlocks; // current
|
||||
long totalCount; // total number of prototypes for this type
|
||||
};
|
||||
|
||||
// In-memory PROTO structure, not the same as PRO file format.
|
||||
struct sProto {
|
||||
struct Tile {
|
||||
|
||||
@@ -166,6 +166,7 @@ PTR_(preload_list_index, DWORD)
|
||||
PTR_(procTableStrs, const char*) // table of procId (from define.h) => procName map
|
||||
PTR_(proto_main_msg_file, MSGList)
|
||||
PTR_(proto_msg_files, MSGList) // array of 6 elements
|
||||
PTR_(protoLists, ProtoList) // array of 11 elements
|
||||
PTR_(ptable, DWORD)
|
||||
PTR_(pud, DWORD)
|
||||
PTR_(queue, Queue*)
|
||||
|
||||
@@ -164,6 +164,7 @@ static const SfallMetarule metaruleArray[] = {
|
||||
{"obj_under_cursor", mf_obj_under_cursor, 2, 2},
|
||||
{"objects_in_radius", mf_objects_in_radius, 3, 4},
|
||||
{"outlined_object", mf_outlined_object, 0, 0},
|
||||
{"proto_exists", mf_proto_exists, 1, 1},
|
||||
{"real_dude_obj", mf_real_dude_obj, 0, 0},
|
||||
{"remove_timer_event", mf_remove_timer_event, 0, 1},
|
||||
{"set_car_intface_art", mf_set_car_intface_art, 1, 1},
|
||||
|
||||
@@ -596,6 +596,17 @@ static void mf_get_loot_object() {
|
||||
opHandler.setReturn((GetLoopFlags() & INTFACELOOT) ? ptr_target_stack[*ptr_target_curr_stack] : 0);
|
||||
}
|
||||
|
||||
static void mf_proto_exists() {
|
||||
const ScriptValue &pidArg = opHandler.arg(0);
|
||||
|
||||
if (pidArg.isInt()) {
|
||||
opHandler.setReturn(CheckProtoID(pidArg.rawValue()));
|
||||
} else {
|
||||
OpcodeInvalidArgs("proto_exists");
|
||||
opHandler.setReturn(0);
|
||||
}
|
||||
}
|
||||
|
||||
static bool protoMaxLimitPatch = false;
|
||||
|
||||
static void __stdcall op_get_proto_data2() {
|
||||
|
||||
Reference in New Issue
Block a user