mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 20:06:41 +00:00
Merge remote-tracking branch 'scrawl/master'
This commit is contained in:
commit
71c868aa94
5 changed files with 95 additions and 22 deletions
|
@ -209,6 +209,9 @@ namespace MWClass
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
MWMechanics::CreatureStats &stats = getCreatureStats(ptr);
|
MWMechanics::CreatureStats &stats = getCreatureStats(ptr);
|
||||||
|
|
||||||
|
if (stats.getDrawState() != MWMechanics::DrawState_Weapon)
|
||||||
|
return;
|
||||||
|
|
||||||
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
||||||
MWWorld::Ptr weapon;
|
MWWorld::Ptr weapon;
|
||||||
if (ptr.getClass().hasInventoryStore(ptr))
|
if (ptr.getClass().hasInventoryStore(ptr))
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
|
|
||||||
#include <components/esm/loadench.hpp>
|
#include <components/esm/loadench.hpp>
|
||||||
#include <components/esm/loadmgef.hpp>
|
#include <components/esm/loadmgef.hpp>
|
||||||
|
@ -292,6 +292,38 @@ namespace MWMechanics
|
||||||
case ESM::MagicEffect::CurePoison:
|
case ESM::MagicEffect::CurePoison:
|
||||||
return 1001.f * numEffectsToCure(actor, ESM::MagicEffect::Poison);
|
return 1001.f * numEffectsToCure(actor, ESM::MagicEffect::Poison);
|
||||||
|
|
||||||
|
case ESM::MagicEffect::DisintegrateArmor: // TODO: check if actor is wearing armor
|
||||||
|
case ESM::MagicEffect::DisintegrateWeapon: // TODO: check if actor is wearing weapon
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESM::MagicEffect::DamageAttribute:
|
||||||
|
case ESM::MagicEffect::DrainAttribute:
|
||||||
|
if (!target.isEmpty() && target.getClass().getCreatureStats(target).getAttribute(effect.mAttribute).getModified() <= 0)
|
||||||
|
return 0.f;
|
||||||
|
{
|
||||||
|
const float attributePriorities[ESM::Attribute::Length] = {
|
||||||
|
1.f, // Strength
|
||||||
|
0.5, // Intelligence
|
||||||
|
0.6, // Willpower
|
||||||
|
0.7, // Agility
|
||||||
|
0.5, // Speed
|
||||||
|
0.8, // Endurance
|
||||||
|
0.7, // Personality
|
||||||
|
0.3 // Luck
|
||||||
|
};
|
||||||
|
if (effect.mAttribute >= 0 && effect.mAttribute < ESM::Attribute::Length)
|
||||||
|
rating *= attributePriorities[effect.mAttribute];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESM::MagicEffect::DamageSkill:
|
||||||
|
case ESM::MagicEffect::DrainSkill:
|
||||||
|
if (target.isEmpty() || !target.getClass().isNpc())
|
||||||
|
return 0.f;
|
||||||
|
if (target.getClass().getNpcStats(target).getSkill(effect.mSkill).getModified() <= 0)
|
||||||
|
return 0.f;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,11 +690,52 @@ void CharacterController::updateIdleStormState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::castSpell(const std::string &spellid)
|
||||||
|
{
|
||||||
|
static const std::string schools[] = {
|
||||||
|
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||||
|
};
|
||||||
|
|
||||||
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid);
|
||||||
|
const ESM::ENAMstruct &effectentry = spell->mEffects.mList.at(0);
|
||||||
|
|
||||||
|
const ESM::MagicEffect *effect;
|
||||||
|
effect = store.get<ESM::MagicEffect>().find(effectentry.mEffectID);
|
||||||
|
|
||||||
|
const ESM::Static* castStatic;
|
||||||
|
if (!effect->mCasting.empty())
|
||||||
|
castStatic = store.get<ESM::Static>().find (effect->mCasting);
|
||||||
|
else
|
||||||
|
castStatic = store.get<ESM::Static>().find ("VFX_DefaultCast");
|
||||||
|
|
||||||
|
mAnimation->addEffect("meshes\\" + castStatic->mModel, effect->mIndex);
|
||||||
|
|
||||||
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
|
if(!effect->mCastSound.empty())
|
||||||
|
sndMgr->playSound3D(mPtr, effect->mCastSound, 1.0f, 1.0f);
|
||||||
|
else
|
||||||
|
sndMgr->playSound3D(mPtr, schools[effect->mData.mSchool]+" cast", 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
bool CharacterController::updateCreatureState()
|
bool CharacterController::updateCreatureState()
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = mPtr.getClass();
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(mPtr);
|
CreatureStats &stats = cls.getCreatureStats(mPtr);
|
||||||
|
|
||||||
|
WeaponType weapType = WeapType_None;
|
||||||
|
if(stats.getDrawState() == DrawState_Weapon)
|
||||||
|
weapType = WeapType_HandToHand;
|
||||||
|
else if (stats.getDrawState() == DrawState_Spell)
|
||||||
|
weapType = WeapType_Spell;
|
||||||
|
|
||||||
|
if (weapType != mWeaponType)
|
||||||
|
{
|
||||||
|
mWeaponType = weapType;
|
||||||
|
if (mAnimation->isPlaying(mCurrentWeapon))
|
||||||
|
mAnimation->disable(mCurrentWeapon);
|
||||||
|
}
|
||||||
|
|
||||||
if(stats.getAttackingOrSpell())
|
if(stats.getAttackingOrSpell())
|
||||||
{
|
{
|
||||||
if(mUpperBodyState == UpperCharState_Nothing && mHitState == CharState_None)
|
if(mUpperBodyState == UpperCharState_Nothing && mHitState == CharState_None)
|
||||||
|
@ -715,7 +756,18 @@ bool CharacterController::updateCreatureState()
|
||||||
1, "start", "stop",
|
1, "start", "stop",
|
||||||
0.0f, 0);
|
0.0f, 0);
|
||||||
mUpperBodyState = UpperCharState_StartToMinAttack;
|
mUpperBodyState = UpperCharState_StartToMinAttack;
|
||||||
|
|
||||||
|
if (weapType == WeapType_Spell)
|
||||||
|
{
|
||||||
|
const std::string spellid = stats.getSpells().getSelectedSpell();
|
||||||
|
if (!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
||||||
|
{
|
||||||
|
castSpell(spellid);
|
||||||
|
MWBase::Environment::get().getWorld()->castSpell(mPtr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stats.setAttackingOrSpell(false);
|
stats.setAttackingOrSpell(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,9 +906,7 @@ bool CharacterController::updateWeaponState()
|
||||||
|
|
||||||
if(!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
if(!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
||||||
{
|
{
|
||||||
static const std::string schools[] = {
|
castSpell(spellid);
|
||||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
|
||||||
};
|
|
||||||
|
|
||||||
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid);
|
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid);
|
||||||
const ESM::ENAMstruct &effectentry = spell->mEffects.mList.at(0);
|
const ESM::ENAMstruct &effectentry = spell->mEffects.mList.at(0);
|
||||||
|
@ -864,15 +914,7 @@ bool CharacterController::updateWeaponState()
|
||||||
const ESM::MagicEffect *effect;
|
const ESM::MagicEffect *effect;
|
||||||
effect = store.get<ESM::MagicEffect>().find(effectentry.mEffectID);
|
effect = store.get<ESM::MagicEffect>().find(effectentry.mEffectID);
|
||||||
|
|
||||||
const ESM::Static* castStatic;
|
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Hands");
|
||||||
if (!effect->mCasting.empty())
|
|
||||||
castStatic = store.get<ESM::Static>().find (effect->mCasting);
|
|
||||||
else
|
|
||||||
castStatic = store.get<ESM::Static>().find ("VFX_DefaultCast");
|
|
||||||
|
|
||||||
mAnimation->addEffect("meshes\\" + castStatic->mModel, effect->mIndex);
|
|
||||||
|
|
||||||
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Hands");
|
|
||||||
if (mAnimation->getNode("Left Hand"))
|
if (mAnimation->getNode("Left Hand"))
|
||||||
{
|
{
|
||||||
mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Left Hand", effect->mParticle);
|
mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Left Hand", effect->mParticle);
|
||||||
|
@ -896,12 +938,6 @@ bool CharacterController::updateWeaponState()
|
||||||
weapSpeed, mAttackType+" start", mAttackType+" stop",
|
weapSpeed, mAttackType+" start", mAttackType+" stop",
|
||||||
0.0f, 0);
|
0.0f, 0);
|
||||||
mUpperBodyState = UpperCharState_CastingSpell;
|
mUpperBodyState = UpperCharState_CastingSpell;
|
||||||
|
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
|
||||||
if(!effect->mCastSound.empty())
|
|
||||||
sndMgr->playSound3D(mPtr, effect->mCastSound, 1.0f, 1.0f);
|
|
||||||
else
|
|
||||||
sndMgr->playSound3D(mPtr, schools[effect->mData.mSchool]+" cast", 1.0f, 1.0f);
|
|
||||||
}
|
}
|
||||||
if (inv.getSelectedEnchantItem() != inv.end())
|
if (inv.getSelectedEnchantItem() != inv.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -181,6 +181,8 @@ class CharacterController
|
||||||
bool updateCreatureState();
|
bool updateCreatureState();
|
||||||
void updateIdleStormState();
|
void updateIdleStormState();
|
||||||
|
|
||||||
|
void castSpell(const std::string& spellid);
|
||||||
|
|
||||||
void updateVisibility();
|
void updateVisibility();
|
||||||
|
|
||||||
void playDeath(float startpoint, CharacterState death);
|
void playDeath(float startpoint, CharacterState death);
|
||||||
|
|
Loading…
Reference in a new issue