Changeset 272 for trunk/src/game/Pet.cpp

Show
Ignore:
Timestamp:
11/22/08 00:35:41 (17 years ago)
Author:
yumileroy
Message:

Delete possessed AI only on creature delete.

Original author: gvcoman
Date: 2008-11-16 14:38:02-05:00

Files:
1 modified

Legend:

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

    r265 r272  
    287287            ++iter; 
    288288            m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); 
    289  
    290             // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST 
    291             // so overwrite old state  
    292             SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction); 
    293             if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) m_charmInfo->GetActionBarEntry(index)->Type = ACT_CAST; 
    294289        } 
    295290 
     
    13281323        SetUInt32Value(i, 0); 
    13291324 
    1330     QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); 
     1325    QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); 
    13311326 
    13321327    if(result) 
     
    13381333            uint32 spellid = fields[1].GetUInt32(); 
    13391334            uint32 effindex = fields[2].GetUInt32(); 
    1340             uint32 stackcount= fields[3].GetUInt32(); 
    1341             int32 damage     = (int32)fields[4].GetUInt32(); 
    1342             int32 maxduration = (int32)fields[5].GetUInt32(); 
    1343             int32 remaintime = (int32)fields[6].GetUInt32(); 
    1344             int32 remaincharges = (int32)fields[7].GetUInt32(); 
     1335            int32 damage     = (int32)fields[3].GetUInt32(); 
     1336            int32 maxduration = (int32)fields[4].GetUInt32(); 
     1337            int32 remaintime = (int32)fields[5].GetUInt32(); 
     1338            int32 remaincharges = (int32)fields[6].GetUInt32(); 
    13451339 
    13461340            SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); 
     
    13791373                continue; 
    13801374 
    1381             for(uint32 i=0; i<stackcount; i++) 
    1382             { 
    1383                 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
    1384  
    1385                 if(!damage) 
    1386                     damage = aura->GetModifier()->m_amount; 
    1387                 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
    1388                 AddAura(aura); 
    1389             } 
     1375            Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
     1376 
     1377            if(!damage) 
     1378                damage = aura->GetModifier()->m_amount; 
     1379            aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
     1380            AddAura(aura); 
    13901381        } 
    13911382        while( result->NextRow() ); 
     
    14001391 
    14011392    AuraMap const& auras = GetAuras(); 
    1402     if (auras.empty()) 
    1403         return; 
    1404  
    1405     spellEffectPair lastEffectPair = auras.begin()->first; 
    1406     uint32 stackCounter = 1; 
    1407  
    1408     for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) 
    1409     { 
    1410         if(itr == auras.end() || lastEffectPair != itr->first) 
    1411         { 
    1412             AuraMap::const_iterator itr2 = itr; 
    1413             // save previous spellEffectPair to db 
    1414             itr2--; 
    1415             SpellEntry const *spellInfo = itr2->second->GetSpellProto(); 
    1416             /// do not save single target auras (unless they were cast by the player) 
    1417             if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) 
    1418             { 
    1419                 if(!itr2->second->IsPassive()) 
    1420                 { 
    1421                     // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. 
    1422                     uint8 i; 
    1423                     for (i = 0; i < 3; i++) 
    1424                         if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || 
    1425                             spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || 
    1426                             spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) 
    1427                             break; 
    1428  
    1429                     if (i == 3) 
    1430                     { 
    1431                         CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " 
    1432                             "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')", 
    1433                             m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); 
    1434                     } 
    1435                 } 
    1436             } 
    1437             if(itr == auras.end()) 
     1393    for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) 
     1394    { 
     1395        // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. 
     1396        SpellEntry const *spellInfo = itr->second->GetSpellProto(); 
     1397        uint8 i; 
     1398        for (i = 0; i < 3; i++) 
     1399            if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || 
     1400                spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || 
     1401                spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) 
    14381402                break; 
    1439         } 
    1440  
    1441         if (lastEffectPair == itr->first) 
    1442             stackCounter++; 
    1443         else 
    1444         { 
    1445             lastEffectPair = itr->first; 
    1446             stackCounter = 1; 
    1447         } 
     1403 
     1404        if (i != 3) 
     1405            continue; 
     1406         
     1407        if(itr->second->IsPassive()) 
     1408            continue; 
     1409 
     1410        /// do not save single target auras (unless they were cast by the player) 
     1411        if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 
     1412            continue; 
     1413 
     1414        CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 
     1415            "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')", 
     1416            m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); 
    14481417    } 
    14491418} 
     
    14651434        return false; 
    14661435    } 
    1467  
    1468     // same spells don't have autocast option 
    1469     if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) 
    1470         active = ACT_CAST; 
    14711436 
    14721437    PetSpellMap::iterator itr = m_spells.find(spell_id); 
     
    15441509        CastSpell(this, spell_id, true); 
    15451510    else if(state == PETSPELL_NEW) 
    1546         m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active); 
     1511        m_charmInfo->AddSpellToAB(oldspell_id, spell_id); 
    15471512 
    15481513    if(newspell->active == ACT_ENABLED) 
     
    16941659        return; 
    16951660 
    1696     //if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 
    1697     //    if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER 
    1698     //        && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) 
    1699     //        return;     
     1661    if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 
     1662        if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER 
     1663            && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) 
     1664            return;     
    17001665 
    17011666    PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid);