diff options
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/localplayer.cpp | 10 | ||||
-rw-r--r-- | src/being/playerinfo.cpp | 53 | ||||
-rw-r--r-- | src/being/playerinfo.h | 10 |
3 files changed, 68 insertions, 5 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ffd2593f0..22a214168 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2349,7 +2349,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const // if sword not equiped if (!item->isEquipped()) - Net::getInventoryHandler()->equipItem(item); + PlayerInfo::equipItem(item); // if need equip shield too if (mAttackWeaponType == 3) @@ -2359,7 +2359,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const if (!item) item = inv->findItem(602, 0); if (item && !item->isEquipped()) - Net::getInventoryHandler()->equipItem(item); + PlayerInfo::equipItem(item); } } // big distance. allowed only bow @@ -2376,7 +2376,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const return; if (!item->isEquipped()) - Net::getInventoryHandler()->equipItem(item); + PlayerInfo::equipItem(item); } } @@ -3981,7 +3981,7 @@ void LocalPlayer::imitateOutfit(Being *const player, const int sprite) const const Item *const item = inv->findItemBySprite(path, player->getGender(), player->getSubType()); if (item && !item->isEquipped()) - Net::getInventoryHandler()->equipItem(item); + PlayerInfo::equipItem(item); } else { @@ -3996,7 +3996,7 @@ void LocalPlayer::imitateOutfit(Being *const player, const int sprite) const if (item) { // logger->log("unequiping"); - Net::getInventoryHandler()->unequipItem(item); + PlayerInfo::unequipItem(item); } } } diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index be9087b77..954cb20f4 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -245,6 +245,59 @@ void setEquipmentBackend(Equipment::Backend *const backend) mEquipment->setBackend(backend); } +void equipItem(const Item *const item) +{ + Net::getInventoryHandler()->equipItem(item); +} + +void unequipItem(const Item *const item) +{ + Net::getInventoryHandler()->unequipItem(item); +} + +void useItem(const Item *const item) +{ + Net::getInventoryHandler()->useItem(item); +} + +void useEquipItem(const Item *const item) +{ + if (item) + { + if (item->isEquipment()) + { + if (item->isEquipped()) + Net::getInventoryHandler()->unequipItem(item); + else + Net::getInventoryHandler()->equipItem(item); + } + else + { + if (mProtectedItems.find(item->getId()) == mProtectedItems.end()) + Net::getInventoryHandler()->useItem(item); + } + } +} + +void useEquipItem2(const Item *const item) +{ + if (item) + { + if (!item->isEquipment()) + { + if (item->isEquipped()) + Net::getInventoryHandler()->unequipItem(item); + else + Net::getInventoryHandler()->equipItem(item); + } + else + { + if (mProtectedItems.find(item->getId()) == mProtectedItems.end()) + Net::getInventoryHandler()->useItem(item); + } + } +} + // --- Misc ------------------------------------------------------------------- void setBackend(const PlayerInfoBackend &backend) diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h index a0b10d4fe..052fbe966 100644 --- a/src/being/playerinfo.h +++ b/src/being/playerinfo.h @@ -255,6 +255,16 @@ namespace PlayerInfo void setEquipmentBackend(Equipment::Backend *const backend); + void equipItem(const Item *const item); + + void unequipItem(const Item *const item); + + void useItem(const Item *const item); + + void useEquipItem(const Item *const item); + + void useEquipItem2(const Item *const item); + void protectItem(const int id); void unprotectItem(const int id); |