Someone asked the same question on gitter a while ago. Here is the code I posted back then:
Lua Code:
local SPRINT_ABILITY_ID = 973
local PLAYER_UNIT_TAG = "player"
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)
if(hitValue == 0) then -- seems the event triggers twice, once with hitValue 0 and a second time with 1
d("sprint start")
end
end)
EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_UNIT_TAG, PLAYER_UNIT_TAG)
EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_GAINED)
EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintStart", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, SPRINT_ABILITY_ID)
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)
d("sprint end")
end)
EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, REGISTER_FILTER_UNIT_TAG, PLAYER_UNIT_TAG)
EVENT_MANAGER:AddFilterForEvent("MyAddonName_SprintEnd", EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_FADED)
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()".