Changeset 213 for trunk/src/game/Unit.cpp
- Timestamp:
- 11/19/08 13:47:00 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Unit.cpp
r186 r213 473 473 474 474 //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)) 476 476 { 477 477 RemoveAurasDueToSpell((*iter)->GetId()); … … 489 489 } 490 490 491 /* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ 492 void 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 491 515 uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) 492 516 { … … 510 534 if( damagetype != DOT) 511 535 { 512 RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_STEALTH);513 514 536 if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 515 537 pVictim->SetStandState(PLAYER_STATE_NONE); … … 889 911 890 912 // TODO: Store auras by interrupt flag to speed this up. 891 AuraMap& vAuras = pVictim->GetAuras();913 /*AuraMap& vAuras = pVictim->GetAuras(); 892 914 for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) 893 915 { … … 909 931 } 910 932 } 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); 922 936 923 937 if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) … … 2193 2207 return; 2194 2208 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); 2203 2210 2204 2211 uint32 hitInfo; … … 3790 3797 if(Aur->GetSpellProto()->AuraInterruptFlags) 3791 3798 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 } 3792 3804 } 3793 3805 … … 4153 4165 if((*i).second->GetSpellProto()->AuraInterruptFlags) 4154 4166 m_interruptableAuras.remove((*i).second); 4167 if((*i).second->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 4168 m_ccAuras.remove((*i).second); 4155 4169 } 4156 4170 … … 8399 8413 return; 8400 8414 8401 RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT ING);8415 RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT); 8402 8416 8403 8417 SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); … … 8467 8481 } 8468 8482 SetInCombatState(false); 8483 } 8484 8485 void 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); 8469 8498 } 8470 8499