From 84d846cf07c75dc13f3fdf488a1d4dee87ee4865 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 09:16:27 +0200 Subject: [PATCH] Issue #314: implemented apply and skillUsageSucceeded functions for MWClass::Npc --- apps/openmw/mwclass/npc.cpp | 22 ++++++++++++++++++++++ apps/openmw/mwclass/npc.hpp | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d54b9441d..2570408f7 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -343,4 +343,26 @@ namespace MWClass return weight; } + + bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id, + const MWWorld::Ptr& actor) const + { + MWMechanics::CreatureStats& stats = getCreatureStats (ptr); + + /// \todo consider instant effects + + return stats.mActiveSpells.addSpell (id); + } + + void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const + { + MWMechanics::NpcStats& stats = getNpcStats (ptr); + + MWWorld::LiveCellRef *ref = ptr.get(); + + const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( + ref->base->cls); + + stats.useSkill (skill, *class_, usageType); + } } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 4cb733977..74a80c085 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -76,6 +76,15 @@ namespace MWClass ///< Returns total weight of objects inside this object (including modifications from magic /// effects). Throws an exception, if the object can't hold other objects. + virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id, + const MWWorld::Ptr& actor) const; + ///< Apply \a id on \a ptr. + /// \param actor Actor that is resposible for the ID being applied to \a ptr. + /// \return Any effect? + + virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const; + ///< Inform actor \a ptr that a skill use has succeeded. + static void registerSelf(); }; }