summaryrefslogtreecommitdiff
path: root/src/emap
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
parent4333293820d5c7de27e9e760dfeaadbc1686f2c3 (diff)
downloadevol-hercules-6f0de26cf8919b92000857a065ad2b0e86167994.tar.gz
evol-hercules-6f0de26cf8919b92000857a065ad2b0e86167994.tar.bz2
evol-hercules-6f0de26cf8919b92000857a065ad2b0e86167994.tar.xz
evol-hercules-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')
-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