From 2f8221773007aa913e04da8aad2fe00b20aba8a2 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 3 Mar 2023 21:18:44 -0300 Subject: Change behavior from item chains so it loops through the whole chain. The rarity should be ordered from most precious to least precious in chains. If an item has 100% drop chance, no item below it will ever drop. --- src/map/itemdb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/map') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index b016af1c9..cbb7a0a1e 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -226,14 +226,19 @@ static int itemdb_chain_item(unsigned short chain_id, int *rate) return UNKNOWN_ITEM_ID; } - entry = &itemdb->chains[chain_id].items[ rnd()%itemdb->chains[chain_id].qty ]; + // [TMW2] Loop through the item chain + for (short i = 0; i < itemdb->chains[chain_id].qty ; i++) { + entry = &itemdb->chains[chain_id].items[ i ]; - if( rnd()%10000 >= entry->rate ) - return 0; + if( rnd()%10000 >= entry->rate ) + continue; - if( rate ) - rate[0] = entry->rate; - return entry->id; + if ( rate ) + rate[0] = entry->rate; + return entry->id; + } + + return 0; } /* [Ind/Hercules] */ static void itemdb_package_item(struct map_session_data *sd, struct item_package *package) -- cgit v1.2.3-60-g2f50