Skip to content

Commit

Permalink
Fix monster loot items stages display on bestiary (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKnopik authored Nov 2, 2021
1 parent 23817b3 commit deec0e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/io/iobestiary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ std::list<uint16_t> IOBestiary::getBestiaryFinished(Player* player) const

int8_t IOBestiary::calculateDifficult(uint32_t chance) const
{
chance = chance / 1000;
float chanceInPercent = chance / 1000;

if (chance < 0.2) {
if (chanceInPercent < 0.2) {
return 4;
} else if (chance < 1) {
} else if (chanceInPercent < 1) {
return 3;
} else if (chance < 5) {
} else if (chanceInPercent < 5) {
return 2;
} else if (chance < 25) {
} else if (chanceInPercent < 25) {
return 1;
}
return 0;
Expand Down
28 changes: 26 additions & 2 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,11 +1826,35 @@ void ProtocolGame::parseBestiarysendMonsterData(NetworkMessage &msg)
newmsg.addByte(lootList.size());
for (LootBlock loot : lootList)
{
newmsg.addItemId(currentLevel > 1 ? loot.id : 0);
int8_t difficult = g_bestiary.calculateDifficult(loot.chance);
bool shouldAddItem = false;

switch (currentLevel)
{
case 1:
shouldAddItem = false;
break;
case 2:
if (difficult < 2)
{
shouldAddItem = true;
}
break;
case 3:
if (difficult < 3)
{
shouldAddItem = true;
}
break;
case 4:
shouldAddItem = true;
break;
}

newmsg.addItemId(shouldAddItem == true ? loot.id : 0);
newmsg.addByte(difficult);
newmsg.addByte(0); // 1 if special event - 0 if regular loot (?)
if (currentLevel > 1)
if (shouldAddItem == true)
{
newmsg.addString(loot.name);
newmsg.addByte(loot.countmax > 0 ? 0x1 : 0x0);
Expand Down

0 comments on commit deec0e5

Please sign in to comment.