for (int32 i=0; i<lts->NumEntries; i++) {
for (int32 k = 1; k <= lts->Entries[i].multiplier; k++) {
if ( MakeRandomInt(0,99) < lts->Entries[i].probability) {
AddLootDropToNPC(npc,lts->Entries[i].lootdrop_id, itemlist);
}
}
pretty much:
- For each lootdrop entry that exists on the mob we iterate (tied to whatever x loottable).
- Then inside each lootdrop, we iterate x times (multiplier).
- Inside the nested for loop we use a random 0-99, if the value is less than the probability you set, we attempt to spawn an item from that lootdrop.
In AddLootDropToNPC (determine the actual item):
- We add up the all the 'chance' values into totalchance (of each item in lootdrop_entries).
- To hit a good chance (its a RandomInt 0-totalchance). The random value must be chance=0 OR chance=100 OR this is the only item in the table (totalchance=itemchance) OR finally the random value is less than the current item chance. The first item that hits one of these conditions is your result. These should order as they are in the DB (so the first lootdrop_entries entry for this lootdrop in the db is the first item entry we check).
__________________
www.eq2emu.com
EQ2Emu Developer
Former EQEMu Developer / GuildWars / Zek Seasons Servers
Member of the "I hate devn00b" club.
|