⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creature.h

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 H
字号:
//////////////////////////////////////////////////////////////////////////////// Filename    : Creature.h// Written By  : reiot// Description : //////////////////////////////////////////////////////////////////////////////#ifndef __CREATURE_H__#define __CREATURE_H__#include "Object.h"#include "EffectManager.h"#include "Assert.h"#include "Timeval.h"#include <stdlib.h>#include <algorithm>#include <bitset>//////////////////////////////////////////////////////////////////////////////// constants//////////////////////////////////////////////////////////////////////////////#define DEFAULT_SIGHT			13	// 盔贰矫具#define DARKNESS_SIGHT			0	// Darkness俊 狼茄 矫具#define YELLOW_POISON_SIGHT		3	// Yellow Poison俊 狼茄 矫具#define LIGHTNESS_SIGHT			13	// Lightness俊 狼茄 矫具#define FLARE_SIGHT				3	// Flare俊 狼茄 矫具const string MoveMode2String [] = {	"MOVE_MODE_WALKING",	"MOVE_MODE_FLYING",	"MOVE_MODE_BURROWING"};//////////////////////////////////////////////////////////////////////////////// forward declaration//////////////////////////////////////////////////////////////////////////////class Zone;class Player;class Inventory;class Stash;class InventorySlot;class Party;class LocalPartyManager;//////////////////////////////////////////////////////////////////////////////// Class Creature;//////////////////////////////////////////////////////////////////////////////class Creature : public Object {public:	// Creature甫 官肺 惑加罐绰 努贰胶甸阑 咯扁俊 沥狼茄促.	enum CreatureClass 	{ 		CREATURE_CLASS_SLAYER = 0,	// PC Slayer		CREATURE_CLASS_VAMPIRE,		// PC Vampire		CREATURE_CLASS_NPC,			// NPC		CREATURE_CLASS_MONSTER,		// NPC Slayer, NPC Vampire		CREATURE_CLASS_OUSTERS,		// PC Ousters		CREATURE_CLASS_MAX	};	// Move Mode	enum MoveMode 	{		MOVE_MODE_WALKING = 0,		MOVE_MODE_FLYING,		MOVE_MODE_BURROWING,		MOVE_MODE_MAX	};public:    Creature(ObjectID_t objectID = 0, Player* pPlayer = NULL) throw();    virtual ~Creature() throw (Error);public:	virtual ObjectClass getObjectClass() const throw() { return OBJECT_CLASS_CREATURE; }	virtual ObjectPriority getObjectPriority() const throw(Error);	virtual string toString() const throw() = 0;public:	virtual bool load() throw (InvalidProtocolException, Error) = 0; // load from DB	virtual void save() const throw(Error) = 0; // save to DB	public:	// 农府贸俊辑 敲饭捞绢肺 立辟茄促.	// 泅犁 农府贸俊 措秦辑 isPC()甫 眉农秦焊绊 true 牢 版快俊父 龋免秦具 茄促.	Player* getPlayer() const throw(Error) { Assert(m_pPlayer != NULL); return m_pPlayer; }	void setPlayer(Player* pPlayer) throw() { m_pPlayer = pPlayer; }public:	virtual const string& getName() const throw() = 0;	virtual CreatureClass getCreatureClass() const throw() = 0;	virtual string getCreatureClassString() const throw() = 0;	virtual Race_t getRace() const = 0;	EffectManager* getEffectManager() const throw() { return m_pEffectManager; }	bool isSlayer() const throw()  { return getCreatureClass() == CREATURE_CLASS_SLAYER; }	bool isVampire() const throw() { return getCreatureClass() == CREATURE_CLASS_VAMPIRE; }	bool isOusters() const throw() { return getCreatureClass() == CREATURE_CLASS_OUSTERS; }	bool isNPC() const throw()     { return getCreatureClass() == CREATURE_CLASS_NPC; }	bool isMonster() const throw() { return getCreatureClass() == CREATURE_CLASS_MONSTER; }	bool isPC() const throw()      { return isSlayer() || isVampire() || isOusters(); }	bool isGOD() const throw()     { return getCompetence() == GOD; }	bool isDM() const throw()      { return getCompetence() == DM; }	bool isHELPER() const throw()  { return getCompetence() == HELPER; }	bool isPLAYER() const throw()  { return getCompetence() == PLAYER; }	virtual BYTE getCompetence() const throw() { return PLAYER; }	virtual BYTE getCompetenceShape() const throw() { return 1; }	virtual bool isDead() const throw() = 0;	virtual bool isAlive() const throw() = 0;	void recoverHP(HP_t recoverAmount) throw();	void setFlag(Effect::EffectClass Flag) throw() { m_Flag.set(Flag); }	void removeFlag(Effect::EffectClass Flag) throw() { m_Flag.reset(Flag); }	bool isFlag(Effect::EffectClass Flag) const throw() { return m_Flag.test(Flag); } 	bool hasRelicItem() const;public:    virtual PhoneNumber_t getPhoneNumber() const throw() { return 0; }public:	virtual void act(const Timeval& currentTime) throw(Error) = 0; // for monster & npcpublic:	////////////////////////////////////////////////////////////	// Creature啊 啊瘤绊 乐绰 酒捞袍甸 开矫 Zone俊 殿废登绢具 茄促. 	// 捞甫 困秦辑绰 家蜡 酒捞袍甸捞 Zone饭骇俊辑 visible秦具 窍绰单, 	// 弊犯瘤 给窍促. 弊犯促绊, Zone俊辑 Creature狼 家蜡 酒捞袍甸阑 	// iteration 窍绰 皋筋靛甫 力傍窍绰 巴档 绢祸窍促. 	// 蝶扼辑, Creature俊 殿废 皋筋靛甫 滴绊 咯扁辑 Zone俊 立辟秦辑 	// 胶胶肺甫 殿废窍档废 茄 巴捞促. 	////////////////////////////////////////////////////////////	virtual void registerObject() throw(Error) = 0;	// 农府贸俊 措茄 漂沥 谅钎狼 矫具 惑怕甫 府畔茄促.	VisionState getVisionState(ZoneCoord_t x, ZoneCoord_t y) throw(Error); 	VisionState getVisionState(Coord_t x, Coord_t y, Sight_t sight) throw(Error);	// get/set zone	Zone* getZone() const throw() { return m_pZone; }	void setZone(Zone* pZone) throw() { m_pZone = pZone; }	// get/set zone id	ZoneID_t getZoneID() const throw();	void setZoneID(ZoneID_t zoneID) throw(Error);	// get/set(x,y,dir)	ZoneCoord_t getX() const throw() { return m_X; }	void setX(ZoneCoord_t x) throw() { m_X = x; }	ZoneCoord_t getY() const throw() { return m_Y; }	void setY(ZoneCoord_t y) throw() { m_Y = y; }	Dir_t getDir() const throw() { return m_Dir; }	void setDir(Dir_t dir) throw() { m_Dir = dir; }	ZoneCoord_t getViewportWidth() const throw() { return m_ViewportWidth; }	ZoneCoord_t getViewportUpperHeight() const throw() { return m_ViewportUpperHeight; }	ZoneCoord_t getViewportLowerHeight() const throw() { return m_ViewportLowerHeight; }	////////////////////////////////////////////////////////////	// *CAUTION*	// 孽府 搬苞甫 历厘且 锭, 2俺 捞惑狼 蔼阑 悼矫俊 瘤沥窍绰 set 皋筋靛绰 荤侩窍瘤 富 巴!	//(窃荐 龋免捞 第俊辑 何磐 捞风绢柳促绰 荤角阑 蜡充且 巴!)	//  ex> setXY(pResult->getInt(++i), pResult->getInt(++i)); 绰 角力肺 setXY(y,x)	//      甫 角青窍霸 等寸... -_-;	////////////////////////////////////////////////////////////	void setXY(ZoneCoord_t x, ZoneCoord_t y) throw() { m_X = x; m_Y = y; }	void setXYDir(ZoneCoord_t x, ZoneCoord_t y, Dir_t dir) throw() { m_X = x; m_Y = y; m_Dir = dir; }	//(nx,ny)肺 框流老 荐 乐绰啊?	bool canMove(ZoneCoord_t nx, ZoneCoord_t ny) const throw(Error);	bool isBlockedByCreature(ZoneCoord_t nx , ZoneCoord_t ny) const throw(Error);	// get/set sight level	Sight_t getSight() const throw() { return m_Sight; }	void setSight(Sight_t sight) throw(Error) { m_Sight = sight; Assert(m_Sight <= maxSight); }	virtual Sight_t getEffectedSight() throw();	// get/set/test move mode	MoveMode getMoveMode() const throw() { return m_MoveMode; }	void setMoveMode(MoveMode moveMode) throw() { m_MoveMode = moveMode; }	bool isWalking() const throw() { return m_MoveMode == MOVE_MODE_WALKING; }	bool isFlying() const throw() { return m_MoveMode == MOVE_MODE_FLYING; }	bool isBurrowing() const throw() { return m_MoveMode == MOVE_MODE_BURROWING; }		// get distance	Distance_t getDistance(ZoneCoord_t x1, ZoneCoord_t y1, ZoneCoord_t x2, ZoneCoord_t y2) const throw();	// P(x1,y1)苞 唱狼 困摹荤捞狼 芭府甫 螟沥茄促.	Distance_t getDistance(ZoneCoord_t x1, ZoneCoord_t y1) const throw();	// get/set EffectInfo	virtual EffectInfo* getEffectInfo() const throw() { return m_pEffectManager->getEffectInfo(); }public :	// get/set zone	Zone* getNewZone() const throw() { return m_pNewZone; }	void setNewZone(Zone* pZone) throw() { m_pNewZone = pZone; }	// get/set zone id	ZoneID_t getNewZoneID() const throw();	//void setNewZoneID(ZoneID_t zoneID) throw(Error);	// get/set(x,y,dir)	ZoneCoord_t getNewX() const throw() { return m_NewX; }	void setNewX(ZoneCoord_t x) throw() { m_NewX = x; }	ZoneCoord_t getNewY() const throw() { return m_NewY; }	void setNewY(ZoneCoord_t y) throw() { m_NewY = y; }	void setNewXY(ZoneCoord_t x, ZoneCoord_t y) throw() { m_NewX = x; m_NewY = y; }public:	bool isEffect(Effect::EffectClass EClass) throw (Error);	void deleteEffect(Effect::EffectClass EClass) throw (Error);	Effect* findEffect(Effect::EffectClass EClass) throw (Error);	void addEffect(Effect* pEffect) throw (Error);public:	virtual Level_t getLevel() const throw() = 0;	virtual Steal_t getHPStealAmount(void) const { return 0; }	virtual void setHPStealAmount(Steal_t steal) {}	virtual Steal_t getMPStealAmount(void) const { return 0; }	virtual void setMPStealAmount(Steal_t steal) {}	virtual Steal_t getHPStealRatio(void) const { return 0; }	virtual void setHPStealRatio(Steal_t steal) {}	virtual Steal_t getMPStealRatio(void) const { return 0; }	virtual void setMPStealRatio(Steal_t steal) {}	virtual Regen_t getHPRegen(void) const { return 0; }	virtual void setHPRegen(Regen_t regen) {}	virtual Regen_t getMPRegen(void) const { return 0; }	virtual void setMPRegen(Regen_t regen) {}	virtual Luck_t getLuck(void) const { return 0; }	virtual void setLuck(Luck_t luck) {}	virtual int getCriticalRatio(void) const { return 0; }	virtual void setCriticalRatio(int ratio) { }	int getPartyID(void) const { return m_PartyID; }	void setPartyID(int ID) { m_PartyID = ID; }	LocalPartyManager* getLocalPartyManager(void) const throw();	virtual ClanType_t getClanType(void) const { return 0; }	virtual void setClanType(ClanType_t clan) { }	Resist_t getResist(uint domain) { return m_Resist[domain]; }	void setResist(uint domain, Resist_t value) { m_Resist[domain] = value; }	ObjectID_t getLastTarget() { return m_LastTarget; }	virtual void setLastTarget(ObjectID_t value) { m_LastTarget = value; }protected:	Player*                          m_pPlayer;                  // Player 俊 措茄 器牢磐(Mob 苞 NPC 老 版快 NULL)	MoveMode                         m_MoveMode;                 // Move Mode	Zone*                            m_pZone;                    // 泅犁 粮俊 措茄 器牢磐	ZoneCoord_t                      m_X;                        // 粮 x 谅钎	ZoneCoord_t                      m_Y;                        // 粮 y 谅钎	Dir_t                            m_Dir;                      // 泅犁 规氢	ZoneCoord_t                      m_ViewportWidth;            // 轰 器飘 	ZoneCoord_t                      m_ViewportUpperHeight;      // 轰 器飘	ZoneCoord_t                      m_ViewportLowerHeight;      // 轰 器飘	EffectManager*                   m_pEffectManager;           // effect manager point	bitset<Effect::EFFECT_CLASS_MAX> m_Flag;                     // effect flag	Sight_t                          m_Sight;                    // current sight	int                              m_PartyID;                  // partyid	Resist_t                         m_Resist[MAGIC_DOMAIN_MAX]; // 付过 历亲仿	// 货肺 甸绢哎 粮, 何劝且 粮. by sigi. 2002.5.11	Zone*                            m_pNewZone;           // 泅犁 粮俊 措茄 器牢磐	ZoneCoord_t                      m_NewX;               // 粮 x 谅钎	ZoneCoord_t                      m_NewY;               // 粮 y 谅钎	// 叼滚弊侩	CreatureClass 					 m_CClass;	string							 m_Owner;	bool							 m_bDeriveDestructed;	int								 m_Value;	ObjectID_t						 m_LastTarget;public:	void setValue(int value) { m_Value = value; }};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -