From 14b59e0e4be30b54e2a84493a34c07140ddf92fc Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 25 Mar 2017 22:40:11 +0400 Subject: [PATCH 1/9] Vanilla-like tgm (fixes #3798) --- apps/openmw/mwclass/creature.cpp | 10 +- apps/openmw/mwclass/npc.cpp | 10 +- apps/openmw/mwmechanics/actors.cpp | 5 +- apps/openmw/mwmechanics/character.cpp | 34 ++++-- apps/openmw/mwmechanics/combat.cpp | 30 +++-- apps/openmw/mwmechanics/spellcasting.cpp | 137 +++++++++++++++-------- apps/openmw/mwworld/worldimp.cpp | 16 ++- 7 files changed, 170 insertions(+), 72 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 51e0bdcce..7c2e05c77 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -323,6 +323,9 @@ namespace MWClass if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength)) damage = 0; + if (victim == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState()) + damage = 0; + MWMechanics::diseaseContact(victim, ptr); victim.getClass().onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true); @@ -371,6 +374,11 @@ namespace MWClass ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); } + bool godmode = object == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + + if (godmode) + damage = 0; + if (!successful) { // Missed @@ -405,7 +413,7 @@ namespace MWClass if(ishealth) { - if (!attacker.isEmpty()) + if (!attacker.isEmpty() && !godmode) { damage = scaleDamage(damage, attacker, ptr); MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 3b7b24981..855850dfd 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -651,6 +651,9 @@ namespace MWClass if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength)) damage = 0; + if (victim == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState()) + damage = 0; + MWMechanics::diseaseContact(victim, ptr); othercls.onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true); @@ -717,6 +720,11 @@ namespace MWClass if (damage < 0.001f) damage = 0; + bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + + if (godmode) + damage = 0; + if (damage > 0.0f && !attacker.isEmpty()) { // 'ptr' is losing health. Play a 'hit' voiced dialog entry if not already saying @@ -802,7 +810,7 @@ namespace MWClass if (ishealth) { - if (!attacker.isEmpty()) + if (!attacker.isEmpty() && !godmode) damage = scaleDamage(damage, attacker, ptr); if (damage > 0.0f) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 0b398a046..9c7d28fc9 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -815,7 +815,10 @@ namespace MWMechanics timeLeft = 0.0f; stats.setTimeToStartDrowning(timeLeft); } - if(timeLeft == 0.0f) + + bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + + if(timeLeft == 0.0f && !godmode) { // If drowning, apply 3 points of damage per second static const float fSuffocationDamage = world->getStore().get().find("fSuffocationDamage")->getFloat(); diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index a11aa586f..e8ad0dc1f 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1574,6 +1574,8 @@ void CharacterController::update(float duration) updateMagicEffects(); + bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + if(!cls.isActor()) updateAnimQueue(); else if(!cls.getCreatureStats(mPtr).isDead()) @@ -1691,8 +1693,12 @@ void CharacterController::update(float duration) } fatigueLoss *= duration; DynamicStat fatigue = cls.getCreatureStats(mPtr).getFatigue(); - fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss, fatigue.getCurrent() < 0); - cls.getCreatureStats(mPtr).setFatigue(fatigue); + + if (!godmode) + { + fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss, fatigue.getCurrent() < 0); + cls.getCreatureStats(mPtr).setFatigue(fatigue); + } if(sneak || inwater || flying) vec.z() = 0.0f; @@ -1748,8 +1754,12 @@ void CharacterController::update(float duration) if (normalizedEncumbrance > 1) normalizedEncumbrance = 1; const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult; - fatigue.setCurrent(fatigue.getCurrent() - fatigueDecrease); - cls.getCreatureStats(mPtr).setFatigue(fatigue); + + if (!godmode) + { + fatigue.setCurrent(fatigue.getCurrent() - fatigueDecrease); + cls.getCreatureStats(mPtr).setFatigue(fatigue); + } } } else if(mJumpState == JumpState_InAir) @@ -1760,16 +1770,22 @@ void CharacterController::update(float duration) float height = cls.getCreatureStats(mPtr).land(); float healthLost = getFallDamage(mPtr, height); + + bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + if (healthLost > 0.0f) { const float fatigueTerm = cls.getCreatureStats(mPtr).getFatigueTerm(); // inflict fall damages - DynamicStat health = cls.getCreatureStats(mPtr).getHealth(); - float realHealthLost = static_cast(healthLost * (1.0f - 0.25f * fatigueTerm)); - health.setCurrent(health.getCurrent() - realHealthLost); - cls.getCreatureStats(mPtr).setHealth(health); - cls.onHit(mPtr, realHealthLost, true, MWWorld::Ptr(), MWWorld::Ptr(), osg::Vec3f(), true); + if (!godmode) + { + DynamicStat health = cls.getCreatureStats(mPtr).getHealth(); + float realHealthLost = static_cast(healthLost * (1.0f - 0.25f * fatigueTerm)); + health.setCurrent(health.getCurrent() - realHealthLost); + cls.getCreatureStats(mPtr).setHealth(health); + cls.onHit(mPtr, realHealthLost, true, MWWorld::Ptr(), MWWorld::Ptr(), osg::Vec3f(), true); + } const int acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics); if (healthLost > (acrobaticsSkill * fatigueTerm)) diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 29d1f9c7c..54ad75135 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -327,11 +327,17 @@ namespace MWMechanics { int weaphealth = weapon.getClass().getItemHealth(weapon); - const float fWeaponDamageMult = MWBase::Environment::get().getWorld()->getStore().get().find("fWeaponDamageMult")->getFloat(); - float x = std::max(1.f, fWeaponDamageMult * damage); + bool godmode = attacker == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); - weaphealth -= std::min(int(x), weaphealth); - weapon.getCellRef().setCharge(weaphealth); + // weapon condition does not degrade when godmode is on + if (!godmode) + { + const float fWeaponDamageMult = MWBase::Environment::get().getWorld()->getStore().get().find("fWeaponDamageMult")->getFloat(); + float x = std::max(1.f, fWeaponDamageMult * damage); + + weaphealth -= std::min(int(x), weaphealth); + weapon.getCellRef().setCharge(weaphealth); + } // Weapon broken? unequip it if (weaphealth == 0) @@ -405,11 +411,17 @@ namespace MWMechanics CreatureStats& stats = attacker.getClass().getCreatureStats(attacker); MWMechanics::DynamicStat fatigue = stats.getFatigue(); const float normalizedEncumbrance = attacker.getClass().getNormalizedEncumbrance(attacker); - float fatigueLoss = fFatigueAttackBase + normalizedEncumbrance * fFatigueAttackMult; - if (!weapon.isEmpty()) - fatigueLoss += weapon.getClass().getWeight(weapon) * attackStrength * fWeaponFatigueMult; - fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); - stats.setFatigue(fatigue); + + bool godmode = attacker == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + + if (!godmode) + { + float fatigueLoss = fFatigueAttackBase + normalizedEncumbrance * fFatigueAttackMult; + if (!weapon.isEmpty()) + fatigueLoss += weapon.getClass().getWeight(weapon) * attackStrength * fWeaponFatigueMult; + fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); + stats.setFatigue(fatigue); + } } bool isEnvironmentCompatible(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 3d8e25ce5..5cfaccb84 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -46,11 +46,6 @@ namespace MWMechanics float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap) { - CreatureStats& stats = actor.getClass().getCreatureStats(actor); - - if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude()) - return 0; - float y = std::numeric_limits::max(); float lowestSkill = 0; @@ -80,6 +75,13 @@ namespace MWMechanics } } + bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + + CreatureStats& stats = actor.getClass().getCreatureStats(actor); + + if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude()&& !godmode) + return 0; + if (spell->mData.mType == ESM::Spell::ST_Power) return stats.getSpells().canUsePower(spell) ? 100 : 0; @@ -89,6 +91,11 @@ namespace MWMechanics if (spell->mData.mFlags & ESM::Spell::F_Always) return 100; + if (godmode) + { + return 100; + } + float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude(); int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified(); @@ -709,14 +716,19 @@ namespace MWMechanics mStack = false; + bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + // Check if there's enough charge left if (enchantment->mData.mType == ESM::Enchantment::WhenUsed || enchantment->mData.mType == ESM::Enchantment::WhenStrikes) { - const int castCost = getEffectiveEnchantmentCastCost(static_cast(enchantment->mData.mCost), mCaster); + int castCost = getEffectiveEnchantmentCastCost(static_cast(enchantment->mData.mCost), mCaster); if (item.getCellRef().getEnchantmentCharge() == -1) item.getCellRef().setEnchantmentCharge(static_cast(enchantment->mData.mCharge)); + if (godmode) + castCost = 0; + if (item.getCellRef().getEnchantmentCharge() < castCost) { if (mCaster == getPlayer()) @@ -746,8 +758,10 @@ namespace MWMechanics if (mCaster == getPlayer()) mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 1); } - if (enchantment->mData.mType == ESM::Enchantment::CastOnce) + if (enchantment->mData.mType == ESM::Enchantment::CastOnce && !godmode) + { item.getContainerStore()->remove(item, 1, mCaster); + } else if (enchantment->mData.mType != ESM::Enchantment::WhenStrikes) { if (mCaster == getPlayer()) @@ -797,44 +811,50 @@ namespace MWMechanics int school = 0; + bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + if (mCaster.getClass().isActor() && !mAlwaysSucceed) { school = getSpellSchool(spell, mCaster); CreatureStats& stats = mCaster.getClass().getCreatureStats(mCaster); - // Reduce fatigue (note that in the vanilla game, both GMSTs are 0, and there's no fatigue loss) - static const float fFatigueSpellBase = store.get().find("fFatigueSpellBase")->getFloat(); - static const float fFatigueSpellMult = store.get().find("fFatigueSpellMult")->getFloat(); - DynamicStat fatigue = stats.getFatigue(); - const float normalizedEncumbrance = mCaster.getClass().getNormalizedEncumbrance(mCaster); - float fatigueLoss = spell->mData.mCost * (fFatigueSpellBase + normalizedEncumbrance * fFatigueSpellMult); - fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); stats.setFatigue(fatigue); + if (!godmode) + { + // Reduce fatigue (note that in the vanilla game, both GMSTs are 0, and there's no fatigue loss) + static const float fFatigueSpellBase = store.get().find("fFatigueSpellBase")->getFloat(); + static const float fFatigueSpellMult = store.get().find("fFatigueSpellMult")->getFloat(); + DynamicStat fatigue = stats.getFatigue(); + const float normalizedEncumbrance = mCaster.getClass().getNormalizedEncumbrance(mCaster); - bool fail = false; + float fatigueLoss = spell->mData.mCost * (fFatigueSpellBase + normalizedEncumbrance * fFatigueSpellMult); + fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); stats.setFatigue(fatigue); - // Check success - if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())) - { - float successChance = getSpellSuccessChance(spell, mCaster); - if (Misc::Rng::roll0to99() >= successChance) + bool fail = false; + + // Check success + if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())) { - if (mCaster == getPlayer()) - MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}"); - fail = true; + float successChance = getSpellSuccessChance(spell, mCaster); + if (Misc::Rng::roll0to99() >= successChance) + { + if (mCaster == getPlayer()) + MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}"); + fail = true; + } } - } - if (fail) - { - // Failure sound - static const std::string schools[] = { - "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" - }; + if (fail) + { + // Failure sound + static const std::string schools[] = { + "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" + }; - MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); - sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f); - return false; + MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); + sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f); + return false; + } } // A power can be used once per 24h @@ -1042,6 +1062,8 @@ namespace MWMechanics bool receivedMagicDamage = false; + bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); + switch (effectKey.mId) { case ESM::MagicEffect::DamageAttribute: @@ -1064,21 +1086,34 @@ namespace MWMechanics adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::RestoreHealth, magnitude); break; case ESM::MagicEffect::DamageHealth: - receivedMagicDamage = true; - adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude); - break; + if (!godmode) + { + receivedMagicDamage = true; + adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude); + } case ESM::MagicEffect::DamageMagicka: case ESM::MagicEffect::DamageFatigue: - adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude); + if (!godmode) + { + adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude); + } + break; + case ESM::MagicEffect::AbsorbHealth: - if (magnitude > 0.f) - receivedMagicDamage = true; - adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude); - break; + if (!godmode) + { + if (magnitude > 0.f) + receivedMagicDamage = true; + adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude); + } case ESM::MagicEffect::AbsorbMagicka: case ESM::MagicEffect::AbsorbFatigue: - adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude); + if (!godmode) + { + adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude); + } + break; case ESM::MagicEffect::DisintegrateArmor: @@ -1123,9 +1158,13 @@ namespace MWMechanics if (weather > 1) damageScale *= fMagicSunBlockedMult; - adjustDynamicStat(creatureStats, 0, -magnitude * damageScale); - if (magnitude * damageScale > 0.f) - receivedMagicDamage = true; + if (!godmode) + { + adjustDynamicStat(creatureStats, 0, -magnitude * damageScale); + if (magnitude * damageScale > 0.f) + receivedMagicDamage = true; + } + break; } @@ -1134,8 +1173,12 @@ namespace MWMechanics case ESM::MagicEffect::FrostDamage: case ESM::MagicEffect::Poison: { - adjustDynamicStat(creatureStats, 0, -magnitude); - receivedMagicDamage = true; + if (!godmode) + { + adjustDynamicStat(creatureStats, 0, -magnitude); + receivedMagicDamage = true; + } + break; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4270a112c..024f2b173 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2340,12 +2340,16 @@ namespace MWWorld MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); if (stats.isDead()) continue; + + mPhysics->markAsNonSolid (object); + + if (actor == getPlayerPtr() && MWBase::Environment::get().getWorld()->getGodModeState()) + return; + MWMechanics::DynamicStat health = stats.getHealth(); health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration()); stats.setHealth(health); - mPhysics->markAsNonSolid (object); - if (healthPerSecond > 0.0f) { if (actor == getPlayerPtr()) @@ -2370,12 +2374,16 @@ namespace MWWorld MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); if (stats.isDead()) continue; + + mPhysics->markAsNonSolid (object); + + if (actor == getPlayerPtr() && MWBase::Environment::get().getWorld()->getGodModeState()) + return; + MWMechanics::DynamicStat health = stats.getHealth(); health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration()); stats.setHealth(health); - mPhysics->markAsNonSolid (object); - if (healthPerSecond > 0.0f) { if (actor == getPlayerPtr()) From edadcb338cab94d1ef9c1266147abc1152b8a26d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 27 Mar 2017 23:10:57 +0400 Subject: [PATCH 2/9] Savegame dialog improvements --- apps/openmw/mwgui/savegamedialog.cpp | 15 +++++++ files/mygui/openmw_button.skin.xml | 2 +- files/mygui/openmw_confirmation_dialog.layout | 2 +- files/mygui/openmw_savegame_dialog.layout | 2 +- files/mygui/openmw_windows.skin.xml | 41 ++++++++++++++++++- 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index f93d1cc0a..cbc95e808 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -253,6 +253,21 @@ namespace MWGui return; } } + else + { + MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState(); + + // If game is running, ask for confirmation first + if (state == MWBase::StateManager::State_Running && !reallySure) + { + ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); + dialog->askForConfirmation("#{sMessage1}"); + dialog->eventOkClicked.clear(); + dialog->eventOkClicked += MyGUI::newDelegate(this, &SaveGameDialog::onConfirmationGiven); + dialog->eventCancelClicked.clear(); + return; + } + } setVisible(false); MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_MainMenu); diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index 09a4c0e39..5aee8de7a 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -111,7 +111,7 @@ - + diff --git a/files/mygui/openmw_confirmation_dialog.layout b/files/mygui/openmw_confirmation_dialog.layout index fbf779cd1..2d533135a 100644 --- a/files/mygui/openmw_confirmation_dialog.layout +++ b/files/mygui/openmw_confirmation_dialog.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_savegame_dialog.layout b/files/mygui/openmw_savegame_dialog.layout index ca11b65f8..f18218430 100644 --- a/files/mygui/openmw_savegame_dialog.layout +++ b/files/mygui/openmw_savegame_dialog.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_windows.skin.xml b/files/mygui/openmw_windows.skin.xml index 423de14aa..00e6f9148 100644 --- a/files/mygui/openmw_windows.skin.xml +++ b/files/mygui/openmw_windows.skin.xml @@ -1,7 +1,7 @@ - + @@ -9,6 +9,14 @@ + + + + + + + + @@ -883,4 +891,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e5a0f899346658eacaa330ceb5efec9b3772634a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 28 Mar 2017 12:49:23 +0400 Subject: [PATCH 3/9] List scroll fix --- files/mygui/openmw_count_window.layout | 14 +++++++------- files/mygui/openmw_list.skin.xml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index 891f9f00c..e8d1afee9 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -1,29 +1,29 @@  - + - - + + - + - + - + - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 9f5b2e94d..111d3bf30 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -131,9 +131,9 @@ - + - + From df5a43363a23a80a1a05ec6ffa0e7c089073357b Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 30 Mar 2017 17:05:56 +0400 Subject: [PATCH 4/9] Confirmation dialogs size fix --- apps/openmw/mwgui/confirmationdialog.cpp | 17 ++++++++++++----- apps/openmw/mwgui/confirmationdialog.hpp | 3 ++- files/mygui/openmw_confirmation_dialog.layout | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/confirmationdialog.cpp b/apps/openmw/mwgui/confirmationdialog.cpp index e4312914f..33f8dbe3e 100644 --- a/apps/openmw/mwgui/confirmationdialog.cpp +++ b/apps/openmw/mwgui/confirmationdialog.cpp @@ -17,19 +17,26 @@ namespace MWGui } void ConfirmationDialog::askForConfirmation(const std::string& message, const std::string& confirmMessage, const std::string& cancelMessage) + { + mCancelButton->setCaptionWithReplacing(cancelMessage); + mOkButton->setCaptionWithReplacing(confirmMessage); + + askForConfirmation(message); + } + + void ConfirmationDialog::askForConfirmation(const std::string& message) { setVisible(true); mMessage->setCaptionWithReplacing(message); - mCancelButton->setCaptionWithReplacing(cancelMessage); - mOkButton->setCaptionWithReplacing(confirmMessage); + int height = mMessage->getTextSize().height + 60; - int height = mMessage->getTextSize().height + 72; + int width = mMessage->getTextSize().width + 24; - mMainWidget->setSize(mMainWidget->getWidth(), height); + mMainWidget->setSize(width, height); - mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height+24); + mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height + 24); center(); } diff --git a/apps/openmw/mwgui/confirmationdialog.hpp b/apps/openmw/mwgui/confirmationdialog.hpp index 14caa7748..745c7a1a5 100644 --- a/apps/openmw/mwgui/confirmationdialog.hpp +++ b/apps/openmw/mwgui/confirmationdialog.hpp @@ -9,7 +9,8 @@ namespace MWGui { public: ConfirmationDialog(); - void askForConfirmation(const std::string& message, const std::string& confirmMessage="#{sOk}", const std::string& cancelMessage="#{sCancel}"); + void askForConfirmation(const std::string& message); + void askForConfirmation(const std::string& message, const std::string& confirmMessage, const std::string& cancelMessage); virtual void exit(); typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; diff --git a/files/mygui/openmw_confirmation_dialog.layout b/files/mygui/openmw_confirmation_dialog.layout index 2d533135a..39e77cb93 100644 --- a/files/mygui/openmw_confirmation_dialog.layout +++ b/files/mygui/openmw_confirmation_dialog.layout @@ -1,10 +1,10 @@ - + - + @@ -12,14 +12,14 @@ - + - + - + From 785b3c3d01b0d18e8fa348a08a5819ce0fb452e9 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 3 Apr 2017 09:02:05 +0300 Subject: [PATCH 5/9] Hide WorldButton when in game mode --- apps/openmw/mwgui/mapwindow.cpp | 6 ++++++ apps/openmw/mwgui/mapwindow.hpp | 1 + 2 files changed, 7 insertions(+) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 8002dc48a..5c7e73862 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -774,6 +774,12 @@ namespace MWGui mLastScrollWindowCoordinates = currentCoordinates; } + void MapWindow::setVisible(bool visible) + { + WindowBase::setVisible(visible); + mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->isGuiMode()); + } + void MapWindow::renderGlobalMap() { mGlobalMapRender->render(); diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index a0136b1c7..4e648c4b7 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -204,6 +204,7 @@ namespace MWGui void setCellName(const std::string& cellName); virtual void setAlpha(float alpha); + void setVisible(bool visible); void renderGlobalMap(); From 5020d03c780853af19a44ebdfca8ec3eda81e38f Mon Sep 17 00:00:00 2001 From: Allofich Date: Wed, 12 Apr 2017 22:52:52 +0900 Subject: [PATCH 6/9] Remove unnecessary line --- apps/openmw/mwmechanics/character.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index e8ad0dc1f..85749d947 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1771,8 +1771,6 @@ void CharacterController::update(float duration) float height = cls.getCreatureStats(mPtr).land(); float healthLost = getFallDamage(mPtr, height); - bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); - if (healthLost > 0.0f) { const float fatigueTerm = cls.getCreatureStats(mPtr).getFatigueTerm(); From 1fe3a3efe46b39737e423c79d37f0d3c25dffca0 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 12 Apr 2017 19:15:22 +0400 Subject: [PATCH 7/9] Count dialog layout changes --- files/mygui/openmw_count_window.layout | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index e8d1afee9..a3234c405 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -2,28 +2,25 @@ - + - + - + - - - - - + + - + From 6272e1c674ba20fdeded8f87409c60b95b9ee4a1 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 13 Apr 2017 01:01:50 +0900 Subject: [PATCH 8/9] Cache allies found while iterating engageCombat (Fixes #3814) --- apps/openmw/mwmechanics/actors.cpp | 47 ++++++++++++++++++++++++------ apps/openmw/mwmechanics/actors.hpp | 4 ++- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 9c7d28fc9..37bef3c78 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -280,7 +280,7 @@ namespace MWMechanics } } - void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer) + void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, std::map >& cachedAllies, bool againstPlayer) { CreatureStats& creatureStats1 = actor1.getClass().getCreatureStats(actor1); if (creatureStats1.getAiSequence().isInCombat(actor2)) @@ -306,7 +306,8 @@ namespace MWMechanics // Get actors allied with actor1. Includes those following or escorting actor1, actors following or escorting those actors, (recursive) // and any actor currently being followed or escorted by actor1 std::set allies1; - getActorsSidingWith(actor1, allies1); + + getActorsSidingWith(actor1, allies1, cachedAllies); // If an ally of actor1 has been attacked by actor2 or has attacked actor2, start combat between actor1 and actor2 for (std::set::const_iterator it = allies1.begin(); it != allies1.end(); ++it) @@ -328,10 +329,10 @@ namespace MWMechanics aggressive = true; } - std::set playerFollowersAndEscorters; - getActorsSidingWith(MWMechanics::getPlayer(), playerFollowersAndEscorters); + std::set playerAllies; + getActorsSidingWith(MWMechanics::getPlayer(), playerAllies, cachedAllies); - bool isPlayerFollowerOrEscorter = std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), actor1) != playerFollowersAndEscorters.end(); + bool isPlayerFollowerOrEscorter = std::find(playerAllies.begin(), playerAllies.end(), actor1) != playerAllies.end(); // If actor2 and at least one actor2 are in combat with actor1, actor1 and its allies start combat with them // Doesn't apply for player followers/escorters @@ -341,7 +342,9 @@ namespace MWMechanics if (actor2.getClass().getCreatureStats(actor2).getAiSequence().isInCombat(actor1)) { std::set allies2; - getActorsSidingWith(actor2, allies2); + + getActorsSidingWith(actor2, allies2, cachedAllies); + // Check that an ally of actor2 is also in combat with actor1 for (std::set::const_iterator it = allies2.begin(); it != allies2.end(); ++it) { @@ -383,11 +386,11 @@ namespace MWMechanics // Do aggression check if actor2 is the player or a player follower or escorter if (!aggressive) { - if (againstPlayer || std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), actor2) != playerFollowersAndEscorters.end()) + if (againstPlayer || std::find(playerAllies.begin(), playerAllies.end(), actor2) != playerAllies.end()) { // Player followers and escorters with high fight should not initiate combat with the player or with // other player followers or escorters - if (std::find(playerFollowersAndEscorters.begin(), playerFollowersAndEscorters.end(), actor1) == playerFollowersAndEscorters.end()) + if (std::find(playerAllies.begin(), playerAllies.end(), actor1) == playerAllies.end()) aggressive = MWBase::Environment::get().getMechanicsManager()->isAggressive(actor1, actor2); } } @@ -1075,6 +1078,8 @@ namespace MWMechanics /// \todo move update logic to Actor class where appropriate + std::map > cachedAllies; // will be filled as engageCombat iterates + // AI and magic effects update for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { @@ -1126,7 +1131,7 @@ namespace MWMechanics { if (it->first == iter->first || iter->first == player) // player is not AI-controlled continue; - engageCombat(iter->first, it->first, it->first == player); + engageCombat(iter->first, it->first, cachedAllies, it->first == player); } } if (timerUpdateHeadTrack == 0) @@ -1591,6 +1596,30 @@ namespace MWMechanics getActorsSidingWith(*it, out); } + void Actors::getActorsSidingWith(const MWWorld::Ptr &actor, std::set& out, std::map >& cachedAllies) { + std::list followers = getActorsSidingWith(actor); + + // If we have already found actor's allies, use the cache + std::map >::const_iterator search = cachedAllies.find(actor); + if (search != cachedAllies.end()) + out = search->second; + else + { + for (std::list::iterator it = followers.begin(); it != followers.end(); ++it) + if (out.insert(*it).second) + getActorsSidingWith(*it, out); + + // Cache ptrs and their sets of allies + cachedAllies.insert(std::make_pair(actor, out)); + for (std::set::const_iterator it = out.begin(); it != out.end(); ++it) + { + search = cachedAllies.find(*it); + if (search == cachedAllies.end()) + cachedAllies.insert(std::make_pair(*it, out)); + } + } + } + std::list Actors::getActorsFollowingIndices(const MWWorld::Ptr &actor) { std::list list; diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 20aef4c17..362c2f126 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -88,7 +88,7 @@ namespace MWMechanics @Notes: If againstPlayer = true then actor2 should be the Player. If one of the combatants is creature it should be actor1. */ - void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer); + void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, std::map >& cachedAllies, bool againstPlayer); void updateHeadTracking(const MWWorld::Ptr& actor, const MWWorld::Ptr& targetActor, MWWorld::Ptr& headTrackTarget, float& sqrHeadTrackDistance); @@ -127,6 +127,8 @@ namespace MWMechanics void getActorsFollowing(const MWWorld::Ptr &actor, std::set& out); /// Recursive version of getActorsSidingWith void getActorsSidingWith(const MWWorld::Ptr &actor, std::set& out); + /// Recursive version of getActorsSidingWith that takes, adds to and returns a cache of actors mapped to their allies + void getActorsSidingWith(const MWWorld::Ptr &actor, std::set& out, std::map >& cachedAllies); /// Get the list of AiFollow::mFollowIndex for all actors following this target std::list getActorsFollowingIndices(const MWWorld::Ptr& actor); From 470988f9ef169b013d1dc8f8bd61458c7ed6a11f Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 13 Apr 2017 03:57:59 +0900 Subject: [PATCH 9/9] Minor changes to getActorsSidingWith --- apps/openmw/mwmechanics/actors.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 37bef3c78..88fee8ef1 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1597,17 +1597,16 @@ namespace MWMechanics } void Actors::getActorsSidingWith(const MWWorld::Ptr &actor, std::set& out, std::map >& cachedAllies) { - std::list followers = getActorsSidingWith(actor); - // If we have already found actor's allies, use the cache std::map >::const_iterator search = cachedAllies.find(actor); if (search != cachedAllies.end()) - out = search->second; + out.insert(search->second.begin(), search->second.end()); else { + std::list followers = getActorsSidingWith(actor); for (std::list::iterator it = followers.begin(); it != followers.end(); ++it) if (out.insert(*it).second) - getActorsSidingWith(*it, out); + getActorsSidingWith(*it, out, cachedAllies); // Cache ptrs and their sets of allies cachedAllies.insert(std::make_pair(actor, out));