Simple Addon: Play sounds with skills (HELP)
Hi Everyone,
I'm very new to addons in eso and I was wondering if anyone with experience could help me? I would like to make a simple addon that plays sounds when abilities are activated. Including light and heavy attacks. The addon "Light Attack Helper" has been useful in that I could edit the code to play sounds when a light attack was successful. I would however like the sound to play even if a light attack isn't connecting with a target. The skills would be different as I would like them only to play a sound when hitting a target. Any help would be greatly appreciated. :) Cheers |
https://wiki.esoui.com/Events#Combat
EVENT_COMBAT_EVENT But be warned: Not all events return a value or a unitTag so you are maybe not able to determine if you, and who you have hit with what value. Define yourself a callback function for the event and check if it returns e.g. the dmg you have done to some enemy NPC/player. Be sure to also register event filters so the event will not fire for EACH non-wanted stuff!!! https://wiki.esoui.com/AddFilterForEvent |
Quote:
Thanks for the response. Honestly though, I have little to no knowledge when it comes to writing lua script. "PlaySound" is as far as I've got. Editing an existing script is probably all I can manage right now. I was hoping it would be a simple solution but maybe not. |
I have another quick question. Is it possible to add a short delay before playing sounds? a faction of a second.
|
NewAddonTemplate
you can use that as start point |
Lua Code:
|
Quote:
Quote:
|
Quote:
|
@Baertram Is it possible to have a sound play even when the light attacks miss? I'm able to get sounds to play on successful attacks using the Light Attack Helper Addon. This section seems to handle the combat event for light and heavy attacks.
function LightAttackHelper.onCombatEvent(_, _, _, abilityName, _, abilityActionSlotType, sourceName, _, _, _, hitValue) if abilityActionSlotType == ACTION_SLOT_TYPE_LIGHT_ATTACK and LightAttackHelper.playerName == sourceName and abilityName == GetString(LAH_LIGHT_ATTACK) then PlaySound("Map_Auto_Navigation_Begin_Zoom") --good LightAttackHelper.castingHeavyAttack = false LightAttackHelper.usedAbilityDuringHeavyAttack = false --d("LA") LightAttackHelper.setCounter(LightAttackHelper.LightAttackCounter + 1) LightAttackHelper.updateRatio(true) elseif abilityActionSlotType == ACTION_SLOT_TYPE_HEAVY_ATTACK then if abilityName == GetString(LAH_HEAVY_ATTACK) and LightAttackHelper.playerName == sourceName then LightAttackHelper.castingHeavyAttack = false LightAttackHelper.usedAbilityDuringHeavyAttack = false if LightAttackHelper.savedVariables.countHeavyAttacks then LightAttackHelper.setCounter(LightAttackHelper.LightAttackCounter + 1) LightAttackHelper.updateRatio(true) end --d("HA") end end end |
LightAttackHelper.onCombatEvent must be assigned as callback function to an event like EVENT_COMBAT_EVENT e.g.
So if this event also fires as the light attack does not hit you need to find out what parameters the callback function "LightAttackHelper.onCombatEvent" returns in this case. Currently it checks for Lua Code:
Maybe one could also use an abilitId instead of a name here, not sure if it's always the same abilityId. You could check what the parameters return by adding something like this at the start of the function LightAttackHelper.onCombatEvent d("ActionSlotType: " ..tostring(abilityActionSlotType ) .. ", source: " .. tostring(sourceName) ) Just add additional .. "variableName: " .. tostring(variable) after the tostring(sourceName) (within the opening ( and closing ) of d) to see what the values are. Do a reloadui then and do some tests what is shown in your chat. The possible variables of the function are these: LightAttackHelper.onCombatEvent(_, _, _, abilityName, _, abilityActionSlotType, sourceName, _, _, _, hitValue) Where all the _ could be special variables as well but you'd need to rename them to use them for a chat output. The event_combat_event uses this parameters: Code:
EVENT_COMBAT_EVENT (number eventCode, number ActionResult result, boolean isError, string abilityName, number abilityGraphic, number ActionSlotType abilityActionSlotType, string sourceName, number CombatUnitType sourceType, string targetName, number CombatUnitType targetType, number hitValue, number CombatMechanicType powerType, number DamageType damageType, boolean log, number sourceUnitId, number targetUnitId, number abilityId, number overflow) You see, if you lay my event_combat_event function definition with all parameters above the function LightAttackHelper.onCombatEvent that the 1st _ would be eventCode, the 2nd would be Actionresult, the 3rd isError and then there is abilityName. And so on. Just replace the _ in the function LightAttackHelper.onCombatEvent with the variables names I have shown you and you would be able to use them in your d() chat output, like e.g. ", isError: " .. tostring(isError) |
Thanks, Baertram! I was able to make some progress with the advice you gave me. I can now play sounds when a specific skill is used. My only problem now is I can't figure out how I play a sound for light attacks when they are not connecting with a target. It seems like all of the events are tied to combat. Thanks again, I really appreciate the help.
|
Well, as I said: There is no way to detect this except maybe with this event, which checks each mouse click:
Code:
EVENT_GLOBAL_MOUSE_DOWN (number eventCode, MouseButtonIndex button, boolean ctrl, boolean alt, boolean shift, boolean command) But this will not tell you if you just did a light attack or heavy attack or if you have clicked somewhere on the UI just because you like to activate skills via mouse during combat. It tracks ALL clicks... |
All times are GMT -6. The time now is 11:50 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI