1 #include "actionapply.hpp" 2 3 #include "class.hpp" 4 5 #include "../mwbase/environment.hpp" 6 #include "../mwbase/world.hpp" 7 8 #include "../mwworld/containerstore.hpp" 9 10 #include "../mwmechanics/actorutil.hpp" 11 12 namespace MWWorld 13 { ActionApply(const Ptr & object,const std::string & id)14 ActionApply::ActionApply (const Ptr& object, const std::string& id) 15 : Action (false, object), mId (id) 16 {} 17 executeImp(const Ptr & actor)18 void ActionApply::executeImp (const Ptr& actor) 19 { 20 MWBase::Environment::get().getWorld()->breakInvisibility(actor); 21 22 actor.getClass().apply (actor, mId, actor); 23 24 actor.getClass().getContainerStore(actor).remove(getTarget(), 1, actor); 25 } 26 27 ActionApplyWithSkill(const Ptr & object,const std::string & id,int skillIndex,int usageType)28 ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& object, const std::string& id, 29 int skillIndex, int usageType) 30 : Action (false, object), mId (id), mSkillIndex (skillIndex), mUsageType (usageType) 31 {} 32 executeImp(const Ptr & actor)33 void ActionApplyWithSkill::executeImp (const Ptr& actor) 34 { 35 MWBase::Environment::get().getWorld()->breakInvisibility(actor); 36 37 if (actor.getClass().apply (actor, mId, actor) && mUsageType!=-1 && actor == MWMechanics::getPlayer()) 38 actor.getClass().skillUsageSucceeded (actor, mSkillIndex, mUsageType); 39 40 actor.getClass().getContainerStore(actor).remove(getTarget(), 1, actor); 41 } 42 } 43