summaryrefslogtreecommitdiff
path: root/src/emap/pc.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-13 20:08:55 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-13 20:30:34 +0300
commitf7cce6ac2d1c010af4865212dc6ddc2a7aea66a4 (patch)
tree7d65ea2e1bd9fb9379157dce324c1d601d0518e9 /src/emap/pc.c
parent5b49e94e000d31299e9e97e339e7ad273cdfa032 (diff)
downloadevol-hercules-f7cce6ac2d1c010af4865212dc6ddc2a7aea66a4.tar.gz
evol-hercules-f7cce6ac2d1c010af4865212dc6ddc2a7aea66a4.tar.bz2
evol-hercules-f7cce6ac2d1c010af4865212dc6ddc2a7aea66a4.tar.xz
evol-hercules-f7cce6ac2d1c010af4865212dc6ddc2a7aea66a4.zip
Add support for drop script for items dropped by player.
Diffstat (limited to 'src/emap/pc.c')
-rw-r--r--src/emap/pc.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/emap/pc.c b/src/emap/pc.c
index c4db70b..1db0963 100644
--- a/src/emap/pc.c
+++ b/src/emap/pc.c
@@ -14,6 +14,7 @@
#include "common/strlib.h"
#include "common/timer.h"
#include "map/itemdb.h"
+#include "map/npc.h"
#include "map/pc.h"
#include "emap/clif.h"
@@ -457,3 +458,38 @@ bool epc_can_insert_card_into_post(bool retVal, struct map_session_data* sd,
return retVal;
}
+// temporary inv index and item id
+static int tempN = 0;
+static int tempId = 0;
+
+int epc_dropitem_pre(struct map_session_data *sd, int *nPtr, int *amountPtr)
+{
+ const int n = *nPtr;
+ if (n < 0 || n >= MAX_INVENTORY)
+ return 0;
+
+ tempN = n;
+ tempId = sd->status.inventory[n].nameid;
+ return 1;
+}
+
+int epc_dropitem_post(int retVal, struct map_session_data *sd, int *nPtr, int *amountPtr)
+{
+ if (retVal && *nPtr == tempN && tempId)
+ {
+ struct item_data *item = itemdb->search(tempId);
+ if (!item)
+ return retVal;
+ struct ItemdExt *data = itemd_get(item);
+ if (!data || !data->dropScript)
+ return retVal;
+ script->current_item_id = tempId;
+ pc->setreg(sd, script->add_str("@itemId"), tempId);
+ pc->setreg(sd, script->add_str("@itemAmount"), *amountPtr);
+ script->run(data->dropScript, 0, sd->bl.id, npc->fake_nd->bl.id);
+ pc->setreg(sd, script->add_str("@itemId"), 0);
+ pc->setreg(sd, script->add_str("@itemAmount"), 0);
+ script->current_item_id = 0;
+ }
+ return retVal;
+}