Added MWMechanics::isPlayerInCombat()

sceneinput
dteviot 9 years ago
parent 84e1801bbc
commit e9c796166a

@ -3,10 +3,17 @@
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp"
namespace MWMechanics
{
MWWorld::Ptr getPlayer()
{
return MWBase::Environment::get().getWorld()->getPlayerPtr();
}
bool isPlayerInCombat()
{
return MWBase::Environment::get().getWorld()->getPlayer().isInCombat();
}
}

@ -9,6 +9,7 @@ namespace MWWorld
namespace MWMechanics
{
MWWorld::Ptr getPlayer();
bool isPlayerInCombat();
}
#endif

@ -927,7 +927,7 @@ namespace MWMechanics
return true;
}
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) {
if(MWMechanics::isPlayerInCombat()) {
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}");
return true;
}

@ -5,15 +5,16 @@
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWWorld
{
void ActionAlchemy::executeImp (const Ptr& actor)
{
if (actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor != MWMechanics::getPlayer())
return;
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) { //Ensure we're not in combat
if(MWMechanics::isPlayerInCombat()) { //Ensure we're not in combat
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage3}");
return;
}

@ -7,6 +7,8 @@
#include "../mwworld/containerstore.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWWorld
{
ActionApply::ActionApply (const Ptr& object, const std::string& id)
@ -32,7 +34,7 @@ namespace MWWorld
{
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
if (actor.getClass().apply (actor, mId, actor) && mUsageType!=-1 && actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor.getClass().apply (actor, mId, actor) && mUsageType!=-1 && actor == MWMechanics::getPlayer())
actor.getClass().skillUsageSucceeded (actor, mSkillIndex, mUsageType);
actor.getClass().getContainerStore(actor).remove(getTarget(), 1, actor);

@ -7,6 +7,8 @@
#include "../mwworld/containerstore.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "class.hpp"
namespace MWWorld
@ -19,7 +21,7 @@ namespace MWWorld
// apply to actor
std::string id = getTarget().getClass().getId (getTarget());
if (actor.getClass().apply (actor, id, actor) && actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor.getClass().apply (actor, id, actor) && actor == MWMechanics::getPlayer())
actor.getClass().skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
}

@ -5,6 +5,7 @@
#include "../mwbase/world.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "player.hpp"
#include "class.hpp"
@ -18,11 +19,11 @@ namespace MWWorld
void ActionRead::executeImp (const MWWorld::Ptr& actor) {
if (actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor != MWMechanics::getPlayer())
return;
//Ensure we're not in combat
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()
if(MWMechanics::isPlayerInCombat()
// Reading in combat is still allowed if the scroll/book is not in the player inventory yet
// (since otherwise, there would be no way to pick it up)
&& getTarget().getContainerStore() == &actor.getClass().getContainerStore(actor)

@ -4,6 +4,7 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWWorld
{
@ -14,10 +15,10 @@ namespace MWWorld
void ActionRepair::executeImp (const Ptr& actor)
{
if (actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor != MWMechanics::getPlayer())
return;
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) {
if(MWMechanics::isPlayerInCombat()) {
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage2}");
return;
}

@ -4,6 +4,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWWorld
{
@ -16,10 +17,10 @@ namespace MWWorld
void ActionSoulgem::executeImp(const Ptr &actor)
{
if (actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
if (actor != MWMechanics::getPlayer())
return;
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) { //Ensure we're not in combat
if(MWMechanics::isPlayerInCombat()) { //Ensure we're not in combat
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage5}");
return;
}

Loading…
Cancel
Save