summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/data/itemd.c2
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/itemdb.c4
-rw-r--r--src/map/pc.c21
-rw-r--r--src/map/pc.h2
-rw-r--r--src/map/struct/itemdext.h5
6 files changed, 34 insertions, 1 deletions
diff --git a/src/map/data/itemd.c b/src/map/data/itemd.c
index 974c86c..6ec2db2 100644
--- a/src/map/data/itemd.c
+++ b/src/map/data/itemd.c
@@ -60,5 +60,7 @@ struct ItemdExt *itemd_create(void)
data->requiredMAtkMax = 0;
data->requiredDef = 0;
data->requiredMDef = 0;
+ data->useEffect = -1;
+ data->useFailEffect = -1;
return data;
}
diff --git a/src/map/init.c b/src/map/init.c
index ffb6033..e8ac062 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -158,6 +158,7 @@ HPExport void plugin_init (void)
addHookPost("skill->check_condition_castend", eskill_check_condition_castend_post);
addHookPost("pc->isequip", epc_isuseequip_post);
addHookPost("pc->isUseitem", epc_isuseequip_post);
+ addHookPost("pc->useitem", epc_useitem_post);
langScriptId = script->add_str("Lang");
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 50c2728..182c38b 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -79,5 +79,9 @@ void eitemdb_readdb_additional_fields(int *itemid,
if (libconfig->setting_lookup_int(it, "requiredMDef", &i32) && i32 >= 0)
data->requiredMDef = i32;
+ if (itemdb->lookup_const(it, "useEffect", &i32))
+ data->useEffect = i32;
+ if (itemdb->lookup_const(it, "useFailEffect", &i32))
+ data->useFailEffect = i32;
hookStop();
}
diff --git a/src/map/pc.c b/src/map/pc.c
index fd03d01..79a3cac 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -201,7 +201,7 @@ int epc_isuseequip_post(int retVal, struct map_session_data *sd, int *nPtr)
struct ItemdExt *data = itemd_get(sd->inventory_data[n]);
if (!data)
- return 1;
+ return retVal;
if (sd->battle_status.str < data->requiredStr ||
sd->battle_status.agi < data->requiredAgi ||
@@ -223,3 +223,22 @@ int epc_isuseequip_post(int retVal, struct map_session_data *sd, int *nPtr)
}
return retVal;
}
+
+int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr)
+{
+ const int n = *nPtr;
+ if (!sd)
+ return retVal;
+
+ if (n < 0 || n >= MAX_INVENTORY)
+ return retVal;
+
+ struct ItemdExt *data = itemd_get(sd->inventory_data[n]);
+ if (!data)
+ return retVal;
+
+ const int effect = retVal ? data->useEffect : data->useFailEffect;
+ if (effect != -1)
+ clif->specialeffect(&sd->bl, effect, AREA);
+ return retVal;
+}
diff --git a/src/map/pc.h b/src/map/pc.h
index 9c81392..84ced8d 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -25,4 +25,6 @@ void epc_validate_levels(void);
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);
+
#endif // EVOL_MAP_PC
diff --git a/src/map/struct/itemdext.h b/src/map/struct/itemdext.h
index 283f20d..1308f39 100644
--- a/src/map/struct/itemdext.h
+++ b/src/map/struct/itemdext.h
@@ -7,6 +7,7 @@
struct ItemdExt
{
int floorLifeTime;
+
int requiredStr;
int requiredAgi;
int requiredVit;
@@ -20,6 +21,10 @@ struct ItemdExt
int requiredMAtkMax;
int requiredDef;
int requiredMDef;
+
+ int useEffect;
+ int useFailEffect;
+
bool allowPickup;
};