Merge pull request #15646 from ShinDarth/ticket

Core/Player: implement ResetCoolDownAfterDuel configurable feature
(cherry picked from commit 5b8f1469ca)

Conflicts:
	src/server/game/Spells/SpellHistory.cpp
	src/server/game/Spells/SpellHistory.h
	src/server/game/World/World.h
This commit is contained in:
Shauren
2015-10-05 16:57:02 +02:00
committed by Carbenium
parent ed20680f92
commit 8ceffaef44
10 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
DELETE FROM `trinity_string` WHERE `entry` = 11010;
INSERT INTO `trinity_string` VALUES
(11010, 'You had cooldowns before starting the duel, so your cooldowns haven\'t been reset.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

View File

@@ -7474,6 +7474,20 @@ 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_COOLDOWN_AFTER_DUEL) &&
type != DUEL_INTERRUPTED)
{
if (!HasCoolDownBeforeDuel())
RemoveArenaSpellCooldowns(true);
else
ChatHandler(GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL);
if (!duel->opponent->HasCoolDownBeforeDuel())
duel->opponent->RemoveArenaSpellCooldowns(true);
else
ChatHandler(duel->opponent->GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL);
}
delete duel->opponent->duel;
duel->opponent->duel = NULL;
delete duel;

View File

@@ -28,6 +28,7 @@
#include "PetDefines.h"
#include "QuestDef.h"
#include "SpellMgr.h"
#include "SpellHistory.h"
#include "Unit.h"
#include "Opcodes.h"
#include "WorldSession.h"
@@ -419,7 +420,7 @@ struct PvPInfo
struct DuelInfo
{
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false) { }
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false), hasCoolDownBeforeDuel(false) { }
Player* initiator;
Player* opponent;
@@ -427,6 +428,7 @@ struct DuelInfo
time_t startTime;
time_t outOfBound;
bool isMounted;
bool hasCoolDownBeforeDuel;
};
struct Areas
@@ -2188,6 +2190,9 @@ class Player : public Unit, public GridObject<Player>
bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false);
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const;
bool HasCoolDownBeforeDuel() const { return duel->hasCoolDownBeforeDuel; }
void UpdateHasCoolDownBeforeDuel() { duel->hasCoolDownBeforeDuel = GetSpellHistory()->GetArenaCooldownsSize() > 0; }
//End of PvP System
void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0);

View File

@@ -69,6 +69,9 @@ 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());
player->UpdateHasCoolDownBeforeDuel();
plTarget->UpdateHasCoolDownBeforeDuel();
time_t now = time(NULL);
player->duel->startTimer = now;
plTarget->duel->startTimer = now;

View File

@@ -1210,6 +1210,8 @@ enum TrinityStrings
LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD = 11007,
LANG_NPCINFO_INHABIT_TYPE = 11008,
LANG_NPCINFO_FLAGS_EXTRA = 11009
LANG_NPCINFO_FLAGS_EXTRA = 11009,
LANG_COOLDOWN_NOT_RESET_AFTER_DUEL = 11010
};
#endif

View File

@@ -870,6 +870,23 @@ void SpellHistory::SendClearCooldowns(std::vector<int32> const& cooldowns) const
}
}
uint16 SpellHistory::GetArenaCooldownsSize()
{
uint16 count = 0;
for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();)
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
if (spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS &&
spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS)
++count;
++itr;
}
return count;
}
template void SpellHistory::LoadFromDB<Player>(PreparedQueryResult cooldownsResult, PreparedQueryResult chargesResult);
template void SpellHistory::LoadFromDB<Pet>(PreparedQueryResult cooldownsResult, PreparedQueryResult chargesResult);
template void SpellHistory::SaveToDB<Player>(SQLTransaction& trans);

View File

@@ -144,6 +144,8 @@ public:
void AddGlobalCooldown(SpellInfo const* spellInfo, uint32 duration);
void CancelGlobalCooldown(SpellInfo const* spellInfo);
uint16 GetArenaCooldownsSize();
private:
Player* GetPlayerOwner() const;
void SendClearCooldowns(std::vector<int32> const& cooldowns) const;

View File

@@ -1278,6 +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_COOLDOWN_AFTER_DUEL] = sConfigMgr->GetBoolDefault("ResetCoolDownAfterDuel", 0);
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

@@ -176,6 +176,7 @@ enum WorldBoolConfigs
CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA,
CONFIG_FEATURE_SYSTEM_BPAY_STORE_ENABLED,
CONFIG_FEATURE_SYSTEM_CHARACTER_UNDELETE_ENABLED,
CONFIG_RESET_COOLDOWN_AFTER_DUEL,
BOOL_CONFIG_VALUE_COUNT
};

View File

@@ -2659,6 +2659,14 @@ PlayerStart.MapsExplored = 0
HonorPointsAfterDuel = 0
#
# ResetCoolDownAfterDuel
# Description: Reset all cooldowns after duel, but only if player has no cooldowns before the duel.
# Default: 0 - (Disabled)
# 1 - (Enabled)
ResetCoolDownAfterDuel = 0
#
# AlwaysMaxWeaponSkill
# Description: Players will automatically gain max weapon/defense skill when logging in,