mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 08:09:39 +00:00
Vanilla-like tgm (fixes #3798)
This commit is contained in:
parent
97dbd07ed2
commit
14b59e0e4b
7 changed files with 171 additions and 73 deletions
|
@ -323,6 +323,9 @@ namespace MWClass
|
||||||
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
|
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
|
||||||
damage = 0;
|
damage = 0;
|
||||||
|
|
||||||
|
if (victim == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
damage = 0;
|
||||||
|
|
||||||
MWMechanics::diseaseContact(victim, ptr);
|
MWMechanics::diseaseContact(victim, ptr);
|
||||||
|
|
||||||
victim.getClass().onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true);
|
victim.getClass().onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true);
|
||||||
|
@ -371,6 +374,11 @@ namespace MWClass
|
||||||
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
|
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool godmode = object == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
|
if (godmode)
|
||||||
|
damage = 0;
|
||||||
|
|
||||||
if (!successful)
|
if (!successful)
|
||||||
{
|
{
|
||||||
// Missed
|
// Missed
|
||||||
|
@ -405,7 +413,7 @@ namespace MWClass
|
||||||
|
|
||||||
if(ishealth)
|
if(ishealth)
|
||||||
{
|
{
|
||||||
if (!attacker.isEmpty())
|
if (!attacker.isEmpty() && !godmode)
|
||||||
{
|
{
|
||||||
damage = scaleDamage(damage, attacker, ptr);
|
damage = scaleDamage(damage, attacker, ptr);
|
||||||
MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition);
|
MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition);
|
||||||
|
|
|
@ -651,6 +651,9 @@ namespace MWClass
|
||||||
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
|
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
|
||||||
damage = 0;
|
damage = 0;
|
||||||
|
|
||||||
|
if (victim == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
damage = 0;
|
||||||
|
|
||||||
MWMechanics::diseaseContact(victim, ptr);
|
MWMechanics::diseaseContact(victim, ptr);
|
||||||
|
|
||||||
othercls.onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true);
|
othercls.onHit(victim, damage, healthdmg, weapon, ptr, hitPosition, true);
|
||||||
|
@ -717,6 +720,11 @@ namespace MWClass
|
||||||
if (damage < 0.001f)
|
if (damage < 0.001f)
|
||||||
damage = 0;
|
damage = 0;
|
||||||
|
|
||||||
|
bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
|
if (godmode)
|
||||||
|
damage = 0;
|
||||||
|
|
||||||
if (damage > 0.0f && !attacker.isEmpty())
|
if (damage > 0.0f && !attacker.isEmpty())
|
||||||
{
|
{
|
||||||
// 'ptr' is losing health. Play a 'hit' voiced dialog entry if not already saying
|
// 'ptr' is losing health. Play a 'hit' voiced dialog entry if not already saying
|
||||||
|
@ -802,7 +810,7 @@ namespace MWClass
|
||||||
|
|
||||||
if (ishealth)
|
if (ishealth)
|
||||||
{
|
{
|
||||||
if (!attacker.isEmpty())
|
if (!attacker.isEmpty() && !godmode)
|
||||||
damage = scaleDamage(damage, attacker, ptr);
|
damage = scaleDamage(damage, attacker, ptr);
|
||||||
|
|
||||||
if (damage > 0.0f)
|
if (damage > 0.0f)
|
||||||
|
|
|
@ -815,7 +815,10 @@ namespace MWMechanics
|
||||||
timeLeft = 0.0f;
|
timeLeft = 0.0f;
|
||||||
stats.setTimeToStartDrowning(timeLeft);
|
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
|
// If drowning, apply 3 points of damage per second
|
||||||
static const float fSuffocationDamage = world->getStore().get<ESM::GameSetting>().find("fSuffocationDamage")->getFloat();
|
static const float fSuffocationDamage = world->getStore().get<ESM::GameSetting>().find("fSuffocationDamage")->getFloat();
|
||||||
|
|
|
@ -1574,6 +1574,8 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
updateMagicEffects();
|
updateMagicEffects();
|
||||||
|
|
||||||
|
bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
if(!cls.isActor())
|
if(!cls.isActor())
|
||||||
updateAnimQueue();
|
updateAnimQueue();
|
||||||
else if(!cls.getCreatureStats(mPtr).isDead())
|
else if(!cls.getCreatureStats(mPtr).isDead())
|
||||||
|
@ -1691,8 +1693,12 @@ void CharacterController::update(float duration)
|
||||||
}
|
}
|
||||||
fatigueLoss *= duration;
|
fatigueLoss *= duration;
|
||||||
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
|
DynamicStat<float> 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)
|
if(sneak || inwater || flying)
|
||||||
vec.z() = 0.0f;
|
vec.z() = 0.0f;
|
||||||
|
@ -1748,8 +1754,12 @@ void CharacterController::update(float duration)
|
||||||
if (normalizedEncumbrance > 1)
|
if (normalizedEncumbrance > 1)
|
||||||
normalizedEncumbrance = 1;
|
normalizedEncumbrance = 1;
|
||||||
const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult;
|
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)
|
else if(mJumpState == JumpState_InAir)
|
||||||
|
@ -1760,16 +1770,22 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
float height = cls.getCreatureStats(mPtr).land();
|
float height = cls.getCreatureStats(mPtr).land();
|
||||||
float healthLost = getFallDamage(mPtr, height);
|
float healthLost = getFallDamage(mPtr, height);
|
||||||
|
|
||||||
|
bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
if (healthLost > 0.0f)
|
if (healthLost > 0.0f)
|
||||||
{
|
{
|
||||||
const float fatigueTerm = cls.getCreatureStats(mPtr).getFatigueTerm();
|
const float fatigueTerm = cls.getCreatureStats(mPtr).getFatigueTerm();
|
||||||
|
|
||||||
// inflict fall damages
|
// inflict fall damages
|
||||||
DynamicStat<float> health = cls.getCreatureStats(mPtr).getHealth();
|
if (!godmode)
|
||||||
float realHealthLost = static_cast<float>(healthLost * (1.0f - 0.25f * fatigueTerm));
|
{
|
||||||
health.setCurrent(health.getCurrent() - realHealthLost);
|
DynamicStat<float> health = cls.getCreatureStats(mPtr).getHealth();
|
||||||
cls.getCreatureStats(mPtr).setHealth(health);
|
float realHealthLost = static_cast<float>(healthLost * (1.0f - 0.25f * fatigueTerm));
|
||||||
cls.onHit(mPtr, realHealthLost, true, MWWorld::Ptr(), MWWorld::Ptr(), osg::Vec3f(), true);
|
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);
|
const int acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics);
|
||||||
if (healthLost > (acrobaticsSkill * fatigueTerm))
|
if (healthLost > (acrobaticsSkill * fatigueTerm))
|
||||||
|
|
|
@ -327,11 +327,17 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
||||||
|
|
||||||
const float fWeaponDamageMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWeaponDamageMult")->getFloat();
|
bool godmode = attacker == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
float x = std::max(1.f, fWeaponDamageMult * damage);
|
|
||||||
|
|
||||||
weaphealth -= std::min(int(x), weaphealth);
|
// weapon condition does not degrade when godmode is on
|
||||||
weapon.getCellRef().setCharge(weaphealth);
|
if (!godmode)
|
||||||
|
{
|
||||||
|
const float fWeaponDamageMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().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
|
// Weapon broken? unequip it
|
||||||
if (weaphealth == 0)
|
if (weaphealth == 0)
|
||||||
|
@ -405,11 +411,17 @@ namespace MWMechanics
|
||||||
CreatureStats& stats = attacker.getClass().getCreatureStats(attacker);
|
CreatureStats& stats = attacker.getClass().getCreatureStats(attacker);
|
||||||
MWMechanics::DynamicStat<float> fatigue = stats.getFatigue();
|
MWMechanics::DynamicStat<float> fatigue = stats.getFatigue();
|
||||||
const float normalizedEncumbrance = attacker.getClass().getNormalizedEncumbrance(attacker);
|
const float normalizedEncumbrance = attacker.getClass().getNormalizedEncumbrance(attacker);
|
||||||
float fatigueLoss = fFatigueAttackBase + normalizedEncumbrance * fFatigueAttackMult;
|
|
||||||
if (!weapon.isEmpty())
|
bool godmode = attacker == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
fatigueLoss += weapon.getClass().getWeight(weapon) * attackStrength * fWeaponFatigueMult;
|
|
||||||
fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss);
|
if (!godmode)
|
||||||
stats.setFatigue(fatigue);
|
{
|
||||||
|
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)
|
bool isEnvironmentCompatible(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim)
|
||||||
|
|
|
@ -46,11 +46,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap)
|
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<float>::max();
|
float y = std::numeric_limits<float>::max();
|
||||||
float lowestSkill = 0;
|
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)
|
if (spell->mData.mType == ESM::Spell::ST_Power)
|
||||||
return stats.getSpells().canUsePower(spell) ? 100 : 0;
|
return stats.getSpells().canUsePower(spell) ? 100 : 0;
|
||||||
|
|
||||||
|
@ -89,6 +91,11 @@ namespace MWMechanics
|
||||||
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
|
if (godmode)
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude();
|
float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude();
|
||||||
|
|
||||||
int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
|
int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
|
||||||
|
@ -709,14 +716,19 @@ namespace MWMechanics
|
||||||
|
|
||||||
mStack = false;
|
mStack = false;
|
||||||
|
|
||||||
|
bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
// Check if there's enough charge left
|
// Check if there's enough charge left
|
||||||
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed || enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed || enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
||||||
{
|
{
|
||||||
const int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), mCaster);
|
int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), mCaster);
|
||||||
|
|
||||||
if (item.getCellRef().getEnchantmentCharge() == -1)
|
if (item.getCellRef().getEnchantmentCharge() == -1)
|
||||||
item.getCellRef().setEnchantmentCharge(static_cast<float>(enchantment->mData.mCharge));
|
item.getCellRef().setEnchantmentCharge(static_cast<float>(enchantment->mData.mCharge));
|
||||||
|
|
||||||
|
if (godmode)
|
||||||
|
castCost = 0;
|
||||||
|
|
||||||
if (item.getCellRef().getEnchantmentCharge() < castCost)
|
if (item.getCellRef().getEnchantmentCharge() < castCost)
|
||||||
{
|
{
|
||||||
if (mCaster == getPlayer())
|
if (mCaster == getPlayer())
|
||||||
|
@ -746,8 +758,10 @@ namespace MWMechanics
|
||||||
if (mCaster == getPlayer())
|
if (mCaster == getPlayer())
|
||||||
mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 1);
|
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);
|
item.getContainerStore()->remove(item, 1, mCaster);
|
||||||
|
}
|
||||||
else if (enchantment->mData.mType != ESM::Enchantment::WhenStrikes)
|
else if (enchantment->mData.mType != ESM::Enchantment::WhenStrikes)
|
||||||
{
|
{
|
||||||
if (mCaster == getPlayer())
|
if (mCaster == getPlayer())
|
||||||
|
@ -797,44 +811,50 @@ namespace MWMechanics
|
||||||
|
|
||||||
int school = 0;
|
int school = 0;
|
||||||
|
|
||||||
|
bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
if (mCaster.getClass().isActor() && !mAlwaysSucceed)
|
if (mCaster.getClass().isActor() && !mAlwaysSucceed)
|
||||||
{
|
{
|
||||||
school = getSpellSchool(spell, mCaster);
|
school = getSpellSchool(spell, mCaster);
|
||||||
|
|
||||||
CreatureStats& stats = mCaster.getClass().getCreatureStats(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)
|
if (!godmode)
|
||||||
static const float fFatigueSpellBase = store.get<ESM::GameSetting>().find("fFatigueSpellBase")->getFloat();
|
|
||||||
static const float fFatigueSpellMult = store.get<ESM::GameSetting>().find("fFatigueSpellMult")->getFloat();
|
|
||||||
DynamicStat<float> 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);
|
|
||||||
|
|
||||||
bool fail = false;
|
|
||||||
|
|
||||||
// Check success
|
|
||||||
if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState()))
|
|
||||||
{
|
{
|
||||||
float successChance = getSpellSuccessChance(spell, mCaster);
|
// Reduce fatigue (note that in the vanilla game, both GMSTs are 0, and there's no fatigue loss)
|
||||||
if (Misc::Rng::roll0to99() >= successChance)
|
static const float fFatigueSpellBase = store.get<ESM::GameSetting>().find("fFatigueSpellBase")->getFloat();
|
||||||
|
static const float fFatigueSpellMult = store.get<ESM::GameSetting>().find("fFatigueSpellMult")->getFloat();
|
||||||
|
DynamicStat<float> 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);
|
||||||
|
|
||||||
|
bool fail = false;
|
||||||
|
|
||||||
|
// Check success
|
||||||
|
if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState()))
|
||||||
{
|
{
|
||||||
if (mCaster == getPlayer())
|
float successChance = getSpellSuccessChance(spell, mCaster);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
if (Misc::Rng::roll0to99() >= successChance)
|
||||||
fail = true;
|
{
|
||||||
|
if (mCaster == getPlayer())
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
||||||
|
fail = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fail)
|
if (fail)
|
||||||
{
|
{
|
||||||
// Failure sound
|
// Failure sound
|
||||||
static const std::string schools[] = {
|
static const std::string schools[] = {
|
||||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||||
};
|
};
|
||||||
|
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f);
|
sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A power can be used once per 24h
|
// A power can be used once per 24h
|
||||||
|
@ -1042,6 +1062,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool receivedMagicDamage = false;
|
bool receivedMagicDamage = false;
|
||||||
|
|
||||||
|
bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
switch (effectKey.mId)
|
switch (effectKey.mId)
|
||||||
{
|
{
|
||||||
case ESM::MagicEffect::DamageAttribute:
|
case ESM::MagicEffect::DamageAttribute:
|
||||||
|
@ -1064,21 +1086,34 @@ namespace MWMechanics
|
||||||
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::RestoreHealth, magnitude);
|
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::RestoreHealth, magnitude);
|
||||||
break;
|
break;
|
||||||
case ESM::MagicEffect::DamageHealth:
|
case ESM::MagicEffect::DamageHealth:
|
||||||
receivedMagicDamage = true;
|
if (!godmode)
|
||||||
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude);
|
{
|
||||||
break;
|
receivedMagicDamage = true;
|
||||||
|
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude);
|
||||||
|
}
|
||||||
case ESM::MagicEffect::DamageMagicka:
|
case ESM::MagicEffect::DamageMagicka:
|
||||||
case ESM::MagicEffect::DamageFatigue:
|
case ESM::MagicEffect::DamageFatigue:
|
||||||
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude);
|
if (!godmode)
|
||||||
|
{
|
||||||
|
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESM::MagicEffect::AbsorbHealth:
|
case ESM::MagicEffect::AbsorbHealth:
|
||||||
if (magnitude > 0.f)
|
if (!godmode)
|
||||||
receivedMagicDamage = true;
|
{
|
||||||
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude);
|
if (magnitude > 0.f)
|
||||||
break;
|
receivedMagicDamage = true;
|
||||||
|
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude);
|
||||||
|
}
|
||||||
case ESM::MagicEffect::AbsorbMagicka:
|
case ESM::MagicEffect::AbsorbMagicka:
|
||||||
case ESM::MagicEffect::AbsorbFatigue:
|
case ESM::MagicEffect::AbsorbFatigue:
|
||||||
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude);
|
if (!godmode)
|
||||||
|
{
|
||||||
|
adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESM::MagicEffect::DisintegrateArmor:
|
case ESM::MagicEffect::DisintegrateArmor:
|
||||||
|
@ -1123,9 +1158,13 @@ namespace MWMechanics
|
||||||
if (weather > 1)
|
if (weather > 1)
|
||||||
damageScale *= fMagicSunBlockedMult;
|
damageScale *= fMagicSunBlockedMult;
|
||||||
|
|
||||||
adjustDynamicStat(creatureStats, 0, -magnitude * damageScale);
|
if (!godmode)
|
||||||
if (magnitude * damageScale > 0.f)
|
{
|
||||||
receivedMagicDamage = true;
|
adjustDynamicStat(creatureStats, 0, -magnitude * damageScale);
|
||||||
|
if (magnitude * damageScale > 0.f)
|
||||||
|
receivedMagicDamage = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,8 +1173,12 @@ namespace MWMechanics
|
||||||
case ESM::MagicEffect::FrostDamage:
|
case ESM::MagicEffect::FrostDamage:
|
||||||
case ESM::MagicEffect::Poison:
|
case ESM::MagicEffect::Poison:
|
||||||
{
|
{
|
||||||
adjustDynamicStat(creatureStats, 0, -magnitude);
|
if (!godmode)
|
||||||
receivedMagicDamage = true;
|
{
|
||||||
|
adjustDynamicStat(creatureStats, 0, -magnitude);
|
||||||
|
receivedMagicDamage = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2340,12 +2340,16 @@ namespace MWWorld
|
||||||
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
||||||
if (stats.isDead())
|
if (stats.isDead())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
mPhysics->markAsNonSolid (object);
|
||||||
|
|
||||||
|
if (actor == getPlayerPtr() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
return;
|
||||||
|
|
||||||
MWMechanics::DynamicStat<float> health = stats.getHealth();
|
MWMechanics::DynamicStat<float> health = stats.getHealth();
|
||||||
health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration());
|
health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration());
|
||||||
stats.setHealth(health);
|
stats.setHealth(health);
|
||||||
|
|
||||||
mPhysics->markAsNonSolid (object);
|
|
||||||
|
|
||||||
if (healthPerSecond > 0.0f)
|
if (healthPerSecond > 0.0f)
|
||||||
{
|
{
|
||||||
if (actor == getPlayerPtr())
|
if (actor == getPlayerPtr())
|
||||||
|
@ -2370,12 +2374,16 @@ namespace MWWorld
|
||||||
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
||||||
if (stats.isDead())
|
if (stats.isDead())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
mPhysics->markAsNonSolid (object);
|
||||||
|
|
||||||
|
if (actor == getPlayerPtr() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
return;
|
||||||
|
|
||||||
MWMechanics::DynamicStat<float> health = stats.getHealth();
|
MWMechanics::DynamicStat<float> health = stats.getHealth();
|
||||||
health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration());
|
health.setCurrent(health.getCurrent()-healthPerSecond*MWBase::Environment::get().getFrameDuration());
|
||||||
stats.setHealth(health);
|
stats.setHealth(health);
|
||||||
|
|
||||||
mPhysics->markAsNonSolid (object);
|
|
||||||
|
|
||||||
if (healthPerSecond > 0.0f)
|
if (healthPerSecond > 0.0f)
|
||||||
{
|
{
|
||||||
if (actor == getPlayerPtr())
|
if (actor == getPlayerPtr())
|
||||||
|
|
Loading…
Reference in a new issue