Advertisement
xingchao

PhasedDueling

Dec 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "MapManager.h"
  2.  
  3. class PhasedDueling : public PlayerScript
  4. {
  5. public:
  6.         PhasedDueling() : PlayerScript("PhasedDueling") { }
  7.  
  8.         void OnDuelStart(Player* firstplayer, Player* secondplayer)
  9.         {
  10.                 uint32 PlayersInsidePhase = 0;
  11.                 uint32 PhaseToCheck = 1;
  12.                 Map* map = sMapMgr->FindMap(firstplayer->GetMapId(), firstplayer->GetInstanceId());
  13.  
  14.                 if (!map)
  15.                         return;
  16.                 Map::PlayerList const& players = map->GetPlayers();
  17.                 for (Map::PlayerList::const_iterator iter = players.begin(); iter != players.end(); ++iter)
  18.                 {
  19.                         Player* check = iter->GetSource();
  20.                         if (!check || !check->GetSession())
  21.                                 continue;
  22.  
  23.                         if (check->GetPhaseMask() == PhaseToCheck)
  24.                         {
  25.                                 ++PlayersInsidePhase;
  26.                                 ++PhaseToCheck;
  27.                                 PlayersInsidePhase = 0;
  28.                         }
  29.                 }
  30.  
  31.                 if (PlayersInsidePhase == 0)
  32.                 {
  33.                         firstplayer->SetPhaseMask(PhaseToCheck, true);
  34.                         secondplayer->SetPhaseMask(PhaseToCheck, true);
  35.                 }
  36.         }
  37.  
  38.         void OnDuelEnd(Player* firstplayer, Player* secondplayer)
  39.         {
  40.                 uint32 PlayersInsidePhase = 0;
  41.                 uint32 PhaseToCheck = 1;
  42.                 Map* map = sMapMgr->FindMap(firstplayer->GetMapId(), firstplayer->GetInstanceId());
  43.  
  44.                 if (!map)
  45.                         return;
  46.                 Map::PlayerList const& players = map->GetPlayers();
  47.                 for (Map::PlayerList::const_iterator iter = players.begin(); iter != players.end(); ++iter)
  48.                 {
  49.                         Player* check = iter->GetSource();
  50.                         if (!check || !check->GetSession())
  51.                                 continue;
  52.  
  53.                         if (check->GetPhaseMask() == PhaseToCheck)
  54.                         {
  55.                                 ++PlayersInsidePhase;
  56.                                 ++PhaseToCheck;
  57.                                 PlayersInsidePhase = 0;
  58.                         }
  59.                 }
  60.  
  61.                 if (PlayersInsidePhase == 0)
  62.                 {
  63.                         firstplayer->SetPhaseMask(PhaseToCheck, false);
  64.                         secondplayer->SetPhaseMask(PhaseToCheck, false);
  65.                 }
  66.         }
  67. };
  68.  
  69. void AddSC_PhasedDueling()
  70. {
  71.         new PhasedDueling();
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement