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