Changeset 272 for trunk/src/game/Player.cpp
- Timestamp:
- 11/22/08 00:35:41 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Player.cpp
r257 r272 800 800 } 801 801 802 void Player::EnvironmentalDamage(uint64 guid, Enviro mentalDamage type, uint32 damage)802 void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage) 803 803 { 804 804 WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); … … 1642 1642 { 1643 1643 // far teleport to another map 1644 Map* oldmap = IsInWorld() ? GetMap() : NULL;1644 Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; 1645 1645 // check if we can enter before stopping combat / removing pet / totems / interrupting spells 1646 1646 … … 3751 3751 } 3752 3752 3753 void Player::ResurrectPlayer(float restore_percent, bool applySickness)3753 void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) 3754 3754 { 3755 3755 WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position … … 4282 4282 } 4283 4283 4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply )4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) 4285 4285 { 4286 4286 if(modGroup >= BASEMOD_END || modType >= MOD_END) … … 5244 5244 } 5245 5245 5246 Map *m = GetMap();5246 Map *m = MapManager::Instance().GetMap(GetMapId(), this); 5247 5247 5248 5248 const float old_x = GetPositionX(); … … 5262 5262 5263 5263 // reread after Map::Relocation 5264 m = GetMap();5264 m = MapManager::Instance().GetMap(GetMapId(), this); 5265 5265 x = GetPositionX(); 5266 5266 y = GetPositionY(); … … 6177 6177 return 0; 6178 6178 6179 uint32 id = (*result)[0].GetUInt32(); 6180 delete result; 6181 return id; 6179 return (*result)[0].GetUInt32(); 6182 6180 } 6183 6181 … … 6710 6708 } 6711 6709 6712 if(!IsUseEquip edWeapon(slot==EQUIPMENT_SLOT_MAINHAND))6710 if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 6713 6711 return; 6714 6712 … … 8488 8486 return item; 8489 8487 8490 if( item->IsBroken() || !IsUseEquip edWeapon(attackType==BASE_ATTACK) )8488 if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) ) 8491 8489 return NULL; 8492 8490 … … 8642 8640 return false; 8643 8641 } 8644 8645 8642 8646 8643 bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const … … 10159 10156 if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10160 10157 pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 10161 pItem->GetProto()->Bonding == BIND_WHEN_EQUIP ED && IsBagPos(pos) )10158 pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 10162 10159 pItem->SetBinding( true ); 10163 10160 … … 10205 10202 if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10206 10203 pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 10207 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIP ED && IsBagPos(pos) )10204 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 10208 10205 pItem2->SetBinding( true ); 10209 10206 … … 10407 10404 10408 10405 // 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_EQUIP ED || 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 ) 10410 10407 pItem->SetBinding( true ); 10411 10408 … … 10551 10548 if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 10552 10549 CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 10550 10551 ItemPrototype const *pProto = pItem->GetProto(); 10553 10552 10554 10553 RemoveEnchantmentDurations(pItem); … … 14209 14208 SetUInt32Value(i, 0); 14210 14209 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()); 14212 14211 14213 14212 if(result) … … 14219 14218 uint32 spellid = fields[1].GetUInt32(); 14220 14219 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(); 14226 14224 14227 14225 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 14260 14258 continue; 14261 14259 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); 14271 14265 } 14272 14266 while( result->NextRow() ); … … 15327 15321 15328 15322 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) 15368 15340 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)); 15377 15348 } 15378 15349 } … … 17940 17911 continue; 17941 17912 17942 if ( sSpellStore.LookupEntry(pAbility->spellId))17913 if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) 17943 17914 { 17944 17915 // Ok need learn spell … … 18353 18324 Player* not_gray_member_with_max_level = NULL; 18354 18325 18326 // gets the max member level of the group, and the max member level that still gets XP 18355 18327 pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 18356 18328 … … 18361 18333 xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 18362 18334 18363 // /skip in check PvP case (for speed, not used)18335 // skip in check PvP case (for speed, not used) 18364 18336 bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 18365 18337 bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); … … 18688 18660 UpdateBlockPercentage(); 18689 18661 } 18690 18691 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const18692 {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 //***********************************18702 18662 18703 18663 void Player::HandleFallDamage(MovementInfo& movementInfo) … … 18937 18897 target->AddThreat(this, 1000000.0f); 18938 18898 } 18939 // D elete the assigned possessed AI18940 ((Creature*)target)->D eletePossessedAI();18899 // Disable the assigned possessed AI 18900 ((Creature*)target)->DisablePossessedAI(); 18941 18901 } 18942 18902 } … … 19002 18962 } 19003 18963 18964 bool 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 19004 18973 bool Player::isTotalImmunity() 19005 18974 {