Disable Ready Magic and Cycle Weapon/Spell hotkeys for werewolves (Fixes #3100)

openmw-38
scrawl 9 years ago
parent a7c886721c
commit 53334d08a2

@ -302,15 +302,19 @@ namespace MWInput
quickLoad(); quickLoad();
break; break;
case A_CycleSpellLeft: case A_CycleSpellLeft:
if (checkAllowedToUseItems())
MWBase::Environment::get().getWindowManager()->cycleSpell(false); MWBase::Environment::get().getWindowManager()->cycleSpell(false);
break; break;
case A_CycleSpellRight: case A_CycleSpellRight:
if (checkAllowedToUseItems())
MWBase::Environment::get().getWindowManager()->cycleSpell(true); MWBase::Environment::get().getWindowManager()->cycleSpell(true);
break; break;
case A_CycleWeaponLeft: case A_CycleWeaponLeft:
if (checkAllowedToUseItems())
MWBase::Environment::get().getWindowManager()->cycleWeapon(false); MWBase::Environment::get().getWindowManager()->cycleWeapon(false);
break; break;
case A_CycleWeaponRight: case A_CycleWeaponRight:
if (checkAllowedToUseItems())
MWBase::Environment::get().getWindowManager()->cycleWeapon(true); MWBase::Environment::get().getWindowManager()->cycleWeapon(true);
break; break;
case A_Sneak: case A_Sneak:
@ -346,6 +350,18 @@ namespace MWInput
} }
} }
bool InputManager::checkAllowedToUseItems() const
{
MWWorld::Ptr player = MWMechanics::getPlayer();
if (player.getClass().getNpcStats(player).isWerewolf())
{
// Cannot use items or spells while in werewolf form
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return false;
}
return true;
}
void InputManager::update(float dt, bool disableControls, bool disableEvents) void InputManager::update(float dt, bool disableControls, bool disableEvents)
{ {
mControlsDisabled = disableControls; mControlsDisabled = disableControls;
@ -902,6 +918,9 @@ namespace MWInput
if (!mControlSwitch["playermagic"] || !mControlSwitch["playercontrols"]) if (!mControlSwitch["playermagic"] || !mControlSwitch["playercontrols"])
return; return;
if (!checkAllowedToUseItems())
return;
// Not allowed if no spell selected // Not allowed if no spell selected
MWWorld::InventoryStore& inventory = mPlayer->getPlayer().getClass().getInventoryStore(mPlayer->getPlayer()); MWWorld::InventoryStore& inventory = mPlayer->getPlayer().getClass().getInventoryStore(mPlayer->getPlayer());
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() && if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() &&
@ -1016,13 +1035,8 @@ namespace MWInput
{ {
if (!mControlSwitch["playercontrols"]) if (!mControlSwitch["playercontrols"])
return; return;
MWWorld::Ptr player = MWMechanics::getPlayer(); if (!checkAllowedToUseItems())
if (player.getClass().getNpcStats(player).isWerewolf())
{
// Cannot use items or spells while in werewolf form
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return; return;
}
if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
MWBase::Environment::get().getWindowManager()->activateQuickKey (index); MWBase::Environment::get().getWindowManager()->activateQuickKey (index);
@ -1033,13 +1047,8 @@ namespace MWInput
if (!MWBase::Environment::get().getWindowManager()->isGuiMode () if (!MWBase::Environment::get().getWindowManager()->isGuiMode ()
&& MWBase::Environment::get().getWorld()->getGlobalFloat ("chargenstate")==-1) && MWBase::Environment::get().getWorld()->getGlobalFloat ("chargenstate")==-1)
{ {
MWWorld::Ptr player = MWMechanics::getPlayer(); if (!checkAllowedToUseItems())
if (player.getClass().getNpcStats(player).isWerewolf())
{
// Cannot use items or spells while in werewolf form
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
return; return;
}
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_QuickKeysMenu); MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_QuickKeysMenu);

@ -213,6 +213,8 @@ namespace MWInput
void updateCursorMode(); void updateCursorMode();
bool checkAllowedToUseItems() const;
private: private:
void toggleMainMenu(); void toggleMainMenu();
void toggleSpell(); void toggleSpell();

Loading…
Cancel
Save