Thread Tools Display Modes
04/02/19, 09:58 AM   #1
scorpius2k1
 
scorpius2k1's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2019
Posts: 6
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?

Thanks in advance for any guidance!
  Reply With Quote
04/02/19, 10:02 AM   #2
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
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?
  Reply With Quote
04/02/19, 10:20 AM   #3
Wheels
AddOn Author - Click to view addons
Join Date: Feb 2017
Posts: 60
Originally Posted by Rhyono View Post
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
  Reply With Quote
04/02/19, 10:39 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,567
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()".
  Reply With Quote
04/09/19, 09:19 AM   #5
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
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.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How to Detect Player/Mount Sprint Start/Stop

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