1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-07 11:17:46 +00:00
sapphire/src/world/Actor/BNpc.h

161 lines
3.2 KiB
C
Raw Normal View History

#ifndef _BNPC_H_
#define _BNPC_H_
#include <Common.h>
#include "Forwards.h"
#include "Chara.h"
#include "Npc.h"
#include <set>
#include <map>
#include <queue>
namespace Sapphire::Entity
2018-10-28 21:53:21 +01:00
{
struct HateListEntry
{
uint32_t m_hateAmount;
CharaPtr m_pChara;
};
enum class BNpcState
{
Idle,
Combat,
Retreat,
Roaming,
JustDied,
Dead,
};
enum BNpcFlag
{
None = 0,
Immobile = 1,
TurningDisabled = 2,
Invincible = 4,
InvincibleRefill = 8,
NoDeaggro = 16,
Untargetable = 32,
};
2018-10-28 21:53:21 +01:00
/*!
\class BNpc
\brief Base class for all BNpcs
2018-10-28 21:53:21 +01:00
*/
class BNpc : public Npc
{
2018-10-28 21:53:21 +01:00
public:
2020-03-01 01:00:57 +11:00
BNpc();
BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, float rot,
2020-03-01 01:00:57 +11:00
uint8_t level, uint32_t maxHp, TerritoryPtr pZone );
2018-10-28 21:53:21 +01:00
virtual ~BNpc() override;
2018-10-28 21:53:21 +01:00
void spawn( PlayerPtr pTarget ) override;
void despawn( PlayerPtr pTarget ) override;
2018-10-28 21:53:21 +01:00
uint16_t getModelChara() const;
uint8_t getLevel() const override;
2018-10-28 21:53:21 +01:00
uint32_t getBNpcBaseId() const;
uint32_t getBNpcNameId() const;
2018-10-28 21:53:21 +01:00
uint8_t getEnemyType() const;
2018-10-28 21:53:21 +01:00
uint64_t getWeaponMain() const;
uint64_t getWeaponSub() const;
2018-10-28 21:53:21 +01:00
uint8_t getAggressionMode() const;
2019-04-19 23:01:27 +10:00
2019-01-31 22:49:04 +11:00
float getNaviTargetReachedDistance() const;
// return true if it reached the position
bool moveTo( const Common::FFXIVARR_POSITION3& pos );
2019-04-20 00:11:00 +02:00
bool moveTo( const Entity::Chara& targetChara );
void sendPositionUpdate();
BNpcState getState() const;
void setState( BNpcState state );
void hateListClear();
CharaPtr hateListGetHighest();
void hateListAdd( CharaPtr pChara, int32_t hateAmount );
void hateListUpdate( CharaPtr pChara, int32_t hateAmount );
void hateListRemove( CharaPtr pChara );
bool hateListHasActor( CharaPtr pChara );
void aggro( CharaPtr pChara );
void deaggro( CharaPtr pChara );
void update( uint64_t tickCount ) override;
void onTick() override;
void onActionHostile( CharaPtr pSource ) override;
void onDeath() override;
void autoAttack( CharaPtr pTarget ) override;
2019-01-23 22:37:55 +01:00
uint32_t getTimeOfDeath() const;
2019-01-26 14:59:04 +11:00
void setTimeOfDeath( uint32_t timeOfDeath );
2019-01-23 22:37:55 +01:00
void regainHp();
void checkAggro();
void setOwner( CharaPtr m_pChara );
void setLevelId( uint32_t levelId );
uint32_t getLevelId() const;
bool hasFlag( uint32_t flag ) const;
void setFlag( uint32_t flags );
void calculateStats() override;
2018-10-28 21:53:21 +01:00
private:
uint32_t m_bNpcBaseId;
uint32_t m_bNpcNameId;
uint64_t m_weaponMain;
uint64_t m_weaponSub;
uint8_t m_aggressionMode;
uint8_t m_enemyType;
uint8_t m_onlineStatus;
uint8_t m_pose;
uint16_t m_modelChara;
uint32_t m_displayFlags;
uint8_t m_level;
uint32_t m_levelId;
uint32_t m_flags;
2019-01-31 22:49:04 +11:00
float m_naviTargetReachedDistance;
2019-01-23 22:37:55 +01:00
uint32_t m_timeOfDeath;
uint32_t m_lastRoamTargetReached;
2019-01-23 22:37:55 +01:00
Common::FFXIVARR_POSITION3 m_spawnPos;
Common::FFXIVARR_POSITION3 m_roamPos;
BNpcState m_state;
std::set< std::shared_ptr< HateListEntry > > m_hateList;
2019-01-23 17:07:40 +01:00
uint64_t m_naviLastUpdate;
std::vector< Common::FFXIVARR_POSITION3 > m_naviLastPath;
uint8_t m_naviPathStep;
Common::FFXIVARR_POSITION3 m_naviTarget;
CharaPtr m_pOwner;
2018-10-28 21:53:21 +01:00
};
}
#endif