From 44188e39d4b3a0ffc5e16ac0798161d320fdea2b Mon Sep 17 00:00:00 2001 From: Joam <35770095+attackjom@users.noreply.github.com> Date: Fri, 18 Feb 2022 04:46:56 +0700 Subject: [PATCH] Add getitempos script (#6621) item script that return equip position. --- doc/script_commands.txt | 9 +++++++++ src/map/script.cpp | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index ed50b6ce5e..ddc70a2758 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3135,6 +3135,15 @@ EQI_COMPOUND_ON - Item slot that calls this script (In context of item scri For a list of others equipment slots see 'getequipid'. +--------------------------------------- + +*getitempos() + +This function will return the equip position of the equipment from which the +function is called. (see EQP_* constants) + +This function is intended for use in item scripts. + --------------------------------------- // 2,1.- End of item-related commands. diff --git a/src/map/script.cpp b/src/map/script.cpp index c8b7589436..6e03531d6a 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -25736,6 +25736,25 @@ BUILDIN_FUNC( openstylist ){ #endif } +BUILDIN_FUNC(getitempos) { + struct map_session_data* sd; + + if ( !script_rid2sd(sd) ){ + script_pushint(st, 0); + return SCRIPT_CMD_FAILURE; + } + + if( current_equip_item_index == -1 ){ + ShowError( "buildin_getitempos: Invalid usage detected. This command should only be used inside item scripts.\n" ); + script_pushint(st, 0); + return SCRIPT_CMD_FAILURE; + } + + script_pushint(st, sd->inventory.u.items_inventory[current_equip_item_index].equip); + + return SCRIPT_CMD_SUCCESS; +} + #include "../custom/script.inc" // declarations that were supposed to be exported from npc_chat.cpp @@ -26443,6 +26462,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF(setinstancevar,"rvi"), BUILDIN_DEF(openstylist, "?"), + + BUILDIN_DEF(getitempos,""), #include "../custom/script_def.inc" {NULL,NULL,NULL},