Thread Tools Display Modes
08/19/14, 12:43 PM   #1
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
GetParentKeepForKeep replacement?

Is there any? This function is in the wiki, but it has been removed http://www.esoui.com/forums/showthre...entKeepForKeep

For example when I get EVENT_KEEP_UNDER_ATTACK_CHANGED on a lumbermill, I want to know the ID of the keep it belongs to. Of course I can build a lookup table using GetResourceKeepForKeep, but that'd be stupid if there was a function for just that
  Reply With Quote
08/19/14, 05:23 PM   #2
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
Is there any? This function is in the wiki, but it has been removed http://www.esoui.com/forums/showthre...entKeepForKeep

For example when I get EVENT_KEEP_UNDER_ATTACK_CHANGED on a lumbermill, I want to know the ID of the keep it belongs to. Of course I can build a lookup table using GetResourceKeepForKeep, but that'd be stupid if there was a function for just that
I don't know anything about the pvp stuff, Just trying to spark an idea here.

But doesn't the event itself give it to you as the 2nd parameter (integer keepId)? Or is the lumbermill considered a keep and its that ID it gives you?
Lua Code:
  1. EVENT_KEEP_UNDER_ATTACK_CHANGED (integer eventCode, integer keepId, integer battlegroundContext, bool underAttack)

If that keep ID refers to the lumbermill, then I am thinking do you have to be within a certain vicinity (close to the keep/lumbermill) to actually receive that event? If so then the closest keep is probably the parent one you are looking for, so could you use this:
Lua Code:
  1. local parentKeepId = GetClosestKeepOfType(keepType, resourceType, battlegroundContext)
  2.  
  3. -- maybe with these parameters --
  4. local parentKeepId = GetClosestKeepOfType(KEEPTYPE_KEEP, RESOURCETYPE_NONE, battlegroundContext)
  5. -- I dont know what battlegroundContext is, but it gets passed to you in your event --

If its not KEEPTYPE_KEEP, maybe one of these:
Lua Code:
  1. KEEPTYPE_ARTIFACT_GATE
  2. KEEPTYPE_ARTIFACT_KEEP
  3. KEEPTYPE_BORDER_KEEP
  4. KEEPTYPE_KEEP
  5. KEEPTYPE_OUTPOST
  6. KEEPTYPE_RESOURCE
  Reply With Quote
08/19/14, 05:45 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
Is there any? This function is in the wiki, but it has been removed http://www.esoui.com/forums/showthre...entKeepForKeep

For example when I get EVENT_KEEP_UNDER_ATTACK_CHANGED on a lumbermill, I want to know the ID of the keep it belongs to. Of course I can build a lookup table using GetResourceKeepForKeep, but that'd be stupid if there was a function for just that
Or this is probably better, it looks like it would work (again I've never looked at pvp stuff before so I could be wrong).
Lua Code:
  1. -- When the event fires, call this function & pass it keepId (given to you by the event) --
  2. local function GetParentKeep(_keepId)
  3.     local iKeepResourceType = GetKeepResourceType(_keepId)
  4.    
  5.     -- If the resourceType is none then I'm guessing that makes it the main (parent) keep? --
  6.     -- so do this to check if its a main (parent) keep under attack --
  7.     if iKeepResourceType ==  RESOURCETYPE_NONE then
  8.         return _keepId
  9.     end
  10.    
  11.     -- Otherwise it is a resource keep so we need to find out which main (parent) --
  12.     -- keep it belongs too --
  13.    
  14.     local iNumKeeps = GetNumKeeps()
  15.    
  16.     for iParentKeepId = 1, iNumKeeps do
  17.         local resourceKeepId = GetResourceKeepForKeep(iParentKeepId, iKeepResourceType)
  18.         -- GetResourceKeepForKeep(integer parentKeepId, integer resourceType)
  19.         --     Returns: integer keepId
  20.  
  21.         if resourceKeepId = _keepId then
  22.             return iParentKeepId
  23.         end
  24.     end
  25. end

Last edited by circonian : 08/19/14 at 05:53 PM.
  Reply With Quote
08/19/14, 06:40 PM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
You get the event from all over the map, and for resources the keepId argument is the Id of the resource. So your function is basically what I'll need to do, or fill it into a lookup table once and then use that. I don't understand why they removed it
  Reply With Quote
08/19/14, 06:48 PM   #5
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
For completeness, keepIds are not completely contiguous, so looping requires one more step:
Lua Code:
  1. for i = 1, GetNumKeeps() do
  2.    local keepId = GetKeepKeysByIndex(i)
  3.    ...
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » GetParentKeepForKeep replacement?


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

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