ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   How to Detect Player/Mount Sprint Start/Stop (https://www.esoui.com/forums/showthread.php?t=8438)

scorpius2k1 04/02/19 09:58 AM

How to Detect Player/Mount Sprint Start/Stop
 
How would I go about detecting when the player starts/stops sprinting whether they are mounted or not? :confused:

Thanks in advance for any guidance!

Rhyono 04/02/19 10:02 AM

I think ACTION_RESULT_SPRINTING can be returned by EVENT_COMBAT_EVENT, but I don't know if that works outside of combat. As for mounted sprinting: maybe just check if mounted at the time of the sprint activating?

Wheels 04/02/19 10:20 AM

Quote:

Originally Posted by Rhyono (Post 37617)
I think ACTION_RESULT_SPRINTING can be returned by EVENT_COMBAT_EVENT, but I don't know if that works outside of combat. As for mounted sprinting: maybe just check if mounted at the time of the sprint activating?

EVENT_COMBAT_EVENT doesn't require the player to be in combat. There are 'abilities' that occur and can be seen by EVENT_COMBAT_EVENT that happen when the player sprints and when they sprint on a mount etc, so with a little work and filtering it would certainly be trackable

sirinsidiator 04/02/19 10:39 AM

Someone asked the same question on gitter a while ago. Here is the code I posted back then:
Lua Code:
  1. local SPRINT_ABILITY_ID = 973
  2. local PLAYER_UNIT_TAG = "player"
  3. EVENT_MANAGER:RegisterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, function(_, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId)
  4.     if(hitValue == 0) then -- seems the event triggers twice, once with hitValue 0 and a second time with 1
  5.         d("sprint start")
  6.     end
  7. end)
  8. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_UNIT_TAG, PLAYER_UNIT_TAG)
  9. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_GAINED)
  10. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, SPRINT_ABILITY_ID)
  11.  
  12. EVENT_MANAGER:RegisterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, function(_, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId)
  13.     d("sprint end")
  14. end)
  15. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, REGISTER_FILTER_UNIT_TAG, PLAYER_UNIT_TAG)
  16. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_FADED)
  17. EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, SPRINT_ABILITY_ID)

You can check if the player is mounted with the function "IsMounted()".

ArtOfShred 04/09/19 09:19 AM

You could register a separate eventhandler for abilityId: 33439 "Mount Sprint (Generic)" if you need to track when the player is sprinting on a mount, that's the id for that.


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

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