*Update spell range calculation. Original patch by QAston.
--HG-- branch : trunk
This commit is contained in:
+1
-1
@@ -4406,7 +4406,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player)
|
||||
player->m_form = FORM_NONE;
|
||||
|
||||
player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE );
|
||||
player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_WORLD_OBJECT_SIZE );
|
||||
player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH );
|
||||
|
||||
player->setFactionForRace(player->getRace());
|
||||
|
||||
|
||||
+2
-1
@@ -34,11 +34,12 @@
|
||||
|
||||
#define CONTACT_DISTANCE 0.5f
|
||||
#define INTERACTION_DISTANCE 5.0f
|
||||
#define ATTACK_DISTANCE 5.0f
|
||||
#define MAX_VISIBILITY_DISTANCE (5*SIZE_OF_GRID_CELL/2.0f) // max distance for visible object show, limited by active zone for player based at cell size (active zone = 5x5 cells)
|
||||
#define DEFAULT_VISIBILITY_DISTANCE (SIZE_OF_GRID_CELL) // default visible distance
|
||||
|
||||
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
|
||||
#define DEFAULT_COMBAT_REACH 1.5f
|
||||
#define ATTACK_DISTANCE (5.0f - DEFAULT_COMBAT_REACH * 2) // melee range: center to center for players
|
||||
|
||||
enum TypeMask
|
||||
{
|
||||
|
||||
@@ -1050,10 +1050,10 @@ void ObjectMgr::LoadCreatureModelInfo()
|
||||
if(!mInfo)
|
||||
continue;
|
||||
|
||||
if(mInfo->combat_reach < 0.5f)
|
||||
if(mInfo->combat_reach < 0.1f)
|
||||
{
|
||||
//sLog.outErrorDb("Creature model (Entry: %u) has invalid combat reach (%f), setting it to 0.5", mInfo->modelid, mInfo->combat_reach);
|
||||
const_cast<CreatureModelInfo*>(mInfo)->combat_reach = 0.5f;
|
||||
const_cast<CreatureModelInfo*>(mInfo)->combat_reach = DEFAULT_COMBAT_REACH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -546,7 +546,7 @@ bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_,
|
||||
}
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE );
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_WORLD_OBJECT_SIZE );
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH );
|
||||
|
||||
switch(gender)
|
||||
{
|
||||
|
||||
@@ -200,13 +200,6 @@ enum SpellCategory
|
||||
SPELL_CATEGORY_DRINK = 59,
|
||||
};
|
||||
|
||||
enum SpellRangeFlag
|
||||
{
|
||||
SPELL_RANGE_DEFAULT = 0,
|
||||
SPELL_RANGE_MEELE = 1, //unused
|
||||
SPELL_RANGE_RANGED = 2, //hunters' shoots, auto shoot, shoot, deadly throw, throw
|
||||
};
|
||||
|
||||
// ***********************************
|
||||
// Spell Attributes definitions
|
||||
// ***********************************
|
||||
|
||||
+23
-5
@@ -4670,19 +4670,35 @@ bool Spell::CanAutoCast(Unit* target)
|
||||
|
||||
uint8 Spell::CheckRange(bool strict)
|
||||
{
|
||||
float range_mod;
|
||||
//float range_mod;
|
||||
|
||||
// self cast doesn't need range checking -- also for Starshards fix
|
||||
if (m_spellInfo->rangeIndex == 1) return 0;
|
||||
|
||||
if (strict) //add radius of caster
|
||||
// i do not know why we need this
|
||||
/*if (strict) //add radius of caster
|
||||
range_mod = 1.25;
|
||||
else //add radius of caster and ~5 yds "give"
|
||||
range_mod = 6.25;
|
||||
range_mod = 6.25;*/
|
||||
|
||||
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
|
||||
float max_range = GetSpellMaxRange(srange) + range_mod;
|
||||
float min_range = GetSpellMinRange(srange);
|
||||
float max_range, min_range;
|
||||
float range_type = GetSpellRangeType(srange);
|
||||
if(range_type == SPELL_RANGE_DEFAULT)
|
||||
{
|
||||
max_range = GetSpellMaxRange(srange);// + range_mod;
|
||||
min_range = GetSpellMinRange(srange);
|
||||
}
|
||||
else if(range_type == SPELL_RANGE_MELEE)
|
||||
{
|
||||
max_range = ATTACK_DISTANCE;
|
||||
min_range = GetSpellMinRange(srange);
|
||||
}
|
||||
else
|
||||
{
|
||||
max_range = GetSpellMaxRange(srange);// + range_mod;
|
||||
min_range = ATTACK_DISTANCE;
|
||||
}
|
||||
|
||||
if(Player* modOwner = m_caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this);
|
||||
@@ -4694,8 +4710,10 @@ uint8 Spell::CheckRange(bool strict)
|
||||
// distance from target center in checks
|
||||
if(!m_caster->IsWithinCombatDist(target, max_range))
|
||||
return SPELL_FAILED_OUT_OF_RANGE; //0x5A;
|
||||
|
||||
if(min_range && m_caster->IsWithinCombatDist(target, min_range)) // skip this check if min_range = 0
|
||||
return SPELL_FAILED_TOO_CLOSE;
|
||||
|
||||
if( m_caster->GetTypeId() == TYPEID_PLAYER &&
|
||||
(m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc( M_PI, target ) )
|
||||
return SPELL_FAILED_UNIT_NOT_INFRONT;
|
||||
|
||||
@@ -69,6 +69,13 @@ enum SpellCastFlags
|
||||
CAST_FLAG_UNKNOWN3 = 0x00000100
|
||||
};
|
||||
|
||||
enum SpellRangeFlag
|
||||
{
|
||||
SPELL_RANGE_DEFAULT = 0,
|
||||
SPELL_RANGE_MELEE = 1, //melee
|
||||
SPELL_RANGE_RANGED = 2, //hunter range and ranged weapon
|
||||
};
|
||||
|
||||
enum SpellNotifyPushType
|
||||
{
|
||||
PUSH_IN_FRONT,
|
||||
|
||||
@@ -90,16 +90,6 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell)
|
||||
|
||||
return (castTime > 0) ? uint32(castTime) : 0;
|
||||
}
|
||||
float GetSpellMinRange(SpellRangeEntry const *range)
|
||||
{
|
||||
if (!range)
|
||||
return 0;
|
||||
if (!range->minRange)
|
||||
if (range->flags==SPELL_RANGE_RANGED)
|
||||
//return 5.0;
|
||||
return 2.0;//this is a hack, needs fix
|
||||
return range->minRange;
|
||||
}
|
||||
|
||||
bool IsPassiveSpell(uint32 spellId)
|
||||
{
|
||||
|
||||
+2
-1
@@ -272,8 +272,9 @@ SpellSpecific GetSpellSpecific(uint32 spellId);
|
||||
// Different spell properties
|
||||
inline float GetSpellRadius(SpellRadiusEntry const *radius) { return (radius ? radius->Radius : 0); }
|
||||
uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL);
|
||||
float GetSpellMinRange(SpellRangeEntry const *range);
|
||||
inline float GetSpellMinRange(SpellRangeEntry const *range) { return (range ? range->minRange : 0); }
|
||||
inline float GetSpellMaxRange(SpellRangeEntry const *range) { return (range ? range->maxRange : 0); }
|
||||
inline uint32 GetSpellRangeType(SpellRangeEntry const *range) { return (range ? range->type : 0); }
|
||||
inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { return spellInfo->RecoveryTime > spellInfo->CategoryRecoveryTime ? spellInfo->RecoveryTime : spellInfo->CategoryRecoveryTime; }
|
||||
int32 GetSpellDuration(SpellEntry const *spellInfo);
|
||||
int32 GetSpellMaxDuration(SpellEntry const *spellInfo);
|
||||
|
||||
+2
-3
@@ -443,14 +443,13 @@ bool Unit::IsWithinCombatDist(Unit *obj, float dist2compare) const
|
||||
|
||||
void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const
|
||||
{
|
||||
//assert(GetCombatReach() > 0.1);
|
||||
float combat_reach = GetCombatReach();
|
||||
if(combat_reach < 0.1)
|
||||
if(combat_reach < 0.1) // sometimes bugged for players
|
||||
{
|
||||
sLog.outError("Unit %u (Type: %u) has invalid combat_reach %f",GetGUIDLow(),GetTypeId(),combat_reach);
|
||||
if(GetTypeId() == TYPEID_UNIT)
|
||||
sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry());
|
||||
combat_reach = 0.5;
|
||||
combat_reach = DEFAULT_COMBAT_REACH;
|
||||
}
|
||||
uint32 attacker_number = getAttackers().size();
|
||||
if(attacker_number > 0) --attacker_number;
|
||||
|
||||
@@ -774,6 +774,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
bool canReachWithAttack(Unit *pVictim) const;
|
||||
float GetCombatReach() const { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
|
||||
bool IsWithinCombatDist(Unit *obj, float dist2compare) const;
|
||||
bool IsWithinMeleeRange(Unit *obj) const { return IsWithinCombatDist(obj, ATTACK_DISTANCE); }
|
||||
void GetRandomContactPoint( const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const;
|
||||
uint32 m_extraAttacks;
|
||||
bool m_canDualWield;
|
||||
|
||||
Reference in New Issue
Block a user