aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp6
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp19
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp3
-rw-r--r--src/server/game/Spells/SpellScript.h18
6 files changed, 24 insertions, 26 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index 8f46896f6e8..befd6b9d16e 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -311,7 +311,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu
Player* FollowerAI::GetLeaderForFollower()
{
- if (Player* player = Unit::GetPlayer(*me, m_uiLeaderGUID))
+ if (Player* player = ObjectAccessor::GetPlayer(*me, m_uiLeaderGUID))
{
if (player->IsAlive())
return player;
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index c5b5cd5dfef..febf2e789a2 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -343,7 +343,7 @@ void SmartAI::UpdateAI(uint32 diff)
{
if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, true))
{
- if (Player* player = me->GetPlayer(*me, mFollowGuid))
+ if (Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid))
{
if (!mFollowCreditType)
player->RewardPlayerAndGroupAtEvent(mFollowCredit, me);
@@ -365,7 +365,9 @@ void SmartAI::UpdateAI(uint32 diff)
return;
}
mFollowArrivedTimer = 1000;
- } else mFollowArrivedTimer -= diff;
+ }
+ else
+ mFollowArrivedTimer -= diff;
}
if (!UpdateVictim())
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 1db86f24e64..57a920ab56b 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -2526,10 +2526,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
// Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
HitChance += int32(m_modSpellHitChance * 100.0f);
- if (HitChance < 100)
- HitChance = 100;
- else if (HitChance > 10000)
- HitChance = 10000;
+ RoundToInterval(HitChance, 100, 10000);
int32 tmp = 10000 - HitChance;
@@ -5741,8 +5738,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// if damage is more than need or target die from damage deal finish spell
if (triggeredByAura->GetAmount() <= int32(damage) || GetHealth() <= damage)
{
- // remember guid before aura delete
- uint64 casterGuid = triggeredByAura->GetCasterGUID();
+ // remember caster before aura delete
+ Unit* caster = triggeredByAura->GetCaster();
// Remove aura (before cast for prevent infinite loop handlers)
RemoveAurasDueToSpell(triggeredByAura->GetId());
@@ -5750,7 +5747,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
uint32 spell = sSpellMgr->GetSpellWithRank(27285, dummySpell->GetRank());
// Cast finish spell (triggeredByAura already not exist!)
- if (Unit* caster = GetUnit(*this, casterGuid))
+ if (caster)
caster->CastSpell(this, spell, true, castItem);
return true; // no hidden cooldown
}
@@ -5765,14 +5762,14 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// if damage is more than need deal finish spell
if (triggeredByAura->GetAmount() <= int32(damage))
{
- // remember guid before aura delete
- uint64 casterGuid = triggeredByAura->GetCasterGUID();
+ // remember caster before aura delete
+ Unit* caster = triggeredByAura->GetCaster();
// Remove aura (before cast for prevent infinite loop handlers)
RemoveAurasDueToSpell(triggeredByAura->GetId());
// Cast finish spell (triggeredByAura already not exist!)
- if (Unit* caster = GetUnit(*this, casterGuid))
+ if (caster)
caster->CastSpell(this, 32865, true, castItem);
return true; // no hidden cooldown
}
@@ -15933,7 +15930,7 @@ void Unit::RestoreFaction()
Unit* Unit::GetRedirectThreatTarget()
{
- return _redirectThreadInfo.GetTargetGUID() ? GetUnit(*this, _redirectThreadInfo.GetTargetGUID()) : NULL;
+ return _redirectThreadInfo.GetTargetGUID() ? ObjectAccessor::GetUnit(*this, _redirectThreadInfo.GetTargetGUID()) : NULL;
}
bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 8f3fc6bd873..d34c66f7893 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -2001,7 +2001,7 @@ class Unit : public WorldObject
int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const;
int32 CalcSpellDuration(SpellInfo const* spellProto);
int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask);
- void ModSpellCastTime(SpellInfo const* spellProto, int32 & castTime, Spell* spell=NULL);
+ void ModSpellCastTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = NULL);
float CalculateLevelPenalty(SpellInfo const* spellProto) const;
void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 51a04749c30..149f422554a 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -998,8 +998,7 @@ int32 Aura::CalcDispelChance(Unit* auraTarget, bool offensive) const
if (offensive && auraTarget)
resistChance += auraTarget->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
- resistChance = resistChance < 0 ? 0 : resistChance;
- resistChance = resistChance > 100 ? 100 : resistChance;
+ RoundToInterval(resistChance, 0, 100);
return 100 - resistChance;
}
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 6f1df2560dc..f7940b2b8da 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -74,9 +74,9 @@ class _SpellScript
EffectHook(uint8 _effIndex);
virtual ~EffectHook() { }
- uint8 GetAffectedEffectsMask(SpellInfo const* spellEntry);
- bool IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndex);
- virtual bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex) = 0;
+ uint8 GetAffectedEffectsMask(SpellInfo const* spellInfo);
+ bool IsEffectAffected(SpellInfo const* spellInfo, uint8 effIndex);
+ virtual bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) = 0;
std::string EffIndexToString();
protected:
uint8 effIndex;
@@ -86,7 +86,7 @@ class _SpellScript
{
public:
EffectNameCheck(uint16 _effName) { effName = _effName; }
- bool Check(SpellInfo const* spellEntry, uint8 effIndex);
+ bool Check(SpellInfo const* spellInfo, uint8 effIndex);
std::string ToString();
private:
uint16 effName;
@@ -96,7 +96,7 @@ class _SpellScript
{
public:
EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
- bool Check(SpellInfo const* spellEntry, uint8 effIndex);
+ bool Check(SpellInfo const* spellInfo, uint8 effIndex);
std::string ToString();
private:
uint16 effAurName;
@@ -114,7 +114,7 @@ class _SpellScript
virtual void Register() = 0;
// Function called on server startup, if returns false script won't be used in core
// use for: dbc/template data presence/correctness checks
- virtual bool Validate(SpellInfo const* /*spellEntry*/) { return true; }
+ virtual bool Validate(SpellInfo const* /*spellInfo*/) { return true; }
// Function called when script is created, if returns false script will be unloaded afterwards
// use for: initializing local script variables (DO NOT USE CONSTRUCTOR FOR THIS PURPOSE!)
virtual bool Load() { return true; }
@@ -185,7 +185,7 @@ class SpellScript : public _SpellScript
public:
EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
std::string ToString();
- bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex);
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex);
void Call(SpellScript* spellScript, SpellEffIndex effIndex);
private:
SpellEffectFnType pEffectHandlerScript;
@@ -204,7 +204,7 @@ class SpellScript : public _SpellScript
{
public:
TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area);
- bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex);
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex);
std::string ToString();
protected:
uint16 targetType;
@@ -488,7 +488,7 @@ class AuraScript : public _SpellScript
public:
EffectBase(uint8 _effIndex, uint16 _effName);
std::string ToString();
- bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex);
+ bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex);
};
class EffectPeriodicHandler : public EffectBase
{