mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-07 13:20:25 +00:00
Introduced attacktype enum, fixed lua docs
This commit is contained in:
parent
2ef0568dda
commit
b01b76b81e
@ -1,6 +1,7 @@
|
|||||||
#include "localscripts.hpp"
|
#include "localscripts.hpp"
|
||||||
|
|
||||||
#include <components/esm3/loadcell.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
|
#include <components/esm3/loadweap.hpp>
|
||||||
#include <components/misc/strings/lower.hpp>
|
#include <components/misc/strings/lower.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
@ -13,6 +14,7 @@
|
|||||||
#include "../mwmechanics/aisequence.hpp"
|
#include "../mwmechanics/aisequence.hpp"
|
||||||
#include "../mwmechanics/aitravel.hpp"
|
#include "../mwmechanics/aitravel.hpp"
|
||||||
#include "../mwmechanics/aiwander.hpp"
|
#include "../mwmechanics/aiwander.hpp"
|
||||||
|
#include "../mwmechanics/attacktype.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
@ -63,8 +65,11 @@ namespace MWLua
|
|||||||
selfAPI["controls"] = sol::readonly_property([](SelfObject& self) { return &self.mControls; });
|
selfAPI["controls"] = sol::readonly_property([](SelfObject& self) { return &self.mControls; });
|
||||||
selfAPI["isActive"] = [](SelfObject& self) { return &self.mIsActive; };
|
selfAPI["isActive"] = [](SelfObject& self) { return &self.mIsActive; };
|
||||||
selfAPI["enableAI"] = [](SelfObject& self, bool v) { self.mControls.mDisableAI = !v; };
|
selfAPI["enableAI"] = [](SelfObject& self, bool v) { self.mControls.mDisableAI = !v; };
|
||||||
selfAPI["AttackTYPE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, int>(
|
selfAPI["AttackTYPE"]
|
||||||
{ { "NoAttack", 0 }, { "Attack", 1 }, { "Chop", 1 }, { "Slash", 2 }, { "Thrust", 3 } }));
|
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, MWMechanics::AttackType>(
|
||||||
|
{ { "NoAttack", MWMechanics::AttackType::NoAttack }, { "Any", MWMechanics::AttackType::Any },
|
||||||
|
{ "Chop", MWMechanics::AttackType::Chop }, { "Slash", MWMechanics::AttackType::Slash },
|
||||||
|
{ "Thrust", MWMechanics::AttackType::Thrust } }));
|
||||||
|
|
||||||
using AiPackage = MWMechanics::AiPackage;
|
using AiPackage = MWMechanics::AiPackage;
|
||||||
sol::usertype<AiPackage> aiPackage = context.mLua->sol().new_usertype<AiPackage>("AiPackage");
|
sol::usertype<AiPackage> aiPackage = context.mLua->sol().new_usertype<AiPackage>("AiPackage");
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "aifollow.hpp"
|
#include "aifollow.hpp"
|
||||||
#include "aipursue.hpp"
|
#include "aipursue.hpp"
|
||||||
#include "aiwander.hpp"
|
#include "aiwander.hpp"
|
||||||
|
#include "attacktype.hpp"
|
||||||
#include "character.hpp"
|
#include "character.hpp"
|
||||||
#include "creaturestats.hpp"
|
#include "creaturestats.hpp"
|
||||||
#include "movement.hpp"
|
#include "movement.hpp"
|
||||||
@ -239,13 +240,13 @@ namespace MWMechanics
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::string_view attackTypeName(int attackTypeNum)
|
std::string_view attackTypeName(AttackType attackType)
|
||||||
{
|
{
|
||||||
if (attackTypeNum == 1)
|
if (attackType == AttackType::Chop)
|
||||||
return "chop";
|
return "chop";
|
||||||
else if (attackTypeNum == 2)
|
else if (attackType == AttackType::Slash)
|
||||||
return "slash";
|
return "slash";
|
||||||
else if (attackTypeNum == 3)
|
else if (attackType == AttackType::Thrust)
|
||||||
return "thrust";
|
return "thrust";
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
@ -376,9 +377,11 @@ namespace MWMechanics
|
|||||||
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);
|
||||||
|
|
||||||
int attackTypeNum = controls.mUse & 3;
|
// Same as mUse % max AttackType int value
|
||||||
stats.setAttackingOrSpell(attackTypeNum != 0);
|
AttackType attackType = static_cast<AttackType>(controls.mUse % static_cast<int>(AttackType::Thrust));
|
||||||
stats.setAttackType(attackTypeName(attackTypeNum));
|
|
||||||
|
stats.setAttackingOrSpell(attackType != AttackType::NoAttack);
|
||||||
|
stats.setAttackType(attackTypeName(attackType));
|
||||||
|
|
||||||
controls.mChanged = false;
|
controls.mChanged = false;
|
||||||
}
|
}
|
||||||
|
16
apps/openmw/mwmechanics/attacktype.hpp
Normal file
16
apps/openmw/mwmechanics/attacktype.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef OPENMW_MWMECHANICS_ATTACKTYPE_H
|
||||||
|
#define OPENMW_MWMECHANICS_ATTACKTYPE_H
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
enum class AttackType
|
||||||
|
{
|
||||||
|
NoAttack,
|
||||||
|
Any,
|
||||||
|
Chop,
|
||||||
|
Slash,
|
||||||
|
Thrust
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -37,11 +37,12 @@
|
|||||||
-- @field [parent=#ActorControls] #boolean run true - run, false - walk
|
-- @field [parent=#ActorControls] #boolean run true - run, false - walk
|
||||||
-- @field [parent=#ActorControls] #boolean sneak If true - sneak
|
-- @field [parent=#ActorControls] #boolean sneak If true - sneak
|
||||||
-- @field [parent=#ActorControls] #boolean jump If true - initiate a jump
|
-- @field [parent=#ActorControls] #boolean jump If true - initiate a jump
|
||||||
-- @field [parent=#ActorControls] #number Accepts an @{#AttackTYPE} value. Activates the readied weapon/spell according to a provided value. For weapons, keeping this value modified will charge the attack until set to @{#AttackTYPE.NoAttack}.
|
-- @field [parent=#ActorControls] #number use Accepts an @{#AttackTYPE} value. Activates the readied weapon/spell according to a provided value. For weapons, keeping this value modified will charge the attack until set to @{#AttackTYPE.NoAttack}. If an @{#AttackTYPE} not appropriate for a currently equipped weapon provided - an appropriate @{#AttackTYPE} will be used instead.
|
||||||
|
|
||||||
|
---
|
||||||
-- @type AttackTYPE
|
-- @type AttackTYPE
|
||||||
-- @field #number NoAttack
|
-- @field #number NoAttack
|
||||||
-- @field #number Attack
|
-- @field #number Any
|
||||||
-- @field #number Chop
|
-- @field #number Chop
|
||||||
-- @field #number Swing
|
-- @field #number Swing
|
||||||
-- @field #number Thrust
|
-- @field #number Thrust
|
||||||
|
Loading…
x
Reference in New Issue
Block a user