Updates map_drops.yml (#7676)
* adjusted the rate in map_drops.yml to 1/100000 instead of 1/10000 Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
parent
8a4b34ef6a
commit
74b2834502
@ -27,7 +27,7 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
# SpecificDrops Drops for specific monsters on this map. (Default: empty)
|
||||
# - Monster Monster name.
|
||||
@ -35,10 +35,10 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
###########################################################################
|
||||
|
||||
Header:
|
||||
Type: MAP_DROP_DB
|
||||
Version: 1
|
||||
Version: 2
|
||||
|
@ -27,7 +27,7 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
# SpecificDrops Drops for specific monsters on this map. (Default: empty)
|
||||
# - Monster Monster name.
|
||||
@ -35,13 +35,13 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
###########################################################################
|
||||
|
||||
Header:
|
||||
Type: MAP_DROP_DB
|
||||
Version: 1
|
||||
Version: 2
|
||||
|
||||
Footer:
|
||||
Imports:
|
||||
|
@ -27,7 +27,7 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
# SpecificDrops Drops for specific monsters on this map. (Default: empty)
|
||||
# - Monster Monster name.
|
||||
@ -35,10 +35,10 @@
|
||||
# These drops are unaffected by server drop rate and cannot be stolen.
|
||||
# - Index Unique index of the drop.
|
||||
# Item Item name.
|
||||
# Rate Drop rate of item.
|
||||
# Rate Drop rate of item, n/100000.
|
||||
# RandomOptionGroup Random Option Group applied to item on drop. (Default: None)
|
||||
###########################################################################
|
||||
|
||||
Header:
|
||||
Type: MAP_DROP_DB
|
||||
Version: 1
|
||||
Version: 2
|
||||
|
@ -43,6 +43,3 @@ int32 rnd_value( int32 min, int32 max ){
|
||||
return min + (int32)( rnd_uniform() * ( max - min + 1 ) );
|
||||
}
|
||||
|
||||
bool rnd_chance( uint16 chance, uint16 base ){
|
||||
return rnd_value( 0, base ) < chance;
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ void rnd_init(void);
|
||||
|
||||
int32 rnd(void);// [0, SINT32_MAX]
|
||||
int32 rnd_value(int32 min, int32 max);// [min, max]
|
||||
bool rnd_chance( uint16 chance, uint16 base );
|
||||
|
||||
template <typename T> bool rnd_chance( T chance, T base ){
|
||||
return rnd_value( 0, base ) < chance;
|
||||
}
|
||||
|
||||
#endif /* RANDOM_HPP */
|
||||
|
@ -2904,8 +2904,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
if( mapdrops != nullptr ){
|
||||
// Process map wide drops
|
||||
for( const auto& it : mapdrops->globals ){
|
||||
if( rnd_chance( it.second->rate, 10000 ) ){
|
||||
mob_item_drop( md, dlist, mob_setdropitem( it.second.get(), 1, md->mob_id ), 0, it.second->rate, homkillonly || merckillonly );
|
||||
if( rnd_chance( it.second->rate, 100000u ) ){
|
||||
// 'Cheat' for autoloot command: rate is changed from n/100000 to n/10000
|
||||
int32 map_drops_rate = max(1, (it.second->rate / 10));
|
||||
mob_item_drop( md, dlist, mob_setdropitem( it.second.get(), 1, md->mob_id ), 0, map_drops_rate, (homkillonly || merckillonly) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -2914,8 +2916,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
|
||||
if( specific != mapdrops->specific.end() ){
|
||||
for( const auto& it : specific->second ){
|
||||
if( rnd_chance( it.second->rate, 10000 ) ){
|
||||
mob_item_drop( md, dlist, mob_setdropitem( it.second.get(), 1, md->mob_id ), 0, it.second->rate, homkillonly || merckillonly );
|
||||
if( rnd_chance( it.second->rate, 100000u ) ){
|
||||
// 'Cheat' for autoloot command: rate is changed from n/100000 to n/10000
|
||||
int32 map_drops_rate = max(1, (it.second->rate / 10));
|
||||
mob_item_drop( md, dlist, mob_setdropitem( it.second.get(), 1, md->mob_id ), 0, map_drops_rate, (homkillonly || merckillonly) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6501,9 +6505,9 @@ bool MapDropDatabase::parseDrop( const ryml::NodeRef& node, std::unordered_map<u
|
||||
}
|
||||
|
||||
if( this->nodeExists( node, "Rate" ) ){
|
||||
uint16 rate;
|
||||
uint32 rate;
|
||||
|
||||
if( !this->asUInt16Rate( node, "Rate", rate ) ){
|
||||
if( !this->asUInt32Rate( node, "Rate", rate, 100000 ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -6512,11 +6516,11 @@ bool MapDropDatabase::parseDrop( const ryml::NodeRef& node, std::unordered_map<u
|
||||
drops.erase( index );
|
||||
return true;
|
||||
}else{
|
||||
this->invalidWarning( node["Rate"], "Rate %" PRIu16 " is below minimum of 1.\n", rate );
|
||||
this->invalidWarning( node["Rate"], "Rate %" PRIu32 " is below minimum of 1.\n", rate );
|
||||
return false;
|
||||
}
|
||||
}else if( rate > 10000 ){
|
||||
this->invalidWarning( node["Rate"], "Rate %" PRIu16 " exceeds maximum of 10000.\n", rate );
|
||||
}else if( rate > 100000 ){
|
||||
this->invalidWarning( node["Rate"], "Rate %" PRIu32 " exceeds maximum of 100000.\n", rate );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ struct s_map_drops{
|
||||
|
||||
class MapDropDatabase : public TypesafeYamlDatabase<uint16, s_map_drops>{
|
||||
public:
|
||||
MapDropDatabase() : TypesafeYamlDatabase( "MAP_DROP_DB", 1 ){
|
||||
MapDropDatabase() : TypesafeYamlDatabase( "MAP_DROP_DB", 2 ){
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ static bool upgrade_achievement_db(std::string file, const uint32 source_version
|
||||
static bool upgrade_item_db(std::string file, const uint32 source_version);
|
||||
static bool upgrade_job_stats(std::string file, const uint32 source_version);
|
||||
static bool upgrade_status_db(std::string file, const uint32 source_version);
|
||||
static bool upgrade_map_drops_db(std::string file, const uint32 source_version);
|
||||
|
||||
template<typename Func>
|
||||
bool process(const std::string &type, uint32 version, const std::vector<std::string> &paths, const std::string &name, Func lambda) {
|
||||
@ -130,6 +131,12 @@ bool YamlUpgradeTool::initialize( int argc, char* argv[] ){
|
||||
})) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!process("MAP_DROP_DB", 2, root_paths, "map_drops", [](const std::string& path, const std::string& name_ext, uint32 source_version) -> bool {
|
||||
return upgrade_map_drops_db(path + name_ext, source_version);
|
||||
})) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -322,6 +329,43 @@ static bool upgrade_status_db(std::string file, const uint32 source_version) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool upgrade_map_drops_db(std::string file, const uint32 source_version) {
|
||||
size_t entries = 0;
|
||||
|
||||
for( auto input : inNode["Body"] ){
|
||||
// If under version 2, adjust the rates from n/10000 to n/100000
|
||||
if( source_version < 2 ){
|
||||
if (input["GlobalDrops"].IsDefined()) {
|
||||
for( auto GlobalDrops : input["GlobalDrops"] ){
|
||||
if (GlobalDrops["Rate"].IsDefined()) {
|
||||
uint32 val = GlobalDrops["Rate"].as<uint32>() * 10;
|
||||
GlobalDrops["Rate"] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input["SpecificDrops"].IsDefined()) {
|
||||
for( auto SpecificDrops : input["SpecificDrops"] ){
|
||||
if (SpecificDrops["Drops"].IsDefined()) {
|
||||
for( auto Drops : SpecificDrops["Drops"] ){
|
||||
if (Drops["Rate"].IsDefined()) {
|
||||
uint32 val = Drops["Rate"].as<uint32>() * 10;
|
||||
Drops["Rate"] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body << input;
|
||||
entries++;
|
||||
}
|
||||
|
||||
ShowStatus("Done converting/upgrading '" CL_WHITE "%zu" CL_RESET "' rates in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] ){
|
||||
return main_core<YamlUpgradeTool>( argc, argv );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user