Changeset 213 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:47:00 (17 years ago)
Author:
yumileroy
Message:

[svn] Fix some aura_interrupt_flag to correctly remove auras.
Add interrupt_flag_unattackable. Source: mangos forum. Adapted by F636y623.
Add function CombatStart?().

Original author: megamage
Date: 2008-11-11 17:49:51-06:00

Location:
trunk/src/game
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Player.cpp

    r212 r213  
    1660616606 
    1660716607    // prevent stealth flight 
    16608     RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
     16608    RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOOT); 
    1660916609 
    1661016610    WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); 
     
    1888618886    return ( //InBattleGround() &&                            // in battleground - not need, check in other cases 
    1888718887             !IsMounted() &&                                  // not mounted 
     18888             !isTotalImmunity() &&                              // not totally immuned 
    1888818889             !HasStealthAura() &&                             // not stealthed 
    1888918890             !HasInvisibilityAura() &&                        // not invisible 
     
    1890118902    return false; 
    1890218903} 
     18904 
     18905bool Player::isTotalImmunity() 
     18906{ 
     18907    AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY); 
     18908 
     18909    for(AuraList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr) 
     18910    { 
     18911        if (((*itr)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_ALL) !=0)   // total immunity 
     18912        { 
     18913            return true; 
     18914        } 
     18915        if (((*itr)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) !=0)   // physical damage immunity 
     18916        { 
     18917            for(AuraList::const_iterator i = immune.begin(); i != immune.end(); ++i) 
     18918            { 
     18919                if (((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) !=0)   // magic immunity 
     18920                { 
     18921                    return true; 
     18922                } 
     18923            } 
     18924        } 
     18925    } 
     18926    return false; 
     18927} 
  • trunk/src/game/Player.h

    r207 r213  
    19151915        bool GetBGAccessByLevel(uint32 bgTypeId) const; 
    19161916        bool isAllowUseBattleGroundObject(); 
     1917        bool isTotalImmunity(); 
    19171918 
    19181919        /*********************************************************/ 
  • trunk/src/game/Spell.cpp

    r203 r213  
    957957                unit->SetStandState(PLAYER_STATE_NONE); 
    958958 
    959             if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) 
    960                 ((Creature*)unit)->AI()->AttackStart(m_caster); 
    961  
    962             unit->SetInCombatWith(m_caster); 
    963             m_caster->SetInCombatWith(unit); 
    964  
    965             if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) 
    966                 m_caster->SetContestedPvP(attackedPlayer); 
     959            m_caster->CombatStart(unit); 
    967960        } 
    968961    } 
     
    1003996            } 
    1004997 
    1005             //if(!IsPositiveSpell(m_spellInfo->Id)) 
    1006             { 
    1007                 //do not remove feign death 
    1008                 unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE); 
    1009             } 
     998            unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); 
    1010999        } 
    10111000        else 
     
    22482237    if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) ) 
    22492238    { 
    2250         m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
     2239        m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); 
    22512240    } 
    22522241 
  • trunk/src/game/SpellAuras.cpp

    r207 r213  
    30723072        m_target->addUnitState(UNIT_STAT_DIED); 
    30733073        m_target->CombatStop(); 
     3074        m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_UNATTACKABLE); 
    30743075 
    30753076        // prevent interrupt message 
     
    32113212        { 
    32123213            // drop flag at stealth in bg 
    3213             if(((Player*)m_target)->InBattleGround()) 
    3214             { 
    3215                 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) 
    3216                     bg->EventPlayerDroppedFlag((Player*)m_target); 
    3217             } 
     3214            m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_UNATTACKABLE); 
     3215 
    32183216            // remove player from the objective's active player count at stealth 
    32193217            if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) 
     
    32993297        m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); 
    33003298 
     3299        m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_UNATTACKABLE); 
     3300 
    33013301        if(Real && m_target->GetTypeId()==TYPEID_PLAYER) 
    33023302        { 
     
    33063306            if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) 
    33073307                pvp->HandlePlayerActivityChanged((Player*)m_target); 
    3308  
    3309             // drop flag at invisible in bg 
    3310             if(((Player*)m_target)->InBattleGround()) 
    3311                 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) 
    3312                     bg->EventPlayerDroppedFlag((Player*)m_target); 
    33133308        } 
    33143309 
     
    38173812void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) 
    38183813{ 
     3814    if(apply && m_modifier.m_miscvalue == SPELL_SCHOOL_MASK_NORMAL) 
     3815        m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_UNATTACKABLE); 
     3816  
    38193817    m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply); 
    38203818 
     
    53775375{ 
    53785376    if(Real && Apply) 
     5377    { 
    53795378        m_target->CombatStop(); 
     5379        m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_UNATTACKABLE); 
     5380    } 
    53805381 
    53815382    m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply); 
  • trunk/src/game/SpellEffects.cpp

    r207 r213  
    34803480        { 
    34813481            // Reveal action + get attack 
    3482             m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
     3482            m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOOT); 
    34833483            if (((Creature*)unitTarget)->AI()) 
    34843484                ((Creature*)unitTarget)->AI()->AttackStart(m_caster); 
  • trunk/src/game/Unit.cpp

    r186 r213  
    473473 
    474474        //sLog.outDetail("auraflag:%u flag:%u = %u",(*iter)->GetSpellProto()->AuraInterruptFlags,flag,(*iter)->GetSpellProto()->AuraInterruptFlags & flag); 
    475         if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag) == flag) 
     475        if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag)) 
    476476        { 
    477477            RemoveAurasDueToSpell((*iter)->GetId()); 
     
    489489} 
    490490 
     491/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ 
     492void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) 
     493{ 
     494    // The chance to dispel an aura depends on the damage taken with respect to the casters level. 
     495    uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; 
     496    float chance = float(damage) / max_dmg * 100.0f; 
     497 
     498    AuraList::iterator i, next; 
     499    for(i = m_ccAuras.begin(); i != m_ccAuras.end(); i = next) 
     500    { 
     501        next = i; 
     502        ++next; 
     503 
     504        if(*i && (!spell || (*i)->GetId() != spell) && roll_chance_f(chance)) 
     505        { 
     506            RemoveAurasDueToSpell((*i)->GetId()); 
     507            if (!m_ccAuras.empty()) 
     508                next = m_ccAuras.begin(); 
     509            else 
     510                return; 
     511        } 
     512    } 
     513} 
     514 
    491515uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) 
    492516{ 
     
    510534    if( damagetype != DOT) 
    511535    { 
    512         RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH); 
    513  
    514536        if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 
    515537            pVictim->SetStandState(PLAYER_STATE_NONE); 
     
    889911 
    890912        // TODO: Store auras by interrupt flag to speed this up. 
    891         AuraMap& vAuras = pVictim->GetAuras(); 
     913        /*AuraMap& vAuras = pVictim->GetAuras(); 
    892914        for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) 
    893915        { 
     
    909931                } 
    910932            } 
    911             else if ( (se->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) && (!spellProto || se->Id != spellProto->Id) ) 
    912             { 
    913                 uint32 max_dmg = pVictim->getLevel() > 8 ? 25 * pVictim->getLevel() - 150 : 50; 
    914                 float chance = float(damage) / max_dmg * 100.0f; 
    915                 if (roll_chance_f(chance)) 
    916                 { 
    917                     pVictim->RemoveAurasDueToSpell(i->second->GetId()); 
    918                     next = vAuras.begin(); 
    919                 } 
    920             } 
    921         } 
     933            else */ 
     934        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DAMAGE); 
     935        pVictim->RemoveSpellbyDamageTaken(damage, spellProto ? spellProto->Id : 0); 
    922936 
    923937        if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) 
     
    21932207        return; 
    21942208 
    2195     if(!pVictim->isInCombat() && pVictim->GetTypeId() != TYPEID_PLAYER && ((Creature*)pVictim)->AI()) 
    2196         ((Creature*)pVictim)->AI()->AttackStart(this); 
    2197  
    2198     SetInCombatWith(pVictim); 
    2199     pVictim->SetInCombatWith(this); 
    2200  
    2201     if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) 
    2202         SetContestedPvP(attackedPlayer); 
     2209    CombatStart(pVictim); 
    22032210 
    22042211    uint32 hitInfo; 
     
    37903797        if(Aur->GetSpellProto()->AuraInterruptFlags) 
    37913798            m_interruptableAuras.push_back(Aur); 
     3799        if(Aur->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 
     3800        { 
     3801            m_ccAuras.push_back(Aur); 
     3802            RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); 
     3803        } 
    37923804    } 
    37933805 
     
    41534165        if((*i).second->GetSpellProto()->AuraInterruptFlags) 
    41544166            m_interruptableAuras.remove((*i).second); 
     4167        if((*i).second->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 
     4168            m_ccAuras.remove((*i).second); 
    41554169    } 
    41564170 
     
    83998413        return; 
    84008414 
    8401     RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); 
     8415    RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT); 
    84028416 
    84038417    SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); 
     
    84678481    } 
    84688482    SetInCombatState(false); 
     8483} 
     8484 
     8485void Unit::CombatStart(Unit* target) 
     8486{ 
     8487    if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) 
     8488        ((Creature*)target)->AI()->AttackStart(this); 
     8489 
     8490    SetInCombatWith(target); 
     8491    target->SetInCombatWith(this); 
     8492 
     8493    if(Player* attackedPlayer = target->GetCharmerOrOwnerPlayerOrPlayerItself()) 
     8494        SetContestedPvP(attackedPlayer); 
     8495 
     8496    if(!isInCombat()) // remove this? 
     8497        RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ATTACK); 
    84698498} 
    84708499 
  • trunk/src/game/Unit.h

    r203 r213  
    5858enum SpellAuraInterruptFlags 
    5959{ 
    60     AURA_INTERRUPT_FLAG_UNK0                = 0x00000001,   // 0    removed when getting hit by a negative spell? 
     60    AURA_INTERRUPT_FLAG_HITBYSPELL          = 0x00000001,   // 0    removed when getting hit by a negative spell? 
    6161    AURA_INTERRUPT_FLAG_DAMAGE              = 0x00000002,   // 1    removed by any damage 
    62     AURA_INTERRUPT_FLAG_UNK2                = 0x00000004,   // 2 
     62    AURA_INTERRUPT_FLAG_CC                  = 0x00000004,   // 2    crowd control 
    6363    AURA_INTERRUPT_FLAG_MOVE                = 0x00000008,   // 3    removed by any movement 
    6464    AURA_INTERRUPT_FLAG_TURNING             = 0x00000010,   // 4    removed by any turning 
    65     AURA_INTERRUPT_FLAG_ENTER_COMBAT        = 0x00000020,   // 5    removed by entering combat 
     65    AURA_INTERRUPT_FLAG_JUMP                = 0x00000020,   // 5    removed by entering combat 
    6666    AURA_INTERRUPT_FLAG_NOT_MOUNTED         = 0x00000040,   // 6    removed by unmounting 
    6767    AURA_INTERRUPT_FLAG_NOT_ABOVEWATER      = 0x00000080,   // 7    removed by entering water 
    6868    AURA_INTERRUPT_FLAG_NOT_UNDERWATER      = 0x00000100,   // 8    removed by leaving water 
    6969    AURA_INTERRUPT_FLAG_NOT_SHEATHED        = 0x00000200,   // 9    removed by unsheathing 
    70     AURA_INTERRUPT_FLAG_UNK10               = 0x00000400,   // 10 
    71     AURA_INTERRUPT_FLAG_UNK11               = 0x00000800,   // 11 
    72     AURA_INTERRUPT_FLAG_UNK12               = 0x00001000,   // 12   removed by attack? 
    73     AURA_INTERRUPT_FLAG_UNK13               = 0x00002000,   // 13 
    74     AURA_INTERRUPT_FLAG_STEALTH             = 0x00003C00, 
     70    AURA_INTERRUPT_FLAG_LOOT                = 0x00000400,   // 10 
     71    AURA_INTERRUPT_FLAG_MOUNT               = 0x00000800,   // 11   removed by mounting 
     72    AURA_INTERRUPT_FLAG_ATTACK              = 0x00001000,   // 12   removed by attacking 
     73    AURA_INTERRUPT_FLAG_CAST                = 0x00002000,   // 13   ??? 
    7574    AURA_INTERRUPT_FLAG_UNK14               = 0x00004000,   // 14 
    76     AURA_INTERRUPT_FLAG_UNK15               = 0x00008000,   // 15   removed by casting a spell? 
     75    AURA_INTERRUPT_FLAG_TRANSFORM           = 0x00008000,   // 15   removed by transform? 
    7776    AURA_INTERRUPT_FLAG_UNK16               = 0x00010000,   // 16 
    78     AURA_INTERRUPT_FLAG_MOUNTING            = 0x00020000,   // 17   removed by mounting 
     77    AURA_INTERRUPT_FLAG_UNK17               = 0x00020000,   // 17   misdirect, aspect, swim speed 
    7978    AURA_INTERRUPT_FLAG_NOT_SEATED          = 0x00040000,   // 18   removed by standing up 
    8079    AURA_INTERRUPT_FLAG_CHANGE_MAP          = 0x00080000,   // 19   leaving map/getting teleported 
    81     AURA_INTERRUPT_FLAG_UNK20               = 0x00100000,   // 20 
     80    AURA_INTERRUPT_FLAG_UNATTACKABLE        = 0x00100000,   // 20   invulnerable or stealth 
    8281    AURA_INTERRUPT_FLAG_UNK21               = 0x00200000,   // 21 
    83     AURA_INTERRUPT_FLAG_UNK22               = 0x00400000,   // 22 
     82    AURA_INTERRUPT_FLAG_TELEPORTED          = 0x00400000,   // 22 
    8483    AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT    = 0x00800000,   // 23   removed by entering pvp combat 
    8584    AURA_INTERRUPT_FLAG_DIRECT_DAMAGE       = 0x01000000    // 24   removed by any direct damage 
     
    845844 
    846845        uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } 
     846        void RemoveSpellbyDamageTaken(uint32 damage, uint32 spell); 
    847847        uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); 
    848848        void DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit = false, bool isTriggeredSpell = false); 
     
    903903 
    904904        bool isInCombat()  const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } 
     905        void CombatStart(Unit* target); 
    905906        void SetInCombatState(bool PvP); 
    906907        void SetInCombatWith(Unit* enemy); 
     
    13351336        AuraList m_modAuras[TOTAL_AURAS]; 
    13361337        AuraList m_interruptableAuras; 
     1338        AuraList m_ccAuras; 
    13371339        float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]; 
    13381340        float m_weaponDamage[MAX_ATTACK][2];