Files
mir_server/server/LogicServer/entity/Creature.h

92 lines
2.5 KiB
C
Raw Normal View History

2025-01-09 17:45:40 +08:00

#pragma once
/***************************************************************/
/*
/* 生物,包括玩家,NPC, 怪物等
/*
/***************************************************************/
class CCreature:
public CEntity
{
public:
typedef CEntity Inherited;
inline bool Init(void * data, size_t size){ m_nDestoryTime = 0;return true;} //创建一个实体
//例行逻辑准备函数,当例行逻辑函数调用前被调用
virtual VOID BeforeLogicRun(TICKCOUNT nCurrentTime)
{
Inherited::BeforeLogicRun(nCurrentTime);
}
//例行逻辑处理函数
virtual VOID LogicRun(TICKCOUNT nCurrentTime)
{
Inherited::LogicRun(nCurrentTime);
}
//例行逻辑收尾函数,当例行逻辑函数调用后被调用
virtual VOID AfterLogicRun(TICKCOUNT nCurrentTime)
{
Inherited::AfterLogicRun(nCurrentTime);
}
/*
* Comments: HP
* Param int nValue:
* Param CEntity * pKiller:
* @Return VOID:
*/
virtual void ChangeHP(int nValue,CEntity * pKiller=NULL,bool bIgnoreDamageRedure=false, bool bIgnoreMaxDropHp=false, bool boSkillResult = false, int btHitType = 0);
//复活
virtual void OnEntityRelive(){}
/*
* Comments:MP
* Param int nValue:
* @Return VOID:
*/
virtual VOID ChangeMP(int nValue)
{
nValue += (int) GetProperty<unsigned int >(PROP_CREATURE_MP);
int nMaxValue = GetProperty<unsigned int >(PROP_CREATURE_MAXMP);
nValue = nValue < 0 ? 0 : __min( nValue,nMaxValue); //如果小于0那么就为0
SetProperty<unsigned int>(PROP_CREATURE_MP,(unsigned int)nValue);
}
/*
* Comments:,CActor)
* nTime:
* @Return VOID:
*/
VOID SetDestoryTime(UINT nTime);
/*
* Comments:m_nDestoryTime置0
* @Return void:
*/
inline void ClearDestoryTime(){m_nDestoryTime = 0;}
/*
* Comments:
* @Return bool:
*/
inline bool IsInDeathList()
{
return m_nDestoryTime != 0;
}
inline UINT GetDeathTime() {return m_nDestoryTime;}
protected:
//当生物死亡时,需要等一段时间(数秒后)才从场景中删除,这个变量表示删除的时间
//初始值是0在非0并且比现在时间小表示这个实体可以清除掉了
UINT m_nDestoryTime;
};