mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "get_current_inven_size" script function.
This commit is contained in:
@@ -192,6 +192,7 @@
|
|||||||
#define critter_inven_obj2(obj, type) sfall_func2("critter_inven_obj2", obj, type)
|
#define critter_inven_obj2(obj, type) sfall_func2("critter_inven_obj2", obj, type)
|
||||||
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
||||||
#define floor2(value) sfall_func1("floor2", value)
|
#define floor2(value) sfall_func1("floor2", value)
|
||||||
|
#define get_current_inven_size(obj) sfall_func1("get_current_inven_size", obj)
|
||||||
#define intface_hide sfall_func0("intface_hide")
|
#define intface_hide sfall_func0("intface_hide")
|
||||||
#define intface_is_hidden sfall_func0("intface_is_hidden")
|
#define intface_is_hidden sfall_func0("intface_is_hidden")
|
||||||
#define intface_redraw sfall_func0("intface_redraw")
|
#define intface_redraw sfall_func0("intface_redraw")
|
||||||
|
|||||||
@@ -385,6 +385,9 @@ Some utility/math functions are available:
|
|||||||
- works just like vanilla floor function, but returns correct integers for negative values
|
- works just like vanilla floor function, but returns correct integers for negative values
|
||||||
- vanilla floor function works exactly the same as ceil for negative values, much like trunc in C/C++
|
- vanilla floor function works exactly the same as ceil for negative values, much like trunc in C/C++
|
||||||
|
|
||||||
|
> int sfall_func1("get_current_inven_size", object)
|
||||||
|
- returns the current inventory size of the container or the critter
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
------ MORE INFO -------
|
------ MORE INFO -------
|
||||||
------------------------
|
------------------------
|
||||||
|
|||||||
+4
-4
@@ -93,7 +93,7 @@ void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
static DWORD __stdcall sf_item_total_size(TGameObj* critter) {
|
DWORD __stdcall sf_item_total_size(TGameObj* critter) {
|
||||||
int totalSize;
|
int totalSize;
|
||||||
__asm {
|
__asm {
|
||||||
mov eax, critter;
|
mov eax, critter;
|
||||||
@@ -103,17 +103,17 @@ static DWORD __stdcall sf_item_total_size(TGameObj* critter) {
|
|||||||
|
|
||||||
if ((critter->artFID & 0xF000000) == (OBJ_TYPE_CRITTER << 24)) {
|
if ((critter->artFID & 0xF000000) == (OBJ_TYPE_CRITTER << 24)) {
|
||||||
TGameObj* item = InvenRightHand(critter);
|
TGameObj* item = InvenRightHand(critter);
|
||||||
if (item && !(item->flags & 0x2000000)) {
|
if (item && !(item->flags & 0x2000000)) { // ObjectFlag Right_Hand
|
||||||
totalSize += ItemSize(item);
|
totalSize += ItemSize(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
TGameObj* itemL = InvenLeftHand(critter);
|
TGameObj* itemL = InvenLeftHand(critter);
|
||||||
if (itemL && item != itemL && !(itemL->flags & 0x1000000)) {
|
if (itemL && item != itemL && !(itemL->flags & 0x1000000)) { // ObjectFlag Left_Hand
|
||||||
totalSize += ItemSize(itemL);
|
totalSize += ItemSize(itemL);
|
||||||
}
|
}
|
||||||
|
|
||||||
item = InvenWorn(critter);
|
item = InvenWorn(critter);
|
||||||
if (item && !(item->flags & 0x4000000)) {
|
if (item && !(item->flags & 0x4000000)) { // ObjectFlag Worn
|
||||||
totalSize += ItemSize(item);
|
totalSize += ItemSize(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void _stdcall SetInvenApCost(int a);
|
void _stdcall SetInvenApCost(int a);
|
||||||
|
DWORD __stdcall sf_item_total_size(TGameObj* critter);
|
||||||
void InventoryInit();
|
void InventoryInit();
|
||||||
void InventoryReset();
|
void InventoryReset();
|
||||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey);
|
void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey);
|
||||||
|
|||||||
@@ -103,17 +103,18 @@ static void sf_get_metarule_table() {
|
|||||||
- minArgs/maxArgs - minimum and maximum number of arguments allowed for this function
|
- minArgs/maxArgs - minimum and maximum number of arguments allowed for this function
|
||||||
*/
|
*/
|
||||||
static const SfallMetarule metaruleArray[] = {
|
static const SfallMetarule metaruleArray[] = {
|
||||||
{"get_metarule_table", sf_get_metarule_table, 0, 0},
|
|
||||||
{"validate_test", sf_test, 2, 5},
|
|
||||||
{"spatial_radius", sf_spatial_radius, 1, 1},
|
|
||||||
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2},
|
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2},
|
||||||
{"intface_redraw", sf_intface_redraw, 0, 0},
|
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
||||||
{"intface_show", sf_intface_show, 0, 0},
|
{"floor2", sf_floor2, 1, 1},
|
||||||
|
{"get_current_inven_size", sf_get_current_inven_size, 1, 1},
|
||||||
|
{"get_metarule_table", sf_get_metarule_table, 0, 0},
|
||||||
{"intface_hide", sf_intface_hide, 0, 0},
|
{"intface_hide", sf_intface_hide, 0, 0},
|
||||||
{"intface_is_hidden", sf_intface_is_hidden, 0, 0},
|
{"intface_is_hidden", sf_intface_is_hidden, 0, 0},
|
||||||
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
{"intface_redraw", sf_intface_redraw, 0, 0},
|
||||||
|
{"intface_show", sf_intface_show, 0, 0},
|
||||||
{"set_ini_setting", sf_set_ini_setting, 2, 2},
|
{"set_ini_setting", sf_set_ini_setting, 2, 2},
|
||||||
{"floor2", sf_floor2, 1, 1},
|
{"spatial_radius", sf_spatial_radius, 1, 1},
|
||||||
|
{"validate_test", sf_test, 2, 5},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void InitMetaruleTable() {
|
static void InitMetaruleTable() {
|
||||||
|
|||||||
@@ -558,3 +558,12 @@ static void sf_critter_inven_obj2() {
|
|||||||
opHandler.printOpcodeError("critter_inven_obj2() - invalid type.");
|
opHandler.printOpcodeError("critter_inven_obj2() - invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sf_get_current_inven_size() {
|
||||||
|
TGameObj* invenObj = opHandler.arg(0).asObject();
|
||||||
|
if (invenObj != nullptr) {
|
||||||
|
opHandler.setReturn(sf_item_total_size(invenObj), DATATYPE_INT);
|
||||||
|
} else {
|
||||||
|
opHandler.setReturn(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user