Thread Tools Display Modes
05/06/17, 10:34 AM   #1
patrick_smyth
AddOn Author - Click to view addons
Join Date: Oct 2016
Posts: 9
How do I detect jump fail?

Hi,

I need to detect when one of these jumps fails:
FastTravelToNode()
JumpToGroupLeader()
JumpToGroupMember()
JumpToFriend()
JumpToGuildMember()
I have tried registering for these events:
EVENT_JUMP_FAILED
EVENT_REQUIREMENTS_FAIL
EVENT_ABILITY_REQUIREMENTS_FAIL
My routine never seems to get called even when the jump fails.
A message is usually displayed in the chat but I need to detect it in the program.
Does anyone know what I am doing wrong?
  Reply With Quote
05/06/17, 10:47 AM   #2
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
I'm not on to test, but this one EVENT_JUMP_FAILED should do it. Post your code that uses that one.
  Reply With Quote
05/06/17, 06:16 PM   #3
patrick_smyth
AddOn Author - Click to view addons
Join Date: Oct 2016
Posts: 9
I thought it was a bit large to do this and I have edited to cut down the size but here is part one:
Code:
JumpBlock = {
    name = "TJump",
    oldZone = "",
    reason = JUMP_SUCCESS,
    eventCode = 0,
    JumpState = JUMP_STATE_IDLE
}

local function FailedJump(eventCode, reason)
    -- Failed Jump Handler
    if JumpBlock.JumpState == JUMP_STATE_STARTED then
        JumpBlock.eventCode = eventCode
        JumpBlock.reason = reason
        JumpBlock.JumpState = JUMP_STATE_FAILED
    end
end

local function DoingJump(eventCode, abilityId)
    -- This is triggered when travel animation plays
    if (abilityId == ABILITY_ID_RECALL) and (JumpBlock.JumpState == JUMP_STATE_STARTED) then
        JumpBlock.JumpState = JUMP_STATE_DONE
    end
end

function Gotos:Initialise()
    EVENT_MANAGER:RegisterForEvent(JumpBlock.name .. "1", EVENT_JUMP_FAILED, FailedJump)
    EVENT_MANAGER:RegisterForEvent(JumpBlock.name .. "2", EVENT_REQUIREMENTS_FAIL, FailedJump)
    EVENT_MANAGER:RegisterForEvent(JumpBlock.name .. "3", EVENT_ABILITY_REQUIREMENTS_FAIL, FailedJump)
    EVENT_MANAGER:RegisterForEvent(JumpBlock.name .. "4", EVENT_ABILITY_COOLDOWN_UPDATED, DoingJump)
    EVENT_MANAGER:AddFilterForEvent(JumpBlock.name .. "4",
                                    EVENT_ABILITY_COOLDOWN_UPDATED,
                                    REGISTER_FILTER_ABILITY_ID,
                                    ABILITY_ID_RECALL)
end
I will add part two shortly.
  Reply With Quote
05/07/17, 02:13 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
The JumpTo functions do not return their status via any of the events you listed.
Instead you have to listen to EVENT_SOCIAL_ERROR which will return a SOCIAL_RESULT_, but you also need to listen to other events for some edge cases that stop the jump, but won't fire a social error.
There are quite a few cases you need to handle. I suggest you take a look at EasyTravel's JumpHelper.lua.
  Reply With Quote
05/07/17, 06:56 AM   #5
patrick_smyth
AddOn Author - Click to view addons
Join Date: Oct 2016
Posts: 9
Thanks sirinsidiator. That explains the problems I have been experiencing.
I think some of my code may resemble yours in the end.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How do I detect jump fail?

Thread Tools
Display Modes

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