summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c26
-rw-r--r--src/emap/script.h1
3 files changed, 28 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 550ebf7..cdbe31a 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -117,6 +117,7 @@ HPExport void plugin_init (void)
addScriptCommand("clientcommand", "s", clientCommand);
addScriptCommand("isunitwalking", "?", isUnitWalking);
addScriptCommand("failedrefindex", "i", failedRefIndex);
+ addScriptCommand("downrefindex", "ii", downRefIndex);
do_init_langs();
diff --git a/src/emap/script.c b/src/emap/script.c
index 88b9f34..40d0473 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -10,6 +10,7 @@
#include "common/HPMi.h"
#include "common/malloc.h"
#include "common/mmo.h"
+#include "common/utils.h"
#include "common/socket.h"
#include "common/strlib.h"
#include "common/timer.h"
@@ -1280,3 +1281,28 @@ BUILDIN(failedRefIndex)
clif->misceffect(&sd->bl, 2);
return true;
}
+
+BUILDIN(downRefIndex)
+{
+ getSD()
+ getInventoryIndex(2)
+
+ if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0)
+ return false;
+
+ const int down = script_getnum(st, 3);
+
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[n], sd->inventory_data[n]);
+
+ if (sd->status.inventory[n].equip)
+ pc->unequipitem(sd, n, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
+ sd->status.inventory[n].refine -= down;
+ sd->status.inventory[n].refine = cap_value(sd->status.inventory[n].refine, 0, MAX_REFINE);
+
+ clif->refine(sd->fd, 2, n, sd->status.inventory[n].refine);
+ clif->delitem(sd, n, 1, DELITEM_MATERIALCHANGE);
+ logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[n], sd->inventory_data[n]);
+ clif->additem(sd, n, 1, 0);
+ clif->misceffect(&sd->bl, 2);
+ return true;
+}
diff --git a/src/emap/script.h b/src/emap/script.h
index abf6b55..4ce5ec2 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -45,5 +45,6 @@ BUILDIN(setMount);
BUILDIN(clientCommand);
BUILDIN(isUnitWalking);
BUILDIN(failedRefIndex);
+BUILDIN(downRefIndex);
#endif // EVOL_MAP_SCRIPT