diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index afdc7daab..af903657f 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -75,6 +75,26 @@ void MechanicsHelper::spawnLeveledCreatures(MWWorld::CellStore* cellStore) objectList->sendObjectSpawn(); } +bool MechanicsHelper::isUsingRangedWeapon(const MWWorld::Ptr& ptr) +{ + if (ptr.getClass().hasInventoryStore(ptr)) + { + MWWorld::InventoryStore &inventoryStore = ptr.getClass().getInventoryStore(ptr); + MWWorld::ContainerStoreIterator weaponSlot = inventoryStore.getSlot( + MWWorld::InventoryStore::Slot_CarriedRight); + + if (weaponSlot != inventoryStore.end()) + { + const ESM::Weapon* weaponRecord = weaponSlot->get()->mBase; + + if (weaponRecord->mData.mType >= ESM::Weapon::MarksmanBow) + return true; + } + } + + return false; +} + Attack *MechanicsHelper::getLocalAttack(const MWWorld::Ptr& ptr) { if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) diff --git a/apps/openmw/mwmp/MechanicsHelper.hpp b/apps/openmw/mwmp/MechanicsHelper.hpp index fd1c50a1c..6fa490384 100644 --- a/apps/openmw/mwmp/MechanicsHelper.hpp +++ b/apps/openmw/mwmp/MechanicsHelper.hpp @@ -15,6 +15,8 @@ namespace MechanicsHelper void spawnLeveledCreatures(MWWorld::CellStore* cellStore); + bool isUsingRangedWeapon(const MWWorld::Ptr& ptr); + mwmp::Attack *getLocalAttack(const MWWorld::Ptr& ptr); mwmp::Attack *getDedicatedAttack(const MWWorld::Ptr& ptr);