mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Merge branch 'activatebooks' into 'master'
Allow NPCs to activate in-world books for the player (part of #7959) See merge request OpenMW/openmw!4080
This commit is contained in:
commit
651a7d569c
1 changed files with 5 additions and 5 deletions
|
@ -23,15 +23,15 @@ namespace MWWorld
|
||||||
|
|
||||||
void ActionRead::executeImp(const MWWorld::Ptr& actor)
|
void ActionRead::executeImp(const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
|
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
if (actor != MWMechanics::getPlayer())
|
if (actor != player && getTarget().getContainerStore() != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ensure we're not in combat
|
// Ensure we're not in combat
|
||||||
if (MWMechanics::isPlayerInCombat()
|
if (MWMechanics::isPlayerInCombat()
|
||||||
// Reading in combat is still allowed if the scroll/book is not in the player inventory yet
|
// 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)
|
// (since otherwise, there would be no way to pick it up)
|
||||||
&& getTarget().getContainerStore() == &actor.getClass().getContainerStore(actor))
|
&& getTarget().getContainerStore() == &player.getClass().getContainerStore(player))
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage4}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage4}");
|
||||||
return;
|
return;
|
||||||
|
@ -44,13 +44,13 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book, getTarget());
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book, getTarget());
|
||||||
|
|
||||||
MWMechanics::NpcStats& npcStats = actor.getClass().getNpcStats(actor);
|
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
|
||||||
|
|
||||||
// Skill gain from books
|
// Skill gain from books
|
||||||
ESM::RefId skill = ESM::Skill::indexToRefId(ref->mBase->mData.mSkillId);
|
ESM::RefId skill = ESM::Skill::indexToRefId(ref->mBase->mData.mSkillId);
|
||||||
if (!skill.empty() && !npcStats.hasBeenUsed(ref->mBase->mId))
|
if (!skill.empty() && !npcStats.hasBeenUsed(ref->mBase->mId))
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getLuaManager()->skillLevelUp(actor, skill, "book");
|
MWBase::Environment::get().getLuaManager()->skillLevelUp(player, skill, "book");
|
||||||
|
|
||||||
npcStats.flagAsUsed(ref->mBase->mId);
|
npcStats.flagAsUsed(ref->mBase->mId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue