2012-06-14 09:06:06 -04:00
# pragma once
2013-08-19 05:39:13 -04:00
# include "../Entities/Pawn.h"
2012-09-23 16:53:08 -04:00
# include "../Defines.h"
# include "../BlockID.h"
2012-09-23 18:09:57 -04:00
# include "../Item.h"
2012-06-14 09:06:06 -04:00
class Vector3f ;
class cClientHandle ;
2013-08-16 04:48:19 -04:00
class cWorld ;
2012-06-14 09:06:06 -04:00
2012-12-21 06:04:08 -05:00
// tolua_begin
class cMonster :
public cPawn
{
typedef cPawn super ;
2012-06-14 09:06:06 -04:00
public :
2013-08-16 04:48:19 -04:00
/// This identifies individual monster type, as well as their network type-ID
enum eType
{
mtCreeper = E_META_SPAWN_EGG_CREEPER ,
mtSkeleton = E_META_SPAWN_EGG_SKELETON ,
mtSpider = E_META_SPAWN_EGG_SPIDER ,
mtGiant = E_META_SPAWN_EGG_GIANT ,
mtZombie = E_META_SPAWN_EGG_ZOMBIE ,
mtSlime = E_META_SPAWN_EGG_SLIME ,
mtGhast = E_META_SPAWN_EGG_GHAST ,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN ,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN ,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER ,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH ,
mtBlaze = E_META_SPAWN_EGG_BLAZE ,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE ,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON ,
mtWither = E_META_SPAWN_EGG_WITHER ,
mtBat = E_META_SPAWN_EGG_BAT ,
mtWitch = E_META_SPAWN_EGG_WITCH ,
mtPig = E_META_SPAWN_EGG_PIG ,
mtSheep = E_META_SPAWN_EGG_SHEEP ,
mtCow = E_META_SPAWN_EGG_COW ,
mtChicken = E_META_SPAWN_EGG_CHICKEN ,
mtSquid = E_META_SPAWN_EGG_SQUID ,
mtWolf = E_META_SPAWN_EGG_WOLF ,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM ,
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM ,
mtOcelot = E_META_SPAWN_EGG_OCELOT ,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM ,
mtVillager = E_META_SPAWN_EGG_VILLAGER ,
2013-09-07 19:21:43 -04:00
mtInvalidType , // MG TODO : be sure this is the way we do in this project. (needed inside cMobSpawner::ChooscMonster for instance if nothing can be spawned)
2013-08-16 04:48:19 -04:00
} ;
2013-09-07 14:02:50 -04:00
enum eFamily
{
mfHostile = 0 , // Spider, Zombies ...
mfPassive = 1 , // Cows, Pigs
mfAmbient = 2 , // Bats
mfWater = 3 , // Squid
2013-09-07 19:21:43 -04:00
mfMaxplusone , // Nothing. Be sure this is the last and the others are in order
2013-09-07 14:02:50 -04:00
} ;
2013-08-16 04:48:19 -04:00
2012-12-21 06:04:08 -05:00
// tolua_end
2013-08-16 04:48:19 -04:00
2013-04-13 17:02:10 -04:00
float m_SightDistance ;
2012-12-21 06:04:08 -05:00
2012-12-22 04:39:13 -05:00
/** Creates the mob object.
* If a_ConfigName is not empty , the configuration is loaded using GetMonsterConfig ( )
* a_ProtocolMobType is the ID of the mob used in the protocol ( http : //wiki.vg/Entities#Mobs , 2012_12_22)
* a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath , respectively
*/
2013-07-01 06:39:56 -04:00
cMonster ( const AString & a_ConfigName , char a_ProtocolMobType , const AString & a_SoundHurt , const AString & a_SoundDeath , double a_Width , double a_Height ) ;
2012-06-14 09:06:06 -04:00
2012-12-21 07:21:20 -05:00
CLASS_PROTODEF ( cMonster ) ;
2012-08-24 03:58:26 -04:00
virtual void SpawnOn ( cClientHandle & a_ClientHandle ) override ;
2012-06-14 09:06:06 -04:00
2013-04-13 17:02:10 -04:00
virtual void Tick ( float a_Dt , cChunk & a_Chunk ) override ;
2012-06-14 09:06:06 -04:00
2012-12-21 06:04:08 -05:00
virtual void DoTakeDamage ( TakeDamageInfo & a_TDI ) override ;
2013-07-01 06:39:56 -04:00
virtual void KilledBy ( cEntity * a_Killer ) override ;
2012-06-14 09:06:06 -04:00
2012-08-24 03:58:26 -04:00
virtual void MoveToPosition ( const Vector3f & a_Position ) ;
virtual bool ReachedDestination ( void ) ;
2013-09-07 14:51:31 -04:00
char GetMobType ( void ) const { return m_MobType ; } // MG TODO : see if we can delete this one.
eType GetMobTypeAsEnum ( void ) const { return ( eType ) m_MobType ; } // MG TODO : see if we should store m_MobType as enum instead of char.
2013-09-07 14:02:50 -04:00
virtual eFamily GetMobFamily ( void ) const = 0 ;
2012-06-14 09:06:06 -04:00
2012-08-24 03:58:26 -04:00
const char * GetState ( ) ;
2012-08-19 15:42:32 -04:00
void SetState ( const AString & str ) ;
2012-06-14 09:06:06 -04:00
2013-04-13 17:02:10 -04:00
virtual void CheckEventSeePlayer ( void ) ;
virtual void EventSeePlayer ( cEntity * a_Player ) ;
2012-12-21 06:04:08 -05:00
virtual cPlayer * FindClosestPlayer ( ) ; // non static is easier. also virtual so other mobs can implement their own searching algo
2012-12-22 04:39:13 -05:00
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig ( const AString & a_Name ) ;
2012-12-22 05:15:53 -05:00
virtual void EventLosePlayer ( void ) ;
2013-04-13 17:02:10 -04:00
virtual void CheckEventLostPlayer ( void ) ;
2012-06-14 09:06:06 -04:00
2013-04-13 17:02:10 -04:00
virtual void InStateIdle ( float a_Dt ) ;
virtual void InStateChasing ( float a_Dt ) ;
virtual void InStateEscaping ( float a_Dt ) ;
2012-06-14 09:06:06 -04:00
virtual void Attack ( float a_Dt ) ;
int GetMobType ( ) { return m_MobType ; }
int GetAttackRate ( ) { return ( int ) m_AttackRate ; }
void SetAttackRate ( int ar ) ;
void SetAttackRange ( float ar ) ;
void SetAttackDamage ( float ad ) ;
void SetSightDistance ( float sd ) ;
2013-09-05 16:40:08 -04:00
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight ( bool a_BurnsInDaylight ) { a_BurnsInDaylight = a_BurnsInDaylight ; }
2012-06-14 09:06:06 -04:00
enum MState { ATTACKING , IDLE , CHASING , ESCAPING } m_EMState ;
enum MPersonality { PASSIVE , AGGRESSIVE , COWARDLY } m_EMPersonality ;
protected :
2012-12-21 06:04:08 -05:00
cEntity * m_Target ;
2012-06-14 09:06:06 -04:00
float m_AttackRate ;
float idle_interval ;
Vector3f m_Destination ;
bool m_bMovingToDestination ;
bool m_bPassiveAggressive ;
float m_DestinationTime ;
float m_DestroyTimer ;
float m_Jump ;
char m_MobType ;
2012-12-21 13:05:34 -05:00
AString m_SoundHurt ;
AString m_SoundDeath ;
2012-06-14 09:06:06 -04:00
float m_SeePlayerInterval ;
float m_AttackDamage ;
float m_AttackRange ;
float m_AttackInterval ;
2013-09-05 16:40:08 -04:00
bool m_BurnsInDaylight ;
2012-06-14 09:06:06 -04:00
2012-08-19 15:42:32 -04:00
void AddRandomDropItem ( cItems & a_Drops , unsigned int a_Min , unsigned int a_Max , short a_Item , short a_ItemHealth = 0 ) ;
2013-09-05 16:40:08 -04:00
void HandleDaylightBurning ( cChunk & a_Chunk ) ;
2012-12-21 06:04:08 -05:00
} ; // tolua_export
2012-06-14 09:06:06 -04:00