mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Move attackingOrSpell flag to the CharacterController
This commit is contained in:
parent
519fb9482a
commit
a1432b0255
11 changed files with 41 additions and 30 deletions
|
@ -207,7 +207,7 @@ namespace MWInput
|
||||||
if (mControlSwitch["playercontrols"])
|
if (mControlSwitch["playercontrols"])
|
||||||
{
|
{
|
||||||
if (action == A_Use)
|
if (action == A_Use)
|
||||||
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue != 0);
|
mPlayer->setAttackingOrSpell(currentValue != 0);
|
||||||
else if (action == A_Jump)
|
else if (action == A_Jump)
|
||||||
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
|
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1086,6 +1086,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
iter->second->getCharacterController()->setActive(inProcessingRange);
|
iter->second->getCharacterController()->setActive(inProcessingRange);
|
||||||
|
|
||||||
|
if (iter->first == player)
|
||||||
|
iter->second->getCharacterController()->setAttackingOrSpell(MWBase::Environment::get().getWorld()->getPlayer().getAttackingOrSpell());
|
||||||
|
|
||||||
if (!iter->first.getClass().getCreatureStats(iter->first).isDead())
|
if (!iter->first.getClass().getCreatureStats(iter->first).isDead())
|
||||||
{
|
{
|
||||||
updateActor(iter->first, duration);
|
updateActor(iter->first, duration);
|
||||||
|
|
|
@ -269,8 +269,7 @@ namespace MWMechanics
|
||||||
attack = false;
|
attack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
actorClass.getCreatureStats(actor).setAttackingOrSpell(attack);
|
characterController.setAttackingOrSpell(attack);
|
||||||
|
|
||||||
|
|
||||||
float& actionCooldown = storage.mActionCooldown;
|
float& actionCooldown = storage.mActionCooldown;
|
||||||
actionCooldown -= duration;
|
actionCooldown -= duration;
|
||||||
|
@ -476,7 +475,7 @@ namespace MWMechanics
|
||||||
movement.mPosition[1] = 0;
|
movement.mPosition[1] = 0;
|
||||||
movement.mPosition[2] = 0;
|
movement.mPosition[2] = 0;
|
||||||
readyToAttack = false;
|
readyToAttack = false;
|
||||||
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
|
characterController.setAttackingOrSpell(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,6 +654,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
, mSecondsOfSwimming(0)
|
, mSecondsOfSwimming(0)
|
||||||
, mSecondsOfRunning(0)
|
, mSecondsOfRunning(0)
|
||||||
, mTurnAnimationThreshold(0)
|
, mTurnAnimationThreshold(0)
|
||||||
|
, mAttackingOrSpell(false)
|
||||||
{
|
{
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
@ -937,7 +938,7 @@ bool CharacterController::updateCreatureState()
|
||||||
mAnimation->disable(mCurrentWeapon);
|
mAnimation->disable(mCurrentWeapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stats.getAttackingOrSpell())
|
if(mAttackingOrSpell)
|
||||||
{
|
{
|
||||||
if(mUpperBodyState == UpperCharState_Nothing && mHitState == CharState_None)
|
if(mUpperBodyState == UpperCharState_Nothing && mHitState == CharState_None)
|
||||||
{
|
{
|
||||||
|
@ -997,7 +998,7 @@ bool CharacterController::updateCreatureState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.setAttackingOrSpell(false);
|
mAttackingOrSpell = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool animPlaying = mAnimation->getInfo(mCurrentWeapon);
|
bool animPlaying = mAnimation->getInfo(mCurrentWeapon);
|
||||||
|
@ -1142,7 +1143,7 @@ bool CharacterController::updateWeaponState()
|
||||||
|
|
||||||
float complete;
|
float complete;
|
||||||
bool animPlaying;
|
bool animPlaying;
|
||||||
if(stats.getAttackingOrSpell())
|
if(mAttackingOrSpell)
|
||||||
{
|
{
|
||||||
if(mUpperBodyState == UpperCharState_WeapEquiped && mHitState == CharState_None)
|
if(mUpperBodyState == UpperCharState_WeapEquiped && mHitState == CharState_None)
|
||||||
{
|
{
|
||||||
|
@ -1152,7 +1153,7 @@ bool CharacterController::updateWeaponState()
|
||||||
{
|
{
|
||||||
// Unset casting flag, otherwise pressing the mouse button down would
|
// Unset casting flag, otherwise pressing the mouse button down would
|
||||||
// continue casting every frame if there is no animation
|
// continue casting every frame if there is no animation
|
||||||
stats.setAttackingOrSpell(false);
|
mAttackingOrSpell = false;
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
|
@ -2041,6 +2042,11 @@ bool CharacterController::isKnockedOut() const
|
||||||
return mHitState == CharState_KnockOut;
|
return mHitState == CharState_KnockOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::setAttackingOrSpell(bool attackingOrSpell)
|
||||||
|
{
|
||||||
|
mAttackingOrSpell = attackingOrSpell;
|
||||||
|
}
|
||||||
|
|
||||||
void CharacterController::setActive(bool active)
|
void CharacterController::setActive(bool active)
|
||||||
{
|
{
|
||||||
mAnimation->setActive(active);
|
mAnimation->setActive(active);
|
||||||
|
|
|
@ -180,6 +180,9 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning
|
float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning
|
||||||
|
|
||||||
std::string mAttackType; // slash, chop or thrust
|
std::string mAttackType; // slash, chop or thrust
|
||||||
|
|
||||||
|
bool mAttackingOrSpell;
|
||||||
|
|
||||||
void determineAttackType();
|
void determineAttackType();
|
||||||
|
|
||||||
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
|
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
|
||||||
|
@ -235,6 +238,8 @@ public:
|
||||||
bool isReadyToBlock() const;
|
bool isReadyToBlock() const;
|
||||||
bool isKnockedOut() const;
|
bool isKnockedOut() const;
|
||||||
|
|
||||||
|
void setAttackingOrSpell(bool attackingOrSpell);
|
||||||
|
|
||||||
/// @see Animation::setActive
|
/// @see Animation::setActive
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
CreatureStats::CreatureStats()
|
CreatureStats::CreatureStats()
|
||||||
: mDrawState (DrawState_Nothing), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
|
: mDrawState (DrawState_Nothing), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
|
||||||
mTalkedTo (false), mAlarmed (false), mAttacked (false), mAttackingOrSpell(false),
|
mTalkedTo (false), mAlarmed (false), mAttacked (false),
|
||||||
mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false),
|
mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false),
|
||||||
mHitRecovery(false), mBlock(false), mMovementFlags(0),
|
mHitRecovery(false), mBlock(false), mMovementFlags(0),
|
||||||
mFallHeight(0), mRecalcMagicka(false), mLastRestock(0,0), mGoldPool(0), mActorId(-1),
|
mFallHeight(0), mRecalcMagicka(false), mLastRestock(0,0), mGoldPool(0), mActorId(-1),
|
||||||
|
@ -88,11 +88,6 @@ namespace MWMechanics
|
||||||
return mMagicEffects;
|
return mMagicEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreatureStats::getAttackingOrSpell() const
|
|
||||||
{
|
|
||||||
return mAttackingOrSpell;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatureStats::getLevel() const
|
int CreatureStats::getLevel() const
|
||||||
{
|
{
|
||||||
return mLevel;
|
return mLevel;
|
||||||
|
@ -212,11 +207,6 @@ namespace MWMechanics
|
||||||
mMagicEffects.setModifiers(effects);
|
mMagicEffects.setModifiers(effects);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatureStats::setAttackingOrSpell(bool attackingOrSpell)
|
|
||||||
{
|
|
||||||
mAttackingOrSpell = attackingOrSpell;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
||||||
{
|
{
|
||||||
mAiSettings[index] = value;
|
mAiSettings[index] = value;
|
||||||
|
@ -487,7 +477,6 @@ namespace MWMechanics
|
||||||
state.mTalkedTo = mTalkedTo;
|
state.mTalkedTo = mTalkedTo;
|
||||||
state.mAlarmed = mAlarmed;
|
state.mAlarmed = mAlarmed;
|
||||||
state.mAttacked = mAttacked;
|
state.mAttacked = mAttacked;
|
||||||
state.mAttackingOrSpell = mAttackingOrSpell;
|
|
||||||
// TODO: rewrite. does this really need 3 separate bools?
|
// TODO: rewrite. does this really need 3 separate bools?
|
||||||
state.mKnockdown = mKnockdown;
|
state.mKnockdown = mKnockdown;
|
||||||
state.mKnockdownOneFrame = mKnockdownOneFrame;
|
state.mKnockdownOneFrame = mKnockdownOneFrame;
|
||||||
|
@ -534,7 +523,6 @@ namespace MWMechanics
|
||||||
mTalkedTo = state.mTalkedTo;
|
mTalkedTo = state.mTalkedTo;
|
||||||
mAlarmed = state.mAlarmed;
|
mAlarmed = state.mAlarmed;
|
||||||
mAttacked = state.mAttacked;
|
mAttacked = state.mAttacked;
|
||||||
mAttackingOrSpell = state.mAttackingOrSpell;
|
|
||||||
// TODO: rewrite. does this really need 3 separate bools?
|
// TODO: rewrite. does this really need 3 separate bools?
|
||||||
mKnockdown = state.mKnockdown;
|
mKnockdown = state.mKnockdown;
|
||||||
mKnockdownOneFrame = state.mKnockdownOneFrame;
|
mKnockdownOneFrame = state.mKnockdownOneFrame;
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace MWMechanics
|
||||||
bool mTalkedTo;
|
bool mTalkedTo;
|
||||||
bool mAlarmed;
|
bool mAlarmed;
|
||||||
bool mAttacked;
|
bool mAttacked;
|
||||||
bool mAttackingOrSpell;
|
|
||||||
bool mKnockdown;
|
bool mKnockdown;
|
||||||
bool mKnockdownOneFrame;
|
bool mKnockdownOneFrame;
|
||||||
bool mKnockdownOverOneFrame;
|
bool mKnockdownOverOneFrame;
|
||||||
|
|
|
@ -36,7 +36,8 @@ namespace MWWorld
|
||||||
mForwardBackward(0),
|
mForwardBackward(0),
|
||||||
mTeleported(false),
|
mTeleported(false),
|
||||||
mCurrentCrimeId(-1),
|
mCurrentCrimeId(-1),
|
||||||
mPaidCrimeId(-1)
|
mPaidCrimeId(-1),
|
||||||
|
mAttackingOrSpell(false)
|
||||||
{
|
{
|
||||||
ESM::CellRef cellRef;
|
ESM::CellRef cellRef;
|
||||||
cellRef.blank();
|
cellRef.blank();
|
||||||
|
@ -216,6 +217,16 @@ namespace MWWorld
|
||||||
mTeleported = teleported;
|
mTeleported = teleported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::setAttackingOrSpell(bool attackingOrSpell)
|
||||||
|
{
|
||||||
|
mAttackingOrSpell = attackingOrSpell;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Player::getAttackingOrSpell() const
|
||||||
|
{
|
||||||
|
return mAttackingOrSpell;
|
||||||
|
}
|
||||||
|
|
||||||
bool Player::isInCombat() {
|
bool Player::isInCombat() {
|
||||||
return MWBase::Environment::get().getMechanicsManager()->getActorsFighting(getPlayer()).size() != 0;
|
return MWBase::Environment::get().getMechanicsManager()->getActorsFighting(getPlayer()).size() != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ namespace MWWorld
|
||||||
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
||||||
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
||||||
|
|
||||||
|
bool mAttackingOrSpell;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Player(const ESM::NPC *player);
|
Player(const ESM::NPC *player);
|
||||||
|
@ -98,6 +100,9 @@ namespace MWWorld
|
||||||
bool wasTeleported() const;
|
bool wasTeleported() const;
|
||||||
void setTeleported(bool teleported);
|
void setTeleported(bool teleported);
|
||||||
|
|
||||||
|
void setAttackingOrSpell(bool attackingOrSpell);
|
||||||
|
bool getAttackingOrSpell() const;
|
||||||
|
|
||||||
///Checks all nearby actors to see if anyone has an aipackage against you
|
///Checks all nearby actors to see if anyone has an aipackage against you
|
||||||
bool isInCombat();
|
bool isInCombat();
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ void ESM::CreatureStats::load (ESMReader &esm)
|
||||||
if (esm.isNextSub("HOST"))
|
if (esm.isNextSub("HOST"))
|
||||||
esm.skipHSub(); // Hostile, no longer used
|
esm.skipHSub(); // Hostile, no longer used
|
||||||
|
|
||||||
mAttackingOrSpell = false;
|
if (esm.isNextSub("ATCK"))
|
||||||
esm.getHNOT (mAttackingOrSpell, "ATCK");
|
esm.skipHSub(); // attackingOrSpell, no longer used
|
||||||
|
|
||||||
mKnockdown = false;
|
mKnockdown = false;
|
||||||
esm.getHNOT (mKnockdown, "KNCK");
|
esm.getHNOT (mKnockdown, "KNCK");
|
||||||
|
@ -149,9 +149,6 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
|
||||||
if (mAttacked)
|
if (mAttacked)
|
||||||
esm.writeHNT ("ATKD", mAttacked);
|
esm.writeHNT ("ATKD", mAttacked);
|
||||||
|
|
||||||
if (mAttackingOrSpell)
|
|
||||||
esm.writeHNT ("ATCK", mAttackingOrSpell);
|
|
||||||
|
|
||||||
if (mKnockdown)
|
if (mKnockdown)
|
||||||
esm.writeHNT ("KNCK", mKnockdown);
|
esm.writeHNT ("KNCK", mKnockdown);
|
||||||
|
|
||||||
|
@ -232,7 +229,6 @@ void ESM::CreatureStats::blank()
|
||||||
mTalkedTo = false;
|
mTalkedTo = false;
|
||||||
mAlarmed = false;
|
mAlarmed = false;
|
||||||
mAttacked = false;
|
mAttacked = false;
|
||||||
mAttackingOrSpell = false;
|
|
||||||
mKnockdown = false;
|
mKnockdown = false;
|
||||||
mKnockdownOneFrame = false;
|
mKnockdownOneFrame = false;
|
||||||
mKnockdownOverOneFrame = false;
|
mKnockdownOverOneFrame = false;
|
||||||
|
|
|
@ -45,7 +45,6 @@ namespace ESM
|
||||||
bool mTalkedTo;
|
bool mTalkedTo;
|
||||||
bool mAlarmed;
|
bool mAlarmed;
|
||||||
bool mAttacked;
|
bool mAttacked;
|
||||||
bool mAttackingOrSpell;
|
|
||||||
bool mKnockdown;
|
bool mKnockdown;
|
||||||
bool mKnockdownOneFrame;
|
bool mKnockdownOneFrame;
|
||||||
bool mKnockdownOverOneFrame;
|
bool mKnockdownOverOneFrame;
|
||||||
|
|
Loading…
Reference in a new issue