mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-21 19:04:42 -04:00
Merge branch 'kelapasawit8123' into 'master'
Make weapon usage less restrictive See merge request OpenMW/openmw!4906
This commit is contained in:
commit
746d4b38ad
@ -146,6 +146,7 @@ namespace MWClass
|
||||
{
|
||||
// Do not allow equip tools from inventory during attack
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc)
|
||||
&& !MWBase::Environment::get().getMechanicsManager()->isCastingSpell(npc)
|
||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return { 0, "#{sCantEquipWeapWarning}" };
|
||||
|
||||
|
@ -144,6 +144,7 @@ namespace MWClass
|
||||
{
|
||||
// Do not allow equip tools from inventory during attack
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc)
|
||||
&& !MWBase::Environment::get().getMechanicsManager()->isCastingSpell(npc)
|
||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return { 0, "#{sCantEquipWeapWarning}" };
|
||||
|
||||
|
@ -270,10 +270,25 @@ namespace MWClass
|
||||
|
||||
std::pair<int, std::string_view> Weapon::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
int type = ptr.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
|
||||
// Do not allow equip weapons from inventory during attack
|
||||
if (npc.isInCell() && MWBase::Environment::get().getWindowManager()->isGuiMode()
|
||||
&& MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc))
|
||||
return { 0, "#{sCantEquipWeapWarning}" };
|
||||
{
|
||||
int activeWeaponType = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(npc, &activeWeaponType);
|
||||
if (activeWeaponType > ESM::Weapon::None || activeWeaponType == ESM::Weapon::HandToHand)
|
||||
{
|
||||
auto* activeWeapon = MWMechanics::getWeaponType(activeWeaponType);
|
||||
bool isAmmo = MWMechanics::getWeaponType(type)->mWeaponClass == ESM::WeaponType::Class::Ammo;
|
||||
bool activeWeapUsesAmmo = activeWeapon->mWeaponClass == ESM::WeaponType::Class::Ranged;
|
||||
bool sameAmmoType = activeWeapon->mAmmoType == type;
|
||||
// special case for ammo equipping
|
||||
if ((activeWeapUsesAmmo && !sameAmmoType) || !isAmmo)
|
||||
return { 0, "#{sCantEquipWeapWarning}" };
|
||||
}
|
||||
}
|
||||
|
||||
if (hasItemHealth(ptr) && getItemHealth(ptr) == 0)
|
||||
return { 0, "#{sInventoryMessage1}" };
|
||||
@ -283,7 +298,6 @@ namespace MWClass
|
||||
if (slots.first.empty())
|
||||
return { 0, {} };
|
||||
|
||||
int type = ptr.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
if (MWMechanics::getWeaponType(type)->mFlags & ESM::WeaponType::TwoHanded)
|
||||
{
|
||||
return { 2, {} };
|
||||
|
@ -325,10 +325,10 @@ namespace MWGui
|
||||
// If we unequip weapon during attack, it can lead to unexpected behaviour
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(mPtr))
|
||||
{
|
||||
bool isWeapon = item.mBase.getType() == ESM::Weapon::sRecordId;
|
||||
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
||||
|
||||
if (isWeapon && invStore.isEquipped(item.mBase))
|
||||
MWWorld::ContainerStoreIterator weapIt = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
bool weapActive = mPtr.getClass().getCreatureStats(mPtr).getDrawState() == MWMechanics::DrawState::Weapon;
|
||||
if (weapActive && weapIt != invStore.end() && *weapIt == item.mBase)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sCantEquipWeapWarning}");
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user