#ifndef _CSPELL_H_ #define _CSPELL_H_ #include #include #include "SpellKind.h" // ·Î±× ·¹º§ : x <--> (void*)0 // MAXLEVEL : ¼¼ºÎ ·Î±× // ERRLEVEL : ¿¡·¯ ·Î±× // TESTLEVEL : Å×½ºÆ® ·Î±× #define SPLOG_MAXLEVEL(x) (void*)0 #define SPLOG_ERRLEVEL(x) (void*)0 #define SPLOG_TESTLEVEL(x) (void*)0 // Àü¹æ ÂüÁ¶ class CAggresiveCreature; class CSpell { public: enum EnchantError { NO_ENCHANT_ERROR = 0, ENCHNAT_FAIL_ALREADY_AFFECTED = 1, ENCHANT_FAIL_BY_ENEMY_ENCHANT = 2, ENCHANT_FAIL_BY_RESIST = 3 }; enum Const { INFINITE_DURATION = ULONG_MAX, REALM_TIME = 7200, REDUCE_MANA_TURN = 5, MAX_AFFECTED = 10 }; enum OperateFlag { DO_NOT_SEND = 1 << 0 }; struct Spell_Info { const Skill::ProtoType& m_SkillProtoType; CAggresiveCreature* m_lpCaster; unsigned long m_dwDurationSec; unsigned short m_wSpellID; unsigned short m_wSpellLevel; unsigned char m_cSpellType; unsigned char m_cPadding; unsigned char m_cSkillLockCount; unsigned char m_cSkillLevel; Spell_Info(const Skill::ProtoType& SkillProtoType, CAggresiveCreature* lpCaster, unsigned char cSpellType, unsigned short wSpellID, unsigned short wSpellLevel, unsigned long dwDurationSec, unsigned char cSkillLockCount = 0, unsigned char cSkillLevel = 0); }; virtual ~CSpell() { Destroy(); } // Caster°ü·Ã void SetCaster(CAggresiveCreature* pCaster); // Caster°¡ ¹Ù²ð ¶§ »ç¿ëÇÑ´Ù. inline CAggresiveCreature* GetCaster(void) { return m_pCaster; } // Affected°ü·Ã. ÁÖ¹®ÀÇ Activate, Deactivate¿Í »óÈ£ ÂüÁ¶ ÇØÁ¦µîÀÇ ¿ªÇÒÀ» ÇÑ´Ù. bool AddAffected(CAggresiveCreature* lpAffected, unsigned short& wError); bool RemoveAffected(CAggresiveCreature* pRemoved); void ClearAffected(void); // Caster, AffectedÁ¤º¸¸¦ ÀüºÎ Á¦°Å. void ClearAll(void); // °Å¸®¸¦ Ã¼Å©ÇØ¼­ ÁÖ¹® È¿°ú¸¦ Àû¿ë ¹× ÇØÁö. void CheckRange(void); // ±âŸ inline bool IsActivate(CAggresiveCreature* lpAffected); inline bool IsValid(void) const { return (0 != m_cAffectedNum); } inline unsigned short GetSpellID(void) const { return m_wSpellID; } inline unsigned short GetSpellLevel(void) const { return m_wSpellLevel; } inline unsigned long GetDurationSec(void) const { return m_dwDurationSec; } inline unsigned char GetSpellType(void) const { return m_cSpellType; } inline unsigned char GetSkillLockCount(void) const { return m_cSkillLockCount; } inline unsigned char GetSkillLevel(void) const { return m_cSkillLevel; } const Skill::SpellTarget::Type GetSpellTarget(void); inline const Skill::Type::SkillType GetSkillType(void) const { return m_eSkillType; } inline const bool IsPartySkill(void) const { return m_ProtoType.m_eTargetType == Skill::Target::PARTY; } inline unsigned short DecreaseSkillLevel(unsigned short usDecreaseAmount); // ÁÖ¹® È¿°ú¸¦ ÀüºÎ ÄÑ°í ²ö´Ù. void Enable(unsigned long dwOperateFlag); void Disable(unsigned long dwOperateFlag); protected: // »ó¼Ó ¹Þ¾Æ¾ß¸¸ »ý¼ºÇÒ ¼ö ÀÖ´Ù. CSpell(Spell_Info& spell_Info, Skill::Type::SkillType eSpellType); bool Operate(void); // ÁÖ¹® ½Ã°£ üũ. ÁÖ¹®À» Àû¿ë. void Destroy(void); // ClearAll°ú °°Àº ¿ªÇÒÀ» Çϳª, ¼Ò¸êÀÚ¿¡¼­ Çѹø¸¸ È£ÃâÇÑ´Ù. // À¯µµ Ŭ·¡½ºÀÇ ¼Ò¸êÀÚµµ ¹Ýµå½Ã ½ÇÇàÇØ ÁÖ¾î¾ß ÇÑ´Ù. // -------------------------------------------------------------------------------------------- // ½ºÅ³ Opeartion °ü·Ã. Override ÇÊ¿ä. inline virtual void Operate(CAggresiveCreature* lpAffected) { }; virtual bool Activate(CAggresiveCreature* lpAffected, unsigned long dwOperateFlag); virtual bool Deactivate(CAggresiveCreature* lpAffected, unsigned long dwOperateFlag); // Activate Ç÷¡±× °ü·Ã inline bool IsActivate(unsigned char cAffectedIndex); inline void SetActivate(unsigned char cAffectedIndex); inline void SetDeactivate(unsigned char cAffectedIndex); inline void RemoveIndex(unsigned char cAffectedIndex); unsigned char GetAffectedIndex(CAggresiveCreature* lpAffected); // Internal Ç÷¡±× °ü·Ã inline bool IsEnabled(void); inline bool SetEnableStatus(bool bStatus); // -------------------------------------------------------------------------------------------- // Send °ü·Ã void SendSpellInfo(CAggresiveCreature* lpAffected, unsigned char cSpellType, unsigned short nEnchantLevel, unsigned long dwEnchantTime, bool bOnOff); enum InternalFlags { DISABLED = ( 1 << 0), // ÁÖ¹®ÀÌ DisabledµÇ¾ú´ÂÁö ¿©ºÎ¸¦ ³ªÅ¸³¿. DESTROYED = ( 1 << 1) // ÁÖ¹®ÀÌ DestroyµÇ¾ú´ÂÁö ¿©ºÎ·ê ³ªÅ¸³¿. }; CSpell* m_pNextSpell; // ÁÖ¹® ¸®½ºÆ®¸¦ À¯ÁöÇϱâ À§ÇÑ Æ÷ÀÎÅÍ. const Skill::ProtoType& m_ProtoType; CAggresiveCreature* m_pAffected[MAX_AFFECTED]; // ÁÖ¹®¿¡ ÀÇÇØ ¿µÇâÀ» ¹Þ°í Àִ ij¸¯ÅÍ. CAggresiveCreature* m_pCaster; // ÁÖ¹® ½ÃÀüÀÚ. Skill::Type::SkillType m_eSkillType; // See Namespace Type unsigned long m_dwActivateStatus; // ÁÖ¹®ÀÇ Activate»óŸ¦ °¡Áö°í ÀÖ´Â Flag. unsigned short m_wSpellID; // ÁÖ¹® ID unsigned short m_wSpellLevel; // ÁÖ¹®ÀÇ Level unsigned long m_dwDurationSec; // ÁÖ¹® Áö¼Ó½Ã°£ unsigned char m_cSpellType; // ÁÖ¹®ÀÇ Å¸ÀÔ (¸¶¹ýÇü/¹°¸®Çü) unsigned char m_cAffectedNum; // ÁÖ¹®¿¡ ÀÇÇØ ¿µÇâÀ» ¹Þ´Â »ç¶÷ÀÇ ¼ö unsigned char m_cInternalFlags; // 8bit InternalÇ÷¡±× unsigned char m_cSkillLockCount; // ÁÖ¹®À» °Ç ½ºÅ³ÀÇ ¶ôÄ«¿îÆ® unsigned char m_cSkillLevel; // ÁÖ¹®À» °Ç ½ºÅ³ÀÇ ·¹º§ friend class CSpellMgr; // Caster¿Í AffectedÀÇ »óÈ£ÂüÁ¶ °ü¸®¸¦ ¿ÜºÎ·Î ³ëÃâ½ÃŰÁö ¾Ê±â À§ÇÔ. friend class CGlobalSpellMgr; // CGlobalSpellMgr¿¡¼­ m_pNextSpell¹× ProtectedÇÔ¼ö¸¦ »ç¿ëÇϱâ À§ÇÔ. }; inline CSpell::Spell_Info::Spell_Info(const Skill::ProtoType& SkillProtoType, CAggresiveCreature* lpCaster, unsigned char cSpellType, unsigned short wSpellID, unsigned short wSpellLevel, unsigned long dwDurationSec, unsigned char cSkillLockCount, unsigned char cSkillLevel) : m_SkillProtoType(SkillProtoType), m_lpCaster(lpCaster), m_cSpellType(cSpellType), m_wSpellID(wSpellID), m_wSpellLevel(wSpellLevel), m_dwDurationSec(dwDurationSec), m_cSkillLockCount(cSkillLockCount), m_cSkillLevel(cSkillLevel) { } inline unsigned short CSpell::DecreaseSkillLevel(unsigned short usDecreaseAmount) { if (m_wSpellLevel < usDecreaseAmount) { m_wSpellLevel = 0; return m_wSpellLevel; } m_wSpellLevel -= usDecreaseAmount; return m_wSpellLevel; } inline bool CSpell::IsEnabled(void) { return (DISABLED != (DISABLED & m_cInternalFlags)); } inline bool CSpell::IsActivate(CAggresiveCreature* lpAffected) { CAggresiveCreature** ppBegin = m_pAffected; CAggresiveCreature** ppPastEnd = m_pAffected + m_cAffectedNum; unsigned char cIndex = 0; for (; ppBegin != ppPastEnd; ++ppBegin, ++cIndex) { if (*ppBegin == lpAffected) { return IsActivate(cIndex); } } return false; } inline bool CSpell::IsActivate(unsigned char cAffectedIndex) { const unsigned long dwIndexValue = (1 << cAffectedIndex); return (dwIndexValue == (m_dwActivateStatus & dwIndexValue)); } inline void CSpell::SetActivate(unsigned char cAffectedIndex) { m_dwActivateStatus |= (1 << cAffectedIndex); } inline void CSpell::SetDeactivate(unsigned char cAffectedIndex) { m_dwActivateStatus &= ~(1 << cAffectedIndex); } inline void CSpell::RemoveIndex(unsigned char cAffectedIndex) { m_dwActivateStatus = (((ULONG_MAX << (cAffectedIndex + 1)) & m_dwActivateStatus) >> 1) | // À妽º ¿ÞÂÊ ºñÆ®¿­(31~nIndex) (((1 << cAffectedIndex) - 1) & m_dwActivateStatus); // À妽º ¿À¸¥ÂÊ ºñÆ®¿­(nIndex~0) } #endif