Merge pull request #15697 from ShinDarth/cd
Core/Player rewritten duel CD reset system (cherry picked from commit 4204805d47078abf54e8a1c50321e63193a7c68d) Conflicts: src/server/game/Spells/SpellHistory.cpp src/server/game/Spells/SpellHistory.h src/server/game/World/World.h
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DELETE FROM `trinity_string` WHERE `entry` = 11010;
|
||||
@@ -7474,18 +7474,13 @@ 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 (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
|
||||
{
|
||||
if (!HasCoolDownBeforeDuel())
|
||||
RemoveArenaSpellCooldowns(true);
|
||||
else
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL);
|
||||
RemoveArenaSpellCooldowns(true);
|
||||
duel->opponent->RemoveArenaSpellCooldowns(true);
|
||||
|
||||
if (!duel->opponent->HasCoolDownBeforeDuel())
|
||||
duel->opponent->RemoveArenaSpellCooldowns(true);
|
||||
else
|
||||
ChatHandler(duel->opponent->GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL);
|
||||
GetSpellHistory()->RestoreCooldownStateAfterDuel();
|
||||
duel->opponent->GetSpellHistory()->RestoreCooldownStateAfterDuel();
|
||||
}
|
||||
|
||||
delete duel->opponent->duel;
|
||||
|
||||
@@ -420,7 +420,7 @@ struct PvPInfo
|
||||
|
||||
struct DuelInfo
|
||||
{
|
||||
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false), hasCoolDownBeforeDuel(false) { }
|
||||
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false) { }
|
||||
|
||||
Player* initiator;
|
||||
Player* opponent;
|
||||
@@ -428,7 +428,6 @@ struct DuelInfo
|
||||
time_t startTime;
|
||||
time_t outOfBound;
|
||||
bool isMounted;
|
||||
bool hasCoolDownBeforeDuel;
|
||||
};
|
||||
|
||||
struct Areas
|
||||
@@ -2190,9 +2189,6 @@ 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);
|
||||
|
||||
@@ -69,8 +69,14 @@ 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();
|
||||
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;
|
||||
|
||||
@@ -1210,8 +1210,7 @@ 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
|
||||
|
||||
@@ -870,21 +870,53 @@ void SpellHistory::SendClearCooldowns(std::vector<int32> const& cooldowns) const
|
||||
}
|
||||
}
|
||||
|
||||
uint16 SpellHistory::GetArenaCooldownsSize()
|
||||
void SpellHistory::SaveCooldownStateBeforeDuel()
|
||||
{
|
||||
uint16 count = 0;
|
||||
_spellCooldownsBeforeDuel = _spellCooldowns;
|
||||
}
|
||||
|
||||
for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();)
|
||||
void SpellHistory::RestoreCooldownStateAfterDuel()
|
||||
{
|
||||
if (Player* player = _owner->ToPlayer())
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
|
||||
// add all profession CDs created while in duel (if any)
|
||||
for (auto const& c : _spellCooldowns)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(c.first);
|
||||
|
||||
if (spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS &&
|
||||
spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS)
|
||||
++count;
|
||||
++itr;
|
||||
if (spellInfo->RecoveryTime > 10 * MINUTE * IN_MILLISECONDS ||
|
||||
spellInfo->CategoryRecoveryTime > 10 * MINUTE * IN_MILLISECONDS)
|
||||
_spellCooldownsBeforeDuel[c.first] = _spellCooldowns[c.first];
|
||||
}
|
||||
|
||||
_spellCooldowns = _spellCooldownsBeforeDuel;
|
||||
|
||||
// update the client: clear all cooldowns
|
||||
std::vector<int32> resetCooldowns;
|
||||
resetCooldowns.reserve(_spellCooldowns.size());
|
||||
|
||||
for (auto const& c : _spellCooldowns)
|
||||
resetCooldowns.push_back(c.first);
|
||||
|
||||
if (resetCooldowns.empty())
|
||||
return;
|
||||
|
||||
SendClearCooldowns(resetCooldowns);
|
||||
|
||||
// update the client: restore old cooldowns
|
||||
WorldPackets::Spells::SpellCooldown spellCooldown;
|
||||
spellCooldown.Caster = _owner->GetGUID();
|
||||
spellCooldown.Flags = SPELL_COOLDOWN_FLAG_NONE;
|
||||
|
||||
for (auto const& c : _spellCooldowns)
|
||||
{
|
||||
Clock::time_point now = Clock::now();
|
||||
uint32 cooldownDuration = c.second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(c.second.CooldownEnd - now).count() : 0;
|
||||
spellCooldown.SpellCooldowns.emplace_back(c.first, cooldownDuration);
|
||||
}
|
||||
|
||||
player->SendDirectMessage(spellCooldown.Write());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
template void SpellHistory::LoadFromDB<Player>(PreparedQueryResult cooldownsResult, PreparedQueryResult chargesResult);
|
||||
|
||||
@@ -145,6 +145,8 @@ public:
|
||||
void CancelGlobalCooldown(SpellInfo const* spellInfo);
|
||||
|
||||
uint16 GetArenaCooldownsSize();
|
||||
void SaveCooldownStateBeforeDuel();
|
||||
void RestoreCooldownStateAfterDuel();
|
||||
|
||||
private:
|
||||
Player* GetPlayerOwner() const;
|
||||
@@ -157,6 +159,7 @@ private:
|
||||
|
||||
Unit* _owner;
|
||||
CooldownStorageType _spellCooldowns;
|
||||
CooldownStorageType _spellCooldownsBeforeDuel;
|
||||
CategoryCooldownStorageType _categoryCooldowns;
|
||||
Clock::time_point _schoolLockouts[MAX_SPELL_SCHOOL];
|
||||
ChargeStorageType _categoryCharges;
|
||||
|
||||
@@ -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_COOLDOWN_AFTER_DUEL] = sConfigMgr->GetBoolDefault("ResetCoolDownAfterDuel", 0);
|
||||
m_bool_configs[CONFIG_RESET_DUEL_COOLDOWNS] = sConfigMgr->GetBoolDefault("ResetDuelCooldowns", 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);
|
||||
|
||||
@@ -176,7 +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,
|
||||
CONFIG_RESET_DUEL_COOLDOWNS,
|
||||
BOOL_CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -2660,12 +2660,12 @@ PlayerStart.MapsExplored = 0
|
||||
HonorPointsAfterDuel = 0
|
||||
|
||||
#
|
||||
# ResetCoolDownAfterDuel
|
||||
# Description: Reset all cooldowns after duel, but only if player has no cooldowns before the duel.
|
||||
# ResetDuelCooldowns
|
||||
# Description: Reset all cooldowns before duel starts and restore them when duel ends.
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
|
||||
ResetCoolDownAfterDuel = 0
|
||||
ResetDuelCooldowns = 0
|
||||
|
||||
#
|
||||
# AlwaysMaxWeaponSkill
|
||||
|
||||
Reference in New Issue
Block a user