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/Player.cpp

    r257 r272  
    800800} 
    801801 
    802 void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) 
     802void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage) 
    803803{ 
    804804    WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); 
     
    16421642    { 
    16431643        // far teleport to another map 
    1644         Map* oldmap = IsInWorld() ? GetMap() : NULL; 
     1644        Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; 
    16451645        // check if we can enter before stopping combat / removing pet / totems / interrupting spells 
    16461646 
     
    37513751} 
    37523752 
    3753 void Player::ResurrectPlayer(float restore_percent, bool applySickness) 
     3753void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) 
    37543754{ 
    37553755    WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4);          // remove spirit healer position 
     
    42824282} 
    42834283 
    4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) 
     4284void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) 
    42854285{ 
    42864286    if(modGroup >= BASEMOD_END || modType >= MOD_END) 
     
    52445244    } 
    52455245 
    5246     Map *m = GetMap(); 
     5246    Map *m = MapManager::Instance().GetMap(GetMapId(), this); 
    52475247 
    52485248    const float old_x = GetPositionX(); 
     
    52625262 
    52635263        // reread after Map::Relocation 
    5264         m = GetMap(); 
     5264        m = MapManager::Instance().GetMap(GetMapId(), this); 
    52655265        x = GetPositionX(); 
    52665266        y = GetPositionY(); 
     
    61776177        return 0; 
    61786178 
    6179     uint32 id = (*result)[0].GetUInt32(); 
    6180     delete result; 
    6181     return id; 
     6179    return (*result)[0].GetUInt32(); 
    61826180} 
    61836181 
     
    67106708    } 
    67116709 
    6712     if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 
     6710    if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 
    67136711        return; 
    67146712 
     
    84888486        return item; 
    84898487 
    8490     if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) 
     8488    if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) ) 
    84918489        return NULL; 
    84928490 
     
    86428640    return false; 
    86438641} 
    8644  
    86458642 
    86468643bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const 
     
    1015910156        if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 
    1016010157            pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 
    10161             pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 
     10158            pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 
    1016210159            pItem->SetBinding( true ); 
    1016310160 
     
    1020510202        if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 
    1020610203            pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 
    10207             pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 
     10204            pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 
    1020810205            pItem2->SetBinding( true ); 
    1020910206 
     
    1040710404 
    1040810405    // check also  BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) 
    10409     if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 
     10406    if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 
    1041010407        pItem->SetBinding( true ); 
    1041110408 
     
    1055110548        if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 
    1055210549            CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 
     10550 
     10551        ItemPrototype const *pProto = pItem->GetProto(); 
    1055310552 
    1055410553        RemoveEnchantmentDurations(pItem); 
     
    1420914208        SetUInt32Value(i, 0); 
    1421014209 
    14211     //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 
     14210    //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 
    1421214211 
    1421314212    if(result) 
     
    1421914218            uint32 spellid = fields[1].GetUInt32(); 
    1422014219            uint32 effindex = fields[2].GetUInt32(); 
    14221             uint32 stackcount = fields[3].GetUInt32(); 
    14222             int32 damage     = (int32)fields[4].GetUInt32(); 
    14223             int32 maxduration = (int32)fields[5].GetUInt32(); 
    14224             int32 remaintime = (int32)fields[6].GetUInt32(); 
    14225             int32 remaincharges = (int32)fields[7].GetUInt32(); 
     14220            int32 damage     = (int32)fields[3].GetUInt32(); 
     14221            int32 maxduration = (int32)fields[4].GetUInt32(); 
     14222            int32 remaintime = (int32)fields[5].GetUInt32(); 
     14223            int32 remaincharges = (int32)fields[6].GetUInt32(); 
    1422614224 
    1422714225            SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); 
     
    1426014258                continue; 
    1426114259 
    14262             for(uint32 i=0; i<stackcount; i++) 
    14263             { 
    14264                 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
    14265                 if(!damage) 
    14266                     damage = aura->GetModifier()->m_amount; 
    14267                 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
    14268                 AddAura(aura); 
    14269                 sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex); 
    14270             } 
     14260            Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
     14261            if(!damage) 
     14262                damage = aura->GetModifier()->m_amount; 
     14263            aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
     14264            AddAura(aura); 
    1427114265        } 
    1427214266        while( result->NextRow() ); 
     
    1532715321 
    1532815322    AuraMap const& auras = GetAuras(); 
    15329  
    15330     if (auras.empty()) 
    15331         return; 
    15332  
    15333     spellEffectPair lastEffectPair = auras.begin()->first; 
    15334     uint32 stackCounter = 1; 
    15335  
    15336     for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) 
    15337     { 
    15338         if(itr == auras.end() || lastEffectPair != itr->first) 
    15339         { 
    15340             AuraMap::const_iterator itr2 = itr; 
    15341             // save previous spellEffectPair to db 
    15342             itr2--; 
    15343             SpellEntry const *spellInfo = itr2->second->GetSpellProto(); 
    15344  
    15345             //skip all auras from spells that are passive or need a shapeshift 
    15346             if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) 
    15347             { 
    15348                 //do not save single target auras (unless they were cast by the player) 
    15349                 if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) 
    15350                 { 
    15351                     uint8 i; 
    15352                     // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 
    15353                     for (i = 0; i < 3; i++) 
    15354                         if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 
    15355                         spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 
    15356                             break; 
    15357  
    15358                     if (i == 3) 
    15359                     { 
    15360                         CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " 
    15361                             "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", 
    15362                             GetGUIDLow(), 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)); 
    15363                     } 
    15364                 } 
    15365             } 
    15366  
    15367             if(itr == auras.end()) 
     15323    for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) 
     15324    { 
     15325        SpellEntry const *spellInfo = itr->second->GetSpellProto(); 
     15326 
     15327        //skip all auras from spells that are passive or need a shapeshift 
     15328        if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) 
     15329            continue; 
     15330 
     15331        //do not save single target auras (unless they were cast by the player) 
     15332        if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 
     15333            continue; 
     15334 
     15335        uint8 i; 
     15336        // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 
     15337        for (i = 0; i < 3; i++) 
     15338            if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 
     15339            spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 
    1536815340                break; 
    15369         } 
    15370  
    15371         if (lastEffectPair == itr->first) 
    15372             stackCounter++; 
    15373         else 
    15374         { 
    15375             lastEffectPair = itr->first; 
    15376             stackCounter = 1; 
     15341 
     15342        if (i == 3) 
     15343        { 
     15344            CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and  effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); 
     15345            CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 
     15346                "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", 
     15347                GetGUIDLow(), 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)); 
    1537715348        } 
    1537815349    } 
     
    1794017911            continue; 
    1794117912 
    17942         if (sSpellStore.LookupEntry(pAbility->spellId)) 
     17913        if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) 
    1794317914        { 
    1794417915            // Ok need learn spell 
     
    1835318324        Player* not_gray_member_with_max_level = NULL; 
    1835418325 
     18326        // gets the max member level of the group, and the max member level that still gets XP 
    1835518327        pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 
    1835618328 
     
    1836118333            xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 
    1836218334 
    18363             /// skip in check PvP case (for speed, not used) 
     18335            // skip in check PvP case (for speed, not used) 
    1836418336            bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 
    1836518337            bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); 
     
    1868818660    UpdateBlockPercentage(); 
    1868918661} 
    18690  
    18691 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 
    18692 { 
    18693     for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) 
    18694         if(itr->pos == pos) 
    18695             return true; 
    18696     return false; 
    18697 } 
    18698  
    18699 //*********************************** 
    18700 //-------------TRINITY--------------- 
    18701 //*********************************** 
    1870218662 
    1870318663void Player::HandleFallDamage(MovementInfo& movementInfo) 
     
    1893718897                target->AddThreat(this, 1000000.0f); 
    1893818898        } 
    18939         // Delete the assigned possessed AI 
    18940         ((Creature*)target)->DeletePossessedAI(); 
     18899        // Disable the assigned possessed AI 
     18900        ((Creature*)target)->DisablePossessedAI(); 
    1894118901    } 
    1894218902} 
     
    1900218962} 
    1900318963 
     18964bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 
     18965{ 
     18966    for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) 
     18967        if(itr->pos == this->pos) 
     18968            return true; 
     18969 
     18970    return false; 
     18971} 
     18972 
    1900418973bool Player::isTotalImmunity() 
    1900518974{