summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-08 01:31:19 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-08 11:54:49 +0300
commit48f6d35d2c293a17a863bb540e686b1c780b9005 (patch)
tree46780b62e99e408247d7e844309505c5e3e11857 /src/map
parent6916a2defdf884cceb67e6699bd9b4cfaeba0279 (diff)
downloadplugin-48f6d35d2c293a17a863bb540e686b1c780b9005.tar.gz
plugin-48f6d35d2c293a17a863bb540e686b1c780b9005.tar.bz2
plugin-48f6d35d2c293a17a863bb540e686b1c780b9005.tar.xz
plugin-48f6d35d2c293a17a863bb540e686b1c780b9005.zip
Add to item_db.conf item attributes for equip/unequip effects.
New attributes: UnequipEffect - send this effect to client if unequip item was success UnequipFailEffect - send this effect to client if unequip item was fail For equip events used same attributes like for use.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/data/itemd.c2
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/itemdb.c12
-rw-r--r--src/map/pc.c37
-rw-r--r--src/map/pc.h6
-rw-r--r--src/map/struct/itemdext.h2
6 files changed, 57 insertions, 4 deletions
diff --git a/src/map/data/itemd.c b/src/map/data/itemd.c
index 6ec2db2..55351a1 100644
--- a/src/map/data/itemd.c
+++ b/src/map/data/itemd.c
@@ -62,5 +62,7 @@ struct ItemdExt *itemd_create(void)
data->requiredMDef = 0;
data->useEffect = -1;
data->useFailEffect = -1;
+ data->unequipEffect = -1;
+ data->unequipFailEffect = -1;
return data;
}
diff --git a/src/map/init.c b/src/map/init.c
index e8ac062..98623d6 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -159,6 +159,8 @@ HPExport void plugin_init (void)
addHookPost("pc->isequip", epc_isuseequip_post);
addHookPost("pc->isUseitem", epc_isuseequip_post);
addHookPost("pc->useitem", epc_useitem_post);
+ addHookPost("pc->equipitem", epc_equipitem_post);
+ addHookPost("pc->unequipitem", epc_unequipitem_post);
langScriptId = script->add_str("Lang");
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 182c38b..13c56cf 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -74,14 +74,18 @@ void eitemdb_readdb_additional_fields(int *itemid,
data->requiredMAtkMin = i32;
if (libconfig->setting_lookup_int(it, "RequiredMAtkMax", &i32) && i32 >= 0)
data->requiredMAtkMax = i32;
- if (libconfig->setting_lookup_int(it, "requiredDef", &i32) && i32 >= 0)
+ if (libconfig->setting_lookup_int(it, "RequiredDef", &i32) && i32 >= 0)
data->requiredDef = i32;
- if (libconfig->setting_lookup_int(it, "requiredMDef", &i32) && i32 >= 0)
+ if (libconfig->setting_lookup_int(it, "RequiredMDef", &i32) && i32 >= 0)
data->requiredMDef = i32;
- if (itemdb->lookup_const(it, "useEffect", &i32))
+ if (itemdb->lookup_const(it, "UseEffect", &i32))
data->useEffect = i32;
- if (itemdb->lookup_const(it, "useFailEffect", &i32))
+ if (itemdb->lookup_const(it, "UseFailEffect", &i32))
data->useFailEffect = i32;
+ if (itemdb->lookup_const(it, "UnequipEffect", &i32))
+ data->unequipEffect = i32;
+ if (itemdb->lookup_const(it, "UnequipFailEffect", &i32))
+ data->unequipFailEffect = i32;
hookStop();
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 79a3cac..504d5c6 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -242,3 +242,40 @@ int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr)
clif->specialeffect(&sd->bl, effect, AREA);
return retVal;
}
+
+static void equippost_effect(struct map_session_data *const sd, const int n, const bool retVal, const bool equip)
+{
+ if (!sd)
+ return;
+
+ if (n < 0 || n >= MAX_INVENTORY)
+ return;
+
+ struct ItemdExt *data = itemd_get(sd->inventory_data[n]);
+ if (!data)
+ return;
+
+ int effect;
+ if (equip)
+ effect = retVal ? data->useEffect : data->useFailEffect;
+ else
+ effect = retVal ? data->unequipEffect : data->unequipFailEffect;
+
+ if (effect != -1)
+ clif->specialeffect(&sd->bl, effect, AREA);
+ return;
+}
+
+int epc_equipitem_post(int retVal, struct map_session_data *sd,
+ int *nPtr, int *data __attribute__ ((unused)))
+{
+ equippost_effect(sd, *nPtr, retVal, true);
+ return retVal;
+}
+
+int epc_unequipitem_post(int retVal, struct map_session_data *sd,
+ int *nPtr, int *data __attribute__ ((unused)))
+{
+ equippost_effect(sd, *nPtr, retVal, false);
+ return retVal;
+}
diff --git a/src/map/pc.h b/src/map/pc.h
index 84ced8d..37f3974 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -27,4 +27,10 @@ int epc_isuseequip_post(int retVal, struct map_session_data *sd, int *nPtr);
int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr);
+int epc_equipitem_post(int retVal, struct map_session_data *sd,
+ int *nPtr, int *data);
+
+int epc_unequipitem_post(int retVal, struct map_session_data *sd,
+ int *nPtr, int *data);
+
#endif // EVOL_MAP_PC
diff --git a/src/map/struct/itemdext.h b/src/map/struct/itemdext.h
index 1308f39..8d4a555 100644
--- a/src/map/struct/itemdext.h
+++ b/src/map/struct/itemdext.h
@@ -24,6 +24,8 @@ struct ItemdExt
int useEffect;
int useFailEffect;
+ int unequipEffect;
+ int unequipFailEffect;
bool allowPickup;
};