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

[svn] Fix 146_world.sql. Do not use default for text. (Ignore this if you have successfully applied 146_world.sql)
Fix HandleAuraModIncreaseHealth?, also increase current health.
Merge from Mangos:
2008-11-02 10:53:27 854e0d64e3410b2a1eff6d56705f8e42b4291534 Do not split self caused damage.
(PART) 2008-10-31 12:45:22 e56b671979623570acd358a9b99aa169be22ffba Move tamed pet creating code to new function.

Original author: megamage
Date: 2008-11-04 09:23:06-06:00

Files:
1 modified

Legend:

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

    r157 r161  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    16971697    } 
    16981698 
    1699     AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); 
    1700     for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) 
    1701     { 
    1702         next = i; ++next; 
    1703  
    1704         // check damage school mask 
    1705         if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) 
    1706             continue; 
    1707  
    1708         // Damage can be splitted only if aura has an alive caster 
    1709         Unit *caster = (*i)->GetCaster(); 
    1710         if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) 
    1711             continue; 
    1712  
    1713         int32 currentAbsorb; 
    1714         if (RemainingDamage >= (*i)->GetModifier()->m_amount) 
    1715             currentAbsorb = (*i)->GetModifier()->m_amount; 
    1716         else 
    1717             currentAbsorb = RemainingDamage; 
    1718  
    1719         RemainingDamage -= currentAbsorb; 
    1720  
    1721         SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false); 
    1722  
    1723         CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL); 
    1724         DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); 
    1725     } 
    1726  
    1727     AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT); 
    1728     for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) 
    1729     { 
    1730         next = i; ++next; 
    1731  
    1732         // check damage school mask 
    1733         if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) 
    1734             continue; 
    1735  
    1736         // Damage can be splitted only if aura has an alive caster 
    1737         Unit *caster = (*i)->GetCaster(); 
    1738         if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) 
    1739             continue; 
    1740  
    1741         int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f); 
    1742  
    1743         RemainingDamage -= splitted; 
    1744  
    1745         SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false); 
    1746  
    1747         CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL); 
    1748         DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); 
     1699    // only split damage if not damaing yourself 
     1700    if(pVictim != this) 
     1701    { 
     1702        AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); 
     1703        for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) 
     1704        { 
     1705            next = i; ++next; 
     1706 
     1707            // check damage school mask 
     1708            if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) 
     1709                continue; 
     1710 
     1711            // Damage can be splitted only if aura has an alive caster 
     1712            Unit *caster = (*i)->GetCaster(); 
     1713            if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) 
     1714                continue; 
     1715 
     1716            int32 currentAbsorb; 
     1717            if (RemainingDamage >= (*i)->GetModifier()->m_amount) 
     1718                currentAbsorb = (*i)->GetModifier()->m_amount; 
     1719            else 
     1720                currentAbsorb = RemainingDamage; 
     1721 
     1722            RemainingDamage -= currentAbsorb; 
     1723 
     1724            SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false); 
     1725 
     1726            CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL); 
     1727            DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); 
     1728        } 
     1729 
     1730        AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT); 
     1731        for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) 
     1732        { 
     1733            next = i; ++next; 
     1734 
     1735            // check damage school mask 
     1736            if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) 
     1737                continue; 
     1738 
     1739            // Damage can be splitted only if aura has an alive caster 
     1740            Unit *caster = (*i)->GetCaster(); 
     1741            if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) 
     1742                continue; 
     1743 
     1744            int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f); 
     1745 
     1746            RemainingDamage -= splitted; 
     1747 
     1748            SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false); 
     1749 
     1750            CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL); 
     1751            DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); 
     1752        } 
    17491753    } 
    17501754 
     
    19451949 
    19461950                // after parry nearest next attack time will reduced at %40 from full attack time. 
    1947                 // The delay cannot be reduced to less than 20% of your weapon's base swing delay. 
     1951                // The delay cannot be reduced to less than 20% of your weapon base swing delay. 
    19481952                if (pVictim->haveOffhandWeapon() && offtime < basetime) 
    19491953                { 
     
    64906494        case 836:                                           // Improved Blizzard (Rank 1) 
    64916495        { 
    6492             if( !procSpell || procSpell->SpellVisual!=9487) 
     6496            if (!procSpell || procSpell->SpellVisual!=9487) 
    64936497                return false; 
    64946498            triggered_spell_id = 12484; 
     
    64976501        case 988:                                           // Improved Blizzard (Rank 2) 
    64986502        { 
    6499             if( !procSpell || procSpell->SpellVisual!=9487) 
     6503            if (!procSpell || procSpell->SpellVisual!=9487) 
    65006504                return false; 
    65016505            triggered_spell_id = 12485; 
     
    65046508        case 989:                                           // Improved Blizzard (Rank 3) 
    65056509        { 
    6506             if( !procSpell || procSpell->SpellVisual!=9487) 
     6510            if (!procSpell || procSpell->SpellVisual!=9487) 
    65076511                return false; 
    65086512            triggered_spell_id = 12486; 
     
    73037307        } 
    73047308    } 
     7309 
    73057310    // .. taken pct: dummy auras 
    73067311    AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); 
     
    75367541            } 
    75377542            // Holy Nova - 14% 
    7538             else if ((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 1874)  
     7543            else if ((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 1874) 
    75397544            { 
    75407545                CastingTime = 500; 
     
    77767781        return healamount; 
    77777782 
    7778  
    77797783    int32 AdvertisedBenefit = SpellBaseHealingBonus(GetSpellSchoolMask(spellProto)); 
    77807784    uint32 CastingTime = GetSpellCastTime(spellProto); 
     
    78817885            case SPELLFAMILY_PRIEST: 
    78827886                // Holy Nova - 14% 
    7883                 if ((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 1874)  
     7887                if ((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 1874) 
    78847888                    CastingTime = 500; 
    78857889                break; 
     
    86438647    // raw invisibility 
    86448648    bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask !=0); 
    8645      
     8649 
    86468650    // detectable invisibility case 
    86478651    if( invisible && ( 
     
    1037610380    WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4); 
    1037710381    data << uint64(GetGUID()); 
    10378     data << uint8(0x0); 
     10382    data << uint8(0x0);                                     // flags (0x1, 0x2) 
    1037910383    data << uint32(spellid); 
    1038010384    data << uint32(cooltime); 
     
    1088710891        pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); 
    1088810892} 
     10893 
     10894Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) 
     10895{ 
     10896    Pet* pet = new Pet(HUNTER_PET); 
     10897 
     10898    if(!pet->CreateBaseAtCreature(creatureTarget)) 
     10899    { 
     10900        delete pet; 
     10901        return NULL; 
     10902    } 
     10903 
     10904    pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID()); 
     10905    pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID()); 
     10906    pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction()); 
     10907    pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); 
     10908 
     10909    if(!pet->InitStatsForLevel(creatureTarget->getLevel())) 
     10910    { 
     10911        sLog.outError("ERROR: Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry()); 
     10912        delete pet; 
     10913        return NULL; 
     10914    } 
     10915 
     10916    pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true); 
     10917    // this enables pet details window (Shift+P) 
     10918    pet->AIM_Initialize(); 
     10919    pet->InitPetCreateSpells(); 
     10920    pet->SetHealth(pet->GetMaxHealth()); 
     10921 
     10922    return pet; 
     10923}