forked from mirror/openmw-tes3mp
Handle spell-casting animation sequences
This commit is contained in:
parent
4d157cb19a
commit
17282c69b1
2 changed files with 51 additions and 22 deletions
|
@ -298,6 +298,7 @@ void CharacterController::updatePtr(const MWWorld::Ptr &ptr)
|
||||||
bool CharacterController::updateNpcState()
|
bool CharacterController::updateNpcState()
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
||||||
|
CreatureStats &crstats = cls.getCreatureStats(mPtr);
|
||||||
NpcStats &stats = cls.getNpcStats(mPtr);
|
NpcStats &stats = cls.getNpcStats(mPtr);
|
||||||
WeaponType weaptype = WeapType_None;
|
WeaponType weaptype = WeapType_None;
|
||||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||||
|
@ -411,32 +412,58 @@ bool CharacterController::updateNpcState()
|
||||||
float complete;
|
float complete;
|
||||||
bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
|
bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
|
||||||
|
|
||||||
if(cls.getCreatureStats(mPtr).getAttackingOrSpell())
|
if(crstats.getAttackingOrSpell())
|
||||||
{
|
{
|
||||||
if(mUpperBodyState == UpperCharState_WeapEquiped && mWeaponType != WeapType_PickProbe)
|
if(mUpperBodyState == UpperCharState_WeapEquiped)
|
||||||
{
|
{
|
||||||
if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow ||
|
if(mWeaponType == WeapType_Spell)
|
||||||
mWeaponType == WeapType_ThowWeapon)
|
|
||||||
mAttackType = "shoot";
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
int attackType = cls.getCreatureStats(mPtr).getAttackType();
|
const std::string spellid = crstats.getSpells().getSelectedSpell();
|
||||||
if(isWeapon && Settings::Manager::getBool("best attack", "Game"))
|
if(!spellid.empty())
|
||||||
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
|
{
|
||||||
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid);
|
||||||
|
|
||||||
if (attackType == MWMechanics::CreatureStats::AT_Chop)
|
switch(spell->mEffects.mList.at(0).mRange)
|
||||||
mAttackType = "chop";
|
{
|
||||||
else if (attackType == MWMechanics::CreatureStats::AT_Slash)
|
case 0: mAttackType = "self"; break;
|
||||||
mAttackType = "slash";
|
case 1: mAttackType = "touch"; break;
|
||||||
else
|
case 2: mAttackType = "target"; break;
|
||||||
mAttackType = "thrust";
|
default: mAttackType = ""; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
||||||
|
MWRender::Animation::Group_UpperBody, true,
|
||||||
|
weapSpeed, mAttackType+" start", mAttackType+" stop",
|
||||||
|
0.0f, 0);
|
||||||
|
mUpperBodyState = UpperCharState_CastingSpell;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if(mWeaponType != WeapType_PickProbe)
|
||||||
|
{
|
||||||
|
if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow ||
|
||||||
|
mWeaponType == WeapType_ThowWeapon)
|
||||||
|
mAttackType = "shoot";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int attackType = crstats.getAttackType();
|
||||||
|
if(isWeapon && Settings::Manager::getBool("best attack", "Game"))
|
||||||
|
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
|
||||||
|
|
||||||
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
if (attackType == MWMechanics::CreatureStats::AT_Chop)
|
||||||
MWRender::Animation::Group_UpperBody, false,
|
mAttackType = "chop";
|
||||||
weapSpeed, mAttackType+" start", mAttackType+" min attack",
|
else if (attackType == MWMechanics::CreatureStats::AT_Slash)
|
||||||
0.0f, 0);
|
mAttackType = "slash";
|
||||||
mUpperBodyState = UpperCharState_StartToMinAttack;
|
else
|
||||||
|
mAttackType = "thrust";
|
||||||
|
}
|
||||||
|
|
||||||
|
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
||||||
|
MWRender::Animation::Group_UpperBody, false,
|
||||||
|
weapSpeed, mAttackType+" start", mAttackType+" min attack",
|
||||||
|
0.0f, 0);
|
||||||
|
mUpperBodyState = UpperCharState_StartToMinAttack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack)
|
else if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack)
|
||||||
|
@ -452,7 +479,8 @@ bool CharacterController::updateNpcState()
|
||||||
if(!animPlaying)
|
if(!animPlaying)
|
||||||
{
|
{
|
||||||
if(mUpperBodyState == UpperCharState_EquipingWeap ||
|
if(mUpperBodyState == UpperCharState_EquipingWeap ||
|
||||||
mUpperBodyState == UpperCharState_FollowStartToFollowStop)
|
mUpperBodyState == UpperCharState_FollowStartToFollowStop ||
|
||||||
|
mUpperBodyState == UpperCharState_CastingSpell)
|
||||||
mUpperBodyState = UpperCharState_WeapEquiped;
|
mUpperBodyState = UpperCharState_WeapEquiped;
|
||||||
else if(mUpperBodyState == UpperCharState_UnEquipingWeap)
|
else if(mUpperBodyState == UpperCharState_UnEquipingWeap)
|
||||||
mUpperBodyState = UpperCharState_Nothing;
|
mUpperBodyState = UpperCharState_Nothing;
|
||||||
|
|
|
@ -104,7 +104,8 @@ enum UpperBodyCharacterState {
|
||||||
UpperCharState_MinAttackToMaxAttack,
|
UpperCharState_MinAttackToMaxAttack,
|
||||||
UpperCharState_MaxAttackToMinHit,
|
UpperCharState_MaxAttackToMinHit,
|
||||||
UpperCharState_MinHitToHit,
|
UpperCharState_MinHitToHit,
|
||||||
UpperCharState_FollowStartToFollowStop
|
UpperCharState_FollowStartToFollowStop,
|
||||||
|
UpperCharState_CastingSpell
|
||||||
};
|
};
|
||||||
|
|
||||||
class CharacterController
|
class CharacterController
|
||||||
|
|
Loading…
Reference in a new issue