当前位置:首页>>魔兽单机>>正文
M端的公共CD防外挂参考代码
2013-07-05 17:35:33 作者:网络 来源: 浏览次数:0
摘要:M端的公共CD防外挂参考代码
 仅用于代码参考

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8456e39..825a304 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -464,10 +469,12 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
 
     // group is initialized in the reference constructor
     SetGroupInvite(NULL);
     m_groupUpdateMask = 0;
     m_auraUpdateMask = 0;
+
+    GlobalCDEnd = 0;
 
     duel = NULL;
 
     m_GuildIdInvited = 0;
     m_ArenaTeamIdInvited = 0;
@@ -18785,10 +18856,13 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
         cat = spellInfo->Category;
         rec = spellInfo->RecoveryTime;
         catrec = spellInfo->CategoryRecoveryTime;
     }
 
+    if(spellInfo->StartRecoveryTime)
+        SetGlobalCD(clock()+spellInfo->StartRecoveryTime);
+
     time_t curTime = time(NULL);
 
     time_t catrecTime;
     time_t recTime;
 
diff --git a/src/game/Player.h b/src/game/Player.h
index 8456e39..825a304 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1662,10 +1666,12 @@ class MANGOS_DLL_SPEC Player : public Unit
 
         PlayerSpellMap const& GetSpellMap() const { return m_spells; }
         PlayerSpellMap      & GetSpellMap()       { return m_spells; }
 
         SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
+        void SetGlobalCD(clock_t newCD) {GlobalCDEnd = newCD;}
+        bool HasGlobalCD() {return GlobalCDEnd > clock();}
 
         PlayerTalent const* GetKnownTalentById(int32 talentId) const;
         SpellEntry const* GetKnownTalentRankById(int32 talentId) const;
 
         void AddSpellMod(SpellModifier* mod, bool apply);
@@ -2485,10 +2504,11 @@ class MANGOS_DLL_SPEC Player : public Unit
 
         PlayerMails m_mail;
         PlayerSpellMap m_spells;
         PlayerTalentMap m_talents[MAX_TALENT_SPEC_COUNT];
         SpellCooldowns m_spellCooldowns;
+        clock_t GlobalCDEnd;
         uint32 m_lastPotionId;                              // last used health/mana potion in combat, that block next potion use
 
         uint8 m_activeSpec;
         uint8 m_specsCount;
 
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index c1723f7..1cf75b4 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4221,10 +4277,14 @@ SpellCastResult Spell::CheckCast(bool strict)
         }
         else if(m_caster->HasAura(m_spellInfo->excludeCasterAuraSpell))
             return SPELL_FAILED_CASTER_AURASTATE;
     }
 
+    if( m_caster->GetTypeId()==TYPEID_PLAYER && !m_triggeredByAuraSpell && m_spellInfo->StartRecoveryTime &&
+        ((Player*)m_caster)->HasGlobalCD())
+        return SPELL_FAILED_NOT_READY;
+
     // cancel autorepeat spells if cast start when moving
     // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code)
     if( m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->isMoving() )
     {
         // skip stuck spell to allow use it in falling case and apply spell limitations at movement


相关报道:

[关闭] [返回顶部]


  返回首页 | 最新资讯 | 资源下载 | 魔兽图片 | 单机文档 | 技术攻略 | 玩家视频
备案号:蜀ICP备2024062380号-1
免责声明:本网站为热爱怀旧WOW的玩家们建立的魔兽世界资料网站,仅供交流和学习使用,非盈利和商用.如有侵权之处,请联系我们,我们会在24小时内确认删除侵权内容,谢谢合作。
Copyright © 2024 - 2024 WOWAII.COM Corporation, All Rights Reserved

机器人国度