Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Player::DuelComplete(DuelCompleteType type)
- {
- // duel not requested
- if (!duel)
- return;
- sLog.outDebug("Duel Complete %s %s", GetName(), duel->opponent->GetName());
- WorldPacket data(SMSG_DUEL_COMPLETE, (1));
- data << (uint8)((type != DUEL_INTERUPTED) ? 1 : 0);
- GetSession()->SendPacket(&data);
- if (duel->opponent->GetSession())
- duel->opponent->GetSession()->SendPacket(&data);
- if (type != DUEL_INTERUPTED)
- {
- data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size
- data << uint8(type == DUEL_WON ? 0 : 1); // 0 = just won; 1 = fled
- data << duel->opponent->GetName();
- data << GetName();
- SendMessageToSet(&data,true);
- }
- sScriptMgr.OnPlayerDuelEnd(duel->opponent, this, type);
- switch (type)
- {
- case DUEL_FLED:
- // if initiator and opponent are on the same team
- // or initiator and opponent are not PvP enabled, forcibly stop attacking
- if (duel->initiator->GetTeam() == duel->opponent->GetTeam())
- {
- duel->initiator->AttackStop();
- duel->opponent->AttackStop();
- }
- else
- {
- if (!duel->initiator->IsPvP())
- duel->initiator->AttackStop();
- if (!duel->opponent->IsPvP())
- duel->opponent->AttackStop();
- }
- break;
- case DUEL_WON:
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1);
- if (duel->opponent)
- {
- duel->opponent->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1);
- //Credit for quest Death's Challenge
- if (getClass() == CLASS_DEATH_KNIGHT && duel->opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE)
- duel->opponent->CastSpell(duel->opponent, 52994, true);
- }
- break;
- default:
- break;
- }
- //Remove Duel Flag object
- GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
- if (obj)
- duel->initiator->RemoveGameObject(obj,true);
- /* remove auras */
- AuraApplicationMap &itsAuras = duel->opponent->GetAppliedAuras();
- for (AuraApplicationMap::iterator i = itsAuras.begin(); i != itsAuras.end();)
- {
- Aura const * aura = i->second->GetBase();
- if (!i->second->IsPositive() && aura->GetCasterGUID() == GetGUID() && aura->GetApplyTime() >= duel->startTime)
- duel->opponent->RemoveAura(i);
- else
- ++i;
- }
- AuraApplicationMap &myAuras = GetAppliedAuras();
- for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();)
- {
- Aura const * aura = i->second->GetBase();
- if (!i->second->IsPositive() && aura->GetCasterGUID() == duel->opponent->GetGUID() && aura->GetApplyTime() >= duel->startTime)
- RemoveAura(i);
- else
- ++i;
- }
- // cleanup combo points
- if (GetComboTarget() == duel->opponent->GetGUID())
- ClearComboPoints();
- else if (GetComboTarget() == duel->opponent->GetPetGUID())
- ClearComboPoints();
- if((GetMapId() == 1 && (GetZoneId() == 618 && GetAreaId() == 2249 || GetZoneId() == 14 && GetAreaId() == 14)) ||
- (GetMapId() == 0 && (GetZoneId() == 41 && GetAreaId() == 41 || GetZoneId() == 12 && GetAreaId() == 12)))
- {
- RemoveAllSpellCooldown();
- duel->opponent->RemoveAllSpellCooldown();
- SetFullHealth();
- duel->opponent->SetFullHealth();
- }
- if (duel->opponent->GetComboTarget() == GetGUID())
- duel->opponent->ClearComboPoints();
- else if (duel->opponent->GetComboTarget() == GetPetGUID())
- duel->opponent->ClearComboPoints();
- // Honor points after duel (the winner) - ImpConfig
- if (uint32 amount = sWorld.getIntConfig(CONFIG_HONOR_AFTER_DUEL))
- duel->opponent->RewardHonor(NULL,1,amount);
- //cleanups
- SetUInt64Value(PLAYER_DUEL_ARBITER, 0);
- SetUInt32Value(PLAYER_DUEL_TEAM, 0);
- duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0);
- duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0);
- delete duel->opponent->duel;
- duel->opponent->duel = NULL;
- delete duel;
- duel = NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment