mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 15:45:37 +00:00
Merge branch 'goblinsnacks' into 'master'
Allow creatures to use potions Closes #7604 See merge request OpenMW/openmw!3469
This commit is contained in:
commit
d9f8757f33
@ -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,34 +176,35 @@ 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);
|
||||||
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
if (it->getType() == ESM::Potion::sRecordId)
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
|
||||||
{
|
{
|
||||||
if (it->getType() == ESM::Potion::sRecordId)
|
float rating = ratePotion(*it, actor);
|
||||||
|
if (rating > bestActionRating)
|
||||||
{
|
{
|
||||||
float rating = ratePotion(*it, actor);
|
bestActionRating = rating;
|
||||||
if (rating > bestActionRating)
|
bestAction = std::make_unique<ActionPotion>(*it);
|
||||||
{
|
antiFleeRating = std::numeric_limits<float>::max();
|
||||||
bestActionRating = rating;
|
|
||||||
bestAction = std::make_unique<ActionPotion>(*it);
|
|
||||||
antiFleeRating = std::numeric_limits<float>::max();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!it->getClass().getEnchantment(*it).empty())
|
|
||||||
{
|
|
||||||
float rating = rateMagicItem(*it, actor, enemy);
|
|
||||||
if (rating > bestActionRating)
|
|
||||||
{
|
|
||||||
bestActionRating = rating;
|
|
||||||
bestAction = std::make_unique<ActionEnchantedItem>(it);
|
|
||||||
antiFleeRating = std::numeric_limits<float>::max();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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);
|
||||||
|
if (rating > bestActionRating)
|
||||||
|
{
|
||||||
|
bestActionRating = rating;
|
||||||
|
bestAction = std::make_unique<ActionEnchantedItem>(it);
|
||||||
|
antiFleeRating = std::numeric_limits<float>::max();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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…
x
Reference in New Issue
Block a user