summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2023-03-03 21:18:44 -0300
committerJesusaves <cpntb1@ymail.com>2023-03-03 21:18:44 -0300
commit2f8221773007aa913e04da8aad2fe00b20aba8a2 (patch)
treec049a65fa54f35fcdc2d4f74e6a311239db0f983
parent1997ab7cb6994dcc0a48e1247e814a3f76f345e4 (diff)
downloadhercules-2f8221773007aa913e04da8aad2fe00b20aba8a2.tar.gz
hercules-2f8221773007aa913e04da8aad2fe00b20aba8a2.tar.bz2
hercules-2f8221773007aa913e04da8aad2fe00b20aba8a2.tar.xz
hercules-2f8221773007aa913e04da8aad2fe00b20aba8a2.zip
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.
-rw-r--r--src/map/itemdb.c17
1 files changed, 11 insertions, 6 deletions
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)