View Single Post
04/02/19, 10:39 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
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