Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-18-2015, 12:52 PM
iluvseq
Sarnak
 
Join Date: Aug 2009
Location: Somewhere
Posts: 53
Default 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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:28 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3