mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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:
3
sql/updates/world/2015_11_07_00_world_2015_10_02_01.sql
Normal file
3
sql/updates/world/2015_11_07_00_world_2015_10_02_01.sql
Normal 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);
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user