mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
125b21de20
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
112 lines
3.7 KiB
C++
112 lines
3.7 KiB
C++
#ifndef OPENMW_AICOMBAT_ACTION_H
|
|
#define OPENMW_AICOMBAT_ACTION_H
|
|
|
|
#include <memory>
|
|
|
|
#include "../mwworld/containerstore.hpp"
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
namespace MWMechanics
|
|
{
|
|
class Action
|
|
{
|
|
public:
|
|
virtual ~Action() {}
|
|
virtual void prepare(const MWWorld::Ptr& actor) = 0;
|
|
virtual float getCombatRange(bool& isRanged) const = 0;
|
|
virtual float getActionCooldown() { return 0.f; }
|
|
virtual const ESM::Weapon* getWeapon() const { return nullptr; }
|
|
virtual bool isAttackingOrSpell() const { return true; }
|
|
virtual bool isFleeing() const { return false; }
|
|
};
|
|
|
|
class ActionFlee : public Action
|
|
{
|
|
public:
|
|
ActionFlee() {}
|
|
void prepare(const MWWorld::Ptr& actor) override {}
|
|
float getCombatRange(bool& isRanged) const override { return 0.0f; }
|
|
float getActionCooldown() override { return 3.0f; }
|
|
bool isAttackingOrSpell() const override { return false; }
|
|
bool isFleeing() const override { return true; }
|
|
};
|
|
|
|
class ActionSpell : public Action
|
|
{
|
|
public:
|
|
ActionSpell(const ESM::RefId& spellId)
|
|
: mSpellId(spellId)
|
|
{
|
|
}
|
|
ESM::RefId mSpellId;
|
|
/// Sets the given spell as selected on the actor's spell list.
|
|
void prepare(const MWWorld::Ptr& actor) override;
|
|
|
|
float getCombatRange(bool& isRanged) const override;
|
|
};
|
|
|
|
class ActionEnchantedItem : public Action
|
|
{
|
|
public:
|
|
ActionEnchantedItem(const MWWorld::ContainerStoreIterator& item)
|
|
: mItem(item)
|
|
{
|
|
}
|
|
MWWorld::ContainerStoreIterator mItem;
|
|
/// Sets the given item as selected enchanted item in the actor's InventoryStore.
|
|
void prepare(const MWWorld::Ptr& actor) override;
|
|
float getCombatRange(bool& isRanged) const override;
|
|
|
|
/// Since this action has no animation, apply a small cool down for using it
|
|
float getActionCooldown() override { return 0.75f; }
|
|
};
|
|
|
|
class ActionPotion : public Action
|
|
{
|
|
public:
|
|
ActionPotion(const MWWorld::Ptr& potion)
|
|
: mPotion(potion)
|
|
{
|
|
}
|
|
MWWorld::Ptr mPotion;
|
|
/// Drinks the given potion.
|
|
void prepare(const MWWorld::Ptr& actor) override;
|
|
float getCombatRange(bool& isRanged) const override;
|
|
bool isAttackingOrSpell() const override { return false; }
|
|
|
|
/// Since this action has no animation, apply a small cool down for using it
|
|
float getActionCooldown() override { return 0.75f; }
|
|
};
|
|
|
|
class ActionWeapon : public Action
|
|
{
|
|
private:
|
|
MWWorld::Ptr mAmmunition;
|
|
MWWorld::Ptr mWeapon;
|
|
|
|
public:
|
|
/// \a weapon may be empty for hand-to-hand combat
|
|
ActionWeapon(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo = MWWorld::Ptr())
|
|
: mAmmunition(ammo)
|
|
, mWeapon(weapon)
|
|
{
|
|
}
|
|
/// Equips the given weapon.
|
|
void prepare(const MWWorld::Ptr& actor) override;
|
|
float getCombatRange(bool& isRanged) const override;
|
|
const ESM::Weapon* getWeapon() const override;
|
|
};
|
|
|
|
std::unique_ptr<Action> prepareNextAction(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
|
float getBestActionRating(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
|
|
|
float getDistanceMinusHalfExtents(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool minusZDist = false);
|
|
float getMaxAttackDistance(const MWWorld::Ptr& actor);
|
|
bool canFight(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
|
|
|
float vanillaRateFlee(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
|
bool makeFleeDecision(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, float antiFleeRating);
|
|
}
|
|
|
|
#endif
|