From 46e028c3ec13e05fc2012d7380efcf8d9e9be65d Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 9 Jul 2026 07:06:25 +0200 Subject: [PATCH] Fix item-drop selection off-by-one and double/slow-drop config defaults GetNewDrop's weighted item-index selection used a do-while that increments before its first RunningTotal check, so index 0 (the first item slot in every drop table) could never be selected -- for the 51 drop tables that only populate item slot 1 (all others zero), this silently discarded every roll ("item at itemindex does not exist"), so those mobs/maps never dropped an item at all. Switch to a pre-check while loop so index 0 is reachable. Also: battle.cpp's kill-drop loop runs GetDrop()/AddDrop() exactly Stats->itemdroprate + Config.DROP_RATE times, not as a probability -- with the shipped drop_rate=2 every kill produced two independently rolled drops (hence always-doubled Zuly boxes for characters with no item-drop-rate gear). Default drop_rate to 1 so a kill yields one roll by default; gear/GM commands that raise itemdroprate still grant extra rolls as designed. Also default dropdelay to 0: the killed-monster's loot became visible to clients only after Config.DropDelay (1s) *plus* the next VisualDelay tick (200ms), giving a ~1.2s lag before drops appeared. Co-Authored-By: Claude Sonnet 5 --- Src/World Server/ServerFunctions.cpp | 3 +-- database sql files/KTRose_DB.sql | 2 +- database sql files/list_config.sql | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Src/World Server/ServerFunctions.cpp b/Src/World Server/ServerFunctions.cpp index 02d09a2..9e78ef1 100644 --- a/Src/World Server/ServerFunctions.cpp +++ b/Src/World Server/ServerFunctions.cpp @@ -238,7 +238,7 @@ CDrop* CWorldServer::GetNewDrop( CMonster* thismon ) //} i=0; - do + while (i < 49 && randitem > thisdrop->RunningTotal[i]) { //if( thisclient->Session->codedebug ) //{ @@ -246,7 +246,6 @@ CDrop* CWorldServer::GetNewDrop( CMonster* thismon ) //} i++; } - while (randitem > thisdrop->RunningTotal[i]); itemindex = i; if(thisdrop->item[itemindex] == 0) diff --git a/database sql files/KTRose_DB.sql b/database sql files/KTRose_DB.sql index 0bb5297..1b5f72b 100644 --- a/database sql files/KTRose_DB.sql +++ b/database sql files/KTRose_DB.sql @@ -290,7 +290,7 @@ CREATE TABLE IF NOT EXISTS `list_config` ( -- INSERT INTO `list_config` (`exp_rate`, `kill_on_fail`, `drop_rate`, `zuly_rate`, `blue_chance`, `slot_chance`, `stat_chance`, `refine_chance`, `rare_refine`, `conf`, `player_damage`, `monster_damage`, `player_acc`, `monster_acc`, `pvp_acc`, `skill_damage`, `maxlevel`, `spawntype`, `dropmultiple`, `massexport`, `attkmult`, `skillmult`, `dropdelay`, `basedroprate`, `ktpointrate`, `movespeedmod`, `greydrop`) VALUES -(1, 0, 2, 3, 15, 5, 15, 5, 0, 'default', 100, 100, 100, 100, 100, 100, 255, 1, 5, 1, 160, 100, 1, 20, 2, 72, 0); +(1, 0, 1, 3, 15, 5, 15, 5, 0, 'default', 100, 100, 100, 100, 100, 100, 255, 1, 5, 1, 160, 100, 0, 20, 2, 72, 0); -- -------------------------------------------------------- diff --git a/database sql files/list_config.sql b/database sql files/list_config.sql index cb4a02a..2ef8c6f 100644 --- a/database sql files/list_config.sql +++ b/database sql files/list_config.sql @@ -55,4 +55,4 @@ CREATE TABLE IF NOT EXISTS `list_config` ( -- INSERT INTO `list_config` (`exp_rate`, `kill_on_fail`, `drop_rate`, `zuly_rate`, `blue_chance`, `slot_chance`, `stat_chance`, `refine_chance`, `rare_refine`, `conf`, `player_damage`, `monster_damage`, `player_acc`, `monster_acc`, `pvp_acc`, `skill_damage`, `maxlevel`, `spawntype`, `dropmultiple`, `massexport`, `attkmult`, `skillmult`, `dropdelay`, `basedroprate`, `ktpointrate`, `movespeedmod`, `greydrop`) VALUES -(1, 0, 2, 3, 15, 5, 15, 5, 0, 'default', 100, 100, 100, 100, 100, 100, 255, 1, 5, 1, 160, 100, 1, 20, 2, 72, 0); +(1, 0, 1, 3, 15, 5, 15, 5, 0, 'default', 100, 100, 100, 100, 100, 100, 255, 1, 5, 1, 160, 100, 0, 20, 2, 72, 0);