diff --git a/conf/battle/items.conf b/conf/battle/items.conf index 692c355bc1..37b1f066fb 100644 --- a/conf/battle/items.conf +++ b/conf/battle/items.conf @@ -116,7 +116,7 @@ default_bind_on_equip: 4 allow_bound_sell: 0x0 // Hide n last characters of player's name with asterisk (*) when the player -// obtained an item with special broadcast flag. +// obtained an item with special broadcast flag or refined an item at a level with broadcast flag. // Note: Players with short names can be fully converted to asterisks if this // config value is set high. broadcast_hide_name: 2 diff --git a/db/import-tmpl/refine.yml b/db/import-tmpl/refine.yml index bdd452b91f..c8fea64da2 100644 --- a/db/import-tmpl/refine.yml +++ b/db/import-tmpl/refine.yml @@ -30,6 +30,8 @@ # Bonus Refinement bonus. (Default: 0) # RandomBonus Extra refinement bonus of 0~RandomBonus stacked on Bonus. (Default: 0) # BlacksmithBlessingAmount Amount of Blacksmith Blessing required. (Default: 0) +# BroadcastSuccess Broadcast to the whole server when a refine attempt at this level succeeds. (Default: false) +# BroadcastFailure Broadcast to the whole server when a refine attempt at this level fails. (Default: false) # Chances: Success chance based on cost type. (Default: null) # - Type Refinement cost type based on ore used. # Rate Chance of success out of 0~10000. (Default: 0) @@ -41,7 +43,7 @@ Header: Type: REFINE_DB - Version: 1 + Version: 2 ########################################################################### # Event Refine Rates diff --git a/db/pre-re/refine.yml b/db/pre-re/refine.yml index 0178f40d62..d00f38f9ec 100644 --- a/db/pre-re/refine.yml +++ b/db/pre-re/refine.yml @@ -30,6 +30,8 @@ # Bonus Refinement bonus. (Default: 0) # RandomBonus Extra refinement bonus of 0~RandomBonus stacked on Bonus. (Default: 0) # BlacksmithBlessingAmount Amount of Blacksmith Blessing required. (Default: 0) +# BroadcastSuccess Broadcast to the whole server when a refine attempt at this level succeeds. (Default: false) +# BroadcastFailure Broadcast to the whole server when a refine attempt at this level fails. (Default: false) # Chances: Success chance based on cost type. (Default: null) # - Type Refinement cost type based on ore used. # Rate Chance of success out of 0~10000. (Default: 0) @@ -41,7 +43,7 @@ Header: Type: REFINE_DB - Version: 1 + Version: 2 Body: - Group: Armor diff --git a/db/re/refine.yml b/db/re/refine.yml index 0f2de8b8b0..7f9c59dcf4 100644 --- a/db/re/refine.yml +++ b/db/re/refine.yml @@ -30,6 +30,8 @@ # Bonus Refinement bonus. (Default: 0) # RandomBonus Extra refinement bonus of 0~RandomBonus stacked on Bonus. (Default: 0) # BlacksmithBlessingAmount Amount of Blacksmith Blessing required. (Default: 0) +# BroadcastSuccess Broadcast to the whole server when a refine attempt at this level succeeds. (Default: false) +# BroadcastFailure Broadcast to the whole server when a refine attempt at this level fails. (Default: false) # Chances: Success chance based on cost type. (Default: null) # - Type Refinement cost type based on ore used. # Rate Chance of success out of 0~10000. (Default: 0) @@ -41,7 +43,7 @@ Header: Type: REFINE_DB - Version: 1 + Version: 2 Body: - Group: Armor @@ -252,6 +254,8 @@ Body: - Level: 13 Bonus: 2800 BlacksmithBlessingAmount: 16 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -267,6 +271,8 @@ Body: - Level: 14 Bonus: 3200 BlacksmithBlessingAmount: 22 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -281,6 +287,8 @@ Body: DowngradeAmount: 1 - Level: 15 Bonus: 3600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -295,6 +303,8 @@ Body: DowngradeAmount: 1 - Level: 16 Bonus: 4000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -309,6 +319,8 @@ Body: DowngradeAmount: 1 - Level: 17 Bonus: 4500 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -323,6 +335,8 @@ Body: DowngradeAmount: 1 - Level: 18 Bonus: 5000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -337,6 +351,8 @@ Body: DowngradeAmount: 1 - Level: 19 Bonus: 5500 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -351,6 +367,8 @@ Body: DowngradeAmount: 1 - Level: 20 Bonus: 6000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -517,6 +535,8 @@ Body: BreakingRate: 10000 - Level: 13 Bonus: 3360 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -530,6 +550,8 @@ Body: BreakingRate: 10000 - Level: 14 Bonus: 3840 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -543,6 +565,8 @@ Body: BreakingRate: 10000 - Level: 15 Bonus: 4320 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -556,6 +580,8 @@ Body: BreakingRate: 10000 - Level: 16 Bonus: 4800 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -569,6 +595,8 @@ Body: BreakingRate: 10000 - Level: 17 Bonus: 5400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -582,6 +610,8 @@ Body: BreakingRate: 10000 - Level: 18 Bonus: 6000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -595,6 +625,8 @@ Body: BreakingRate: 10000 - Level: 19 Bonus: 6600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -608,6 +640,8 @@ Body: BreakingRate: 10000 - Level: 20 Bonus: 7200 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -824,6 +858,8 @@ Body: Bonus: 2600 RandomBonus: 1800 BlacksmithBlessingAmount: 16 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -840,6 +876,8 @@ Body: Bonus: 2800 RandomBonus: 2100 BlacksmithBlessingAmount: 22 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -855,6 +893,8 @@ Body: - Level: 15 Bonus: 3000 RandomBonus: 2400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -870,6 +910,8 @@ Body: - Level: 16 Bonus: 4800 RandomBonus: 2700 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -885,6 +927,8 @@ Body: - Level: 17 Bonus: 5100 RandomBonus: 3000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -900,6 +944,8 @@ Body: - Level: 18 Bonus: 5400 RandomBonus: 3300 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -915,6 +961,8 @@ Body: - Level: 19 Bonus: 5700 RandomBonus: 3600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -930,6 +978,8 @@ Body: - Level: 20 Bonus: 6000 RandomBonus: 3900 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -1149,6 +1199,8 @@ Body: Bonus: 3900 RandomBonus: 3500 BlacksmithBlessingAmount: 16 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1165,6 +1217,8 @@ Body: Bonus: 4200 RandomBonus: 4000 BlacksmithBlessingAmount: 22 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1180,6 +1234,8 @@ Body: - Level: 15 Bonus: 4500 RandomBonus: 4500 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1195,6 +1251,8 @@ Body: - Level: 16 Bonus: 8000 RandomBonus: 5000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1210,6 +1268,8 @@ Body: - Level: 17 Bonus: 8500 RandomBonus: 5500 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1225,6 +1285,8 @@ Body: - Level: 18 Bonus: 9000 RandomBonus: 6000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1240,6 +1302,8 @@ Body: - Level: 19 Bonus: 9500 RandomBonus: 6500 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -1255,6 +1319,8 @@ Body: - Level: 20 Bonus: 10000 RandomBonus: 7000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -1478,6 +1544,8 @@ Body: Bonus: 6500 RandomBonus: 6400 BlacksmithBlessingAmount: 16 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1494,6 +1562,8 @@ Body: Bonus: 7000 RandomBonus: 7200 BlacksmithBlessingAmount: 22 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1509,6 +1579,8 @@ Body: - Level: 15 Bonus: 7500 RandomBonus: 8000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1800 @@ -1524,6 +1596,8 @@ Body: - Level: 16 Bonus: 11200 RandomBonus: 8800 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1539,6 +1613,8 @@ Body: - Level: 17 Bonus: 11900 RandomBonus: 9600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1554,6 +1630,8 @@ Body: - Level: 18 Bonus: 12600 RandomBonus: 10400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1700 @@ -1569,6 +1647,8 @@ Body: - Level: 19 Bonus: 13300 RandomBonus: 11200 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -1584,6 +1664,8 @@ Body: - Level: 20 Bonus: 14000 RandomBonus: 12000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 1500 @@ -1811,6 +1893,8 @@ Body: Bonus: 9100 RandomBonus: 12600 BlacksmithBlessingAmount: 16 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -1827,6 +1911,8 @@ Body: Bonus: 9800 RandomBonus: 14000 BlacksmithBlessingAmount: 22 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -1842,6 +1928,8 @@ Body: - Level: 15 Bonus: 10500 RandomBonus: 15400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -1857,6 +1945,8 @@ Body: - Level: 16 Bonus: 16000 RandomBonus: 16800 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -1872,6 +1962,8 @@ Body: - Level: 17 Bonus: 17000 RandomBonus: 18200 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -1887,6 +1979,8 @@ Body: - Level: 18 Bonus: 18000 RandomBonus: 19600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -1902,6 +1996,8 @@ Body: - Level: 19 Bonus: 19000 RandomBonus: 21000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -1917,6 +2013,8 @@ Body: - Level: 20 Bonus: 20000 RandomBonus: 22400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -2083,6 +2181,8 @@ Body: BreakingRate: 10000 - Level: 13 Bonus: 10400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -2096,6 +2196,8 @@ Body: BreakingRate: 10000 - Level: 14 Bonus: 11200 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 800 @@ -2109,6 +2211,8 @@ Body: BreakingRate: 10000 - Level: 15 Bonus: 12000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -2122,6 +2226,8 @@ Body: BreakingRate: 10000 - Level: 16 Bonus: 12800 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -2135,6 +2241,8 @@ Body: BreakingRate: 10000 - Level: 17 Bonus: 13600 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -2148,6 +2256,8 @@ Body: BreakingRate: 10000 - Level: 18 Bonus: 14400 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 700 @@ -2161,6 +2271,8 @@ Body: BreakingRate: 10000 - Level: 19 Bonus: 15200 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 @@ -2174,6 +2286,8 @@ Body: BreakingRate: 10000 - Level: 20 Bonus: 16000 + BroadcastSuccess: true + BroadcastFailure: true Chances: - Type: Normal Rate: 500 diff --git a/db/refine.yml b/db/refine.yml index 611b651981..47c5971b97 100644 --- a/db/refine.yml +++ b/db/refine.yml @@ -30,6 +30,8 @@ # Bonus Refinement bonus. (Default: 0) # RandomBonus Extra refinement bonus of 0~RandomBonus stacked on Bonus. (Default: 0) # BlacksmithBlessingAmount Amount of Blacksmith Blessing required. (Default: 0) +# BroadcastSuccess Broadcast to the whole server when a refine attempt at this level succeeds. (Default: false) +# BroadcastFailure Broadcast to the whole server when a refine attempt at this level fails. (Default: false) # Chances: Success chance based on cost type. (Default: null) # - Type Refinement cost type based on ore used. # Rate Chance of success out of 0~10000. (Default: 0) @@ -41,7 +43,7 @@ Header: Type: REFINE_DB - Version: 1 + Version: 2 Footer: Imports: diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 486929eeea..211029cb7a 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -20878,6 +20878,14 @@ void clif_parse_merge_item_cancel(int fd, struct map_session_data* sd) { return; // Nothing todo yet } +static std::string clif_hide_name(const char* original_name) +{ + std::string censored(original_name); + int hide = min(battle_config.broadcast_hide_name, censored.length() - 1); + censored.replace(censored.length() - hide, hide, hide, '*'); + return censored; +} + /** * 07fd .W .B .W .B .24B .B .W (ZC_BROADCASTING_SPECIAL_ITEM_OBTAIN) * 07fd .W .B .W .B .24B .B .24B (ZC_BROADCASTING_SPECIAL_ITEM_OBTAIN) @@ -20888,10 +20896,8 @@ void clif_broadcast_obtain_special_item( const char *char_name, t_itemid nameid, char name[NAME_LENGTH]; if( battle_config.broadcast_hide_name ){ - std::string dispname = std::string( char_name ); - int hide = min( battle_config.broadcast_hide_name, dispname.length() - 1 ); - dispname.replace( dispname.length() - hide, hide, hide, '*' ); - safestrncpy( name, dispname.c_str(), sizeof( name ) ); + std::string dispname = clif_hide_name(char_name); + safestrncpy(name, dispname.c_str(), sizeof(name)); }else{ safestrncpy( name, char_name, sizeof( name ) ); } @@ -22308,6 +22314,9 @@ void clif_parse_refineui_refine( int fd, struct map_session_data* sd ){ log_pick_pc( sd, LOG_TYPE_OTHER, 1, item ); clif_misceffect( &sd->bl, 3 ); clif_refine( fd, 0, index, item->refine ); + if (info->broadcast_success) { + clif_broadcast_refine_result(*sd, item->nameid, item->refine, true); + } if( id->type == IT_WEAPON ){ achievement_update_objective( sd, AG_ENCHANT_SUCCESS, 2, id->weapon_level, item->refine ); } @@ -22315,6 +22324,9 @@ void clif_parse_refineui_refine( int fd, struct map_session_data* sd ){ }else{ // Failure + if (info->broadcast_failure) { + clif_broadcast_refine_result(*sd, item->nameid, item->refine, false); + } // Blacksmith blessings were used to prevent breaking and downgrading if( blacksmith_amount > 0 ){ clif_refine( fd, 3, index, item->refine ); @@ -24593,6 +24605,27 @@ void clif_parse_itempackage_select( int fd, struct map_session_data* sd ){ #endif } +void clif_broadcast_refine_result(map_session_data& sd, t_itemid itemId, int8 level, bool success) +{ +#if PACKETVER_MAIN_NUM >= 20170906 || PACKETVER_RE_NUM >= 20170830 || defined(PACKETVER_ZERO) + PACKET_ZC_BROADCAST_ITEMREFINING_RESULT p{}; + p.packetType = HEADER_ZC_BROADCAST_ITEMREFINING_RESULT; + p.itemId = itemId; + p.refine_level = level; + p.status = (int8)success; + + if (battle_config.broadcast_hide_name) { + std::string dispname = clif_hide_name(sd.status.name); + safestrncpy(p.name, dispname.c_str(), sizeof(p.name)); + } + else { + safestrncpy(p.name, sd.status.name, sizeof(p.name)); + } + + clif_send(&p, sizeof(p), &sd.bl, ALL_CLIENT); +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 71be9d3af0..113963a87a 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -1215,4 +1215,6 @@ void clif_enchantwindow_open( struct map_session_data& sd, uint64 clientLuaIndex // Enchanting Shadow / Shadow Scar Spirit void clif_enchantingshadow_spirit(unit_data &ud); +void clif_broadcast_refine_result(struct map_session_data& sd, t_itemid itemId, int8 level, bool success); + #endif /* CLIF_HPP */ diff --git a/src/map/status.cpp b/src/map/status.cpp index e4b1bc9231..f905e00f06 100644 --- a/src/map/status.cpp +++ b/src/map/status.cpp @@ -230,6 +230,32 @@ uint64 RefineDatabase::parseBodyNode( const ryml::NodeRef& node ){ } } + if (this->nodeExists(refineLevelNode, "BroadcastSuccess")) { + bool bcast; + if (!this->asBool(refineLevelNode, "BroadcastSuccess", bcast)) { + return 0; + } + level_info->broadcast_success = bcast; + } + else { + if (!level_exists) { + level_info->broadcast_success = false; + } + } + + if (this->nodeExists(refineLevelNode, "BroadcastFailure")) { + bool bcast; + if (!this->asBool(refineLevelNode, "BroadcastFailure", bcast)) { + return 0; + } + level_info->broadcast_failure = bcast; + } + else { + if (!level_exists) { + level_info->broadcast_failure = false; + } + } + if( this->nodeExists( refineLevelNode, "Chances" ) ){ const auto& chancesNode = refineLevelNode["Chances"]; for( const auto& chanceNode : chancesNode ){ diff --git a/src/map/status.hpp b/src/map/status.hpp index fe1f6294e5..d738cbae8e 100644 --- a/src/map/status.hpp +++ b/src/map/status.hpp @@ -73,6 +73,8 @@ struct s_refine_level_info{ uint32 bonus; uint32 randombonus_max; uint16 blessing_amount; + bool broadcast_success; + bool broadcast_failure; std::unordered_map> costs; }; @@ -92,7 +94,7 @@ private: std::shared_ptr findLevelInfoSub( const struct item_data& data, struct item& item, uint16 refine ); public: - RefineDatabase() : TypesafeYamlDatabase( "REFINE_DB", 1 ){ + RefineDatabase() : TypesafeYamlDatabase( "REFINE_DB", 2, 1 ){ }