fix rune charges display when using hotkey. Add minimap scan talkaction. Add znoteshop talkaction.

This commit is contained in:
ErikasKontenis
2020-01-19 14:18:08 +02:00
parent 544a6b34a4
commit 80a7d99866
6 changed files with 289 additions and 4 deletions

View File

@@ -324,7 +324,14 @@ bool Actions::useItem(Player* player, const Position& pos, uint8_t index, Item*
player->stopWalk();
if (isHotkey) {
showUseHotkeyMessage(player, item, player->getItemTypeCount(item->getID(), (!item->getFluidType() ? -1 : item->getSubType())));
uint32_t count = 0;
if (item->isRune()) {
count = player->getRuneCount(item->getID());
} else {
count = player->getItemTypeCount(item->getID(), (!item->getFluidType() ? -1 : item->getSubType()));
}
showUseHotkeyMessage(player, item, count);
}
ReturnValue ret = internalUseItem(player, pos, index, item, isHotkey);
@@ -354,7 +361,15 @@ bool Actions::useItemEx(Player* player, const Position& fromPos, const Position&
}
if (isHotkey) {
showUseHotkeyMessage(player, item, player->getItemTypeCount(item->getID(), (!item->getFluidType() ? -1 : item->getSubType())));
uint32_t count = 0;
if (item->isRune()) {
count = player->getRuneCount(item->getID());
}
else {
count = player->getItemTypeCount(item->getID(), (!item->getFluidType() ? -1 : item->getSubType()));
}
showUseHotkeyMessage(player, item, count);
}
if (!action->executeUse(player, item, fromPos, action->getTarget(player, creature, toPos, toStackPos), toPos, isHotkey)) {

View File

@@ -2540,6 +2540,31 @@ uint32_t Player::getItemTypeCount(uint16_t itemId, int32_t subType /*= -1*/) con
return count;
}
// 7.8 mechanics to count runes by charges requires different logic to be implemented
uint32_t Player::getRuneCount(uint16_t itemId) const
{
uint32_t count = 0;
for (int32_t i = CONST_SLOT_FIRST; i <= CONST_SLOT_LAST; i++) {
Item* item = inventory[i];
if (!item) {
continue;
}
if (item->getID() == itemId) {
count += item->getCharges();
}
if (Container* container = item->getContainer()) {
for (ContainerIterator it = container->iterator(); it.hasNext(); it.advance()) {
if ((*it)->getID() == itemId) {
count += (*it)->getCharges();
}
}
}
}
return count;
}
bool Player::removeItemOfType(uint16_t itemId, uint32_t amount, int32_t subType, bool ignoreEquipped/* = false*/) const
{
if (amount == 0) {

View File

@@ -972,6 +972,7 @@ class Player final : public Creature, public Cylinder
size_t getFirstIndex() const final;
size_t getLastIndex() const final;
uint32_t getItemTypeCount(uint16_t itemId, int32_t subType = -1) const final;
uint32_t getRuneCount(uint16_t itemId) const;
std::map<uint32_t, uint32_t>& getAllItemTypeCount(std::map<uint32_t, uint32_t>& countMap) const final;
Thing* getThing(size_t index) const final;