mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-02 22:45:33 +00:00
Implement MWWorld::World::setWerewolf()
This commit is contained in:
parent
aa563e947e
commit
20d40c4368
4 changed files with 42 additions and 0 deletions
|
@ -384,6 +384,9 @@ namespace MWBase
|
|||
|
||||
/// Returns true if teleport spell effects are allowed.
|
||||
virtual bool isTeleportingEnabled() const = 0;
|
||||
|
||||
/// Turn actor into werewolf or normal form.
|
||||
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include <components/esm/loadgmst.hpp>
|
||||
#include <components/esm/loadfact.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "../mwrender/sky.hpp"
|
||||
#include "../mwrender/animation.hpp"
|
||||
|
@ -1848,4 +1849,38 @@ namespace MWWorld
|
|||
return mTeleportEnabled;
|
||||
}
|
||||
|
||||
void World::setWerewolf(const MWWorld::Ptr& actor, bool werewolf)
|
||||
{
|
||||
MWMechanics::NpcStats& npcStats = Class::get(actor).getNpcStats(actor);
|
||||
|
||||
// The actor does not have to change state
|
||||
if (npcStats.isWerewolf() == werewolf)
|
||||
return;
|
||||
|
||||
npcStats.setWerewolf(werewolf);
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
||||
if (werewolf)
|
||||
invStore.unequipAll();
|
||||
else
|
||||
invStore.autoEquip(actor);
|
||||
|
||||
if (actor.getRefData().getHandle() == "player")
|
||||
{
|
||||
// Update the GUI only when called on the player
|
||||
MWBase::WindowManager* windowManager = MWBase::Environment::get().getWindowManager();
|
||||
if (werewolf)
|
||||
{
|
||||
windowManager->forceHide(MWGui::GW_Inventory);
|
||||
windowManager->forceHide(MWGui::GW_Magic);
|
||||
windowManager->unsetSelectedWeapon();
|
||||
}
|
||||
else
|
||||
{
|
||||
windowManager->unsetForceHide(MWGui::GW_Inventory);
|
||||
windowManager->unsetForceHide(MWGui::GW_Magic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -428,6 +428,8 @@ namespace MWWorld
|
|||
|
||||
/// Returns true if teleport spell effects are allowed.
|
||||
virtual bool isTeleportingEnabled() const;
|
||||
|
||||
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue