Changeset 257
- Timestamp:
- 11/19/08 13:51:33 (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 38 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bindings/scripts/include/sc_creature.cpp
r229 r257 680 680 } 681 681 682 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 683 InstanceMap::PlayerList::const_iterator i; 684 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 685 { 686 if((*i)->isAlive()) 687 pUnit->AddThreat(*i, 0.0f); 688 } 682 Map::PlayerList const &PlayerList = map->GetPlayers(); 683 for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 684 if (Player* i_pl = i->getSource()) 685 if (!i_pl->isAlive()) 686 pUnit->AddThreat(i_pl, 0.0f); 689 687 } 690 688 … … 721 719 ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 722 720 } 721 722 void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) 723 { 724 Map *map = m_creature->GetMap(); 725 if (!map->IsDungeon()) 726 return; 727 728 Map::PlayerList const &PlayerList = map->GetPlayers(); 729 for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 730 if (Player* i_pl = i->getSource()) 731 if (!i_pl->isAlive()) 732 i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 733 } 734 723 735 724 736 Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) -
trunk/src/bindings/scripts/include/sc_creature.h
r203 r257 147 147 //Teleports a player without dropping threat (only teleports to same map) 148 148 void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); 149 void DoTeleportAll(float x, float y, float z, float o); 149 150 150 151 //Returns friendly unit with the most amount of hp missing from max hp -
trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
r229 r257 221 221 if ( DrawnShadows_Timer < diff) 222 222 { 223 Map *map = m_creature->GetMap(); 224 if(map->IsDungeon()) 225 { 226 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 227 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 228 { 229 if((*i)->isAlive()) 230 { 231 (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 232 } 233 } 234 } 223 DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 235 224 m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 236 225 DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); -
trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
r229 r257 251 251 //remove old tainted cores to prevent cheating in phase 2 252 252 Map *map = m_creature->GetMap(); 253 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();254 for( InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)255 { 256 if( (*i))253 Map::PlayerList const &PlayerList = map->GetPlayers(); 254 for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 255 { 256 if(Player* i_pl = i->getSource()) 257 257 { 258 (*i)->DestroyItemCount(31088, 1, true);258 i_pl->DestroyItemCount(31088, 1, true); 259 259 } 260 260 } -
trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
r229 r257 755 755 { 756 756 Map *map = m_creature->GetMap(); 757 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();758 for( InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)757 Map::PlayerList const &PlayerList = map->GetPlayers(); 758 for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) 759 759 { 760 bool isCasting = false; 761 for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 762 if((*itr)->m_currentSpells[i]) 763 isCasting = true; 764 765 if(isCasting) 766 { 767 DoCast((*itr), SPELL_EARTHSHOCK); 768 break; 769 } 760 if (Player* i_pl = itr->getSource()) 761 { 762 bool isCasting = false; 763 for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 764 if(i_pl->m_currentSpells[i]) 765 isCasting = true; 766 767 if(isCasting) 768 { 769 DoCast(i_pl, SPELL_EARTHSHOCK); 770 break; 771 } 772 } 770 773 } 771 774 Earthshock_Timer = 8000 + rand()%7000; -
trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
r141 r257 119 119 void SetData(uint32 type, uint32 data) 120 120 { 121 Player *player = GetPlayer();122 if(!player) return;123 124 121 switch(type) 125 122 { … … 130 127 if(data != IN_PROGRESS) 131 128 { 132 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))129 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 133 130 Door->SetGoState(0); 134 131 } … … 143 140 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 144 141 { 145 if(Creature *Channeler = (Creature*)Unit::GetUnit(*player,*i))142 if(Creature *Channeler = instance->GetCreatureInMap(*i)) 146 143 { 147 144 if(Channeler->isAlive()) … … 152 149 } 153 150 CageTimer = 0; 154 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))151 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 155 152 Door->SetGoState(0); 156 153 }break; … … 162 159 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 163 160 { 164 Creature *Channeler = (Creature*)Unit::GetUnit(*player,*i);161 Creature *Channeler = instance->GetCreatureInMap(*i); 165 162 if(Channeler && Channeler->isAlive()) 166 163 { … … 171 168 } 172 169 // Release Magtheridon after two minutes. 173 Creature *Magtheridon = (Creature*)Unit::GetUnit(*player,MagtheridonGUID);170 Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 174 171 if(Magtheridon && Magtheridon->isAlive()) 175 172 { … … 177 174 CageTimer = 120000; 178 175 } 179 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))176 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 180 177 Door->SetGoState(1); 181 178 }break; … … 183 180 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 184 181 { 185 Unit *Channeler = Unit::GetUnit(*player,*i);182 Creature *Channeler = instance->GetCreatureInMap(*i); 186 183 if(Channeler && Channeler->isAlive()) 187 184 { … … 198 195 for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i) 199 196 { 200 if(GameObject *Column = GameObject::GetGameObject(*player,*i))197 if(GameObject *Column = instance->GetGameObjectInMap(*i)) 201 198 Column->SetGoState(!data); 202 199 } … … 214 211 } 215 212 216 Player* GetPlayer()217 {218 if(((InstanceMap*)instance)->GetPlayers().size())219 return ((InstanceMap*)instance)->GetPlayers().front();220 return NULL;221 }222 223 213 void AttackNearestTarget(Creature *creature) 224 214 { … … 226 216 float range; 227 217 Player* target = NULL; 228 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers();229 InstanceMap::PlayerList::const_iterator i;218 Map::PlayerList const &PlayerList = instance->GetPlayers(); 219 Map::PlayerList::const_iterator i; 230 220 for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 231 221 { 232 if((*i)->isTargetableForAttack()) 233 { 234 range = (*i)->GetDistance(creature); 235 if(range < minRange) 236 { 237 minRange = range; 238 target = *i; 239 } 222 if(Player* i_pl = i->getSource()) 223 { 224 if(i_pl->isTargetableForAttack()) 225 { 226 range = i_pl->GetDistance(creature); 227 if(range < minRange) 228 { 229 minRange = range; 230 target = i_pl; 231 } 232 } 240 233 } 241 234 } … … 249 242 if(CageTimer <= diff) 250 243 { 251 if(Player *player = GetPlayer()) 252 { 253 Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); 254 if(Magtheridon && Magtheridon->isAlive()) 255 { 256 Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 257 AttackNearestTarget(Magtheridon); 258 } 244 Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 245 if(Magtheridon && Magtheridon->isAlive()) 246 { 247 Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 248 AttackNearestTarget(Magtheridon); 259 249 } 260 250 CageTimer = 0; … … 266 256 if(RespawnTimer <= diff) 267 257 { 268 if(Player *player = GetPlayer()) 269 { 270 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 271 { 272 if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) 273 { 274 if(Channeler->isAlive()) 275 Channeler->AI()->EnterEvadeMode(); 276 else 277 Channeler->Respawn(); 278 } 258 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 259 { 260 if(Creature *Channeler = instance->GetCreatureInMap(*i)) 261 { 262 if(Channeler->isAlive()) 263 Channeler->AI()->EnterEvadeMode(); 264 else 265 Channeler->Respawn(); 279 266 } 280 267 } -
trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp
r90 r257 286 286 if(!map->IsDungeon()) return; 287 287 288 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();289 if(PlayerList. empty())288 Map::PlayerList const &PlayerList = map->GetPlayers(); 289 if(PlayerList.isEmpty()) 290 290 return; 291 291 292 292 RaidWiped = true; 293 for( InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)293 for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 294 294 { 295 if ((*i)->isAlive() && !(*i)->isGameMaster())295 if (i->getSource()->isAlive() && !i->getSource()->isGameMaster()) 296 296 { 297 297 RaidWiped = false; -
trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
r137 r257 232 232 m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0); 233 233 Map *map = m_creature->GetMap(); 234 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();235 InstanceMap::PlayerList::const_iterator i;234 Map::PlayerList const &PlayerList = map->GetPlayers(); 235 Map::PlayerList::const_iterator i; 236 236 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 237 237 { 238 //if(!(*i)->isGameMaster())239 if((*i) && (*i)->isAlive())240 {241 (*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true);242 m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);243 (*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation());244 }238 if (Player* i_pl = i->getSource()) 239 if(i_pl->isAlive()) 240 { 241 i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true); 242 m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); 243 i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation()); 244 } 245 245 } 246 246 DoCast(m_creature, SPELL_TELEPORT_CENTER, true); … … 250 250 { 251 251 Map *map = m_creature->GetMap(); 252 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();253 InstanceMap::PlayerList::const_iterator i;252 Map::PlayerList const &PlayerList = map->GetPlayers(); 253 Map::PlayerList::const_iterator i; 254 254 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 255 { 256 if((*i) && (*i)->isAlive()) 255 { 256 if (Player* i_pl = i->getSource()) 257 if(i_pl->isAlive()) 257 258 // Knockback into the air 258 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());259 i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); 259 260 } 260 261 } … … 263 264 { 264 265 Map *map = m_creature->GetMap(); 265 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 266 InstanceMap::PlayerList::const_iterator i; 266 Map::PlayerList const &PlayerList = map->GetPlayers(); 267 Map::PlayerList::const_iterator i; 268 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 269 { 270 if (Player* i_pl = i->getSource()) 271 { 272 if(i_pl->isAlive()) 273 { 274 // Also needs an exception in spell system. 275 i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 276 // Use packet hack 277 WorldPacket data(12); 278 data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 279 data.append(i_pl->GetPackGUID()); 280 data << uint32(0); 281 i_pl->SendMessageToSet(&data, true); 282 i_pl->SetSpeed(MOVE_FLY, 2.0f); 283 } 284 } 285 } 286 } 287 288 void RemoveGravityLapse() 289 { 290 Map *map = m_creature->GetMap(); 291 Map::PlayerList const &PlayerList = map->GetPlayers(); 292 Map::PlayerList::const_iterator i; 267 293 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 268 294 { 269 if((*i) && (*i)->isAlive())295 if(Player* i_pl = i->getSource()) 270 296 { 271 // Also needs an exception in spell system. 272 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 273 // Use packet hack 274 WorldPacket data(12); 275 data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 276 data.append((*i)->GetPackGUID()); 277 data << uint32(0); 278 (*i)->SendMessageToSet(&data, true); 279 (*i)->SetSpeed(MOVE_FLY, 2.0f); 280 } 281 } 282 } 283 284 void RemoveGravityLapse() 285 { 286 Map *map = m_creature->GetMap(); 287 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 288 InstanceMap::PlayerList::const_iterator i; 289 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 290 { 291 if((*i)) 292 { 293 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 294 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 297 i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 298 i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 295 299 WorldPacket data(12); 296 300 data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); 297 data.append( (*i)->GetPackGUID());301 data.append(i_pl->GetPackGUID()); 298 302 data << uint32(0); 299 (*i)->SendMessageToSet(&data, true);303 i_pl->SendMessageToSet(&data, true); 300 304 } 301 305 } -
trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp
r122 r257 296 296 break; 297 297 case 2: 298 if( Player* target = SelectRandomPlayer(150))298 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 299 299 { 300 300 Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); … … 312 312 DespawnSummons(MOB_VAPOR_TRAIL); 313 313 //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support 314 if( Player* target = SelectRandomPlayer(150))314 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 315 315 { 316 316 //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support … … 331 331 break; 332 332 case 5: 333 if( Player* target = SelectRandomPlayer(150))333 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 334 334 { 335 335 BreathX = target->GetPositionX(); … … 434 434 break; 435 435 case EVENT_ENCAPSULATE: 436 if(Unit* target = Select RandomPlayer(150))436 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 437 437 { 438 438 m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false); … … 516 516 } 517 517 } 518 519 Player* SelectRandomPlayer(float range = 0.0f)520 {521 Map *map = m_creature->GetMap();522 if (!map->IsDungeon()) return NULL;523 524 InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();525 InstanceMap::PlayerList::iterator i;526 while(PlayerList.size())527 {528 i = PlayerList.begin();529 advance(i, rand()%PlayerList.size());530 if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))531 && (*i)->isTargetableForAttack())532 return *i;533 else534 PlayerList.erase(i);535 }536 return NULL;537 }538 518 }; 539 519 -
trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp
r239 r257 369 369 Map *map = m_creature->GetMap(); 370 370 if(!map->IsDungeon()) return; 371 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 372 InstanceMap::PlayerList::const_iterator i; 373 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 374 { 375 if((*i)->HasAura(AURA_SPECTRAL_REALM,0)) 376 (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 377 } 371 Map::PlayerList const &PlayerList = map->GetPlayers(); 372 Map::PlayerList::const_iterator i; 373 for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 374 if(Player* i_pl = i->getSource()) 375 if(i_pl->HasAura(AURA_SPECTRAL_REALM,0)) 376 i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 378 377 } 379 378 -
trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp
r206 r257 578 578 if(!map->IsDungeon()) return; 579 579 580 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 581 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 582 { 583 //Play random sound to the zone 584 switch (rand()%8) 580 Map::PlayerList const &PlayerList = map->GetPlayers(); 581 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 582 { 583 if (Player* i_pl = i->getSource()) 585 584 { 586 case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break; 587 case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break; 588 case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break; 589 case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break; 590 case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break; 591 case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break; 592 case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break; 593 case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break; 585 //Play random sound to the zone 586 switch (rand()%8) 587 { 588 case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break; 589 case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break; 590 case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break; 591 case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break; 592 case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break; 593 case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break; 594 case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break; 595 case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break; 596 } 594 597 } 595 598 } -
trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp
r202 r257 372 372 if(SiphonSoul_Timer < diff) 373 373 { 374 Player* target = SelectRandomPlayer(50);374 Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true); 375 375 Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); 376 376 if(!target || !trigger) EnterEvadeMode(); … … 436 436 m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false); 437 437 } 438 439 Player* SelectRandomPlayer(float range = 0.0f, bool alive = true)440 {441 Map *map = m_creature->GetMap();442 if (!map->IsDungeon()) return NULL;443 444 InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();445 InstanceMap::PlayerList::iterator i;446 while(PlayerList.size())447 {448 i = PlayerList.begin();449 advance(i, rand()%PlayerList.size());450 if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))451 && (!alive || (*i)->isAlive()))452 return *i;453 else454 PlayerList.erase(i);455 }456 return NULL;457 }458 438 }; 459 439 -
trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp
r90 r257 398 398 Map *map = m_creature->GetMap(); 399 399 if(!map->IsDungeon()) return; 400 InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers(); 401 for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 402 { 403 if((*i)->isAlive()) 404 DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 400 Map::PlayerList const &PlayerList = map->GetPlayers(); 401 for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 402 { 403 if (Player* i_pl = i->getSource()) 404 if(i_pl->isAlive()) 405 DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 405 406 } 406 407 //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far -
trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
r90 r257 140 140 void OpenDoor(uint64 DoorGUID, bool open) 141 141 { 142 if(((InstanceMap*)instance)->GetPlayers().size()) 143 if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 144 if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID)) 145 Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 142 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 143 Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 146 144 } 147 145 148 146 void SummonHostage(uint8 num) 149 147 { 150 if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size()) 151 if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 152 if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 153 { 154 Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 155 Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 156 } 148 if(!QuestMinute) 149 return; 150 151 Map::PlayerList const &PlayerList = instance->GetPlayers(); 152 if (PlayerList.isEmpty()) 153 return; 154 155 Map::PlayerList::const_iterator i = PlayerList.begin(); 156 if(Player* i_pl = i->getSource()) 157 { 158 if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 159 { 160 Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 161 Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 162 } 163 } 157 164 } 158 165 -
trunk/src/framework/Utilities/LinkedReference/RefManager.h
r102 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 34 34 35 35 Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); } 36 Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); } 36 37 Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); } 38 Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); } 37 39 38 40 iterator begin() { return iterator(getFirst()); } -
trunk/src/framework/Utilities/LinkedReference/Reference.h
r102 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 75 75 76 76 Reference<TO,FROM>* next() { return((Reference<TO,FROM>*)LinkedListElement::next()); } 77 Reference<TO,FROM>const* next() const { return((Reference<TO,FROM> const*)LinkedListElement::next()); } 77 78 Reference<TO,FROM>* prev() { return((Reference<TO,FROM>*)LinkedListElement::prev()); } 78 79 -
trunk/src/game/BattleGround.h
r102 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 96 96 RESPAWN_ONE_DAY = 86400, // secs 97 97 RESPAWN_IMMEDIATELY = 0, // secs 98 BUFF_RESPAWN_TIME = 180 // secs 98 BUFF_RESPAWN_TIME = 180, // secs 99 BG_HONOR_SCORE_TICKS = 330 // points 99 100 }; 100 101 … … 434 435 435 436 virtual void AddPlayer(Player *plr); // must be implemented in BG subclass 436 437 437 virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); 438 438 // can be extended in in BG subclass -
trunk/src/game/ItemPrototype.h
r230 r257 79 79 NO_BIND = 0, 80 80 BIND_WHEN_PICKED_UP = 1, 81 BIND_WHEN_EQUIP PED = 2,81 BIND_WHEN_EQUIPED = 2, 82 82 BIND_WHEN_USE = 3, 83 83 BIND_QUEST_ITEM = 4, -
trunk/src/game/Map.cpp
r233 r257 36 36 #include "ScriptCalls.h" 37 37 #include "Group.h" 38 #include "MapRefManager.h" 38 39 39 40 #include "MapInstanced.h" … … 450 451 bool Map::Add(Player *player) 451 452 { 453 player->GetMapRef().link(this, player); 454 452 455 player->SetInstanceId(GetInstanceId()); 453 456 … … 594 597 void Map::Update(const uint32 &t_diff) 595 598 { 599 resetMarkedCells(); 600 601 Trinity::ObjectUpdater updater(t_diff); 602 // for creature 603 TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater); 604 // for pets 605 TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); 606 607 for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 608 { 609 Player* plr = iter->getSource(); 610 if(!plr->IsInWorld()) 611 continue; 612 613 CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY())); 614 615 // Check for correctness of standing_cell, it also avoids problems with update_cell 616 if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 617 continue; 618 619 // the overloaded operators handle range checking 620 // so ther's no need for range checking inside the loop 621 CellPair begin_cell(standing_cell), end_cell(standing_cell); 622 begin_cell << 1; begin_cell -= 1; // upper left 623 end_cell >> 1; end_cell += 1; // lower right 624 625 for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) 626 { 627 for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) 628 { 629 // marked cells are those that have been visited 630 // don't visit the same cell twice 631 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; 632 if(!isCellMarked(cell_id)) 633 { 634 markCell(cell_id); 635 CellPair pair(x,y); 636 Cell cell(pair); 637 cell.data.Part.reserved = CENTER_DISTRICT; 638 cell.SetNoCreate(); 639 CellLock<NullGuard> cell_lock(cell, pair); 640 cell_lock->Visit(cell_lock, grid_object_update, *this); 641 cell_lock->Visit(cell_lock, world_object_update, *this); 642 } 643 } 644 } 645 } 646 647 596 648 // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! 597 649 // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended … … 611 663 void Map::Remove(Player *player, bool remove) 612 664 { 665 player->GetMapRef().unlink(); 613 666 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 614 667 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) … … 910 963 911 964 { 912 if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) )965 if(!pForce && PlayersNearGrid(x, y) ) 913 966 return false; 914 967 … … 1419 1472 } 1420 1473 1474 uint32 Map::GetPlayersCountExceptGMs() const 1475 { 1476 uint32 count = 0; 1477 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1478 if(!itr->getSource()->isGameMaster()) 1479 ++count; 1480 return count; 1481 } 1482 1483 void Map::SendToPlayers(WorldPacket const* data) const 1484 { 1485 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1486 itr->getSource()->GetSession()->SendPacket(data); 1487 } 1488 1489 bool Map::PlayersNearGrid(uint32 x, uint32 y) const 1490 { 1491 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); 1492 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); 1493 cell_min << 2; 1494 cell_min -= 2; 1495 cell_max >> 2; 1496 cell_max += 2; 1497 1498 for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 1499 { 1500 Player* plr = iter->getSource(); 1501 1502 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); 1503 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 1504 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 1505 return true; 1506 } 1507 1508 return false; 1509 } 1510 1421 1511 template void Map::Add(Corpse *); 1422 1512 template void Map::Add(Creature *); … … 1454 1544 bool InstanceMap::CanEnter(Player *player) 1455 1545 { 1456 if( std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())1546 if(player->GetMapRef().getTarget() == this) 1457 1547 { 1458 1548 sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); … … 1571 1661 SetResetSchedule(false); 1572 1662 1573 i_Players.push_back(player);1574 1663 player->SendInitWorldStates(); 1575 1664 sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); … … 1596 1685 { 1597 1686 sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 1598 i_Players.remove(player);1599 1687 SetResetSchedule(true); 1600 if(!m_unloadTimer && i_Players.empty()) 1688 //if last player set unload timer 1689 if(!m_unloadTimer && m_mapRefManager.getSize() == 1) 1601 1690 m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); 1602 1691 Map::Remove(player, remove); … … 1663 1752 // the instance must be deleted from the DB by InstanceSaveManager 1664 1753 1665 if( !i_Players.empty())1754 if(HavePlayers()) 1666 1755 { 1667 1756 if(method == INSTANCE_RESET_ALL) 1668 1757 { 1669 1758 // notify the players to leave the instance so it can be reset 1670 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1671 (*itr)->SendResetFailedNotify(GetId());1759 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1760 itr->getSource()->SendResetFailedNotify(GetId()); 1672 1761 } 1673 1762 else … … 1676 1765 { 1677 1766 // set the homebind timer for players inside (1 minute) 1678 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1679 (*itr)->m_InstanceValid = false;1767 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1768 itr->getSource()->m_InstanceValid = false; 1680 1769 } 1681 1770 … … 1693 1782 } 1694 1783 1695 return i_Players.empty(); 1696 } 1697 1698 uint32 InstanceMap::GetPlayersCountExceptGMs() const 1699 { 1700 uint32 count = 0; 1701 for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1702 if(!(*itr)->isGameMaster()) 1703 ++count; 1704 return count; 1784 return m_mapRefManager.isEmpty(); 1705 1785 } 1706 1786 … … 1716 1796 Group *group = player->GetGroup(); 1717 1797 // group members outside the instance group don't get bound 1718 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1719 { 1720 if(*itr) 1721 { 1722 // players inside an instance cannot be bound to other instances 1723 // some players may already be permanently bound, in this case nothing happens 1724 InstancePlayerBind *bind = (*itr)->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 1725 if(!bind || !bind->perm) 1726 { 1727 (*itr)->BindToInstance(save, true); 1728 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 1729 data << uint32(0); 1730 (*itr)->GetSession()->SendPacket(&data); 1731 } 1732 1733 // if the leader is not in the instance the group will not get a perm bind 1734 if(group && group->GetLeaderGUID() == (*itr)->GetGUID()) 1735 group->BindToInstance(save, true); 1736 } 1798 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1799 { 1800 Player* plr = itr->getSource(); 1801 // players inside an instance cannot be bound to other instances 1802 // some players may already be permanently bound, in this case nothing happens 1803 InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 1804 if(!bind || !bind->perm) 1805 { 1806 plr->BindToInstance(save, true); 1807 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 1808 data << uint32(0); 1809 plr->GetSession()->SendPacket(&data); 1810 } 1811 1812 // if the leader is not in the instance the group will not get a perm bind 1813 if(group && group->GetLeaderGUID() == plr->GetGUID()) 1814 group->BindToInstance(save, true); 1737 1815 } 1738 1816 } … … 1746 1824 void InstanceMap::UnloadAll(bool pForce) 1747 1825 { 1748 if( !i_Players.empty())1826 if(HavePlayers()) 1749 1827 { 1750 1828 sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!"); 1751 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1752 if(*itr) (*itr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 1829 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1830 { 1831 Player* plr = itr->getSource(); 1832 plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 1833 } 1753 1834 } 1754 1835 … … 1759 1840 } 1760 1841 1761 void InstanceMap::SendResetWarnings(uint32 timeLeft) 1762 { 1763 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1764 (*itr)->SendInstanceResetWarning(GetId(), timeLeft);1842 void InstanceMap::SendResetWarnings(uint32 timeLeft) const 1843 { 1844 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1845 itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft); 1765 1846 } 1766 1847 … … 1770 1851 // the reset time is only scheduled when there are no payers inside 1771 1852 // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled 1772 if( i_Players.empty() && !IsRaid() && !IsHeroic())1853 if(!HavePlayers() && !IsRaid() && !IsHeroic()) 1773 1854 { 1774 1855 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); … … 1778 1859 } 1779 1860 1780 void InstanceMap::SendToPlayers(WorldPacket const* data) const1781 {1782 for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1783 (*itr)->GetSession()->SendPacket(data);1784 }1785 1786 1861 /* ******* Battleground Instance Maps ******* */ 1787 1862 … … 1797 1872 bool BattleGroundMap::CanEnter(Player * player) 1798 1873 { 1799 if( std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())1874 if(player->GetMapRef().getTarget() == this) 1800 1875 { 1801 1876 sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); … … 1818 1893 if(!CanEnter(player)) 1819 1894 return false; 1820 i_Players.push_back(player);1821 1895 // reset instance validity, battleground maps do not homebind 1822 1896 player->m_InstanceValid = true; … … 1828 1902 { 1829 1903 sLog.outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 1830 i_Players.remove(player);1831 1904 Map::Remove(player, remove); 1832 1905 } … … 1839 1912 void BattleGroundMap::UnloadAll(bool pForce) 1840 1913 { 1841 while(!i_Players.empty()) 1842 { 1843 PlayerList::iterator itr = i_Players.begin(); 1844 Player * plr = *itr; 1845 if(plr) (plr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 1914 while(HavePlayers()) 1915 { 1916 Player * plr = m_mapRefManager.getFirst()->getSource(); 1917 if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 1846 1918 // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. 1847 1919 // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop 1848 1920 // note that this remove is not needed if the code works well in other places 1849 i_Players.remove(plr);1921 plr->GetMapRef().unlink(); 1850 1922 } 1851 1923 -
trunk/src/game/Map.h
r206 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 34 34 #include "SharedDefines.h" 35 35 #include "GameSystem/GridRefManager.h" 36 #include "MapRefManager.h" 36 37 37 38 #include <bitset> … … 127 128 class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex> 128 129 { 130 friend class MapReference; 129 131 public: 130 132 Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); … … 238 240 GameObject* GetGameObjectInMap(uint64 guid); 239 241 242 bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } 243 uint32 GetPlayersCountExceptGMs() const; 244 bool PlayersNearGrid(uint32 x,uint32 y) const; 245 246 void SendToPlayers(WorldPacket const* data) const; 247 248 typedef MapRefManager PlayerList; 249 PlayerList const& GetPlayers() const { return m_mapRefManager; } 240 250 template<class T> void SwitchGridContainers(T* obj, bool active); 241 251 private: … … 287 297 uint32 m_unloadTimer; 288 298 299 MapRefManager m_mapRefManager; 289 300 private: 290 301 typedef GridReadGuard ReadGuard; … … 326 337 { 327 338 public: 328 typedef std::list<Player *> PlayerList; // online players only329 330 339 InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); 331 340 ~InstanceMap(); … … 338 347 InstanceData* GetInstanceData() { return i_data; } 339 348 void PermBindAllPlayers(Player *player); 340 PlayerList const& GetPlayers() const { return i_Players;}341 void SendToPlayers(WorldPacket const* data) const;342 349 time_t GetResetTime(); 343 350 void UnloadAll(bool pForce); 344 351 bool CanEnter(Player* player); 345 uint32 GetPlayersCountExceptGMs() const; 346 uint32 HavePlayers() const { return !i_Players.empty(); } 347 void SendResetWarnings(uint32 timeLeft); 352 void SendResetWarnings(uint32 timeLeft) const; 348 353 void SetResetSchedule(bool on); 349 354 private: … … 360 365 { 361 366 public: 362 typedef std::list<Player *> PlayerList; // online players only363 364 367 BattleGroundMap(uint32 id, time_t, uint32 InstanceId); 365 368 ~BattleGroundMap(); … … 370 373 void SetUnload(); 371 374 void UnloadAll(bool pForce); 372 private:373 PlayerList i_Players;374 375 }; 375 376 -
trunk/src/game/MapInstanced.cpp
r102 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 27 27 #include "World.h" 28 28 29 MapInstanced::MapInstanced(uint32 id, time_t expiry , uint32 aInstanceId) : Map(id, expiry, 0, 0)29 MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0) 30 30 { 31 31 // initialize instanced maps list … … 262 262 m_InstancedMaps.erase(itr++); 263 263 } 264 -
trunk/src/game/MapInstanced.h
r206 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 31 31 typedef UNORDERED_MAP< uint32, Map* > InstancedMaps; 32 32 33 MapInstanced(uint32 id, time_t , uint32 aInstanceId);33 MapInstanced(uint32 id, time_t expiry); 34 34 ~MapInstanced() {} 35 35 -
trunk/src/game/MapManager.cpp
r132 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 112 112 if (entry && entry->Instanceable()) 113 113 { 114 m = new MapInstanced(id, i_gridCleanUpDelay , 0);114 m = new MapInstanced(id, i_gridCleanUpDelay); 115 115 } 116 116 else … … 247 247 return; 248 248 249 ObjectAccessor::Instance().UpdatePlayers(i_timer.GetCurrent()); 250 249 251 for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) 250 252 { … … 337 339 for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) 338 340 if(mitr->second->IsDungeon()) 339 ret += ((InstanceMap*)mitr->second)->GetPlayers(). size();341 ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize(); 340 342 } 341 343 return ret; -
trunk/src/game/NPCHandler.cpp
r230 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 223 223 TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); 224 224 if(!trainer_spells) 225 return; 225 return; 226 226 227 227 // not found, cheat? … … 340 340 if(!code.empty()) 341 341 { 342 343 342 if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str())) 344 343 unit->OnGossipSelect (_player, option); 345 344 } 346 345 else 347 348 346 { 349 347 if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) 350 348 unit->OnGossipSelect (_player, option); 351 349 } 352 350 } … … 378 376 void WorldSession::SendSpiritResurrect() 379 377 { 380 _player->ResurrectPlayer(0.5f, false,true);378 _player->ResurrectPlayer(0.5f, true); 381 379 382 380 _player->DurabilityLossAll(0.25f,true); -
trunk/src/game/ObjectAccessor.cpp
r237 r257 143 143 { 144 144 Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); 145 if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; 145 if(!ret) 146 return NULL; 147 148 if(ret->GetMapId() != u.GetMapId()) 149 return NULL; 150 151 if(ret->GetInstanceId() != u.GetInstanceId()) 152 return NULL; 153 146 154 return ret; 147 155 } … … 249 257 250 258 void 251 ObjectAccessor::_update()252 {253 UpdateDataMapType update_players;254 {255 Guard guard(i_updateGuard);256 while(!i_objects.empty())257 {258 Object* obj = *i_objects.begin();259 i_objects.erase(i_objects.begin());260 if (!obj)261 continue;262 _buildUpdateObject(obj, update_players);263 obj->ClearUpdateMask(false);264 }265 }266 267 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000268 for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)269 {270 iter->second.BuildPacket(&packet);271 iter->first->GetSession()->SendPacket(&packet);272 packet.clear(); // clean the string273 }274 }275 276 void277 259 ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 278 260 { … … 362 344 TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 363 345 CellLock<GridReadGuard> cell_lock(cell, p); 364 cell_lock->Visit(cell_lock, player_notifier, * MapManager::Instance().GetMap(obj->GetMapId(), obj));346 cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); 365 347 } 366 348 … … 520 502 ObjectAccessor::Update(uint32 diff) 521 503 { 504 522 505 { 523 506 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. … … 590 573 } 591 574 } 592 593 _update(); 575 } 576 577 void 578 ObjectAccessor::UpdatePlayers(uint32 diff) 579 { 580 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 581 for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 582 if(iter->second->IsInWorld()) 583 iter->second->Update(diff); 594 584 } 595 585 … … 678 668 Cell cell(p); 679 669 680 MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p);670 obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 681 671 } 682 672 … … 685 675 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 686 676 Cell cell(p); 687 Map* m = MapManager::Instance().GetMap(player->GetMapId(),player);677 Map* m = player->GetMap(); 688 678 689 679 m->UpdatePlayerVisibility(player,cell,p); -
trunk/src/game/ObjectAccessor.h
r233 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 187 187 188 188 void Update(uint32 diff); 189 void UpdatePlayers(uint32 diff); 189 190 190 191 Corpse* GetCorpseForPlayerGUID(uint64 guid); -
trunk/src/game/Player.cpp
r233 r257 800 800 } 801 801 802 void Player::EnvironmentalDamage(uint64 guid, Enviro nmentalDamageType type, uint32 damage)802 void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage 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() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL;1644 Map* oldmap = IsInWorld() ? GetMap() : 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 updateToWorld, boolapplySickness)3753 void Player::ResurrectPlayer(float restore_percent, 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 , bool affectStats)4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) 4285 4285 { 4286 4286 if(modGroup >= BASEMOD_END || modType >= MOD_END) … … 5244 5244 } 5245 5245 5246 Map *m = MapManager::Instance().GetMap(GetMapId(), this);5246 Map *m = GetMap(); 5247 5247 5248 5248 const float old_x = GetPositionX(); … … 5262 5262 5263 5263 // reread after Map::Relocation 5264 m = MapManager::Instance().GetMap(GetMapId(), this);5264 m = GetMap(); 5265 5265 x = GetPositionX(); 5266 5266 y = GetPositionY(); … … 6177 6177 return 0; 6178 6178 6179 return (*result)[0].GetUInt32(); 6179 uint32 id = (*result)[0].GetUInt32(); 6180 delete result; 6181 return id; 6180 6182 } 6181 6183 … … 6708 6710 } 6709 6711 6710 if(!IsUseEquip pedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))6712 if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 6711 6713 return; 6712 6714 … … 8486 8488 return item; 8487 8489 8488 if( item->IsBroken() || !IsUseEquip pedWeapon(attackType==BASE_ATTACK) )8490 if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) 8489 8491 return NULL; 8490 8492 … … 8640 8642 return false; 8641 8643 } 8644 8642 8645 8643 8646 bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const … … 10156 10159 if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10157 10160 pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 10158 pItem->GetProto()->Bonding == BIND_WHEN_EQUIP PED && IsBagPos(pos) )10161 pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 10159 10162 pItem->SetBinding( true ); 10160 10163 … … 10202 10205 if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10203 10206 pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 10204 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIP PED && IsBagPos(pos) )10207 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 10205 10208 pItem2->SetBinding( true ); 10206 10209 … … 10404 10407 10405 10408 // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) 10406 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIP PED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM )10409 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 10407 10410 pItem->SetBinding( true ); 10408 10411 … … 10548 10551 if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 10549 10552 CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 10550 10551 ItemPrototype const *pProto = pItem->GetProto();10552 10553 10553 10554 RemoveEnchantmentDurations(pItem); … … 14208 14209 SetUInt32Value(i, 0); 14209 14210 14210 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index, amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());14211 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 14211 14212 14212 14213 if(result) … … 14218 14219 uint32 spellid = fields[1].GetUInt32(); 14219 14220 uint32 effindex = fields[2].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(); 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(); 14224 14226 14225 14227 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 14258 14260 continue; 14259 14261 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); 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 } 14265 14271 } 14266 14272 while( result->NextRow() ); … … 15321 15327 15322 15328 AuraMap const& auras = GetAuras(); 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) 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()) 15340 15368 break; 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)); 15369 } 15370 15371 if (lastEffectPair == itr->first) 15372 stackCounter++; 15373 else 15374 { 15375 lastEffectPair = itr->first; 15376 stackCounter = 1; 15348 15377 } 15349 15378 } … … 17911 17940 continue; 17912 17941 17913 if ( SpellEntry const* spellentry =sSpellStore.LookupEntry(pAbility->spellId))17942 if (sSpellStore.LookupEntry(pAbility->spellId)) 17914 17943 { 17915 17944 // Ok need learn spell … … 18324 18353 Player* not_gray_member_with_max_level = NULL; 18325 18354 18326 // gets the max member level of the group, and the max member level that still gets XP18327 18355 pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 18328 18356 … … 18333 18361 xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 18334 18362 18335 // skip in check PvP case (for speed, not used)18363 /// skip in check PvP case (for speed, not used) 18336 18364 bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 18337 18365 bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); … … 18660 18688 UpdateBlockPercentage(); 18661 18689 } 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 //*********************************** 18662 18702 18663 18703 void Player::HandleFallDamage(MovementInfo& movementInfo) … … 18962 19002 } 18963 19003 18964 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const18965 {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 18973 19004 bool Player::isTotalImmunity() 18974 19005 { -
trunk/src/game/Player.h
r233 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 34 34 #include "WorldSession.h" 35 35 #include "Pet.h" 36 #include "MapReference.h" 36 37 #include "Util.h" // for Tokens typedef 37 38 … … 780 781 781 782 /// Type of environmental damages 782 enum Enviro nmentalDamageType783 enum EnviromentalDamage 783 784 { 784 785 DAMAGE_EXHAUSTED = 0, … … 1125 1126 uint32 GetArmorProficiency() const { return m_ArmorProficiency; } 1126 1127 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } 1127 bool IsUseEquip pedWeapon( bool mainhand ) const1128 bool IsUseEquipedWeapon( bool mainhand ) const 1128 1129 { 1129 1130 // disarm applied only to mainhand weapon … … 1307 1308 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); 1308 1309 else 1309 SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d? GetMoney() + d : MAX_MONEY_AMOUNT);1310 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); 1310 1311 1311 1312 // "At Gold Limit" … … 1429 1430 PlayerSpellMap const& GetSpellMap() const { return m_spells; } 1430 1431 PlayerSpellMap & GetSpellMap() { return m_spells; } 1431 ActionButtonList const& GetActionButtonList() const { return m_actionButtons; }1432 1432 1433 1433 void AddSpellMod(SpellModifier* mod, bool apply); … … 1519 1519 void SendUpdateToOutOfRangeGroupMembers(); 1520 1520 1521 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); }1522 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); }1521 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); } 1522 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); } 1523 1523 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } 1524 1524 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } … … 1533 1533 { 1534 1534 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); 1535 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID());1535 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID()); 1536 1536 } 1537 1537 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } … … 1609 1609 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); 1610 1610 1611 1611 //Low Level Packets 1612 1612 void PlaySound(uint32 Sound, bool OnlySelf); 1613 1613 //notifiers … … 1641 1641 void KillPlayer(); 1642 1642 uint32 GetResurrectionSpellId(); 1643 void ResurrectPlayer(float restore_percent, bool updateToWorld = true, boolapplySickness = false);1643 void ResurrectPlayer(float restore_percent, bool applySickness = false); 1644 1644 void BuildPlayerRepop(); 1645 1645 void RepopAtGraveyard(); … … 1763 1763 void SetRegularAttackTime(); 1764 1764 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } 1765 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply , bool affectStats = true);1765 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply); 1766 1766 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; 1767 1767 float GetTotalBaseModValue(BaseModGroup modGroup) const; … … 1770 1770 void _RemoveAllStatBonuses(); 1771 1771 1772 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType,bool apply);1772 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); 1773 1773 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); 1774 1774 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); … … 1935 1935 1936 1936 /*********************************************************/ 1937 /*** ENVIRO NMENTAL SYSTEM ***/1938 /*********************************************************/ 1939 1940 void EnvironmentalDamage(uint64 guid, Enviro nmentalDamageType type, uint32 damage);1937 /*** ENVIROMENTAL SYSTEM ***/ 1938 /*********************************************************/ 1939 1940 void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); 1941 1941 1942 1942 /*********************************************************/ … … 2063 2063 2064 2064 GridReference<Player> &GetGridRef() { return m_gridRef; } 2065 MapReference &GetMapRef() { return m_mapRef; } 2066 2065 2067 bool isAllowedToLoot(Creature* creature); 2066 2068 … … 2308 2310 2309 2311 GridReference<Player> m_gridRef; 2312 MapReference m_mapRef; 2310 2313 }; 2311 2314 -
trunk/src/game/SpellAuras.cpp
r252 r257 171 171 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus 172 172 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus 173 &Aura::Handle AuraHealing, //115 SPELL_AURA_MOD_HEALING173 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim 174 174 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT 175 175 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult 176 &Aura::Handle AuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT176 &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus 177 177 &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless 178 178 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE … … 192 192 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT 193 193 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE 194 &Aura::Handle AuraHealingPct,//136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus194 &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus 195 195 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE 196 196 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE … … 221 221 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE 222 222 &Aura::HandleUnused, //164 useless, only one test spell 223 &Aura::Handle AuraAttackPowerAttacker,//165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus223 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus 224 224 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT 225 225 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT … … 2000 2000 } 2001 2001 2002 // Waiting to Resurrect 2003 if(GetId()==2584) 2004 { 2005 // Waiting to resurrect spell cancel, we must remove player from resurrect queue 2006 if(m_target->GetTypeId() == TYPEID_PLAYER) 2007 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) 2008 bg->RemovePlayerFromResurrectQueue(m_target->GetGUID()); 2009 return; 2010 } 2011 2002 2012 // Dark Fiend 2003 2013 if(GetId()==45934) … … 2295 2305 void Aura::HandleAuraMounted(bool apply, bool Real) 2296 2306 { 2307 // only at real add/remove aura 2308 if(!Real) 2309 return; 2310 2297 2311 if(apply) 2298 2312 { … … 2694 2708 else 2695 2709 { 2696 if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 2710 // Will use the default model here 2711 if (uint32 modelid = ci->GetRandomValidModelId()) 2712 m_target->SetDisplayId(modelid); 2697 2713 2698 2714 // Dragonmaw Illusion (set mount model also) … … 3590 3606 /*** MODIFY SPEED ***/ 3591 3607 /*********************************************************/ 3592 void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real)3608 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) 3593 3609 { 3594 3610 // all applied/removed only at real aura add/remove … … 3599 3615 } 3600 3616 3601 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)3617 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) 3602 3618 { 3603 3619 // all applied/removed only at real aura add/remove … … 3638 3654 } 3639 3655 3640 void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real)3656 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) 3641 3657 { 3642 3658 // all applied/removed only at real aura add/remove … … 3647 3663 } 3648 3664 3649 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)3665 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real) 3650 3666 { 3651 3667 // all applied/removed only at real aura add/remove … … 3658 3674 } 3659 3675 3660 void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real)3676 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) 3661 3677 { 3662 3678 // all applied/removed only at real aura add/remove … … 4343 4359 } 4344 4360 4345 void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real)4361 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real) 4346 4362 { 4347 4363 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4354 4370 } 4355 4371 4356 void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real)4372 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real) 4357 4373 { 4358 4374 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4372 4388 } 4373 4389 4374 void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real)4390 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real) 4375 4391 { 4376 4392 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4383 4399 } 4384 4400 4385 void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real)4401 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real) 4386 4402 { 4387 4403 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4392 4408 } 4393 4409 4394 void Aura::HandleModHealingDone(bool apply, bool Real)4410 void Aura::HandleModHealingDone(bool /*apply*/, bool Real) 4395 4411 { 4396 4412 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4432 4448 } 4433 4449 4434 void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real)4450 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real) 4435 4451 { 4436 4452 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4567 4583 } 4568 4584 4569 void Aura::HandleModPowerRegenPCT(bool apply, bool Real)4585 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) 4570 4586 { 4571 4587 // spells required only Real aura add/remove … … 4581 4597 } 4582 4598 4583 void Aura::HandleModManaRegen(bool apply, bool Real)4599 void Aura::HandleModManaRegen(bool /*apply*/, bool Real) 4584 4600 { 4585 4601 // spells required only Real aura add/remove … … 4668 4684 /********************************/ 4669 4685 4670 void Aura::HandleAuraModParryPercent(bool apply, bool Real)4686 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real) 4671 4687 { 4672 4688 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4676 4692 } 4677 4693 4678 void Aura::HandleAuraModDodgePercent(bool apply, bool Real)4694 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real) 4679 4695 { 4680 4696 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4685 4701 } 4686 4702 4687 void Aura::HandleAuraModBlockPercent(bool apply, bool Real)4703 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real) 4688 4704 { 4689 4705 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4694 4710 } 4695 4711 4696 void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real)4712 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) 4697 4713 { 4698 4714 // spells required only Real aura add/remove … … 4762 4778 } 4763 4779 4764 void Aura::HandleModSpellCritChanceShool(bool apply, bool Real)4780 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) 4765 4781 { 4766 4782 // spells required only Real aura add/remove … … 4842 4858 4843 4859 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); 4844 }4845 4846 void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real)4847 {4848 // spells required only Real aura add/remove4849 if(!Real)4850 return;4851 Unit *caster = GetCaster();4852 4853 if (!caster)4854 return;4855 4856 // Hunter's Mark4857 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)4858 {4859 // Check Improved Hunter's Mark bonus on caster4860 Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);4861 for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)4862 {4863 Modifier* mod = (*i)->GetModifier();4864 // mproved Hunter's Mark script from 5236 to 52404865 if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240)4866 {4867 // Get amount of ranged bonus for this spell..4868 int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target);4869 // Set melee attack power bonus % from ranged depends from Improved mask aura4870 m_modifier.m_amount = mod->m_amount * ranged_bonus / 100;4871 m_currentBasePoints = m_modifier.m_amount;4872 break;4873 }4874 }4875 return;4876 }4877 4860 } 4878 4861 … … 5324 5307 } 5325 5308 5326 void Aura::HandleAuraModExpertise(bool apply, bool Real)5309 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real) 5327 5310 { 5328 5311 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 5347 5330 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) 5348 5331 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); 5349 }5350 5351 //HandleNoImmediateEffect auras implementation to support new stat system5352 void Aura::HandleAuraHealing(bool apply, bool Real)5353 {5354 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply);5355 }5356 5357 void Aura::HandleAuraHealingPct(bool apply, bool Real)5358 {5359 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply);5360 5332 } 5361 5333 -
trunk/src/game/SpellAuras.h
r236 r257 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 #ifndef TRINITY_SPELLAURAS_H … … 186 186 void HandleModRating(bool apply, bool Real); 187 187 void HandleModTargetResistance(bool apply, bool Real); 188 void HandleAuraAttackPowerAttacker(bool apply, bool Real);189 188 void HandleAuraModAttackPowerPercent(bool apply, bool Real); 190 189 void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); 191 190 void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); 192 191 void HandleSpiritOfRedemption(bool apply, bool Real); 193 void HandleAuraHealingPct(bool apply, bool Real);194 192 void HandleModManaRegen(bool apply, bool Real); 195 193 void HandleComprehendLanguage(bool apply, bool Real); 196 void HandleAuraHealing(bool apply, bool Real);197 194 void HandleShieldBlockValue(bool apply, bool Real); 198 195 void HandleModSpellCritChanceShool(bool apply, bool Real); … … 254 251 uint8 slot = GetAuraSlot(); 255 252 256 // only aura in slot with charges and without stack limitation253 // only aura in slot with charges and without stack limitation 257 254 if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) 258 255 SetAuraApplication(slot, m_procCharges - 1); -
trunk/src/game/SpellEffects.cpp
r246 r257 1172 1172 m_caster->CastSpell(m_caster, 45009, true); 1173 1173 return; 1174 } 1174 } 1175 1175 case 45030: // Impale Emissary 1176 1176 { … … 1275 1275 //Polymorph Cast Visual Rank 1 1276 1276 const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; 1277 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1277 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1278 1278 } 1279 1279 return; … … 2251 2251 m_caster->ModifyPower(POWER_MANA,gain); 2252 2252 //send log 2253 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA ,false);2253 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA); 2254 2254 } 2255 2255 } … … 2267 2267 /*do not uncomment . 2268 2268 if(bg->GetTypeID()==BATTLEGROUND_WS) 2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2270 2270 sLog.outDebug("Send Event Horde Flag Picked Up"); 2271 2271 break; … … 2280 2280 /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion 2281 2281 if(bg->GetTypeID()==BATTLEGROUND_WS) 2282 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2282 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2283 2283 sLog.outDebug("Send Event Alliance Flag Picked Up"); 2284 2284 break; … … 2291 2291 case 23385: // Alliance Flag Returns 2292 2292 if(bg->GetTypeID()==BATTLEGROUND_WS) 2293 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2293 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2294 2294 sLog.outDebug("Alliance Flag Returned"); 2295 2295 break; 2296 2296 case 23386: // Horde Flag Returns 2297 2297 if(bg->GetTypeID()==BATTLEGROUND_WS) 2298 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2298 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2299 2299 sLog.outDebug("Horde Flag Returned"); 2300 2300 break;*/ … … 2302 2302 /* 2303 2303 if(bg->GetTypeID()==BATTLEGROUND_EY) 2304 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2304 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2305 2305 */ 2306 2306 break; … … 2681 2681 2682 2682 // Some level depends spells 2683 int multiplier 2683 int multiplier = 0; 2684 2684 int level_diff = 0; 2685 2685 switch (m_spellInfo->Id) … … 2688 2688 case 9512: 2689 2689 level_diff = m_caster->getLevel() - 40; 2690 multiplier 2690 multiplier = 2; 2691 2691 break; 2692 2692 // Blood Fury 2693 2693 case 24571: 2694 2694 level_diff = m_caster->getLevel() - 60; 2695 multiplier 2695 multiplier = 10; 2696 2696 break; 2697 2697 // Burst of Energy 2698 2698 case 24532: 2699 2699 level_diff = m_caster->getLevel() - 60; 2700 multiplier 2700 multiplier = 4; 2701 2701 break; 2702 2702 default: … … 3760 3760 ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); 3761 3761 else 3762 MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());3762 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); 3763 3763 } 3764 3764 … … 3781 3781 return; 3782 3782 3783 sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow());3783 sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); 3784 3784 3785 3785 // TODO: find formula for honor reward based on player's level! … … 3787 3787 // now fixed only for level 70 players: 3788 3788 if (((Player*)unitTarget)->getLevel() == 70) 3789 ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage);3789 ((Player*)unitTarget)->RewardHonor(NULL, 1, damage); 3790 3790 } 3791 3791 … … 4002 4002 4003 4003 // add to world 4004 MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);4004 pet->GetMap()->Add((Creature*)pet); 4005 4005 4006 4006 // visual effect for levelup … … 4032 4032 return; 4033 4033 4034 MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false);4034 OldSummon->GetMap()->Remove((Creature*)OldSummon,false); 4035 4035 OldSummon->SetMapId(m_caster->GetMapId()); 4036 4036 … … 4039 4039 4040 4040 OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); 4041 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon);4041 m_caster->GetMap()->Add((Creature*)OldSummon); 4042 4042 4043 4043 if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) … … 4122 4122 if(m_caster->GetTypeId() == TYPEID_UNIT) 4123 4123 { 4124 4125 4126 4127 4124 if ( ((Creature*)m_caster)->isTotem() ) 4125 NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); 4126 else 4127 NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); 4128 4128 } 4129 4129 … … 4447 4447 ((Player*)m_caster)->AddComboPoints(unitTarget, 1); 4448 4448 } 4449 4449 4450 // Mangle (Cat): CP 4450 4451 if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) … … 4453 4454 ((Player*)m_caster)->AddComboPoints(unitTarget,1); 4454 4455 } 4455 4456 4456 4457 4457 // take ammo … … 5449 5449 } 5450 5450 5451 void Spell::EffectResurrect(uint32 i)5451 void Spell::EffectResurrect(uint32 /*effIndex*/) 5452 5452 { 5453 5453 if(!unitTarget) … … 5670 5670 int32 targetLevel = creature->getLevel(); 5671 5671 5672 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5672 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5673 5673 5674 5674 ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); … … 5697 5697 5698 5698 if(m_caster->GetTypeId() != TYPEID_PLAYER) 5699 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation());5699 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); 5700 5700 5701 5701 // not all charge effects used in negative spells … … 6133 6133 linkedGO->SetOwnerGUID(m_caster->GetGUID() ); 6134 6134 6135 MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO);6135 linkedGO->GetMap()->Add(linkedGO); 6136 6136 } 6137 6137 else -
trunk/src/game/StatSystem.cpp
r229 r257 385 385 weapon_maxdamage = lvl*1.25*att_speed; 386 386 } 387 else if(!IsUseEquip pedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc)387 else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) 388 388 { 389 389 weapon_mindamage = BASE_MINDAMAGE; -
trunk/src/game/Unit.cpp
r253 r257 1149 1149 if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) 1150 1150 { 1151 uint32 modDamage=*damage;1152 1153 1151 // apply spellmod to Done damage 1154 1152 if(Player* modOwner = GetSpellModOwner()) … … 1435 1433 if(!this || !pVictim) 1436 1434 return 0; 1437 if(! this->isAlive() || !pVictim->isAlive())1435 if(!isAlive() || !pVictim->isAlive()) 1438 1436 return 0; 1439 1437 … … 4128 4126 void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) 4129 4127 { 4130 if (IsSingleTargetSpell((*i).second->GetSpellProto())) 4131 { 4132 if(Unit* caster = (*i).second->GetCaster()) 4128 Aura* Aur = i->second; 4129 SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); 4130 4131 Unit* caster = NULL; 4132 if (IsSingleTargetSpell(AurSpellInfo)) 4133 { 4134 caster = Aur->GetCaster(); 4135 if(caster) 4133 4136 { 4134 4137 AuraList& scAuras = caster->GetSingleCastAuras(); 4135 scAuras.remove( (*i).second);4138 scAuras.remove(Aur); 4136 4139 } 4137 4140 else … … 4142 4145 } 4143 4146 4144 if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) 4147 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 4148 if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) 4145 4149 { 4146 4150 m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); … … 4154 4158 } 4155 4159 4156 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)4157 Aura* Aur = i->second;4158 4160 // Set remove mode 4159 4161 Aur->SetRemoveMode(mode); … … 4163 4165 ++m_removedAuras; // internal count used by unit update 4164 4166 4165 // Statu sunsummoned at aura remove4167 // Statue unsummoned at aura remove 4166 4168 Totem* statue = NULL; 4167 if(IsChanneledSpell(Aur->GetSpellProto())) 4168 if(Unit* caster = Aur->GetCaster()) 4169 bool caster_channeled = false; 4170 if(IsChanneledSpell(AurSpellInfo)) 4171 { 4172 if(!caster) // can be already located for IsSingleTargetSpell case 4173 caster = Aur->GetCaster(); 4174 4175 if(caster) 4176 { 4169 4177 if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) 4170 4178 statue = ((Totem*)caster); 4171 4179 else 4180 caster_channeled = caster==this; 4181 } 4182 } 4172 4183 4173 4184 if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) … … 4186 4197 Aur->_RemoveAura(); 4187 4198 delete Aur; 4199 4200 if(caster_channeled) 4201 RemoveAurasAtChanneledTarget (AurSpellInfo); 4188 4202 4189 4203 if(statue) … … 4612 4626 } 4613 4627 4614 bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) 4615 { 4628 bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown) 4629 { 4630 SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); 4631 4616 4632 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4617 4633 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 4673 4689 } 4674 4690 4675 bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4676 { 4691 bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4692 { 4693 SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); 4694 uint32 effIndex = triggeredByAura->GetEffIndex (); 4695 4677 4696 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4678 4697 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 6262 6281 return false; 6263 6282 6264 uint32 spell = 0;6265 6283 switch(triggeredByAura->GetSpellProto()->Id) 6266 6284 { … … 6292 6310 6293 6311 // overwrite non existing triggered spell call in spell.dbc 6294 uint32 spell = 0;6295 6312 switch(triggeredByAura->GetSpellProto()->Id) 6296 6313 { … … 6492 6509 } 6493 6510 6494 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6495 { 6511 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6512 { 6513 int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; 6514 6496 6515 if(!pVictim || !pVictim->isAlive()) 6497 6516 return false; … … 7259 7278 } 7260 7279 7261 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype , bool critical)7280 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) 7262 7281 { 7263 7282 WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); … … 7359 7378 AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 7360 7379 for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 7361 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto))7380 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) 7362 7381 TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 7363 7382 … … 8207 8226 8208 8227 // ..done (for creature type by mask) in taken 8209 AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);8228 AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); 8210 8229 for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) 8211 8230 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8275 8294 // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage 8276 8295 8277 AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);8296 AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); 8278 8297 for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) 8279 8298 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8730 8749 if(IsInWorld()) 8731 8750 { 8732 Map *m = MapManager::Instance().GetMap(GetMapId(), this);8751 Map *m = GetMap(); 8733 8752 8734 8753 if(GetTypeId()==TYPEID_PLAYER) … … 9792 9811 } 9793 9812 9794 9795 9796 9813 CharmInfo* Unit::InitCharmInfo(Unit *charm) 9797 9814 { … … 9957 9974 struct ProcTriggeredData 9958 9975 { 9959 ProcTriggeredData( SpellEntry const * _spellInfo, uint32 _spellParam,Aura* _triggeredByAura, uint32 _cooldown)9960 : spellInfo(_spellInfo), spellParam(_spellParam),triggeredByAura(_triggeredByAura),9976 ProcTriggeredData(Aura* _triggeredByAura, uint32 _cooldown) 9977 : triggeredByAura(_triggeredByAura), 9961 9978 triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), 9962 9979 cooldown(_cooldown) 9963 {} 9964 9965 SpellEntry const * spellInfo; 9966 uint32 spellParam; 9967 Aura* triggeredByAura; 9968 Unit::spellEffectPair triggeredByAura_SpellPair; 9969 uint32 cooldown; 9980 {} 9981 9982 Aura* triggeredByAura; // triggred aura, can be invalidate at triggered aura proccessing 9983 Unit::spellEffectPair triggeredByAura_SpellPair; // spell pair, used for re-find aura (by pointer comparison in range) 9984 uint32 cooldown; // possible hidden cooldown 9970 9985 }; 9971 9986 … … 9984 9999 next = i; ++next; 9985 10000 9986 SpellEntry const *spellProto = (*i)->GetSpellProto(); 9987 if(!spellProto) 10001 Aura* i_aura = *i; 10002 10003 uint32 cooldown; // returned at next line 10004 if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown)) 9988 10005 continue; 9989 10006 9990 SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 9991 if(!spellProcEvent) 9992 { 9993 // used to prevent spam in log about same non-handled spells 9994 static std::set<uint32> nonHandledSpellProcSet; 9995 9996 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 9997 { 9998 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 9999 nonHandledSpellProcSet.insert(spellProto->Id); 10000 } 10001 10002 // spell.dbc use totally different flags, that only can create problems if used. 10003 continue; 10004 } 10005 10006 // Check spellProcEvent data requirements 10007 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 10008 continue; 10009 10010 // Check if current equipment allows aura to proc 10011 if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 10012 { 10013 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 10014 { 10015 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 10016 10017 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10018 continue; 10019 } 10020 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 10021 { 10022 // Check if player is wearing shield 10023 Item *item = ((Player*)this)->GetShield(true); 10024 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10025 continue; 10026 } 10027 } 10028 10029 float chance = (float)spellProto->procChance; 10030 10031 if(Player* modOwner = GetSpellModOwner()) 10032 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 10033 10034 if(!isVictim && spellProcEvent->ppmRate != 0) 10035 { 10036 uint32 WeaponSpeed = GetAttackTime(attType); 10037 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 10038 } 10039 10040 if(roll_chance_f(chance)) 10041 { 10042 uint32 cooldown = spellProcEvent->cooldown; 10043 10044 uint32 i_spell_eff = (*i)->GetEffIndex(); 10045 10046 int32 i_spell_param; 10047 switch(*aur) 10048 { 10049 case SPELL_AURA_PROC_TRIGGER_SPELL: 10050 i_spell_param = procFlag; 10051 break; 10052 case SPELL_AURA_DUMMY: 10053 case SPELL_AURA_PRAYER_OF_MENDING: 10054 case SPELL_AURA_MOD_HASTE: 10055 i_spell_param = i_spell_eff; 10056 break; 10057 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10058 i_spell_param = (*i)->GetModifier()->m_miscvalue; 10059 break; 10060 default: 10061 i_spell_param = (*i)->GetModifier()->m_amount; 10062 break; 10063 } 10064 10065 procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); 10066 } 10007 procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) ); 10067 10008 } 10068 10009 … … 10097 10038 } 10098 10039 10099 // save charges existence before processing to prevent crash at access to deleted triggered aura after 10100 bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; 10101 10040 /// this is aura triggering code call 10041 Aura* triggeredByAura = i->triggeredByAura; 10042 10043 /// save charges existence before processing to prevent crash at access to deleted triggered aura after 10044 /// used in speedup code check before check aura existance. 10045 bool triggeredByAuraWithCharges = triggeredByAura->m_procCharges > 0; 10046 10047 /// success in event proccesing 10048 /// used in speedup code check before check aura existance. 10102 10049 bool casted = false; 10050 10051 /// process triggered code 10103 10052 switch(*aur) 10104 10053 { 10105 10054 case SPELL_AURA_PROC_TRIGGER_SPELL: 10106 10055 { 10107 sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10108 casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); 10056 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)", 10057 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10058 casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown); 10109 10059 break; 10110 10060 } 10111 10061 case SPELL_AURA_PROC_TRIGGER_DAMAGE: 10112 10062 { 10113 sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10114 uint32 damage = i->spellParam; 10115 SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); 10063 uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount; 10064 sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)", 10065 triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10066 SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true); 10116 10067 casted = true; 10117 10068 break; … … 10119 10070 case SPELL_AURA_DUMMY: 10120 10071 { 10121 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10122 casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10072 uint32 effect = triggeredByAura->GetEffIndex(); 10073 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)", 10074 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10075 casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10123 10076 break; 10124 10077 } 10125 10078 case SPELL_AURA_PRAYER_OF_MENDING: 10126 10079 { 10127 sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10128 10129 // aura can be deleted at casts 10130 int32 heal = i->triggeredByAura->GetModifier()->m_amount; 10131 uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); 10132 10133 // jumps 10134 int32 jumps = i->triggeredByAura->m_procCharges-1; 10135 10136 // current aura expire 10137 i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease 10138 10139 // next target selection 10140 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 10141 { 10142 Aura* aura = i->triggeredByAura; 10143 10144 SpellEntry const* spellProto = aura->GetSpellProto(); 10145 uint32 effIdx = aura->GetEffIndex(); 10146 10147 float radius; 10148 if (spellProto->EffectRadiusIndex[effIdx]) 10149 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 10150 else 10151 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 10152 10153 if(Player* caster = ((Player*)aura->GetCaster())) 10154 { 10155 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 10156 10157 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 10158 { 10159 // aura will applied from caster, but spell casted from current aura holder 10160 SpellModifier *mod = new SpellModifier; 10161 mod->op = SPELLMOD_CHARGES; 10162 mod->value = jumps-5; // negative 10163 mod->type = SPELLMOD_FLAT; 10164 mod->spellId = spellProto->Id; 10165 mod->effectId = effIdx; 10166 mod->lastAffected = NULL; 10167 mod->mask = spellProto->SpellFamilyFlags; 10168 mod->charges = 0; 10169 10170 caster->AddSpellMod(mod, true); 10171 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); 10172 caster->AddSpellMod(mod, false); 10173 } 10174 } 10175 } 10176 10177 // heal 10178 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 10179 casted = true; 10080 sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)", 10081 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10082 10083 casted = HandleMeandingAuraProc(triggeredByAura); 10180 10084 break; 10181 10085 } 10182 10086 case SPELL_AURA_MOD_HASTE: 10183 10087 { 10184 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10185 casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10088 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)", 10089 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10090 casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10186 10091 break; 10187 10092 } … … 10190 10095 // nothing do, just charges counter 10191 10096 // but count only in case appropriate school damage 10192 casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask;10097 casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; 10193 10098 break; 10194 10099 } 10195 10100 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10196 10101 { 10197 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10198 casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); 10102 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", 10103 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10104 casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); 10199 10105 break; 10200 10106 } … … 10207 10113 } 10208 10114 10209 // Update charge (aura can be removed by triggers)10115 /// Update charge (aura can be removed by triggers) 10210 10116 if(casted && triggeredByAuraWithCharges) 10211 10117 { 10212 // needfound aura (can be dropped by triggers)10118 /// need re-found aura (can be dropped by triggers) 10213 10119 AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); 10214 10120 AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); 10215 10121 for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) 10216 10122 { 10217 if(itr->second == i->triggeredByAura)10123 if(itr->second == triggeredByAura) // pointer still valid 10218 10124 { 10219 if( i->triggeredByAura->m_procCharges > 0)10220 i->triggeredByAura->m_procCharges -= 1;10221 10222 i->triggeredByAura->UpdateAuraCharges();10125 if(triggeredByAura->m_procCharges > 0) 10126 triggeredByAura->m_procCharges -= 1; 10127 10128 triggeredByAura->UpdateAuraCharges(); 10223 10129 break; 10224 10130 } … … 10227 10133 } 10228 10134 10229 // Safely remove auras with zero charges10135 /// Safely remove auras with zero charges 10230 10136 for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) 10231 10137 { … … 10340 10246 // send explicit stop packet 10341 10247 // rely on vmaps here because for example stormwind is in air 10342 float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);10248 //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 10343 10249 //if (fabs(GetPositionZ() - z) < 2.0f) 10344 10250 // Relocate(GetPositionX(), GetPositionY(), z); … … 10824 10730 } 10825 10731 10826 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID());10827 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID());10828 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, this->getFaction());10732 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()); 10733 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID()); 10734 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction()); 10829 10735 pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); 10830 10736 … … 10844 10750 return pet; 10845 10751 } 10752 10753 bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ) 10754 { 10755 SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 10756 10757 if(!spellProcEvent) 10758 { 10759 // used to prevent spam in log about same non-handled spells 10760 static std::set<uint32> nonHandledSpellProcSet; 10761 10762 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 10763 { 10764 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 10765 nonHandledSpellProcSet.insert(spellProto->Id); 10766 } 10767 10768 // spell.dbc use totally different flags, that only can create problems if used. 10769 return false; 10770 } 10771 10772 // Check spellProcEvent data requirements 10773 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 10774 return false; 10775 10776 // Check if current equipment allows aura to proc 10777 if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 10778 { 10779 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 10780 { 10781 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 10782 10783 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10784 return false; 10785 } 10786 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 10787 { 10788 // Check if player is wearing shield 10789 Item *item = ((Player*)this)->GetShield(true); 10790 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10791 return false; 10792 } 10793 } 10794 10795 float chance = (float)spellProto->procChance; 10796 10797 if(Player* modOwner = GetSpellModOwner()) 10798 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 10799 10800 if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) 10801 { 10802 uint32 WeaponSpeed = GetAttackTime(attType); 10803 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 10804 } 10805 10806 cooldown = spellProcEvent ? spellProcEvent->cooldown : 0; 10807 return roll_chance_f(chance); 10808 } 10809 10810 bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura ) 10811 { 10812 // aura can be deleted at casts 10813 SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); 10814 uint32 effIdx = triggeredByAura->GetEffIndex(); 10815 int32 heal = triggeredByAura->GetModifier()->m_amount; 10816 uint64 caster_guid = triggeredByAura->GetCasterGUID(); 10817 10818 // jumps 10819 int32 jumps = triggeredByAura->m_procCharges-1; 10820 10821 // current aura expire 10822 triggeredByAura->m_procCharges = 1; // will removed at next charges decrease 10823 10824 // next target selection 10825 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 10826 { 10827 float radius; 10828 if (spellProto->EffectRadiusIndex[effIdx]) 10829 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 10830 else 10831 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 10832 10833 if(Player* caster = ((Player*)triggeredByAura->GetCaster())) 10834 { 10835 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 10836 10837 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 10838 { 10839 // aura will applied from caster, but spell casted from current aura holder 10840 SpellModifier *mod = new SpellModifier; 10841 mod->op = SPELLMOD_CHARGES; 10842 mod->value = jumps-5; // negative 10843 mod->type = SPELLMOD_FLAT; 10844 mod->spellId = spellProto->Id; 10845 mod->effectId = effIdx; 10846 mod->lastAffected = NULL; 10847 mod->mask = spellProto->SpellFamilyFlags; 10848 mod->charges = 0; 10849 10850 caster->AddSpellMod(mod, true); 10851 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID()); 10852 caster->AddSpellMod(mod, false); 10853 } 10854 } 10855 } 10856 10857 // heal 10858 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 10859 return true; 10860 } 10861 10862 void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) 10863 { 10864 uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT); 10865 10866 if(!IS_UNIT_GUID(target_guid)) 10867 return; 10868 10869 Unit* target = ObjectAccessor::GetUnit(*this, target_guid); 10870 if(!target) 10871 return; 10872 10873 for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); ) 10874 { 10875 if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID()) 10876 target->RemoveAura(iter); 10877 else 10878 ++iter; 10879 } 10880 } -
trunk/src/game/Unit.h
r252 r257 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 934 934 935 935 void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); 936 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype , bool critical = false);936 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); 937 937 uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); 938 938 void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); … … 1040 1040 void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); 1041 1041 void RemoveAurasDueToSpellByCancel(uint32 spellId); 1042 void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); 1042 1043 void RemoveNotOwnSingleTargetAuras(); 1043 1044 … … 1371 1372 1372 1373 void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); 1373 bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1374 bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); 1375 bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1376 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown); 1374 bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ); 1375 bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1376 bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown); 1377 bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1378 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown); 1379 bool HandleMeandingAuraProc(Aura* triggeredByAura); 1377 1380 1378 1381 uint32 m_state; // Even derived shouldn't modify -
trunk/src/shared/Common.h
r255 r257 147 147 #define strnicmp strncasecmp 148 148 #define I64FMT "%016llX" 149 #define I64FMTD "% llu"149 #define I64FMTD "%I64u" 150 150 #define SI64FMTD "%lld" 151 151 #endif -
trunk/win/VC71/game.vcproj
r208 r257 338 338 </File> 339 339 <File 340 RelativePath="..\..\src\game\MapReference.h"> 341 </File> 342 <File 343 RelativePath="..\..\src\game\MapRefManager.h"> 344 </File> 345 <File 340 346 RelativePath="..\..\src\game\MiscHandler.cpp"> 341 347 </File> -
trunk/win/VC80/game.vcproj
r208 r257 628 628 </File> 629 629 <File 630 RelativePath="..\..\src\game\MapReference.h" 631 > 632 </File> 633 <File 634 RelativePath="..\..\src\game\MapRefManager.h" 635 > 636 </File> 637 <File 630 638 RelativePath="..\..\src\game\MiscHandler.cpp" 631 639 > -
trunk/win/VC90/game.vcproj
r208 r257 633 633 </File> 634 634 <File 635 RelativePath="..\..\src\game\MapReference.h" 636 > 637 </File> 638 <File 639 RelativePath="..\..\src\game\MapRefManager.h" 640 > 641 </File> 642 <File 635 643 RelativePath="..\..\src\game\MiscHandler.cpp" 636 644 >