summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Zidan <brahem@aotsw.com>2019-04-27 23:14:09 +0200
committerIbrahim Zidan <brahem@aotsw.com>2019-05-05 23:40:43 +0200
commit8598e0cbf421eded6943d416f7da8881997c960a (patch)
tree35c1c6c6af1efddba2c91c1f5ca867f7c6b62f26
parentfdcd121237eb03cc264dbd8ad1371603bd6622c7 (diff)
downloadhercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.gz
hercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.bz2
hercules-8598e0cbf421eded6943d416f7da8881997c960a.tar.xz
hercules-8598e0cbf421eded6943d416f7da8881997c960a.zip
Implement Refine success/failure announcement feature
Currently as far as we know kRO only sends this on success in refining an item through the refinery ui, from level 10 all the way to 20. Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
-rw-r--r--db/pre-re/refine_db.conf6
-rw-r--r--db/re/refine_db.conf26
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/refine.c33
-rw-r--r--src/map/refine.h2
-rw-r--r--src/map/refine.p.h15
7 files changed, 101 insertions, 0 deletions
diff --git a/db/pre-re/refine_db.conf b/db/pre-re/refine_db.conf
index 5896e49f6..725b8c225 100644
--- a/db/pre-re/refine_db.conf
+++ b/db/pre-re/refine_db.conf
@@ -42,6 +42,12 @@ Armors/WeaponLevel1~4: { // Specifies weap
Level: (int or array of int) // Holds either the individule refine level meant for this setting or an array defining a range
of Low to Max level
BlacksmithBlessing: (int) (optional) // How many Blacksmith Blessing required for this range to be safe from breaking
+ Announce: "(string)" (optional) // Sends an announcement server wide when a player reach this refine level using
+ Refinery UI, this feature is only available starting from 2017-08-30 RagexeRE or
+ 2017-09-06 Ragexe the field accepts the following values and it defaults to not announce
+ Success to set the announcement on item refine successful
+ Failure to set the announcement on item refine failure
+ Always to always announce it
Items: {
AegisName: {
Type: "(string)" // The type to determine the chances used for this item, REFINE_CHANCE_TYPE_*
diff --git a/db/re/refine_db.conf b/db/re/refine_db.conf
index 31335fffd..c83f71334 100644
--- a/db/re/refine_db.conf
+++ b/db/re/refine_db.conf
@@ -42,6 +42,12 @@ Armors/WeaponLevel1~4: { // Specifies weap
Level: (int or array of int) // Holds either the individule refine level meant for this setting or an array defining a range
of Low to Max level
BlacksmithBlessing: (int) (optional) // How many Blacksmith Blessing required for this range to be safe from breaking
+ Announce: "(string)" (optional) // Sends an announcement server wide when a player reach this refine level using
+ Refinery UI, this feature is only available starting from 2017-08-30 RagexeRE or
+ 2017-09-06 Ragexe the field accepts the following values and it defaults to not announce
+ Success to set the announcement on item refine successful
+ Failure to set the announcement on item refine failure
+ Always to always announce it
Items: {
AegisName: {
Type: "(string)" // The type to determine the chances used for this item, REFINE_CHANCE_TYPE_*
@@ -127,6 +133,7 @@ Armors: {
{
Level: 10
BlacksmithBlessing: 4
+ Announce: "Success"
Items: {
Elunium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -146,6 +153,7 @@ Armors: {
{
Level: 11
BlacksmithBlessing: 7
+ Announce: "Always"
Items: {
Carnium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -161,6 +169,7 @@ Armors: {
{
Level: 12
BlacksmithBlessing: 11
+ Announce: "Always"
Items: {
Carnium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -175,6 +184,7 @@ Armors: {
},
{
Level: [13, 20]
+ Announce: "Always"
Items: {
Carnium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -364,6 +374,7 @@ WeaponLevel1: {
{
Level: 10
BlacksmithBlessing: 4
+ Announce: "Success"
Items: {
Phracon: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -383,6 +394,7 @@ WeaponLevel1: {
{
Level: 11
BlacksmithBlessing: 7
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -398,6 +410,7 @@ WeaponLevel1: {
{
Level: 12
BlacksmithBlessing: 11
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -412,6 +425,7 @@ WeaponLevel1: {
},
{
Level: [13, 20]
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -560,6 +574,7 @@ WeaponLevel2: {
{
Level: 10
BlacksmithBlessing: 4
+ Announce: "Success"
Items: {
Emveretarcon: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -579,6 +594,7 @@ WeaponLevel2: {
{
Level: 11
BlacksmithBlessing: 7
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -594,6 +610,7 @@ WeaponLevel2: {
{
Level: 12
BlacksmithBlessing: 11
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -608,6 +625,7 @@ WeaponLevel2: {
},
{
Level: [13, 20]
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -762,6 +780,7 @@ WeaponLevel3: {
{
Level: 10
BlacksmithBlessing: 4
+ Announce: "Success"
Items: {
Oridecon: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -781,6 +800,7 @@ WeaponLevel3: {
{
Level: 11
BlacksmithBlessing: 7
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -796,6 +816,7 @@ WeaponLevel3: {
{
Level: 12
BlacksmithBlessing: 11
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -810,6 +831,7 @@ WeaponLevel3: {
},
{
Level: [13, 20]
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -970,6 +992,7 @@ WeaponLevel4: {
{
Level: 10
BlacksmithBlessing: 4
+ Announce: "Success"
Items: {
Oridecon: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -989,6 +1012,7 @@ WeaponLevel4: {
{
Level: 11
BlacksmithBlessing: 7
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -1004,6 +1028,7 @@ WeaponLevel4: {
{
Level: 12
BlacksmithBlessing: 11
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
@@ -1018,6 +1043,7 @@ WeaponLevel4: {
},
{
Level: [13, 20]
+ Announce: "Always"
Items: {
Bradium: {
Type: "REFINE_CHANCE_TYPE_NORMAL"
diff --git a/src/map/clif.c b/src/map/clif.c
index b8a54166a..462991510 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -22574,6 +22574,23 @@ static void clif_parse_RefineryUIClose(int fd, struct map_session_data *sd)
#endif
}
+static void clif_announce_refine_status(struct map_session_data *sd, int item_id, int refine_level, bool success, enum send_target target)
+{
+#if PACKETVER_MAIN_NUM >= 20170906 || PACKETVER_RE_NUM >= 20170830 || defined(PACKETVER_ZERO)
+ nullpo_retv(sd);
+
+ Assert_retv(refine_level > 0 && refine_level <= INT8_MAX);
+
+ struct PACKET_ZC_REFINE_STATUS p;
+ p.packetType = HEADER_ZC_REFINE_STATUS;
+ safestrncpy(p.name, sd->status.name, NAME_LENGTH);
+ p.itemId = item_id;
+ p.refine_level = refine_level;
+ p.status = (success) ? true : false;
+ clif->send(&p, sizeof(p), &sd->bl, target);
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -23792,4 +23809,5 @@ void clif_defaults(void)
clif->AddItemRefineryUIAck = clif_AddItemRefineryUIAck;
clif->pRefineryUIClose = clif_parse_RefineryUIClose;
clif->pRefineryUIRefine = clif_parse_RefineryUIRefine;
+ clif->announce_refine_status = clif_announce_refine_status;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 0515fbd05..19c321ed3 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1617,6 +1617,7 @@ struct clif_interface {
void (*AddItemRefineryUIAck) (struct map_session_data *sd, int item_index, struct s_refine_requirement *req);
void (*pRefineryUIClose) (int fd, struct map_session_data *sd);
void (*pRefineryUIRefine) (int fd, struct map_session_data *sd);
+ void (*announce_refine_status) (struct map_session_data *sd, int item_id, int refine_level, bool success, enum send_target target);
};
#ifdef HERCULES_CORE
diff --git a/src/map/refine.c b/src/map/refine.c
index 58e006012..1ff893c56 100644
--- a/src/map/refine.c
+++ b/src/map/refine.c
@@ -131,6 +131,9 @@ static void refine_refinery_refine_request(struct map_session_data *sd, int item
pc->delitem(sd, item_index, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_REFINE);
break;
}
+
+ if ((req->announce & REFINE_ANNOUNCE_FAILURE) != 0)
+ clif->announce_refine_status(sd, sd->status.inventory[item_index].nameid, sd->status.inventory[item_index].refine, false, ALL_CLIENT);
} else {
sd->status.inventory[item_index].refine += 1;
sd->status.inventory[item_index].refine = cap_value(sd->status.inventory[item_index].refine, 0, MAX_REFINE);
@@ -139,6 +142,9 @@ static void refine_refinery_refine_request(struct map_session_data *sd, int item
clif->refine(sd->fd, 0, item_index, sd->status.inventory[item_index].refine);
logs->pick_pc(sd, LOG_TYPE_REFINE, 1, &sd->status.inventory[item_index], sd->inventory_data[item_index]);
refine->refinery_add_item(sd, item_index);
+
+ if ((req->announce & REFINE_ANNOUNCE_SUCCESS) != 0)
+ clif->announce_refine_status(sd, sd->status.inventory[item_index].nameid, sd->status.inventory[item_index].refine, true, ALL_CLIENT);
}
}
@@ -222,6 +228,24 @@ static int refine_get_refine_chance(enum refine_type wlv, int refine_level, enum
return refine->p->dbs->refine_info[wlv].chance[type][refine_level];
}
+/// @copydoc refine_interface_private::announce_behavior_string2enum()
+static bool refine_announce_behavior_string2enum(const char *str, unsigned int *result)
+{
+ nullpo_retr(false, str);
+ nullpo_retr(false, result);
+
+ if (strcasecmp(str, "Success") == 0)
+ *result = REFINE_ANNOUNCE_SUCCESS;
+ else if (strcasecmp(str, "Failure") == 0)
+ *result = REFINE_ANNOUNCE_FAILURE;
+ else if (strcasecmp(str, "Always") == 0)
+ *result = REFINE_ANNOUNCE_ALWAYS;
+ else
+ return false;
+
+ return true;
+}
+
/// @copydoc refine_interface_private::failure_behavior_string2enum()
static bool refine_failure_behavior_string2enum(const char *str, enum refine_ui_failure_behavior *result)
{
@@ -373,6 +397,14 @@ static bool refine_readdb_refinery_ui_settings_sub(const struct config_setting_t
}
}
+ req.announce = 0;
+ const char *announce_behavior = NULL;
+ if (libconfig->setting_lookup_string(elem, "Announce", &announce_behavior) != CONFIG_FALSE) {
+ if (!refine->p->announce_behavior_string2enum(announce_behavior, &req.announce)) {
+ ShowWarning("refine_readdb_requirements_sub: invalid announce behavior value '%s' in entry '%s' in \"%s\" defaulting to not announce...\n", announce_behavior, name, source);
+ }
+ }
+
struct config_setting_t *items_t;
if ((items_t = libconfig->setting_get_member(elem, "Items")) == NULL) {
ShowWarning("refine_readdb_requirements_sub: a requirements element missing Items element for entry '%s' in \"%s\" skipping...\n", name, source);
@@ -620,6 +652,7 @@ void refine_defaults(void)
refine->p->readdb_refine_libconfig = refine_readdb_refine_libconfig;
refine->p->readdb_refine_libconfig_sub = refine_readdb_refine_libconfig_sub;
+ refine->p->announce_behavior_string2enum = refine_announce_behavior_string2enum;
refine->p->failure_behavior_string2enum = refine_failure_behavior_string2enum;
refine->p->readdb_refinery_ui_settings_items = refine_readdb_refinery_ui_settings_items;
refine->p->readdb_refinery_ui_settings_sub = refine_readdb_refinery_ui_settings_sub;
diff --git a/src/map/refine.h b/src/map/refine.h
index 100d2c6b2..410811e06 100644
--- a/src/map/refine.h
+++ b/src/map/refine.h
@@ -71,6 +71,8 @@ enum refine_ui_failure_behavior {
struct s_refine_requirement {
int blacksmith_blessing;
int req_count;
+ unsigned int announce;
+
struct {
int nameid;
int cost;
diff --git a/src/map/refine.p.h b/src/map/refine.p.h
index e1a24f6b7..3247d15c9 100644
--- a/src/map/refine.p.h
+++ b/src/map/refine.p.h
@@ -27,7 +27,14 @@
#include "refine.h"
#include "common/conf.h"
+/* Enums */
+enum refine_announce_condition {
+ REFINE_ANNOUNCE_SUCCESS = 0x1,
+ REFINE_ANNOUNCE_FAILURE = 0x2,
+ REFINE_ANNOUNCE_ALWAYS = REFINE_ANNOUNCE_SUCCESS | REFINE_ANNOUNCE_FAILURE,
+};
+/* Structures */
struct s_refine_info {
int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; //< success chance
int bonus[MAX_REFINE]; //< cumulative fixed bonus damage
@@ -68,6 +75,14 @@ struct refine_interface_private {
int (*readdb_refine_libconfig) (const char *filename);
/**
+ * Converts refine database announce behvaior string to enum refine_announce_condition
+ * @param str the string to convert
+ * @param result pointer to where the converted value will be held
+ * @return true on success, false otherwise.
+ **/
+ bool (*announce_behavior_string2enum) (const char *str, unsigned int *result);
+
+ /**
* Converts refine database failure behvaior string to enum refine_ui_failure_behavior
* @param str the string to convert
* @param result pointer to where the converted value will be held