aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGigaDev90 <gabriele.gelardi@gmail.com>2015-10-25 16:23:51 +0100
committerShinDarth <borzifrancesco@gmail.com>2015-10-28 20:14:21 +0100
commitb774aedd93a229fd3cbcd17a09ac195a9c0c47c6 (patch)
treec6b15b723b727a237f6b091d4a24e3fa7fe942d3
parentf5781ec3af1e0958f505d5d4b3e452cb10f1a70c (diff)
Scripts/DuelReset:
- fixed druid mana restoration - fixed bug when a player accepts duel with a spel on onHold true (like when stealth of rogue/druid is active)
-rw-r--r--src/server/game/Spells/SpellHistory.cpp27
-rw-r--r--src/server/scripts/World/duel_reset.cpp34
2 files changed, 36 insertions, 25 deletions
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index ca0e8cc6238..c76c4545643 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -652,23 +652,16 @@ void SpellHistory::RestoreCooldownStateAfterDuel()
SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first);
if (spellInfo->RecoveryTime > 10 * MINUTE * IN_MILLISECONDS ||
- spellInfo->CategoryRecoveryTime > 10 * MINUTE * IN_MILLISECONDS)
+ spellInfo->CategoryRecoveryTime > 10 * MINUTE * IN_MILLISECONDS)
_spellCooldownsBeforeDuel[itr->first] = _spellCooldowns[itr->first];
}
-
- _spellCooldowns = _spellCooldownsBeforeDuel;
-
- // update the client: clear all cooldowns
- std::vector<int32> resetCooldowns;
- resetCooldowns.reserve(_spellCooldowns.size());
-
- for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end(); ++itr)
- resetCooldowns.push_back(itr->first);
-
- if (resetCooldowns.empty())
- return;
-
- SendClearCooldowns(resetCooldowns);
+ //check for spell with onHold active before and during the duel
+ for (auto itr = _spellCooldownsBeforeDuel.begin(); itr != _spellCooldownsBeforeDuel.end(); ++itr)
+ {
+ if (!itr->second.OnHold)
+ if (!_spellCooldowns[itr->first].OnHold)
+ _spellCooldowns[itr->first] = _spellCooldownsBeforeDuel[itr->first];
+ }
// update the client: restore old cooldowns
PacketCooldowns cooldowns;
@@ -679,14 +672,14 @@ void SpellHistory::RestoreCooldownStateAfterDuel()
uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0;
// cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs
- if (cooldownDuration == 0 || cooldownDuration > 10 * MINUTE * IN_MILLISECONDS)
+ if (cooldownDuration <= 0 || cooldownDuration > 10 * MINUTE * IN_MILLISECONDS || itr->second.OnHold)
continue;
cooldowns[itr->first] = cooldownDuration;
}
WorldPacket data;
- BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, cooldowns);
+ BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_INCLUDE_EVENT_COOLDOWNS, cooldowns);
player->SendDirectMessage(&data);
}
}
diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp
index f7d7201c56a..593906074c5 100644
--- a/src/server/scripts/World/duel_reset.cpp
+++ b/src/server/scripts/World/duel_reset.cpp
@@ -17,6 +17,7 @@
#include "ScriptMgr.h"
#include "Player.h"
+#include "Pet.h"
class DuelResetScript : public PlayerScript
{
@@ -32,8 +33,9 @@ class DuelResetScript : public PlayerScript
player1->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player2->GetSpellHistory()->SaveCooldownStateBeforeDuel();
- player1->RemoveArenaSpellCooldowns(true);
- player2->RemoveArenaSpellCooldowns(true);
+
+ ResetSpellCooldowns(player1, true);
+ ResetSpellCooldowns(player2, true);
}
// Health and mana reset
@@ -46,14 +48,14 @@ class DuelResetScript : public PlayerScript
player2->SetHealth(player2->GetMaxHealth());
// check if player1 class uses mana
- if (player1->getPowerType() == POWER_MANA)
+ if (player1->getPowerType() == POWER_MANA || player1->getClass() == CLASS_DRUID)
{
player1->SaveManaBeforeDuel();
player1->SetPower(POWER_MANA, player1->GetMaxPower(POWER_MANA));
}
// check if player2 class uses mana
- if (player2->getPowerType() == POWER_MANA)
+ if (player2->getPowerType() == POWER_MANA || player2->getClass() == CLASS_DRUID)
{
player2->SaveManaBeforeDuel();
player2->SetPower(POWER_MANA, player2->GetMaxPower(POWER_MANA));
@@ -70,8 +72,9 @@ class DuelResetScript : public PlayerScript
// Cooldown restore
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
- winner->RemoveArenaSpellCooldowns(true);
- loser->RemoveArenaSpellCooldowns(true);
+
+ ResetSpellCooldowns(winner, true);
+ ResetSpellCooldowns(loser, true);
winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
@@ -84,15 +87,30 @@ class DuelResetScript : public PlayerScript
loser->RestoreHealthAfterDuel();
// check if player1 class uses mana
- if (winner->getPowerType() == POWER_MANA)
+ if (winner->getPowerType() == POWER_MANA || winner->getClass() == CLASS_DRUID)
winner->RestoreManaAfterDuel();
// check if player2 class uses mana
- if (loser->getPowerType() == POWER_MANA)
+ if (loser->getPowerType() == POWER_MANA || loser->getClass() == CLASS_DRUID)
loser->RestoreManaAfterDuel();
}
}
}
+
+ void ResetSpellCooldowns(Player* player, bool removeActivePetCooldowns)
+ {
+ // remove cooldowns on spells that have < 10 min CD and has no onHold
+ player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool
+ {
+ SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first);
+ return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS && !itr->second.OnHold;
+ }, true);
+
+ // pet cooldowns
+ if (removeActivePetCooldowns)
+ if (Pet* pet = player->GetPet())
+ pet->GetSpellHistory()->ResetAllCooldowns();
+ }
};
void AddSC_duel_reset()