Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.02 KB | None | 0 0
  1. void Spell::SpellEffectApplyAura(uint32 i)  // Apply Aura
  2. {
  3.     if( unitTarget == NULL )
  4.         return;
  5.     // can't apply stuns/fear/polymorph/root etc on boss
  6.     if( unitTarget->IsCreature() )
  7.     {
  8.         if( u_caster != NULL && ( u_caster != unitTarget ) )
  9.         {
  10.             Creature * c = TO< Creature* >( unitTarget );
  11.             /*
  12.             Charm (Mind Control, enslave demon): 1
  13.             Confuse (Blind etc): 2
  14.             Fear: 4
  15.             Root: 8
  16.             Silence : 16
  17.             Stun: 32
  18.             Sheep: 64
  19.             Banish: 128
  20.             Sap: 256
  21.             Frozen : 512
  22.             Ensnared 1024
  23.             Sleep 2048
  24.             Taunt (aura): 4096
  25.             Decrease Speed (Hamstring) (aura): 8192
  26.             Spell Haste (Curse of Tongues) (aura): 16384
  27.             Interrupt Cast: 32768
  28.             Mod Healing % (Mortal Strike) (aura): 65536
  29.             Total Stats % (Vindication) (aura): 131072
  30.             */
  31.  
  32.             //Spells with Mechanic also add other ugly auras, but if the main aura is the effect --> immune to whole spell
  33.             if (c->GetProto()->modImmunities)
  34.             {
  35.                 bool immune = false;
  36.                 if (m_spellInfo->MechanicsType)
  37.                 {
  38.                     switch(m_spellInfo->MechanicsType)
  39.                     {
  40.                     case MECHANIC_CHARMED:
  41.                         if (c->GetProto()->modImmunities & 1)
  42.                             immune = true;
  43.                         break;
  44.                     case MECHANIC_DISORIENTED:
  45.                         if (c->GetProto()->modImmunities & 2)
  46.                             immune = true;
  47.                         break;
  48.                     case MECHANIC_FLEEING:
  49.                         if (c->GetProto()->modImmunities & 4)
  50.                             immune = true;
  51.                         break;
  52.                     case MECHANIC_ROOTED:
  53.                         if (c->GetProto()->modImmunities & 8)
  54.                             immune = true;
  55.                         break;
  56.                     case MECHANIC_SILENCED:
  57.                         if ( c->GetProto()->modImmunities & 16)
  58.                             immune = true;
  59.                         break;
  60.                     case MECHANIC_STUNNED:
  61.                         if (c->GetProto()->modImmunities & 32)
  62.                             immune = true;
  63.                         break;
  64.                     case MECHANIC_POLYMORPHED:
  65.                         if (c->GetProto()->modImmunities & 64)
  66.                             immune = true;
  67.                         break;
  68.                     case MECHANIC_BANISHED:
  69.                         if (c->GetProto()->modImmunities & 128)
  70.                             immune = true;
  71.                         break;
  72.                     case MECHANIC_SAPPED:
  73.                         if (c->GetProto()->modImmunities & 256)
  74.                             immune = true;
  75.                         break;
  76.                     case MECHANIC_FROZEN:
  77.                         if (c->GetProto()->modImmunities & 512)
  78.                             immune = true;
  79.                         break;
  80.                     case MECHANIC_ENSNARED:
  81.                         if (c->GetProto()->modImmunities & 1024)
  82.                             immune = true;
  83.                         break;
  84.                     case MECHANIC_ASLEEP:
  85.                         if (c->GetProto()->modImmunities & 2048)
  86.                             immune = true;
  87.                         break;
  88.                     }
  89.                 }
  90.                 if (!immune)
  91.                 {
  92.                     // Spells that do more than just one thing (damage and the effect) don't have a mechanic and we should only cancel the aura to be placed
  93.                     switch (m_spellInfo->EffectApplyAuraName[i])
  94.                     {
  95.                     case SPELL_AURA_MOD_CONFUSE:
  96.                         if (c->GetProto()->modImmunities & 2)
  97.                             immune = true;
  98.                         break;
  99.                     case SPELL_AURA_MOD_FEAR:
  100.                         if (c->GetProto()->modImmunities & 4)
  101.                             immune = true;
  102.                         break;
  103.                     case SPELL_AURA_MOD_TAUNT:
  104.                         if (c->GetProto()->modImmunities & 4096)
  105.                             immune = true;
  106.                         break;
  107.                     case SPELL_AURA_MOD_STUN:
  108.                         if (c->GetProto()->modImmunities & 32)
  109.                             immune = true;
  110.                         break;
  111.                     case SPELL_AURA_MOD_SILENCE:
  112.                         if ((c->GetProto()->modImmunities & 32768) || (c->GetProto()->modImmunities & 16))
  113.                             immune = true;
  114.                         break;
  115.                     case SPELL_AURA_MOD_DECREASE_SPEED:
  116.                         if (c->GetProto()->modImmunities & 8192)
  117.                             immune = true;
  118.                         break;
  119.                     case SPELL_AURA_INCREASE_CASTING_TIME_PCT:
  120.                         if (c->GetProto()->modImmunities & 16384)
  121.                             immune = true;
  122.                         break;
  123.                     case SPELL_AURA_MOD_LANGUAGE: //hacky way to prefer that the COT icon is set to mob
  124.                         if (c->GetProto()->modImmunities & 16384)
  125.                             immune = true;
  126.                         break;
  127.                     case SPELL_AURA_MOD_HEALING_DONE_PERCENT:
  128.                         if (c->GetProto()->modImmunities & 65536)
  129.                             immune = true;
  130.                         break;
  131.                     case SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE:
  132.                         if (c->GetProto()->modImmunities & 131072)
  133.                             immune = true;
  134.                         break;
  135.                     }
  136.                 }
  137.                 if( immune )
  138.                     return;
  139.             }
  140.         }
  141.     }
  142.  
  143. #ifdef GM_Z_DEBUG_DIRECTLY
  144.     else {
  145.         if( unitTarget->IsPlayer() && unitTarget->IsInWorld() && TO< Player* >( unitTarget )->GetSession() && TO< Player* >( unitTarget )->GetSession()->CanUseCommand('z')  ) {
  146.             sChatHandler.BlueSystemMessage( TO< Player* >( unitTarget  )->GetSession(), "[%sSystem%s] |rSpell::SpellEffectApplyAura: %s EffectApplyAuraName [%u] .", MSG_COLOR_WHITE, MSG_COLOR_LIGHTBLUE, MSG_COLOR_SUBWHITE,
  147.                 i );
  148.         }
  149.     }
  150. #endif
  151.  
  152.     // avoid map corruption.
  153.     if(unitTarget->GetInstanceID() != m_caster->GetInstanceID())
  154.         return;
  155.  
  156.     //check if we already have stronger aura
  157.     Aura *pAura;
  158.  
  159.     std::map<uint64, Aura*>::iterator itr = m_pendingAuras.find(unitTarget->GetGUID());
  160.     //if we do not make a check to see if the aura owner is the same as the caster then we will stack the 2 auras and they will not be visible client sided
  161.     if(itr == m_pendingAuras.end())
  162.     {
  163.         if( GetProto()->NameHash == SPELL_HASH_BLOOD_FRENZY && ProcedOnSpell )//Warrior's Blood Frenzy
  164.             GetProto()->DurationIndex = ProcedOnSpell->DurationIndex;
  165.  
  166.         uint32 Duration = GetDuration();
  167.  
  168.         // Handle diminishing returns, if it should be resisted, it'll make duration 0 here.
  169.         if(!(GetProto()->Attributes & ATTRIBUTES_PASSIVE)) // Passive
  170.             ::ApplyDiminishingReturnTimer(&Duration, unitTarget, GetProto());
  171.  
  172.         if(!Duration)
  173.         {
  174.             SendCastResult(SPELL_FAILED_IMMUNE);
  175.             return;
  176.         }
  177.  
  178.         if( g_caster && g_caster->GetUInt32Value(OBJECT_FIELD_CREATED_BY) && g_caster->m_summoner )
  179.             pAura = new Aura( GetProto(), Duration, g_caster->m_summoner, unitTarget, m_triggeredSpell, i_caster );
  180.         else
  181.             pAura = new Aura( GetProto(), Duration, m_caster, unitTarget, m_triggeredSpell, i_caster );
  182.  
  183.         pAura->pSpellId = pSpellId; //this is required for triggered spells
  184.  
  185.         m_pendingAuras.insert(std::make_pair(unitTarget->GetGUID(), pAura));
  186.         AddRef();
  187.         sEventMgr.AddEvent(this, &Spell::HandleAddAura, unitTarget->GetGUID(), EVENT_SPELL_HIT, 100, 1, 0);
  188.     }
  189.     else
  190.     {
  191.         pAura = itr->second;
  192.     }
  193.     pAura->AddMod( GetProto()->EffectApplyAuraName[i], damage, GetProto()->EffectMiscValue[i], i );
  194.  
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement