Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
AggressiveNpc Class Reference

AggressiveNpc is a type of Npc that attacks the player within its aggression range. More...

#include <AggressiveNpc.hpp>

Inheritance diagram for AggressiveNpc:
Inheritance graph
Collaboration diagram for AggressiveNpc:
Collaboration graph

Public Member Functions

 AggressiveNpc (GameWorld *pGameWorld, std::string name, int aggressionRange, int baseDamage, int baseAccuracy, SpawnCoordinateBounds spawnCoordinateBounds, std::vector< std::string > chatResponses, unsigned int id=0, Coordinates location=Coordinates())
 
 ~AggressiveNpc ()=default
 
void update () override
 Updates the AggressiveNpc. More...
 
- Public Member Functions inherited from Npc
 Npc (GameWorld *pGameWorld, std::string name, int baseDamage, int baseAccuracy, SpawnCoordinateBounds spawnCoordinateBounds, std::vector< std::string > chatResponses, unsigned int id=0, Coordinates location=Coordinates())
 
 ~Npc ()=default
 
void update ()
 Updates the NPC. More...
 
void respawn ()
 Respawn the NPC. More...
 
std::string getChatResponse ()
 Get a random chat response. More...
 
void addRandomItemToInventory ()
 
- Public Member Functions inherited from Entity
 Entity (GameWorld *pGameWorld, std::string name, int baseAccuracy, int baseDamage, SpawnCoordinateBounds spawnCoordinateBounds, unsigned int id=0, Coordinates location=Coordinates())
 
 ~Entity ()=default
 
unsigned int getId ()
 Get the type id of this entity. More...
 
unsigned int getInstanceId ()
 Get the unique id of this entity. More...
 
std::string getName ()
 Get the name of this entity. More...
 
CoordinatesgetLocation ()
 Get the current location of this entity. More...
 
void setLocation (Coordinates location)
 Set the location of this entity. More...
 
Coordinates getRespawnLocation ()
 Returns a random location within the spawn bounds. More...
 
std::shared_ptr< Action > & getCurrentAction ()
 Get the current action of this entity. More...
 
int getHp ()
 Get the current hp of this entity. More...
 
int getMaxHp ()
 Get the maximum hp of this entity. More...
 
InventorygetInventory ()
 Get the Inventory object of this entity. More...
 
EquipmentgetEquipment ()
 Get the Equipment object of this entity. More...
 
int getRange ()
 Get tha attack range of this entity. More...
 
int getAttackSpeed ()
 Get the attack speed of this entity in milliseconds. More...
 
std::chrono::milliseconds getMoveSpeed ()
 Get the movement speed of this entity. More...
 
GameWorldgetGameWorld ()
 Get pointer to the GameWorld that this entity resides in. More...
 
void changeHp (int amount)
 Change the hp of this entity by amount. More...
 
void setAction (std::shared_ptr< Action > action)
 Set the current action to parameter action. More...
 
bool move (Coordinates location)
 Move to a neighboring tile. More...
 
virtual void attack (Entity &target)
 Perform an attack on target entity. More...
 
void pickUpItem (int itemId, Coordinates itemLocation)
 Pick up an item. More...
 
void dropItem (int itemId)
 Drop an item. More...
 
SkillSetgetSkillSet ()
 Get the SkillSet of this entity. More...
 
bool isDisconnected ()
 Returns whether entity is disconnected, only relevant for players. More...
 
void setDisconnected ()
 Sets entity as disconnected, only relevant for players. More...
 

Private Member Functions

std::shared_ptr< PlayerCharacterfindClosestPlayer ()
 Finds the closest player to the AggressiveNpc. More...
 

Private Attributes

int aggressionRangeM
 

Additional Inherited Members

- Protected Attributes inherited from Entity
unsigned int idM
 
unsigned int instanceIdM
 
std::string nameM
 
Coordinates locationM
 
SpawnCoordinateBounds spawnCoordinateBoundsM
 
std::shared_ptr< ActioncurrentActionM = nullptr
 
int maxHpM = 1000
 
int hpM = maxHpM
 
GameWorldpGameWorldM
 
Inventory inventoryM
 
Equipment equipmentM
 
SkillSet skillSetM
 
int baseDamageM
 
int baseAccuracyM
 
bool isDisconnectedM = false
 
std::chrono::milliseconds respawnTimeM {2000}
 
std::chrono::milliseconds moveSpeedM {1000}
 
- Static Protected Attributes inherited from Entity
static int nextInstanceIdM = 0
 

Detailed Description

AggressiveNpc is a type of Npc that attacks the player within its aggression range.

Constructor & Destructor Documentation

◆ AggressiveNpc()

AggressiveNpc::AggressiveNpc ( GameWorld pGameWorld,
std::string  name,
int  aggressionRange,
int  baseDamage,
int  baseAccuracy,
SpawnCoordinateBounds  spawnCoordinateBounds,
std::vector< std::string >  chatResponses,
unsigned int  id = 0,
Coordinates  location = Coordinates() 
)

◆ ~AggressiveNpc()

AggressiveNpc::~AggressiveNpc ( )
default

Member Function Documentation

◆ findClosestPlayer()

std::shared_ptr< PlayerCharacter > AggressiveNpc::findClosestPlayer ( )
private

Finds the closest player to the AggressiveNpc.

Returns
std::shared_ptr<PlayerCharacter>
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void AggressiveNpc::update ( )
overridevirtual

Updates the AggressiveNpc.

If the AggressiveNpc is not currently performing an action, it will find the closest player and attack it.

Implements Entity.

Here is the call graph for this function:

Member Data Documentation

◆ aggressionRangeM

int AggressiveNpc::aggressionRangeM
private

The documentation for this class was generated from the following files: