吾爱尚玩资源基地

标题: 魔兽私服M端的公共CD防外挂参考代码 [打印本页]

作者: admin    时间: 2016-4-19 22:54
标题: 魔兽私服M端的公共CD防外挂参考代码
仅用于代码参考

diff --git a/src/game/Player.cpp b/src/game/Player.cppindex 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


作者: 1314    时间: 2016-10-24 03:59
找了好久终于找到了!吾爱尚玩免费服务端下载!




欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/) Powered by Discuz! X3.4