Merge pull request #15731 from ShinDarth/toscri

Convert the Duel Cooldown Reset feature to scripts
(cherry picked from commit 5c449b50aa)
This commit is contained in:
blub
2015-10-18 18:46:28 +02:00
committed by Carbenium
parent 42cf4e7713
commit bf7175ee83
5 changed files with 60 additions and 19 deletions

View File

@@ -7474,15 +7474,6 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty);
duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0);
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
RemoveArenaSpellCooldowns(true);
duel->opponent->RemoveArenaSpellCooldowns(true);
GetSpellHistory()->RestoreCooldownStateAfterDuel();
duel->opponent->GetSpellHistory()->RestoreCooldownStateAfterDuel();
}
delete duel->opponent->duel;
duel->opponent->duel = NULL;
delete duel;

View File

@@ -69,15 +69,6 @@ void WorldSession::HandleDuelAccepted()
TC_LOG_DEBUG("network", "Player 1 is: %s (%s)", player->GetGUID().ToString().c_str(), player->GetName().c_str());
TC_LOG_DEBUG("network", "Player 2 is: %s (%s)", plTarget->GetGUID().ToString().c_str(), plTarget->GetName().c_str());
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
player->GetSpellHistory()->SaveCooldownStateBeforeDuel();
plTarget->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player->RemoveArenaSpellCooldowns(true);
plTarget->RemoveArenaSpellCooldowns(true);
}
time_t now = time(NULL);
player->duel->startTimer = now;
plTarget->duel->startTimer = now;

View File

@@ -93,6 +93,7 @@ void AddSC_npcs_special();
void AddSC_npc_taxi();
void AddSC_achievement_scripts();
void AddSC_action_ip_logger();
void AddSC_duel_reset();
//eastern kingdoms
void AddSC_alterac_valley(); //Alterac Valley
@@ -809,6 +810,7 @@ void AddWorldScripts()
// To avoid duplicate code, we check once /*ONLY*/ if logging is permitted or not.
if (sWorld->getBoolConfig(CONFIG_IP_BASED_ACTION_LOGGING))
AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp
AddSC_duel_reset();
#endif
}

View File

@@ -1278,7 +1278,7 @@ void World::LoadConfigSettings(bool reload)
if (m_bool_configs[CONFIG_START_ALL_SPELLS])
TC_LOG_WARN("server.loading", "PlayerStart.AllSpells enabled - may not function as intended!");
m_int_configs[CONFIG_HONOR_AFTER_DUEL] = sConfigMgr->GetIntDefault("HonorPointsAfterDuel", 0);
m_bool_configs[CONFIG_RESET_DUEL_COOLDOWNS] = sConfigMgr->GetBoolDefault("ResetDuelCooldowns", 0);
m_bool_configs[CONFIG_RESET_DUEL_COOLDOWNS] = sConfigMgr->GetBoolDefault("ResetDuelCooldowns", false);
m_bool_configs[CONFIG_START_ALL_EXPLORED] = sConfigMgr->GetBoolDefault("PlayerStart.MapsExplored", false);
m_bool_configs[CONFIG_START_ALL_REP] = sConfigMgr->GetBoolDefault("PlayerStart.AllReputation", false);
m_bool_configs[CONFIG_ALWAYS_MAXSKILL] = sConfigMgr->GetBoolDefault("AlwaysMaxWeaponSkill", false);

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Player.h"
class DuelResetScript : public PlayerScript
{
public:
DuelResetScript() : PlayerScript("DuelResetScript") { }
// Called when a duel starts (after 3s countdown)
void OnDuelStart(Player* player1, Player* player2) override
{
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
player1->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player2->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player1->RemoveArenaSpellCooldowns(true);
player2->RemoveArenaSpellCooldowns(true);
}
}
// Called when a duel ends
void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType /*type*/) override
{
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
winner->RemoveArenaSpellCooldowns(true);
loser->RemoveArenaSpellCooldowns(true);
winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
}
}
};
void AddSC_duel_reset()
{
new DuelResetScript();
}