Fork me on GitHub
[Classic] Mobs stop chasing and stare blankly when they cannot reach you
Post: #1
Hello everyone!

I recently had a problem with my classic server. In some cases, like youarestanding on a tallpillar, or somewhere elsethe mobscan not reach you, the mobswill stop chasing andstanding staringyou. Thenyou can easilykill them without any hassle. Big Grin

May Iask for some help, how to avoid this situation? For example.Letthe mobs returnto their original position or dosomething instead ofstanding and waitfor dead.

Thank you for help!
Reply
Post: #2
I think I have resolved this problem partially.

Code:
bool Unit::CanReachWithMeleeAttack(Unit const* pVictim, float flat_mod /*= 0.0f*/) const
{
  if (GetTypeId() != TYPEID_PLAYER &&   // if the mob
        movespline->Finalized() &&          // he want to melee attack but stop moving
        !isInRoots())                          // except some spell trapped him
    return true;                     // let him can.

  MANGOS_ASSERT(pVictim);

  float reach = GetCombatReach(pVictim, true, flat_mod);

  // This check is not related to bounding radius
  float dx = GetPositionX() - pVictim->GetPositionX();
  float dy = GetPositionY() - pVictim->GetPositionY();
  float dz = GetPositionZ() - pVictim->GetPositionZ();

  return dx * dx + dy * dy + dz * dz < reach * reach;
}

I know this way is ugly and not perfect, but it resolved my problem.

If anyone has more nice way, or some improvement, show me please.I appreciate. Big Grin
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Question Make creature stop and stay on waypoint stavaren 4 698 03-02-2017, 04:22 PM
Last Post: stavaren
  [Classic] Implement cross faction raid and battleground decadewow 0 548 12-17-2016, 11:33 AM
Last Post: decadewow
  [Classic] Debuff Limit (8/16) Settings/Code?.. hunter9 2 665 12-13-2016, 05:14 PM
Last Post: namreeb
  [Classic] RewXPId Zooke 1 886 06-15-2016, 04:54 PM
Last Post: Tobschinski
  [Classic] Crushing Blows. Zooke 5 1,518 06-01-2016, 09:30 PM
Last Post: Beerfish
  Classic Auto join chat, trading channels..? Jefferson 0 799 04-13-2016, 07:35 AM
Last Post: Jefferson
  TBC Core/Database support for spawning different mobs on spawn? Blizzlike 5 2,928 10-17-2015, 07:24 AM
Last Post: Blizzlike
  Midsummer Festival (classic) Screenshots/Videos/Data needed Zingzah 4 2,434 07-10-2015, 10:10 AM
Last Post: Zingzah
  (Classic) Battleground WSG Sound Problem kallefleetwood123 3 2,748 03-02-2015, 11:07 AM
Last Post: cala
  [classic] Honor ID Metal 1 1,945 01-22-2015, 07:26 AM
Last Post: Metal

Forum Jump:


Users browsing this thread: 1 Guest(s)

Continued MaNGOS | Return to Top | | Lite (Archive) Mode | RSS Syndication