1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00

Merge remote-tracking branch 'miroslavr/master'

This commit is contained in:
Marc Zinnschlag 2014-09-07 10:22:07 +02:00
commit 16aa55dcde
5 changed files with 60 additions and 2 deletions

View File

@ -23,6 +23,8 @@
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwsound/soundmanagerimp.hpp"
#include "console.hpp"
@ -1442,6 +1444,10 @@ namespace MWGui
void WindowManager::updatePlayer()
{
mInventoryWindow->updatePlayer();
const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (player.getClass().getNpcStats(player).isWerewolf())
forceHide((GuiWindow)(MWGui::GW_Inventory | MWGui::GW_Magic));
}
void WindowManager::setKeyFocusWidget(MyGUI::Widget *widget)
@ -1532,6 +1538,8 @@ namespace MWGui
mCustomMarkers.clear();
mForceHidden = GW_None;
mGuiModes.clear();
MWBase::Environment::get().getInputManager()->changeInputMode(false);
updateVisible();

View File

@ -580,6 +580,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
, mIdleState(CharState_None)
, mMovementState(CharState_None)
, mMovementSpeed(0.0f)
, mHasMovedInXY(false)
, mMovementAnimationControlled(true)
, mDeathState(CharState_None)
, mHitState(CharState_None)
@ -794,6 +795,7 @@ bool CharacterController::updateWeaponState()
{
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
if(cls.getCreatureStats(mPtr).getStance(MWMechanics::CreatureStats::Stance_Run)
&& mHasMovedInXY
&& !MWBase::Environment::get().getWorld()->isSwimming(mPtr)
&& mWeaponType == WeapType_None)
{
@ -1249,11 +1251,12 @@ void CharacterController::update(float duration)
CharacterState idlestate = CharState_SpecialIdle;
bool forcestateupdate = false;
isrunning = isrunning && std::abs(vec[0])+std::abs(vec[1]) > 0.0f;
mHasMovedInXY = std::abs(vec[0])+std::abs(vec[1]) > 0.0f;
isrunning = isrunning && mHasMovedInXY;
// advance athletics
if(std::abs(vec[0])+std::abs(vec[1]) > 0.0f && mPtr.getRefData().getHandle() == "player")
if(mHasMovedInXY && mPtr.getRefData().getHandle() == "player")
{
if(inwater)
{

View File

@ -147,6 +147,7 @@ class CharacterController
CharacterState mMovementState;
std::string mCurrentMovement;
float mMovementSpeed;
bool mHasMovedInXY;
bool mMovementAnimationControlled;
CharacterState mDeathState;

View File

@ -869,6 +869,12 @@ namespace MWMechanics
bool MechanicsManager::sleepInBed(const MWWorld::Ptr &ptr, const MWWorld::Ptr &bed)
{
if (ptr.getClass().getNpcStats(ptr).isWerewolf())
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return true;
}
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) {
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}");
return true;
@ -1296,6 +1302,17 @@ namespace MWMechanics
+ ((50 - disposition) * fFightDispMult))
+ bias;
if (ptr.getClass().isNpc() && target.getClass().isNpc())
{
if (target.getClass().getNpcStats(target).isWerewolf() ||
(target == MWBase::Environment::get().getWorld()->getPlayerPtr() &&
MWBase::Environment::get().getWorld()->getGlobalInt("pcknownwerewolf")))
{
const ESM::GameSetting * iWerewolfFightMod = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("iWerewolfFightMod");
fight += iWerewolfFightMod->getInt();
}
}
return (fight >= 100);
}

View File

@ -390,6 +390,7 @@ namespace MWWorld
// vanilla Morrowind does not define dayspassed.
globals["dayspassed"] = ESM::Variant(1); // but the addons start counting at 1 :(
globals["WerewolfClawMult"] = ESM::Variant(1.f);
globals["PCKnownWerewolf"] = ESM::Variant(0);
for (std::map<std::string, ESM::Variant>::iterator it = gmst.begin(); it != gmst.end(); ++it)
{
@ -2330,6 +2331,34 @@ namespace MWWorld
windowManager->unsetForceHide(MWGui::GW_Inventory);
windowManager->unsetForceHide(MWGui::GW_Magic);
}
// Witnesses of the player's transformation will make them a globally known werewolf
std::vector<MWWorld::Ptr> closeActors;
MWBase::Environment::get().getMechanicsManager()->getActorsInRange(Ogre::Vector3(actor.getRefData().getPosition().pos),
getStore().get<ESM::GameSetting>().search("fAlarmRadius")->getFloat(),
closeActors);
bool detected = false;
for (std::vector<MWWorld::Ptr>::const_iterator it = closeActors.begin(); it != closeActors.end(); ++it)
{
if (*it == actor)
continue;
if (!it->getClass().isNpc())
continue;
if (getLOS(*it, actor) && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(actor, *it))
{
detected = true;
break;
}
}
if (detected)
{
windowManager->messageBox("#{sWerewolfAlarmMessage}");
setGlobalInt("pcknownwerewolf", 1);
}
}
}