mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:23:53 +00:00
Fix AiCombat exception when actor has a lockpick/probe equipped.
Don't make NPCs autoEquip lockpicks/probes, since they can't use them.
This commit is contained in:
parent
136813a882
commit
1444cd9051
2 changed files with 11 additions and 2 deletions
|
@ -250,6 +250,9 @@ namespace MWMechanics
|
|||
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
||||
actorCls.getCreatureStats(actor).setDrawState(MWMechanics::DrawState_Weapon);
|
||||
|
||||
// TODO: Check equipped weapon and equip a different one if we can't attack with it
|
||||
// (e.g. no ammunition, or wrong type of ammunition equipped, etc. autoEquip is not very smart in this regard))
|
||||
|
||||
//Get weapon speed and range
|
||||
MWWorld::ContainerStoreIterator weaponSlot =
|
||||
MWMechanics::getActiveWeapon(actorCls.getCreatureStats(actor), actorCls.getInventoryStore(actor), &weaptype);
|
||||
|
@ -260,8 +263,9 @@ namespace MWMechanics
|
|||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
weapRange = gmst.find("fHandToHandReach")->getFloat();
|
||||
}
|
||||
else
|
||||
else if (weaptype != WeapType_PickProbe && weaptype != WeapType_Spell)
|
||||
{
|
||||
// All other WeapTypes are actually weapons, so get<ESM::Weapon> is safe.
|
||||
weapon = weaponSlot->get<ESM::Weapon>()->mBase;
|
||||
weapRange = weapon->mData.mReach;
|
||||
weapSpeed = weapon->mData.mSpeed;
|
||||
|
|
|
@ -192,12 +192,17 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
|||
{
|
||||
Ptr test = *iter;
|
||||
|
||||
// Don't autoEquip lights
|
||||
// Don't autoEquip lights. Handled in Actors::updateEquippedLight based on environment light.
|
||||
if (test.getTypeName() == typeid(ESM::Light).name())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't auto-equip probes or lockpicks. NPCs can't use them (yet). And AiCombat would attempt to "attack" with them.
|
||||
// NOTE: In the future AiCombat should handle equipping appropriate weapons
|
||||
if (test.getTypeName() == typeid(ESM::Lockpick).name() || test.getTypeName() == typeid(ESM::Probe).name())
|
||||
continue;
|
||||
|
||||
// Only autoEquip if we are the original owner of the item.
|
||||
// This stops merchants from auto equipping anything you sell to them.
|
||||
// ...unless this is a companion, he should always equip items given to him.
|
||||
|
|
Loading…
Reference in a new issue