mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-12 21:11:27 +00:00
Allow creatures to use potions
This commit is contained in:
parent
08ff69f199
commit
0814ef5697
6 changed files with 39 additions and 36 deletions
|
@ -74,6 +74,7 @@
|
||||||
Bug #7557: Terrain::ChunkManager::createChunk is called twice for the same position, lod on initial loading
|
Bug #7557: Terrain::ChunkManager::createChunk is called twice for the same position, lod on initial loading
|
||||||
Bug #7573: Drain Fatigue can't bring fatigue below zero by default
|
Bug #7573: Drain Fatigue can't bring fatigue below zero by default
|
||||||
Bug #7603: Scripts menu size is not updated properly
|
Bug #7603: Scripts menu size is not updated properly
|
||||||
|
Bug #7604: Goblins Grunt becomes idle once injured
|
||||||
Feature #3537: Shader-based water ripples
|
Feature #3537: Shader-based water ripples
|
||||||
Feature #5492: Let rain and snow collide with statics
|
Feature #5492: Let rain and snow collide with statics
|
||||||
Feature #6149: Dehardcode Lua API_REVISION
|
Feature #6149: Dehardcode Lua API_REVISION
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <components/esm3/loadmgef.hpp>
|
#include <components/esm3/loadmgef.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/luamanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
#include "../mwphysics/physicssystem.hpp"
|
#include "../mwphysics/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
#include "../mwworld/worldmodel.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
@ -90,4 +92,15 @@ namespace MWClass
|
||||||
moveSpeed *= 0.75f;
|
moveSpeed *= 0.75f;
|
||||||
return moveSpeed;
|
return moveSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Actor::consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
|
||||||
|
MWMechanics::CastSpell cast(actor, actor);
|
||||||
|
const ESM::RefId& recordId = consumable.getCellRef().getRefId();
|
||||||
|
MWBase::Environment::get().getWorldModel()->registerPtr(consumable);
|
||||||
|
MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor);
|
||||||
|
actor.getClass().getContainerStore(actor).remove(consumable, 1);
|
||||||
|
return cast.cast(recordId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,8 @@ namespace MWClass
|
||||||
/// Return current movement speed.
|
/// Return current movement speed.
|
||||||
float getCurrentSpeed(const MWWorld::Ptr& ptr) const override;
|
float getCurrentSpeed(const MWWorld::Ptr& ptr) const override;
|
||||||
|
|
||||||
|
bool consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const override;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Actor(const Actor&) = delete;
|
Actor(const Actor&) = delete;
|
||||||
Actor& operator=(const Actor&) = delete;
|
Actor& operator=(const Actor&) = delete;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/luamanager.hpp"
|
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
@ -1123,17 +1122,6 @@ namespace MWClass
|
||||||
return getNpcStats(ptr).isWerewolf() ? 0.0f : Actor::getEncumbrance(ptr);
|
return getNpcStats(ptr).isWerewolf() ? 0.0f : Actor::getEncumbrance(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Npc::consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
|
|
||||||
MWMechanics::CastSpell cast(actor, actor);
|
|
||||||
const ESM::RefId& recordId = consumable.getCellRef().getRefId();
|
|
||||||
MWBase::Environment::get().getWorldModel()->registerPtr(consumable);
|
|
||||||
MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor);
|
|
||||||
actor.getClass().getContainerStore(actor).remove(consumable, 1);
|
|
||||||
return cast.cast(recordId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Npc::skillUsageSucceeded(const MWWorld::Ptr& ptr, ESM::RefId skill, int usageType, float extraFactor) const
|
void Npc::skillUsageSucceeded(const MWWorld::Ptr& ptr, ESM::RefId skill, int usageType, float extraFactor) const
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
||||||
|
|
|
@ -114,8 +114,6 @@ namespace MWClass
|
||||||
float getArmorRating(const MWWorld::Ptr& ptr) const override;
|
float getArmorRating(const MWWorld::Ptr& ptr) const override;
|
||||||
///< @return combined armor rating of this actor
|
///< @return combined armor rating of this actor
|
||||||
|
|
||||||
bool consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const override;
|
|
||||||
|
|
||||||
void adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const override;
|
void adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const override;
|
||||||
/// @param rendering Indicates if the scale to adjust is for the rendering mesh, or for the collision mesh
|
/// @param rendering Indicates if the scale to adjust is for the rendering mesh, or for the collision mesh
|
||||||
|
|
||||||
|
|
|
@ -176,10 +176,8 @@ namespace MWMechanics
|
||||||
return bestAction;
|
return bestAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actor.getClass().hasInventoryStore(actor))
|
const bool hasInventoryStore = actor.getClass().hasInventoryStore(actor);
|
||||||
{
|
MWWorld::ContainerStore& store = actor.getClass().getContainerStore(actor);
|
||||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->getType() == ESM::Potion::sRecordId)
|
if (it->getType() == ESM::Potion::sRecordId)
|
||||||
|
@ -192,7 +190,8 @@ namespace MWMechanics
|
||||||
antiFleeRating = std::numeric_limits<float>::max();
|
antiFleeRating = std::numeric_limits<float>::max();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!it->getClass().getEnchantment(*it).empty())
|
// TODO remove inventory store check, creatures should be able to use enchanted items they cannot equip
|
||||||
|
else if (hasInventoryStore && !it->getClass().getEnchantment(*it).empty())
|
||||||
{
|
{
|
||||||
float rating = rateMagicItem(*it, actor, enemy);
|
float rating = rateMagicItem(*it, actor, enemy);
|
||||||
if (rating > bestActionRating)
|
if (rating > bestActionRating)
|
||||||
|
@ -204,6 +203,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasInventoryStore)
|
||||||
|
{
|
||||||
MWWorld::Ptr bestArrow;
|
MWWorld::Ptr bestArrow;
|
||||||
float bestArrowRating = rateAmmo(actor, enemy, bestArrow, ESM::Weapon::Arrow);
|
float bestArrowRating = rateAmmo(actor, enemy, bestArrow, ESM::Weapon::Arrow);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue