EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::LUA (https://www.eqemulator.org/forums/forumdisplay.php?f=680)
-   -   Client:HateList() or determining which mobs are aggro on a client... (https://www.eqemulator.org/forums/showthread.php?t=39245)

iluvseq 01-18-2015 12:52 PM

Client:HateList() or determining which mobs are aggro on a client...
 
It appears that Client:HateList() does nothing? The #hatelist command on a client returns nothing even when the client is engaged in combat?

Is this correct?

I'm building a routine that has guards who will only assist those who have good faction. To do that, I need to get a list of all the mobs who have client on their hatelist.

The only way I can figure out how to do this is to walk GetMobList() and call CheckAggro(client) on each mob in the zone. This seems pretty heavy duty, although it does work.

Is there a better way?

My code:
Code:

local ProxRangeXY = 40
local prox_friends = {}
 
function event_spawn(e)
  eq.set_proximity(e.self:GetX() - ProxRangeXY, e.self:GetX() + ProxRangeXY, e.self:GetY() - ProxRangeXY, e.self:GetY() + ProxRangeXY)
  eq.set_timer("setprox", 2000)
  eq.set_timer("checkaggro", 500)
end
 
function event_timer(e)
  if (e.timer == "setprox") then
    eq.clear_proximity()
    eq.set_proximity(e.self:GetX() - ProxRangeXY, e.self:GetX() + ProxRangeXY, e.self:GetY() - ProxRangeXY, e.self:GetY() + ProxRangeXY)
  elseif (e.timer == "checkaggro" and #prox_friends > 0) then
    local mob_list = eq.get_entity_list():GetMobList()
    for i,friend in pairs(prox_friends) do
      for ent in mob_list.entries do
        if (ent:CheckAggro(friend) and ent:CalculateDistance(e.self:GetX(), e.self:GetY(), e.self:GetZ()) < ProxRangeXY) then
          e.self:AddToHateList(ent)
        end
      end
    end
  end
end
 
function event_enter(e)
  local faction = e.other:GetFaction(e.self)
  if (faction < 5) then  -- only help folks Amiable or better
    table.insert(prox_friends, e.other)
  end
end

function event_leave(e)
  for i, friend in pairs(prox_friends) do
    if (friend == e.other) then
      table.remove(prox_friends, i)
    end
  end
end


joligario 01-18-2015 01:01 PM

Does a client have a hatelist?

iluvseq 01-18-2015 02:12 PM

That's my question!

There are methods for it throughout the code, but it doesn't seem to ever return anything, so I'm guessing it does not.

ghanja 01-18-2015 02:39 PM

Quote:

Originally Posted by iluvseq (Post 236995)
That's my question!

There are methods for it throughout the code, but it doesn't seem to ever return anything, so I'm guessing it does not.

I never thought to see how a PC is handled when they are charmed. When charmed do they gain their own hatelist or does the NPC having done the charming use its hatelist to decide who the charmed PC attacks, etc?

Your post has me interested now, just wish I were in a position to look.


All times are GMT -4. The time now is 06:15 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.