ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   How do I detect jump fail? (https://www.esoui.com/forums/showthread.php?t=7020)

patrick_smyth 05/06/17 10:34 AM

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?

Rhyono 05/06/17 10:47 AM

I'm not on to test, but this one EVENT_JUMP_FAILED should do it. Post your code that uses that one.

patrick_smyth 05/06/17 06:16 PM

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.

sirinsidiator 05/07/17 02:13 AM

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.

patrick_smyth 05/07/17 06:56 AM

Thanks sirinsidiator. That explains the problems I have been experiencing.
I think some of my code may resemble yours in the end.


All times are GMT -6. The time now is 01:50 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI