aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Unit
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-07-06 00:05:13 +0200
committerShauren <shauren.trinity@gmail.com>2016-07-06 00:05:13 +0200
commit70137b8f3aae7c875f1fc0b1643d80aece933104 (patch)
tree2ffc5d94bca4988dd5ba5af1a4bd3f077de5e238 /src/server/game/Entities/Unit
parentf7883bd5251a759da1ca8be3ba6f6cead36723ec (diff)
parenta7fcae93280d5d8010c4fe8139ce1925a92c8744 (diff)
Merge branch '6.x' of https://github.com/TrinityCore/TrinityCore into legion
Diffstat (limited to 'src/server/game/Entities/Unit')
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp33
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp58
-rw-r--r--src/server/game/Entities/Unit/Unit.h70
3 files changed, 95 insertions, 66 deletions
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 035bc4d8703..2c9da5cf672 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -163,7 +163,10 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply)
ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply);
if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
+ {
UpdateAttackPowerAndDamage();
+ UpdateAttackPowerAndDamage(true);
+ }
}
void Player::UpdateSpellDamageAndHealingBonus()
@@ -177,7 +180,10 @@ void Player::UpdateSpellDamageAndHealingBonus()
SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
+ {
UpdateAttackPowerAndDamage();
+ UpdateAttackPowerAndDamage(true);
+ }
}
bool Player::UpdateAllStats()
@@ -313,19 +319,24 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
index = UNIT_FIELD_RANGED_ATTACK_POWER;
index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MOD_POS;
index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
- val2 = (level + std::max(GetStat(STAT_AGILITY), 0.0f)) * entry->RangedAttackPowerPerAgility;
}
- else if (!HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
+
+ if (!HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT))
{
- float strengthValue = std::max(GetStat(STAT_STRENGTH) * entry->AttackPowerPerStrength, 0.0f);
- float agilityValue = std::max(GetStat(STAT_AGILITY) * entry->AttackPowerPerAgility, 0.0f);
+ if (!ranged)
+ {
+ float strengthValue = std::max(GetStat(STAT_STRENGTH) * entry->AttackPowerPerStrength, 0.0f);
+ float agilityValue = std::max(GetStat(STAT_AGILITY) * entry->AttackPowerPerAgility, 0.0f);
- SpellShapeshiftFormEntry const* form = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
- // Directly taken from client, SHAPESHIFT_FLAG_AP_FROM_STRENGTH ?
- if (form && form->Flags & 0x20)
- agilityValue += std::max(GetStat(STAT_AGILITY) * entry->AttackPowerPerStrength, 0.0f);
+ SpellShapeshiftFormEntry const* form = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
+ // Directly taken from client, SHAPESHIFT_FLAG_AP_FROM_STRENGTH ?
+ if (form && form->Flags & 0x20)
+ agilityValue += std::max(GetStat(STAT_AGILITY) * entry->AttackPowerPerStrength, 0.0f);
- val2 = strengthValue + agilityValue;
+ val2 = strengthValue + agilityValue;
+ }
+ else
+ val2 = (level + std::max(GetStat(STAT_AGILITY), 0.0f)) * entry->RangedAttackPowerPerAgility;
}
else
{
@@ -416,12 +427,12 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
if (Item* weapon = GetWeaponForAttack(BASE_ATTACK, true))
weaponSpeed = weapon->GetTemplate()->GetDelay() / 1000;
- if (GetShapeshiftForm() == FORM_CAT)
+ if (GetShapeshiftForm() == FORM_CAT_FORM)
{
weaponMinDamage = weaponMinDamage / weaponSpeed;
weaponMaxDamage = weaponMaxDamage / weaponSpeed;
}
- else if (GetShapeshiftForm() == FORM_BEAR)
+ else if (GetShapeshiftForm() == FORM_BEAR_FORM)
{
weaponMinDamage = weaponMinDamage / weaponSpeed + weaponMinDamage / 2.5;
weaponMaxDamage = weaponMinDamage / weaponSpeed + weaponMaxDamage / 2.5;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index e117a859da6..abb2f8a9d07 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -484,12 +484,6 @@ void Unit::resetAttackTimer(WeaponAttackType type)
m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
}
-float Unit::GetMeleeReach() const
-{
- float reach = m_floatValues[UNIT_FIELD_COMBATREACH];
- return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH;
-}
-
bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
{
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
@@ -516,7 +510,7 @@ bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const
float dz = GetPositionZMinusOffset() - obj->GetPositionZMinusOffset();
float distsq = dx*dx + dy*dy + dz*dz;
- float sizefactor = GetMeleeReach() + obj->GetMeleeReach();
+ float sizefactor = GetCombatReach() + obj->GetCombatReach() + 4.0f / 3.0f;
float maxdist = dist + sizefactor;
return distsq < maxdist * maxdist;
@@ -3308,7 +3302,7 @@ void Unit::_RemoveNoStackAurasDueToAura(Aura* aura)
{
Unit* caster = aura->GetCaster();
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
- Spell::SendCastResult(caster->ToPlayer(), aura->GetSpellInfo(), aura->GetSpellInfo()->GetSpellXSpellVisualId(caster->GetMap()->GetDifficultyID()), aura->GetCastGUID(), SPELL_FAILED_AURA_BOUNCED);
+ Spell::SendCastResult(caster->ToPlayer(), aura->GetSpellInfo(), aura->GetSpellXSpellVisualId(), aura->GetCastGUID(), SPELL_FAILED_AURA_BOUNCED);
}
aura->Remove();
@@ -6183,10 +6177,10 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
switch (GetShapeshiftForm())
{
case FORM_NONE: trigger_spell_id = 37344; break;
- case FORM_CAT: trigger_spell_id = 37341; break;
- case FORM_BEAR: trigger_spell_id = 37340; break;
- case FORM_TREE: trigger_spell_id = 37342; break;
- case FORM_MOONKIN: trigger_spell_id = 37343; break;
+ case FORM_CAT_FORM: trigger_spell_id = 37341; break;
+ case FORM_BEAR_FORM: trigger_spell_id = 37340; break;
+ case FORM_TREE_OF_LIFE: trigger_spell_id = 37342; break;
+ case FORM_MOONKIN_FORM: trigger_spell_id = 37343; break;
default:
return false;
}
@@ -6197,8 +6191,8 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
{
switch (GetShapeshiftForm())
{
- case FORM_CAT: trigger_spell_id = 67355; break;
- case FORM_BEAR: trigger_spell_id = 67354; break;
+ case FORM_CAT_FORM: trigger_spell_id = 67355; break;
+ case FORM_BEAR_FORM: trigger_spell_id = 67354; break;
default:
return false;
}
@@ -10660,7 +10654,7 @@ void Unit::SetShapeshiftForm(ShapeshiftForm form)
bool Unit::IsInFeralForm() const
{
ShapeshiftForm form = GetShapeshiftForm();
- return form == FORM_CAT || form == FORM_BEAR;
+ return form == FORM_CAT_FORM || form == FORM_BEAR_FORM;
}
bool Unit::IsInDisallowedMountForm() const
@@ -11582,6 +11576,7 @@ bool InitTriggerAuraData()
isAlwaysTriggeredAura[i] = false;
}
isTriggerAura[SPELL_AURA_PROC_ON_POWER_AMOUNT] = true;
+ isTriggerAura[SPELL_AURA_PROC_ON_POWER_AMOUNT_2] = true;
isTriggerAura[SPELL_AURA_DUMMY] = true;
isTriggerAura[SPELL_AURA_MOD_CONFUSE] = true;
isTriggerAura[SPELL_AURA_MOD_THREAT] = true;
@@ -11906,6 +11901,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
break;
}
case SPELL_AURA_PROC_ON_POWER_AMOUNT:
+ case SPELL_AURA_PROC_ON_POWER_AMOUNT_2:
{
triggeredByAura->HandleProcTriggerSpellOnPowerAmountAuraProc(aurApp, eventInfo);
takeCharges = true;
@@ -13106,7 +13102,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
// restore for use at real death
victim->SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId);
- // FORM_SPIRITOFREDEMPTION and related auras
+ // FORM_SPIRIT_OF_REDEMPTION and related auras
victim->CastSpell(victim, 27827, true, NULL, aurEff);
spiritOfRedemption = true;
break;
@@ -14195,7 +14191,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const
{
switch (form)
{
- case FORM_CAT:
+ case FORM_CAT_FORM:
// Based on Hair color
if (getRace() == RACE_NIGHTELF)
{
@@ -14343,7 +14339,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const
return 892;
else
return 8571;
- case FORM_BEAR:
+ case FORM_BEAR_FORM:
// Based on Hair color
if (getRace() == RACE_NIGHTELF)
{
@@ -14491,17 +14487,17 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const
return 2281;
else
return 2289;
- case FORM_FLIGHT:
+ case FORM_FLIGHT_FORM:
if (Player::TeamForRace(getRace()) == ALLIANCE)
return 20857;
return 20872;
- case FORM_FLIGHT_EPIC:
+ case FORM_FLIGHT_FORM_EPIC:
if (Player::TeamForRace(getRace()) == ALLIANCE)
return (getRace() == RACE_WORGEN ? 37729 : 21243);
if (getRace() == RACE_TROLL)
return 37730;
return 21244;
- case FORM_MOONKIN:
+ case FORM_MOONKIN_FORM:
switch (getRace())
{
case RACE_NIGHTELF:
@@ -14516,7 +14512,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const
break;
}
break;
- case FORM_GHOSTWOLF:
+ case FORM_GHOST_WOLF:
if (HasAura(58135)) //! Glyph of Arctic Wolf
return 27312;
default:
@@ -16038,6 +16034,24 @@ SpellInfo const* Unit::GetCastSpellInfo(SpellInfo const* spellInfo) const
return spellInfo;
}
+uint32 Unit::GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const
+{
+ Unit::AuraEffectList const& visualOverrides = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_SPELL_VISUAL);
+ for (AuraEffect const* effect : visualOverrides)
+ {
+ if (uint32(effect->GetMiscValue()) == spellInfo->Id)
+ {
+ if (SpellInfo const* visualSpell = sSpellMgr->GetSpellInfo(effect->GetMiscValueB()))
+ {
+ spellInfo = visualSpell;
+ break;
+ }
+ }
+ }
+
+ return spellInfo->GetSpellXSpellVisualId(this);
+}
+
struct CombatLogSender
{
WorldObject const* i_source;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 209958f430b..8dbe00d54c2 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -259,37 +259,40 @@ enum UnitBytes1_Flags
// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2
enum ShapeshiftForm
{
- FORM_NONE = 0x00,
- FORM_CAT = 0x01,
- FORM_TREE = 0x02,
- FORM_TRAVEL = 0x03,
- FORM_AQUA = 0x04,
- FORM_BEAR = 0x05,
- FORM_AMBIENT = 0x06,
- FORM_GHOUL = 0x07,
- FORM_DIREBEAR = 0x08, // Removed in 4.0.1
- FORM_STEVES_GHOUL = 0x09,
- FORM_THARONJA_SKELETON = 0x0A,
- FORM_TEST_OF_STRENGTH = 0x0B,
- FORM_BLB_PLAYER = 0x0C,
- FORM_SHADOW_DANCE = 0x0D,
- FORM_CREATUREBEAR = 0x0E,
- FORM_CREATURECAT = 0x0F,
- FORM_GHOSTWOLF = 0x10,
- FORM_BATTLESTANCE = 0x11,
- FORM_DEFENSIVESTANCE = 0x12,
- FORM_BERSERKERSTANCE = 0x13,
- FORM_TEST = 0x14,
- FORM_ZOMBIE = 0x15,
- FORM_METAMORPHOSIS = 0x16,
- FORM_UNDEAD = 0x19,
- FORM_MASTER_ANGLER = 0x1A,
- FORM_FLIGHT_EPIC = 0x1B,
- FORM_SHADOW = 0x1C,
- FORM_FLIGHT = 0x1D,
- FORM_STEALTH = 0x1E,
- FORM_MOONKIN = 0x1F,
- FORM_SPIRITOFREDEMPTION = 0x20
+ FORM_NONE = 0,
+ FORM_CAT_FORM = 1,
+ FORM_TREE_OF_LIFE = 2,
+ FORM_TRAVEL_FORM = 3,
+ FORM_AQUATIC_FORM = 4,
+ FORM_BEAR_FORM = 5,
+ FORM_AMBIENT = 6,
+ FORM_GHOUL = 7,
+ FORM_DIRE_BEAR_FORM = 8,
+ FORM_CRANE_STANCE = 9,
+ FORM_THARONJA_SKELETON = 10,
+ FORM_DARKMOON_TEST_OF_STRENGTH = 11,
+ FORM_BLB_PLAYER = 12,
+ FORM_SHADOW_DANCE = 13,
+ FORM_CREATURE_BEAR = 14,
+ FORM_CREATURE_CAT = 15,
+ FORM_GHOST_WOLF = 16,
+ FORM_BATTLE_STANCE = 17,
+ FORM_DEFENSIVE_STANCE = 18,
+ FORM_BERSERKER_STANCE = 19,
+ FORM_SERPENT_STANCE = 20,
+ FORM_ZOMBIE = 21,
+ FORM_METAMORPHOSIS = 22,
+ FORM_OX_STANCE = 23,
+ FORM_TIGER_STANCE = 24,
+ FORM_UNDEAD = 25,
+ FORM_FRENZY = 26,
+ FORM_FLIGHT_FORM_EPIC = 27,
+ FORM_SHADOWFORM = 28,
+ FORM_FLIGHT_FORM = 29,
+ FORM_STEALTH = 30,
+ FORM_MOONKIN_FORM = 31,
+ FORM_SPIRIT_OF_REDEMPTION = 32,
+ FORM_GLADIATOR_STANCE = 33
};
// low byte (0 from 0..3) of UNIT_FIELD_BYTES_2
@@ -734,7 +737,8 @@ enum UnitFlags2
UNIT_FLAG2_DISABLE_TURN = 0x00008000,
UNIT_FLAG2_UNK2 = 0x00010000,
UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000, // Plays special death animation upon death
- UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000 // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL
+ UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL
+ UNIT_FLAG2_NO_ACTIONS = 0x00800000
};
/// Non Player Character flags
@@ -1370,7 +1374,6 @@ class TC_GAME_API Unit : public WorldObject
bool CanDualWield() const { return m_canDualWield; }
virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
float GetCombatReach() const { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
- float GetMeleeReach() const;
bool IsWithinCombatRange(const Unit* obj, float dist2compare) const;
bool IsWithinMeleeRange(const Unit* obj, float dist = MELEE_RANGE) const;
void GetRandomContactPoint(const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const;
@@ -1936,6 +1939,7 @@ class TC_GAME_API Unit : public WorldObject
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
int32 GetCurrentSpellCastTime(uint32 spell_id) const;
virtual SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const;
+ uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const;
SpellHistory* GetSpellHistory() { return _spellHistory; }
SpellHistory const* GetSpellHistory() const { return _spellHistory; }