mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-06 00:40:04 +00:00
An ability to specify attack type in controls.use value
This commit is contained in:
parent
82285dadc4
commit
22d9906978
@ -239,6 +239,18 @@ namespace MWMechanics
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string_view attackTypeName(int attackTypeNum)
|
||||
{
|
||||
if (attackTypeNum == 1)
|
||||
return "chop";
|
||||
else if (attackTypeNum == 2)
|
||||
return "slash";
|
||||
else if (attackTypeNum == 3)
|
||||
return "thrust";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
float getTimeToDestination(const AiPackage& package, const osg::Vec3f& position, float speed, float duration,
|
||||
const osg::Vec3f& halfExtents)
|
||||
{
|
||||
@ -363,7 +375,11 @@ namespace MWMechanics
|
||||
mov.mSpeedFactor = osg::Vec2(controls.mMovement, controls.mSideMovement).length();
|
||||
stats.setMovementFlag(MWMechanics::CreatureStats::Flag_Run, controls.mRun);
|
||||
stats.setMovementFlag(MWMechanics::CreatureStats::Flag_Sneak, controls.mSneak);
|
||||
stats.setAttackingOrSpell((controls.mUse & 1) == 1);
|
||||
|
||||
int attackTypeNum = controls.mUse & 3;
|
||||
stats.setAttackingOrSpell(attackTypeNum != 0);
|
||||
stats.setAttackType(attackTypeName(attackTypeNum));
|
||||
|
||||
controls.mChanged = false;
|
||||
}
|
||||
// For the player we don't need to copy these values to Lua because mwinput doesn't change them.
|
||||
|
@ -1674,7 +1674,12 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
else if (aiInactive)
|
||||
mAttackType = getRandomAttackType();
|
||||
{
|
||||
mAttackType = getDesiredAttackType();
|
||||
if (mAttackType == "")
|
||||
mAttackType = getRandomAttackType();
|
||||
}
|
||||
|
||||
// else if (mPtr != getPlayer()) use mAttackType set by AiCombat
|
||||
startKey = mAttackType + ' ' + startKey;
|
||||
stopKey = mAttackType + " max attack";
|
||||
@ -3002,6 +3007,11 @@ namespace MWMechanics
|
||||
return mPtr.getClass().getCreatureStats(mPtr).getAttackingOrSpell();
|
||||
}
|
||||
|
||||
std::string_view CharacterController::getDesiredAttackType() const
|
||||
{
|
||||
return mPtr.getClass().getCreatureStats(mPtr).getAttackType();
|
||||
}
|
||||
|
||||
void CharacterController::setActive(int active) const
|
||||
{
|
||||
mAnimation->setActive(active);
|
||||
|
@ -247,6 +247,8 @@ namespace MWMechanics
|
||||
bool getAttackingOrSpell() const;
|
||||
void setAttackingOrSpell(bool attackingOrSpell) const;
|
||||
|
||||
std::string_view getDesiredAttackType() const;
|
||||
|
||||
void prepareHit();
|
||||
|
||||
public:
|
||||
|
@ -45,6 +45,7 @@ namespace MWMechanics
|
||||
, mSideMovementAngle(0)
|
||||
, mLevel(0)
|
||||
, mAttackingOrSpell(false)
|
||||
, mAttackType("")
|
||||
{
|
||||
for (const ESM::Attribute& attribute : MWBase::Environment::get().getESMStore()->get<ESM::Attribute>())
|
||||
{
|
||||
|
@ -97,6 +97,7 @@ namespace MWMechanics
|
||||
protected:
|
||||
int mLevel;
|
||||
bool mAttackingOrSpell;
|
||||
std::string mAttackType;
|
||||
|
||||
public:
|
||||
CreatureStats();
|
||||
@ -130,6 +131,7 @@ namespace MWMechanics
|
||||
const MagicEffects& getMagicEffects() const;
|
||||
|
||||
bool getAttackingOrSpell() const { return mAttackingOrSpell; }
|
||||
std::string_view getAttackType() const { return mAttackType; }
|
||||
|
||||
int getLevel() const;
|
||||
|
||||
@ -156,6 +158,8 @@ namespace MWMechanics
|
||||
|
||||
void setAttackingOrSpell(bool attackingOrSpell) { mAttackingOrSpell = attackingOrSpell; }
|
||||
|
||||
void setAttackType(std::string_view attackType) { mAttackType = attackType; }
|
||||
|
||||
void setLevel(int level);
|
||||
|
||||
void setAiSetting(AiSetting index, Stat<int> value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user