Pelf

Pelf guardian of ancient kings 1

May 18th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.35 KB | None | 0 0
  1. diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
  2. index 3991595..11f1a02 100644
  3. --- a/src/server/game/Entities/Unit/Unit.cpp
  4. +++ b/src/server/game/Entities/Unit/Unit.cpp
  5. @@ -7603,6 +7603,80 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
  6.          }
  7.          case SPELLFAMILY_PALADIN:
  8.          {
  9. +            // Ancient Crusader (player)
  10. +            if (dummySpell->Id == 86701)
  11. +            {
  12. +                if (!etTypeId() != TYPEID_PLAYER)
  13. +                    return false;
  14. +
  15. +                // if caster has no guardian of ancient kings aura then remove dummy aura
  16. +                if (!HasAura(86698))
  17. +                {
  18. +                    RemoveAurasDueToSpell(86701);
  19. +                    return false;
  20. +                }
  21. +
  22. +                CastSpell(this, 86700, true);
  23. +                return true;
  24. +            }
  25. +            // Ancient Crusader (guardian)
  26. +            if (dummySpell->Id == 86703)
  27. +            {
  28. +
  29. +                if (!GetOwner() || GetOwner()->GetTypeId() != TYPEID_PLAYER)
  30. +                    return false;
  31. +
  32. +                GetOwner()->CastSpell(this, 86700, true);                    
  33. +                return true;
  34. +            }
  35. +            // Ancient Healer
  36. +            if (dummySpell->Id == 86674)
  37. +            {
  38. +                if (GetTypeId() != TYPEID_PLAYER)
  39. +                    return false;
  40. +
  41. +                // if caster has no guardian of ancient kings aura then remove dummy aura
  42. +                if (!HasAura(86669))
  43. +                {
  44. +                    RemoveAurasDueToSpell(86674);
  45. +                    return false;
  46. +                }
  47. +        
  48. +                // check for single target spell (TARGET_SINGLE_FRIEND, NO_TARGET)
  49. +                if (!(procSpell->EffectImplicitTargetA[triggeredByAura->GetEffIndex()] == 21 &&
  50. +                    procSpell->EffectImplicitTargetB[triggeredByAura->GetEffIndex()] == 0))
  51. +                    return false;
  52. +
  53. +                // Need to get guardian but that do NOT WORK!!!
  54. +                //if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, GetPetGUID()))
  55. +                              
  56. +                std::list<Creature*> petlist;
  57. +                GetCreatureListWithEntryInGrid(petlist, 46499, 100.0f);
  58. +                if (!petlist.empty())
  59. +                for (std::list<Creature*>::const_iterator itr = petlist.begin(); itr != petlist.end(); ++itr)
  60. +                {
  61. +                    Unit* pPet = (*itr);
  62. +                    if (pPet->GetOwnerGUID() == GetGUID())
  63. +                    {
  64. +                        //need to save num of heals up to 5
  65. +                        //I've done it with AI, maybe there's better way
  66. +                        uint32 heals = pPet->GetAI()->GetData(1001);
  67. +                        int32 bp0 = damage;
  68. +                        int32 bp1 = damage / 10;
  69. +                        pPet->CastCustomSpell(pVictim, 86678, &bp0, &bp1, NULL, true);
  70. +                        if (heals > 3)
  71. +                        {
  72. +                            //Dismiss guardian and remove auras
  73. +                            pPet->ToCreature()->ForcedDespawn();
  74. +                            RemoveAurasDueToSpell(86669);
  75. +                            RemoveAurasDueToSpell(86674);
  76. +                        }
  77. +                        else
  78. +                            pPet->GetAI()->SetData(1001, heals + 1);
  79. +                    }
  80. +                }
  81. +                return true;
  82. +            }
  83.              // Seal of Righteousness - melee proc dummy (addition {$MWS*(0.011*$AP+0.022*$SPH)} damage)
  84.              if (dummySpell->Id == 20154 && !procSpell)
  85.              {
  86. @@ -7905,12 +7979,6 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
  87.                      target = pVictim;
  88.                      break;
  89.                  }
  90. -                case 86698:
  91. -                {
  92. -                    target = GetOwner() ? GetOwner() : this;
  93. -                    target->CastSpell(target, 86700, true);
  94. -                    return true;
  95. -                }
  96.              }
  97.              break;
  98.          }
  99. @@ -14290,21 +14358,6 @@ void Unit::setDeathState(DeathState s)
  100.                      }
  101.                  }
  102.                  break;
  103. -            case 46506:
  104. -            case 46499:
  105. -            case 46490:
  106. -                if (Unit* owner = GetOwner())
  107. -                {
  108. -                    if (owner->isAlive())
  109. -                    {
  110. -                        owner->RemoveAurasDueToSpell(86659);
  111. -                        owner->RemoveAurasDueToSpell(86669);
  112. -                        owner->RemoveAurasDueToSpell(86698);
  113. -                        if (GetEntry() == 46506)
  114. -                            owner->CastSpell(owner, 86704, true);
  115. -                    }
  116. -                }
  117. -                break;
  118.          }
  119.      }
  120.      else if (s == JUST_ALIVED)
  121. diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
  122. index 4314832..d3b8c8c 100644
  123. --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
  124. +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
  125. @@ -7002,6 +7002,27 @@ void AuraEffect::HandleAuraDummy(AuraApplication const *aurApp, uint8 mode, bool
  126.              break;
  127.          }
  128.          case SPELLFAMILY_PALADIN:
  129. +        {
  130. +            switch (GetId())
  131. +            {
  132. +                //Guardian of Ancient Kings (retribution)
  133. +                case 86698:
  134. +                    if (!apply)
  135. +                    {
  136. +                        if (caster->HasAura(86700))
  137. +                        {
  138. +                            caster->CastSpell(caster, 86704, true);
  139. +                            caster->RemoveAurasDueToSpell(86700);
  140. +                            caster->RemoveAurasDueToSpell(86701);
  141. +                        }
  142. +                    }
  143. +                    break;
  144. +                //Guardian of Ancient Kings (holy)
  145. +                case 86669:
  146. +                if (!apply)
  147. +                    caster->RemoveAurasDueToSpell(86674);
  148. +                break;
  149. +            }
  150.              break;
  151.          case SPELLFAMILY_DEATHKNIGHT:
  152.          {
  153. diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
  154. index 576cbf4..871d4e6 100644
  155. --- a/src/server/game/Spells/SpellEffects.cpp
  156. +++ b/src/server/game/Spells/SpellEffects.cpp
  157. @@ -394,10 +394,6 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
  158.  
  159.                  switch(m_spellInfo->Id)                     // better way to check unknown
  160.                  {
  161. -                    case 86150: // Guardian of Ancient Kings
  162. -                        if (unitTarget)
  163. -                        m_caster->CastSpell(m_caster, 86698, false, NULL);
  164. -                    return;
  165.                      // Positive/Negative Charge
  166.                      case 28062:
  167.                      case 28085:
  168. @@ -541,16 +537,6 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
  169.                              (m_caster->getLevel() * 2) + (m_caster->GetStat(STAT_INTELLECT) * 0.50193f));
  170.                          break;
  171.                      }
  172. -                    case 86704:
  173. -                    {
  174. -                        if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_caster->isAlive() || !m_UniqueTargetInfo.size())
  175. -                            return;
  176. -
  177. -                        int32 total = m_caster->getLevel() * 2.5f;
  178. -                        total *= m_caster->GetAuraCount(86700);
  179. -                        damage = total / (m_UniqueTargetInfo.size() ? m_UniqueTargetInfo.size() : 1);
  180. -                        break;
  181. -                    }
  182.                  }
  183.                  break;
  184.              }
  185. @@ -2038,6 +2024,28 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
  186.  
  187.              switch (m_spellInfo->Id)
  188.              {
  189. +                // Guardian of ancient kings
  190. +                case 86150:    
  191. +                {
  192. +                    if (m_caster->GetTypeId() != TYPEID_PLAYER)
  193. +                        return;
  194. +                    
  195. +                    switch (m_caster->ToPlayer()->GetTalentBranchSpec(GetCaster()->ToPlayer()->GetActiveSpec()))
  196. +                    {
  197. +                    case BS_PALADIN_HOLY:
  198. +                        m_caster->CastSpell(m_caster, 86669, true);
  199. +                        m_caster->CastSpell(m_caster, 86674, true);
  200. +                        break;
  201. +                    case BS_PALADIN_PROTECTION:
  202. +                        m_caster->CastSpell(m_caster, 86659, true);
  203. +                        break;
  204. +                    case BS_PALADIN_RETRIBUTION)
  205. +                        m_caster->CastSpell(m_caster, 86698, true);
  206. +                        m_caster->CastSpell(m_caster, 86701, true);
  207. +                        break;
  208. +                    }
  209. +                    break;
  210. +                }
  211.                  case 31789: // Righteous Defense (step 1)
  212.                  {
  213.                      // Clear targets for eff 1
  214. @@ -2524,16 +2532,6 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
  215.          // Coldflame
  216.          case 33801:
  217.              return; // just make the core stfu
  218. -        case 86760:
  219. -            for (Unit::ControlList::iterator itr = m_caster->m_Controlled.begin(); itr != m_caster->m_Controlled.end(); ++itr)
  220. -            {
  221. -                if ((*itr)->GetEntry() == 46506 && (*itr)->isSummon() && (*itr)->isAlive())
  222. -                {
  223. -                    unitTarget->AddAura(86698, *itr);
  224. -                    return;
  225. -                }
  226. -            }
  227. -            return;
  228.      }
  229.  
  230.      // normal case
  231. @@ -3230,30 +3228,6 @@ void Spell::SpellDamageHeal(SpellEffIndex effIndex)
  232.              m_caster->RemoveAura(74434);
  233.          }
  234.  
  235. -        if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->getClass() == CLASS_PALADIN)
  236. -        {
  237. -            // Light of the Ancient Kings
  238. -            if (Aura* aur = m_caster->GetAura(86669))
  239. -            {
  240. -                Unit* summon = NULL;
  241. -                for (Unit::ControlList::iterator itr = m_caster->m_Controlled.begin(); itr != m_caster->m_Controlled.end(); ++itr)
  242. -                {
  243. -                    if ((*itr)->GetEntry() == 46499 && (*itr)->isSummon() && (*itr)->isAlive())
  244. -                    {
  245. -                        summon = *itr;
  246. -                        break;
  247. -                    }
  248. -                }
  249. -
  250. -                if (summon && aur->HasEffect(1) && aur->GetEffect(1)->GetAmount())
  251. -                {
  252. -                    int32 bp1 = CalculatePctN(addhealth, 10);
  253. -                    summon->CastCustomSpell(unitTarget, 86678, &addhealth, &bp1, NULL, true);
  254. -                    aur->GetEffect(1)->SetAmount(aur->GetEffect(1)->GetAmount()-1);
  255. -                }
  256. -            }
  257. -        }
  258. -
  259.          // Divine Purpose
  260.          if (m_spellInfo->Id == 85222)
  261.              addhealth *= GetPowerCost();
  262. diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
  263. index 1fc07b8..2ff3c5c 100644
  264. --- a/src/server/game/Spells/SpellMgr.cpp
  265. +++ b/src/server/game/Spells/SpellMgr.cpp
  266. @@ -3597,13 +3597,6 @@ void SpellMgr::LoadSpellCustomAttr()
  267.              case 72505: // Ooze Eruption
  268.              case 72624: // Ooze Eruption
  269.              case 72625: // Ooze Eruption
  270. -            case 86704: // Ancient Fury
  271. -                // ONLY SPELLS WITH SPELLFAMILY_GENERIC and EFFECT_SCHOOL_DAMAGE
  272. -                spellInfo->AttributesCu |= SPELL_ATTR0_CU_SHARE_DAMAGE;
  273. -                break;
  274. -            case 86674: // Ancient Healer
  275. -                spellInfo->ProcCharges = 5;
  276. -                break;
  277.              case 18500: // Wing Buffet
  278.              case 33086: // Wild Bite
  279.              case 49749: // Piercing Blow
  280. @@ -3654,10 +3647,6 @@ void SpellMgr::LoadSpellCustomAttr()
  281.                  // 4.06 dbc issue which was fixed in 4.20 (or 4.10?)
  282.                  spellInfo->Effects[1].BasePoints = 7;
  283.                  break;
  284. -            case 86150: // Guardian of Ancient Kings
  285. -                spellInfo->Effects[0].TriggerSpell = 86698;
  286. -                spellInfo->Effects[0].TargetA = TARGET_UNIT_CASTER;
  287. -                break;
  288.              default:
  289.                  break;
  290.          }
  291. diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
  292. index f5b4837..d197c8e 100644
  293. --- a/src/server/scripts/World/npcs_special.cpp
  294. +++ b/src/server/scripts/World/npcs_special.cpp
  295. @@ -2974,82 +2974,6 @@ public:
  296.      }
  297.  };
  298.  
  299. -// Uncomment this once guardians are able to cast spells
  300. -// on owner at AI initialization and be able to cast spells based on owner's triggered spellcasts.
  301. -
  302. -enum GuardianSpellsAndEntries
  303. -{
  304. -    NPC_PROTECTION_GUARDIAN         = 46490,
  305. -    NPC_HOLY_GUARDIAN               = 46499,
  306. -    NPC_RETRI_GUARDIAN              = 46506,
  307. -    SPELL_ANCIENT_GUARDIAN_VISUAL   = 86657,
  308. -    SPELL_ANCIENT_CRUSADER_PLAYER   = 86703,
  309. -    SPELL_ANCIENT_CRUSADER_GUARDIAN = 86701
  310. -};
  311. -
  312. -class npc_guardian_of_ancient_kings : public CreatureScript
  313. -{
  314. -public:
  315. -    npc_guardian_of_ancient_kings() : CreatureScript("npc_guardian_of_ancient_kings") { }
  316. -
  317. -    struct npc_guardian_of_ancient_kingsAI : public ScriptedAI
  318. -    {
  319. -        npc_guardian_of_ancient_kingsAI(Creature *creature) : ScriptedAI(creature)
  320. -        {
  321. -            _healcount = 0;
  322. -        }
  323. -
  324. -        void InitializeAI()
  325. -        {
  326. -            Unit* owner = me->GetOwner();
  327. -
  328. -            if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
  329. -                return;
  330. -
  331. -            if (me->GetEntry() == NPC_PROTECTION_GUARDIAN)
  332. -            {
  333. -                me->SetUnitMovementFlags(MOVEMENTFLAG_ROOT);
  334. -                me->SetReactState(REACT_PASSIVE);
  335. -                me->CastSpell(owner, SPELL_ANCIENT_GUARDIAN_VISUAL, true);
  336. -            }
  337. -        }
  338. -
  339. -        void UpdateAI(const uint32 diff)
  340. -        {
  341. -            Unit* owner = me->GetOwner();
  342. -
  343. -            if (!UpdateVictim() || !owner)
  344. -                return;
  345. -
  346. -            if (me->GetEntry() == NPC_RETRI_GUARDIAN) // Only the retpaladin guardian hits melee,
  347. -                DoMeleeAttackIfReady();  // at least is what i saw on vids.
  348. -        }
  349. -
  350. -        void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell)
  351. -        {
  352. -            if (me->GetEntry() == NPC_HOLY_GUARDIAN) // Holy paladin guardian
  353. -            {
  354. -                for (uint32 i = 0; i = MAX_SPELL_EFFECTS;)
  355. -                {
  356. -                    if (spell->Effects[i].Effect == SPELL_EFFECT_HEAL // if the spell is a heal...
  357. -                        && spell->Effects[i].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY) //... and is single target
  358. -                        _healcount++;
  359. -
  360. -                    if (_healcount == 5) // "Your Guardian of Ancient Spirits heals the target of your next 5 heals for the same amount as your heal"
  361. -                        me->DespawnOrUnsummon();
  362. -                }
  363. -            }
  364. -        }
  365. -        private:
  366. -            uint32 _healcount;
  367. -    };
  368. -
  369. -    CreatureAI* GetAI(Creature* creature) const
  370. -    {
  371. -        return new npc_guardian_of_ancient_kingsAI(creature);
  372. -    }
  373. -};
  374. -
  375.  // Power Word Barrier
  376.  class npc_power_word_barrier : public CreatureScript
  377.  {
  378. @@ -3128,6 +3052,73 @@ class npc_power_word_barrier : public CreatureScript
  379.      }
  380.  };
  381.  
  382. +class npc_guardian_of_ancient_kings : public CreatureScript
  383. +{
  384. +public:
  385. +    npc_guardian_of_ancient_kings() : CreatureScript("npc_guardian_of_ancient_kings") { }
  386. +
  387. +       CreatureAI *GetAI(Creature *creature) const
  388. +    {
  389. +        return new npc_guardian_of_ancient_kingsAI(creature);
  390. +    }
  391. +
  392. +    struct npc_guardian_of_ancient_kingsAI : public ScriptedAI
  393. +    {
  394. +        npc_guardian_of_ancient_kingsAI(Creature *c) : ScriptedAI(c)
  395. +        {
  396. +            uiHeals = 0;
  397. +        }
  398. +
  399. +        uint32 uiHeals;
  400. +
  401. +        void Reset()
  402. +        {
  403. +            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  404. +            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  405. +            
  406. +            if (me->GetEntry() == 46506)
  407. +                me->SetReactState(REACT_AGGRESSIVE);
  408. +            else
  409. +                me->SetReactState(REACT_PASSIVE);
  410. +
  411. +            if (me->GetEntry() == 46490)
  412. +            {
  413. +                if (me->GetOwner())
  414. +                    DoCast(me->GetOwner(), 86657);
  415. +            }
  416. +            else if (me->GetEntry() == 46506)
  417. +            {
  418. +                if (me->GetOwner())
  419. +                    DoCast(me, 86703, true);
  420. +             }
  421. +        }
  422. +
  423. +        void SetData(uint32 type, uint32 data)
  424. +        {
  425. +            if (type == 1001)
  426. +                uiHeals = data;
  427. +        }
  428. +
  429. +        uint32 GetData(uint32 type)
  430. +        {
  431. +            if (type == 1001)
  432. +                return uiHeals;
  433. +                return 0;
  434. +        }
  435. +
  436. +        void UpdateAI(const uint32 diff)
  437. +        {
  438. +            if (!UpdateVictim())
  439. +                return;
  440. +
  441. +            if (me->HasUnitState(UNIT_STAT_CASTING))
  442. +                return;
  443. +
  444. +            DoMeleeAttackIfReady();
  445. +        }
  446. +    };
  447. +};
  448. +
  449.  void AddSC_npcs_special()
  450.  {
  451.      new npc_air_force_bots;
  452. @@ -3159,6 +3150,6 @@ void AddSC_npcs_special()
  453.      new npc_tabard_vendor;
  454.      new npc_experience;
  455.      new npc_firework;
  456. -    new npc_guardian_of_ancient_kings;
  457.      new npc_power_word_barrier;
  458. +    new npc_guardian_of_ancient_kings();
  459.  }
Advertisement
Add Comment
Please, Sign In to add comment