From 5a533a7a12efc349c53c74e3376a2b6a3e4cb151 Mon Sep 17 00:00:00 2001 From: Singe Horizontal <62802903+Singe-Horizontal@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:23:00 +0100 Subject: [PATCH] Fixes drop rate for size-moded mobs (#7482) * Fixes #7481. * Restores correct drop rate for spawned size-modified monsters so that they read the current memory instead of the database value if changed. --- src/map/mob.cpp | 11 ++++++----- src/map/mob.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 5d59817a8b..735510c1e6 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -2456,14 +2456,15 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) * @param drop_modifier: RENEWAL_DROP level modifier * @return Modified drop rate */ -int mob_getdroprate(struct block_list *src, std::shared_ptr mob, int base_rate, int drop_modifier) +int mob_getdroprate(struct block_list *src, std::shared_ptr mob, int base_rate, int drop_modifier, mob_data* md) { int drop_rate = base_rate; - if (battle_config.mob_size_influence) { // Change drops depending on monsters size [Valaris] - if (mob->status.size == SZ_MEDIUM && drop_rate >= 2) + if (md && battle_config.mob_size_influence) { // Change drops depending on monsters size [Valaris] + unsigned int mob_size = md->special_state.size; + if (mob_size == SZ_MEDIUM && drop_rate >= 2) drop_rate /= 2; // SZ_MEDIUM actually is small size modification... this is not a bug! - else if (mob->status.size == SZ_BIG) + else if (mob_size == SZ_BIG) drop_rate *= 2; } @@ -2809,7 +2810,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if ( it == nullptr ) continue; - drop_rate = mob_getdroprate(src, md->db, md->db->dropitem[i].rate, drop_modifier); + drop_rate = mob_getdroprate(src, md->db, md->db->dropitem[i].rate, drop_modifier, md); // attempt to drop the item if (rnd() % 10000 >= drop_rate) diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 865f6d9665..6c280c6d3d 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -547,7 +547,7 @@ void mob_add_spawn(uint16 mob_id, const struct spawn_info& new_spawn); const std::vector mob_get_spawns(uint16 mob_id); bool mob_has_spawn(uint16 mob_id); -int mob_getdroprate(struct block_list *src, std::shared_ptr mob, int base_rate, int drop_modifier); +int mob_getdroprate(struct block_list *src, std::shared_ptr mob, int base_rate, int drop_modifier, mob_data* md = nullptr); // MvP Tomb System int mvptomb_setdelayspawn(struct npc_data *nd);