Cuberite
A lightweight, fast and extensible game server for Minecraft
PassiveAggressiveMonster.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
5 
6 #include "../Entities/Player.h"
7 
8 
9 
10 
11 
12 cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, float a_Width, float a_Height) :
13  Super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height)
14 {
16 }
17 
18 
19 
20 
21 
23 {
24  if (!Super::DoTakeDamage(a_TDI))
25  {
26  return false;
27  }
28 
29  if ((GetTarget() != nullptr) && GetTarget()->IsPlayer())
30  {
31  if (static_cast<cPlayer *>(GetTarget())->CanMobsTarget())
32  {
34  }
35  }
36  return true;
37 }
38 
39 
40 
41 
42 
44 {
45  // don't do anything, neutral mobs don't react to just seeing the player
46 }
47 
48 
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
std::string AString
Definition: StringUtils.h:11
Definition: Chunk.h:36
Definition: Entity.h:76
bool IsPlayer(void) const
Definition: Entity.h:160
Definition: Player.h:29
cPawn * GetTarget()
Returns the current target.
Definition: Monster.cpp:1243
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
Definition: Monster.cpp:572
@ CHASING
Definition: Monster.h:40
enum cMonster::MState m_EMState
@ PASSIVE
Definition: Monster.h:41
enum cMonster::MPersonality m_EMPersonality
cPassiveAggressiveMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, const AString &a_SoundAmbient, float a_Width, float a_Height)
virtual void EventSeePlayer(cPlayer *, cChunk &a_Chunk) override
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.