summaryrefslogtreecommitdiff
path: root/src/emap/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-22 00:15:38 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-22 00:15:38 +0300
commit6f0de26cf8919b92000857a065ad2b0e86167994 (patch)
tree9078dc09729ed6f0f0e1a25bf6109e2ccf48074e /src/emap/script.c
parent4333293820d5c7de27e9e760dfeaadbc1686f2c3 (diff)
downloadplugin-6f0de26cf8919b92000857a065ad2b0e86167994.tar.gz
plugin-6f0de26cf8919b92000857a065ad2b0e86167994.tar.bz2
plugin-6f0de26cf8919b92000857a065ad2b0e86167994.tar.xz
plugin-6f0de26cf8919b92000857a065ad2b0e86167994.zip
Add script function downrefindex for downgrade refine level.
New script function: downrefindex index, number index - inventory index number - number of levels to downgrade. Example: downrefindex .@index, 1;
Diffstat (limited to 'src/emap/script.c')
-rw-r--r--src/emap/script.c26
1 files changed, 26 insertions, 0 deletions
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;
+}