PHP Code:
/*
* Copyright (C) 2008-2018 TrinityCore <https://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/>.
*/
/* --[[ Coded by CoC / Lucky_Patcher 2018 || Do not remove this Copyright || You are allowed to modify this script.]]-- */
#include "ScriptMgr.h"
#include "Config.h"
#include "Player.h"
#include "World.h"
class duel_reset : public PlayerScript
{
public:
duel_reset() : PlayerScript("duel_reset") { }
void OnDuelEnd(Player* winner, Player* looser, DuelCompleteType type)
{
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_ON_FINISH))
{
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_ONLY_IN_ELWYNN_AND_DUROTAR))
{
if (winner->GetZoneId() == 14 || winner->GetZoneId() == 12)
{
if (type == DUEL_WON)
{
winner->RemoveArenaSpellCooldowns();
looser->RemoveArenaSpellCooldowns();
winner->SetHealth(winner->GetMaxHealth());
looser->SetHealth(looser->GetMaxHealth());
if (winner->getPowerType() == POWER_MANA)
winner->SetPower(POWER_MANA, winner->GetMaxPower(POWER_MANA));
if (looser->getPowerType() == POWER_MANA)
looser->SetPower(POWER_MANA, looser->GetMaxPower(POWER_MANA));
}
winner->HandleEmoteCommand(EMOTE_ONESHOT_DANCE);
looser->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
}
}
else
{
if (type == DUEL_WON)
{
winner->RemoveArenaSpellCooldowns();
looser->RemoveArenaSpellCooldowns();
winner->SetHealth(winner->GetMaxHealth());
looser->SetHealth(looser->GetMaxHealth());
if (winner->getPowerType() == POWER_MANA)
winner->SetPower(POWER_MANA, winner->GetMaxPower(POWER_MANA));
if (looser->getPowerType() == POWER_MANA)
looser->SetPower(POWER_MANA, looser->GetMaxPower(POWER_MANA));
}
winner->HandleEmoteCommand(EMOTE_ONESHOT_DANCE);
looser->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
}
}
}
void OnDuelStart(Player* player1, Player* player2)
{
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_ON_START))
{
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_ONLY_IN_ELWYNN_AND_DUROTAR))
{
if (player1->GetZoneId() == 14 || player1->GetZoneId() == 12)
{
player1->RemoveArenaSpellCooldowns();
player2->RemoveArenaSpellCooldowns();
player1->SetHealth(player1->GetMaxHealth());
player2->SetHealth(player2->GetMaxHealth());
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_RESET_ENERGY_ON_START))
{
switch (player1->getPowerType())
{
case POWER_MANA:
player1->SetPower(POWER_MANA, 0);
break;
case POWER_RAGE:
player1->SetPower(POWER_RAGE, 0);
break;
case POWER_RUNIC_POWER:
player1->SetPower(POWER_RUNIC_POWER, 0);
break;
case POWER_FOCUS:
player1->SetPower(POWER_FOCUS, 0);
break;
case POWER_ENERGY:
player1->SetPower(POWER_ENERGY, 0);
break;
default:
break;
}
switch (player2->getPowerType())
{
case POWER_MANA:
player2->SetPower(POWER_MANA, 0);
break;
case POWER_RAGE:
player2->SetPower(POWER_RAGE, 0);
break;
case POWER_RUNIC_POWER:
player2->SetPower(POWER_RUNIC_POWER, 0);
break;
case POWER_FOCUS:
player2->SetPower(POWER_FOCUS, 0);
break;
case POWER_ENERGY:
player2->SetPower(POWER_ENERGY, 0);
break;
default:
break;
}
}
if (sWorld->getBoolConfig(CONFIG_DUEL_RESET_COOLDOWN_MAX_ENERGY_ON_START))
{
switch (player1->getPowerType())
{
case POWER_MANA:
player1->SetPower(POWER_MANA, player1->GetMaxPower(POWER_MANA));
break;
case POWER_RAGE:
player1->SetPower(POWER_RAGE, player1->GetMaxPower(POWER_RAGE));
break;
case POWER_RUNIC_POWER:
player1->SetPower(POWER_RUNIC_POWER, player1->GetMaxPower(POWER_RUNIC_POWER));
break;
case POWER_FOCUS:
player1->SetPower(POWER_FOCUS, player1->GetMaxPower(POWER_FOCUS));
break;
case POWER_ENERGY:
player1->SetPower(POWER_ENERGY, player1->GetMaxPower(POWER_ENERGY));
break;
default:
break;
}
switch (player2->getPowerType())
{
case POWER_MANA:
player2->SetPower(POWER_MANA, player2->GetMaxPower(POWER_MANA));
break;
case POWER_RAGE:
player2->SetPower(POWER_RAGE, player2->GetMaxPower(POWER_RAGE));
break;
case POWER_RUNIC_POWER:
player2->SetPower(POWER_RUNIC_POWER, player2->GetMaxPower(POWER_RUNIC_POWER));
break;
case POWER_FOCUS:
player2->SetPower(POWER_FOCUS, player2->GetMaxPower(POWER_FOCUS));
break;
case POWER_ENERGY:
player2->SetPower(POWER_ENERGY, player2->GetMaxPower(POWER_ENERGY));
break;
default:
break;
}
}
}
}
}
}
};
void AddSC_DuelReset()
{
new duel_reset();
}
PHP Code:
CONFIG_DUEL_RESET_COOLDOWN_ON_START,
CONFIG_DUEL_RESET_COOLDOWN_ON_FINISH,
CONFIG_DUEL_RESET_COOLDOWN_ONLY_IN_ELWYNN_AND_DUROTAR,
CONFIG_DUEL_RESET_COOLDOWN_RESET_ENERGY_ON_START,
CONFIG_DUEL_RESET_COOLDOWN_MAX_ENERGY_ON_START,