2012-07-13 07:41:38 +00:00
|
|
|
|
|
|
|
#include "actionapply.hpp"
|
|
|
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
2014-05-12 00:20:56 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2014-06-16 18:23:57 +00:00
|
|
|
#include "../mwworld/containerstore.hpp"
|
|
|
|
|
2012-07-13 07:41:38 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2014-06-16 18:23:57 +00:00
|
|
|
ActionApply::ActionApply (const Ptr& object, const std::string& id)
|
|
|
|
: Action (false, object), mId (id)
|
2012-07-13 07:41:38 +00:00
|
|
|
{}
|
|
|
|
|
2012-07-27 10:00:10 +00:00
|
|
|
void ActionApply::executeImp (const Ptr& actor)
|
2012-07-13 07:41:38 +00:00
|
|
|
{
|
2014-05-12 00:20:56 +00:00
|
|
|
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
|
|
|
|
|
2014-06-16 18:23:57 +00:00
|
|
|
actor.getClass().apply (actor, mId, actor);
|
|
|
|
|
|
|
|
actor.getClass().getContainerStore(actor).remove(getTarget(), 1, actor);
|
2012-07-13 07:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-16 18:23:57 +00:00
|
|
|
ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& object, const std::string& id,
|
2012-07-27 10:00:10 +00:00
|
|
|
int skillIndex, int usageType)
|
2014-06-16 18:23:57 +00:00
|
|
|
: Action (false, object), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
|
2012-07-13 07:41:38 +00:00
|
|
|
{}
|
|
|
|
|
2012-07-27 10:00:10 +00:00
|
|
|
void ActionApplyWithSkill::executeImp (const Ptr& actor)
|
2012-07-13 07:41:38 +00:00
|
|
|
{
|
2014-05-12 00:20:56 +00:00
|
|
|
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
|
|
|
|
|
2014-06-16 18:23:57 +00:00
|
|
|
if (actor.getClass().apply (actor, mId, actor) && mUsageType!=-1)
|
|
|
|
actor.getClass().skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
|
|
|
|
|
|
|
actor.getClass().getContainerStore(actor).remove(getTarget(), 1, actor);
|
2012-07-13 07:41:38 +00:00
|
|
|
}
|
|
|
|
}
|