Guest User

Untitled

a guest
Dec 12th, 2010
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.36 KB | None | 0 0
  1. void Player::DuelComplete(DuelCompleteType type)
  2. {
  3.     // duel not requested
  4.     if (!duel)
  5.         return;
  6.  
  7.     sLog.outDebug("Duel Complete %s %s", GetName(), duel->opponent->GetName());
  8.  
  9.     WorldPacket data(SMSG_DUEL_COMPLETE, (1));
  10.     data << (uint8)((type != DUEL_INTERUPTED) ? 1 : 0);
  11.     GetSession()->SendPacket(&data);
  12.  
  13.     if (duel->opponent->GetSession())
  14.         duel->opponent->GetSession()->SendPacket(&data);
  15.  
  16.     if (type != DUEL_INTERUPTED)
  17.     {
  18.         data.Initialize(SMSG_DUEL_WINNER, (1+20));          // we guess size
  19.         data << uint8(type == DUEL_WON ? 0 : 1);            // 0 = just won; 1 = fled
  20.         data << duel->opponent->GetName();
  21.         data << GetName();
  22.         SendMessageToSet(&data,true);
  23.     }
  24.  
  25.     sScriptMgr.OnPlayerDuelEnd(duel->opponent, this, type);
  26.  
  27.     switch (type)
  28.     {
  29.         case DUEL_FLED:
  30.             // if initiator and opponent are on the same team
  31.             // or initiator and opponent are not PvP enabled, forcibly stop attacking
  32.             if (duel->initiator->GetTeam() == duel->opponent->GetTeam())
  33.             {
  34.                 duel->initiator->AttackStop();
  35.                 duel->opponent->AttackStop();
  36.             }
  37.             else
  38.             {
  39.                 if (!duel->initiator->IsPvP())
  40.                     duel->initiator->AttackStop();
  41.                 if (!duel->opponent->IsPvP())
  42.                     duel->opponent->AttackStop();
  43.             }
  44.             break;
  45.         case DUEL_WON:
  46.             GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1);
  47.             if (duel->opponent)
  48.             {
  49.                  duel->opponent->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1);
  50.  
  51.                 //Credit for quest Death's Challenge
  52.                 if (getClass() == CLASS_DEATH_KNIGHT && duel->opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE)
  53.                     duel->opponent->CastSpell(duel->opponent, 52994, true);
  54.             }
  55.             break;
  56.         default:
  57.             break;
  58.     }
  59.  
  60.     //Remove Duel Flag object
  61.     GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
  62.     if (obj)
  63.         duel->initiator->RemoveGameObject(obj,true);
  64.  
  65.     /* remove auras */
  66.     AuraApplicationMap &itsAuras = duel->opponent->GetAppliedAuras();
  67.     for (AuraApplicationMap::iterator i = itsAuras.begin(); i != itsAuras.end();)
  68.     {
  69.         Aura const * aura = i->second->GetBase();
  70.         if (!i->second->IsPositive() && aura->GetCasterGUID() == GetGUID() && aura->GetApplyTime() >= duel->startTime)
  71.             duel->opponent->RemoveAura(i);
  72.         else
  73.             ++i;
  74.     }
  75.  
  76.     AuraApplicationMap &myAuras = GetAppliedAuras();
  77.     for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();)
  78.     {
  79.         Aura const * aura = i->second->GetBase();
  80.         if (!i->second->IsPositive() && aura->GetCasterGUID() == duel->opponent->GetGUID() && aura->GetApplyTime() >= duel->startTime)
  81.             RemoveAura(i);
  82.         else
  83.             ++i;
  84.     }
  85.  
  86.     // cleanup combo points
  87.     if (GetComboTarget() == duel->opponent->GetGUID())
  88.         ClearComboPoints();
  89.     else if (GetComboTarget() == duel->opponent->GetPetGUID())
  90.         ClearComboPoints();
  91.     if((GetMapId() == 1 && (GetZoneId() == 618 && GetAreaId() == 2249 || GetZoneId() == 14 && GetAreaId() == 14)) ||
  92.         (GetMapId() == 0 && (GetZoneId() == 41 && GetAreaId() == 41 || GetZoneId() == 12 && GetAreaId() == 12)))
  93.     {
  94.         RemoveAllSpellCooldown();
  95.                 duel->opponent->RemoveAllSpellCooldown();
  96.         SetFullHealth();
  97.         duel->opponent->SetFullHealth();
  98.     }
  99.  
  100.  
  101.     if (duel->opponent->GetComboTarget() == GetGUID())
  102.         duel->opponent->ClearComboPoints();
  103.     else if (duel->opponent->GetComboTarget() == GetPetGUID())
  104.         duel->opponent->ClearComboPoints();
  105.  
  106.     // Honor points after duel (the winner) - ImpConfig
  107.     if (uint32 amount = sWorld.getIntConfig(CONFIG_HONOR_AFTER_DUEL))
  108.         duel->opponent->RewardHonor(NULL,1,amount);
  109.  
  110.     //cleanups
  111.     SetUInt64Value(PLAYER_DUEL_ARBITER, 0);
  112.     SetUInt32Value(PLAYER_DUEL_TEAM, 0);
  113.     duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0);
  114.     duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0);
  115.  
  116.     delete duel->opponent->duel;
  117.     duel->opponent->duel = NULL;
  118.     delete duel;
  119.     duel = NULL;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment