From 31be467b2e9698a05fde5525a6ce758ab2d940f5 Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 6 Nov 2008 10:36:40 -0600 Subject: [PATCH] [svn] Check combat reach in GetRandomContactPoint() until find out why some units have invalid combat reach. --HG-- branch : trunk --- src/game/Unit.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 00cd8694b35..aec00fa2b82 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -428,11 +428,19 @@ 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); + //assert(GetCombatReach() > 0.1); + float combat_reach = GetCombatReach(); + if(combat_reach < 0.1) + { + 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; + } uint32 attacker_number = getAttackers().size(); if(attacker_number > 0) --attacker_number; GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm() - , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / GetCombatReach() / 3 : 0)); + , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0)); } void Unit::RemoveSpellsCausingAura(AuraType auraType)