summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorGuilherme Menaldo <guilherme.menaldo@outlook.com>2019-06-01 14:37:42 -0300
committerHaru <haru@dotalux.com>2019-07-01 01:22:27 +0200
commit24c4d531b150863caed448fbbf4a9964dadbb63e (patch)
tree0cbb091d00675a0be1954498f89cb6607a4daebb /src/map
parent462f1d0bc01dd432004b74732c06baa9d8a7a00c (diff)
downloadhercules-24c4d531b150863caed448fbbf4a9964dadbb63e.tar.gz
hercules-24c4d531b150863caed448fbbf4a9964dadbb63e.tar.bz2
hercules-24c4d531b150863caed448fbbf4a9964dadbb63e.tar.xz
hercules-24c4d531b150863caed448fbbf4a9964dadbb63e.zip
Add identify script command
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index ba5412588..c1e210d27 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -25516,6 +25516,42 @@ static BUILDIN(openrefineryui)
}
/**
+ * identify(<item id>)
+ * Identifies the first unidentified <item id> item on player's inventory.
+ * Returns -2 on error, -1 if no item to identify was found, identified idx otherwise.
+ */
+static BUILDIN(identify)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+
+ if (sd == NULL) {
+ script_pushint(st, -2);
+ return true;
+ }
+
+ int itemid = script_getnum(st, 2);
+ if (itemdb->exists(itemid) == NULL) {
+ ShowError("buildin_identify: Invalid item ID (%d)\n", itemid);
+ script_pushint(st, -2);
+ return true;
+ }
+
+ int idx = -1;
+ ARR_FIND(0, sd->status.inventorySize, idx, (sd->status.inventory[idx].nameid == itemid && sd->status.inventory[idx].identify == 0));
+
+ if (idx < 0 || idx >= sd->status.inventorySize) {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ sd->status.inventory[idx].identify = 1;
+ clif->item_identified(sd, idx, 0);
+ script_pushint(st, idx);
+
+ return true;
+}
+
+/**
* identifyidx(idx)
* Identifies item at idx.
* Returns true if item is identified, false otherwise.
@@ -26309,6 +26345,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(setfavoriteitemidx, "ii"),
BUILDIN_DEF(autofavoriteitem, "ii"),
+ BUILDIN_DEF(identify, "i"),
BUILDIN_DEF(identifyidx, "i"),
};
int i, len = ARRAYLENGTH(BUILDIN);