summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Menaldo <guilherme.menaldo@outlook.com>2019-06-01 14:16:37 -0300
committerHaru <haru@dotalux.com>2019-07-01 01:22:22 +0200
commit462f1d0bc01dd432004b74732c06baa9d8a7a00c (patch)
treea5ff515471b7848a6122ebdb76520e32e7967a6c
parent33b0658e174fdd50e513daa807a8824f959ded44 (diff)
downloadhercules-462f1d0bc01dd432004b74732c06baa9d8a7a00c.tar.gz
hercules-462f1d0bc01dd432004b74732c06baa9d8a7a00c.tar.bz2
hercules-462f1d0bc01dd432004b74732c06baa9d8a7a00c.tar.xz
hercules-462f1d0bc01dd432004b74732c06baa9d8a7a00c.zip
Add identifyidx script command
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--doc/script_commands.txt9
-rw-r--r--src/map/script.c35
2 files changed, 44 insertions, 0 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 5cc3ea186..3d22914b9 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -3369,6 +3369,15 @@ This will set a Hat Effect onto the player. The state field allows you to
enable (true) or disable (false) the effect on the player.
---------------------------------------
+
+*identifyidx(<Inventory Index>)
+
+This will identify item at attached player's <Inventory Index> inventory index.
+
+Returns true if the item was identified, false otherwise.
+Note: If the item was already identified, it returns false.
+
+---------------------------------------
//=====================================
2.1 - End of Item-Related Commands
//=====================================
diff --git a/src/map/script.c b/src/map/script.c
index 35217a4d7..ba5412588 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -25516,6 +25516,39 @@ static BUILDIN(openrefineryui)
}
/**
+ * identifyidx(idx)
+ * Identifies item at idx.
+ * Returns true if item is identified, false otherwise.
+ */
+static BUILDIN(identifyidx)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+
+ if (sd == NULL) {
+ script_pushint(st, false);
+ return true;
+ }
+
+ int idx = script_getnum(st, 2);
+ if (idx < 0 || idx >= sd->status.inventorySize) {
+ ShowError("buildin_identifyidx: Invalid inventory index (%d), expected a value between 0 and %d\n", idx, sd->status.inventorySize);
+ script_pushint(st, false);
+ return true;
+ }
+
+ if (sd->status.inventory[idx].nameid <= 0 || sd->status.inventory[idx].identify != 0) {
+ script_pushint(st, false);
+ return true;
+ }
+
+ sd->status.inventory[idx].identify = 1;
+ clif->item_identified(sd, idx, 0);
+ script_pushint(st, true);
+
+ return true;
+}
+
+/**
* Adds a built-in script function.
*
* @param buildin Script function data
@@ -26275,6 +26308,8 @@ static void script_parse_builtin(void)
BUILDIN_DEF(openrefineryui, ""),
BUILDIN_DEF(setfavoriteitemidx, "ii"),
BUILDIN_DEF(autofavoriteitem, "ii"),
+
+ BUILDIN_DEF(identifyidx, "i"),
};
int i, len = ARRAYLENGTH(BUILDIN);
RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up