jordan83221

Transcendence / Transcendence Transfer

Nov 7th, 2019
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.65 KB | None | 0 0
  1. /// Transcendence : Transfer - 119996
  2. class spell_monk_transcendence_transfer: public SpellScriptLoader
  3. {
  4.     public:
  5.         spell_monk_transcendence_transfer() : SpellScriptLoader("spell_monk_transcendence_transfer") { }
  6.  
  7.         class spell_monk_transcendence_transfer_SpellScript : public SpellScript
  8.         {
  9.             PrepareSpellScript(spell_monk_transcendence_transfer_SpellScript);
  10.  
  11.             SpellCastResult CheckSpiritRange()
  12.             {
  13.                 if (Unit* caster = GetCaster())
  14.                 {
  15.                     for (Unit::ControlList::const_iterator itr = caster->m_Controlled.begin(); itr != caster->m_Controlled.end(); ++itr)
  16.                     {
  17.                         if ((*itr)->GetEntry() == 54569)
  18.                         {
  19.                             if ((*itr)->GetDistance(caster) > 40.0f)
  20.                                 return SPELL_FAILED_DONT_REPORT;
  21.                         }
  22.                     }
  23.                 }
  24.  
  25.                 return SPELL_CAST_OK;
  26.             }
  27.  
  28.             void HandleDummy()
  29.             {
  30.                 if (Unit* caster = GetCaster())
  31.                 {
  32.                     for (Unit::ControlList::const_iterator itr = caster->m_Controlled.begin(); itr != caster->m_Controlled.end(); ++itr)
  33.                     {
  34.                         if ((*itr)->GetEntry() == 54569)
  35.                         {
  36.                             Creature* clone = (*itr)->ToCreature();
  37.                             if (clone && clone->AI())
  38.                                 clone->AI()->DoAction(1);
  39.                         }
  40.                     }
  41.                 }
  42.             }
  43.  
  44.             void Register()
  45.             {
  46.                 OnCheckCast += SpellCheckCastFn(spell_monk_transcendence_transfer_SpellScript::CheckSpiritRange);
  47.                 OnHit += SpellHitFn(spell_monk_transcendence_transfer_SpellScript::HandleDummy);
  48.             }
  49.         };
  50.  
  51.         SpellScript* GetSpellScript() const
  52.         {
  53.             return new spell_monk_transcendence_transfer_SpellScript();
  54.         }
  55. };
  56.  
  57.  
  58. /*######
  59. ## npc_transcendence_spirit -- 54569
  60. ######*/
  61.  
  62. enum TranscendenceSpiritSpells
  63. {
  64.     SPELL_MEDITATE          = 124416,
  65.     SPELL_ROOT_FOR_EVER     = 31366,
  66.     SPELL_VISUAL_SPIRIT     = 119053,
  67.     SPELL_INITIALIZE_IMAGES = 102284,
  68.     SPELL_CLONE_CASTER      = 102288
  69. };
  70.  
  71. enum transcendenceActions
  72. {
  73.     ACTION_TELEPORT = 1
  74. };
  75.  
  76. class npc_transcendence_spirit : public CreatureScript
  77. {
  78.     public:
  79.         npc_transcendence_spirit() : CreatureScript("npc_transcendence_spirit") { }
  80.  
  81.         struct npc_transcendence_spiritAI : public Scripted_NoMovementAI
  82.         {
  83.             npc_transcendence_spiritAI(Creature* c) : Scripted_NoMovementAI(c)
  84.             {
  85.                 me->SetReactState(REACT_PASSIVE);
  86.             }
  87.  
  88.             void Reset()
  89.             {
  90.                 me->CastSpell(me, SPELL_MEDITATE, true);
  91.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE|UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE);
  92.                 me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN);
  93.             }
  94.  
  95.             void IsSummonedBy(Unit* owner)
  96.             {
  97.                 if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
  98.                     return;
  99.  
  100.                 me->SetMaxHealth(owner->GetMaxHealth() / 2);
  101.                 me->SetHealth(me->GetMaxHealth());
  102.  
  103.                 me->CastSpell(me, SPELL_VISUAL_SPIRIT, true);
  104.                 owner->CastSpell(me, SPELL_INITIALIZE_IMAGES, true);
  105.                 owner->CastSpell(me, SPELL_CLONE_CASTER, true);
  106.                 owner->AddAura(SPELL_MEDITATE, me);
  107.                 me->AddAura(SPELL_ROOT_FOR_EVER, me);
  108.             }
  109.  
  110.             void DoAction(int32 const action)
  111.             {
  112.                 switch (action)
  113.                 {
  114.                     case ACTION_TELEPORT:
  115.                     {
  116.                         if (Unit* owner = me->GetOwner())
  117.                         {
  118.                             Position ownerPos;
  119.                             owner->GetPosition(&ownerPos);
  120.  
  121.                             owner->NearTeleportTo(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
  122.                             me->NearTeleportTo(ownerPos.m_positionX, ownerPos.m_positionY, ownerPos.m_positionZ, ownerPos.m_orientation);
  123.                         }
  124.  
  125.                         break;
  126.                     }
  127.                     default:
  128.                         break;
  129.                 }
  130.             }
  131.         };
  132.  
  133.         CreatureAI* GetAI(Creature *creature) const
  134.         {
  135.             return new npc_transcendence_spiritAI(creature);
  136.         }
  137. };
Add Comment
Please, Sign In to add comment