@@ -629,34 +629,22 @@ GraveyardStruct const* Battlefield::GetClosestGraveyard(Player* player)
629629 return nullptr ;
630630}
631631
632- void Battlefield::AddPlayerToResurrectQueue (ObjectGuid npcGuid, ObjectGuid playerGuid)
632+ void Battlefield::AddPlayerToResurrectQueue (ObjectGuid /* npcGuid*/ , ObjectGuid playerGuid)
633633{
634- for (BfGraveyard* gy : GraveyardList)
635- {
636- if (!gy)
637- continue ;
634+ Player* player = ObjectAccessor::FindPlayer (playerGuid);
635+ if (!player)
636+ return ;
638637
639- if (gy->HasNpc (npcGuid))
640- {
641- gy->AddPlayer (playerGuid);
642- break ;
643- }
644- }
638+ player->CastSpell (player, SPELL_WAITING_FOR_RESURRECT , true );
645639}
646640
647641void Battlefield::RemovePlayerFromResurrectQueue (ObjectGuid playerGuid)
648642{
649- for (BfGraveyard* gy : GraveyardList)
650- {
651- if (!gy)
652- continue ;
643+ Player* player = ObjectAccessor::FindPlayer (playerGuid);
644+ if (!player)
645+ return ;
653646
654- if (gy->HasPlayer (playerGuid))
655- {
656- gy->RemovePlayer (playerGuid);
657- break ;
658- }
659- }
647+ player->RemoveAurasDueToSpell (SPELL_WAITING_FOR_RESURRECT );
660648}
661649
662650void Battlefield::SendAreaSpiritHealerQueryOpcode (Player* player, ObjectGuid const & guid)
@@ -702,80 +690,9 @@ float BfGraveyard::GetDistance(Player* player)
702690 return player->GetDistance2d (safeLoc->x , safeLoc->y );
703691}
704692
705- void BfGraveyard::AddPlayer (ObjectGuid playerGuid)
706- {
707- if (!ResurrectQueue.count (playerGuid))
708- {
709- ResurrectQueue.insert (playerGuid);
710-
711- if (Player* player = ObjectAccessor::FindPlayer (playerGuid))
712- player->CastSpell (player, SPELL_WAITING_FOR_RESURRECT , true );
713- }
714- }
715-
716- void BfGraveyard::RemovePlayer (ObjectGuid playerGuid)
717- {
718- ResurrectQueue.erase (ResurrectQueue.find (playerGuid));
719-
720- if (Player* player = ObjectAccessor::FindPlayer (playerGuid))
721- player->RemoveAurasDueToSpell (SPELL_WAITING_FOR_RESURRECT );
722- }
723-
724- void BfGraveyard::Resurrect ()
725- {
726- if (ResurrectQueue.empty ())
727- return ;
728-
729- for (ObjectGuid const & guid : ResurrectQueue)
730- {
731- // Get player object from his guid
732- Player* player = ObjectAccessor::FindPlayer (guid);
733- if (!player)
734- continue ;
735-
736- // Check if the player is in world and on the good graveyard
737- if (player->IsInWorld ())
738- if (Unit* spirit = ObjectAccessor::GetCreature (*player, SpiritGuide[ControlTeam]))
739- spirit->CastSpell (spirit, SPELL_SPIRIT_HEAL , true );
740-
741- // Resurrect player
742- player->CastSpell (player, SPELL_RESURRECTION_VISUAL , true );
743- player->ResurrectPlayer (1 .0f );
744- player->CastSpell (player, 6962 , true );
745- player->CastSpell (player, SPELL_SPIRIT_HEAL_MANA , true );
746-
747- player->SpawnCorpseBones (false );
748- }
749-
750- ResurrectQueue.clear ();
751- }
752-
753- // For changing graveyard control
754693void BfGraveyard::GiveControlTo (TeamId team)
755694{
756695 ControlTeam = team;
757- // Teleport to other graveyard, players which were on this graveyard
758- RelocateDeadPlayers ();
759- }
760-
761- void BfGraveyard::RelocateDeadPlayers ()
762- {
763- GraveyardStruct const * closestGrave = nullptr ;
764- for (ObjectGuid const & guid : ResurrectQueue)
765- {
766- Player* player = ObjectAccessor::FindPlayer (guid);
767- if (!player)
768- continue ;
769-
770- if (closestGrave)
771- player->TeleportTo (player->GetMapId (), closestGrave->x , closestGrave->y , closestGrave->z , player->GetOrientation ());
772- else
773- {
774- closestGrave = Bf->GetClosestGraveyard (player);
775- if (closestGrave)
776- player->TeleportTo (player->GetMapId (), closestGrave->x , closestGrave->y , closestGrave->z , player->GetOrientation ());
777- }
778- }
779696}
780697
781698Creature* Battlefield::SpawnCreature (uint32 entry, Position pos, TeamId teamId)
0 commit comments