Skip to content

Commit

Permalink
Quiver checking for ammunition level (#297)
Browse files Browse the repository at this point in the history
Description
Added check for minReqLevel of ammunitions in quiver both for total count of arrow as well as to select which ammunition to use

Actual behaviour
Quiver ignore level requirement as stated in #77

Expected behaviour
Quiver actually doesn't throw ammunitions which has higher level requirement than player level
  • Loading branch information
andersonfaaria committed Apr 17, 2022
1 parent 905f774 commit f50096b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/creatures/players/player.cpp
Expand Up @@ -242,9 +242,11 @@ Item* Player::getWeapon(Slots_t slot, bool ignoreAmmo) const
bool found = false;
for (Item* ammoItem : container->getItemList()) {
if (ammoItem->getAmmoType() == it.ammoType) {
item = ammoItem;
found = true;
break;
if (level >= Item::items[ammoItem->getID()].minReqLevel) {
item = ammoItem;
found = true;
break;
}
}
}
if (!found)
Expand Down
4 changes: 3 additions & 1 deletion src/server/network/protocol/protocolgame.cpp
Expand Up @@ -143,7 +143,9 @@ void ProtocolGame::AddItem(NetworkMessage &msg, const Item *item)
if (container && item->getWeaponType() == WEAPON_QUIVER && player->getThing(CONST_SLOT_RIGHT) == item) {
uint16_t ammoTotal = 0;
for (Item* listItem : container->getItemList()) {
ammoTotal += listItem->getItemCount();
if (player->getLevel() >= Item::items[listItem->getID()].minReqLevel) {
ammoTotal += listItem->getItemCount();
}
}
msg.addByte(0x01);
msg.add<uint32_t>(ammoTotal);
Expand Down

0 comments on commit f50096b

Please sign in to comment.