Go to Page... |
Thread Tools | Display Modes |
04/24/15, 11:28 AM | #1 |
EVENT_ACTIVE_WEAPON_PAIR_CHANGED always fired for every attack (even out of combat)
Hey there,
I just tried to use the event EVENT_ACTIVE_WEAPON_PAIR_CHANGED to see if the active weapon bar was changed. 1) It gets fired once with locked = true for the current active action bar (1) to lock it (but this does not happen always?). 2) Afterwards it gets fired for the new action bar (2) with locked = true. 3) And then finally it gets fired with the new action bar (2) and locked = false. "Locked" means the small "lock symbol" at the action bar which says you cannot use or change the bar currently. I just want to react on a player changing his action bar. But this chain of event firing will be ALWAYS fired with steps 2 and 3 if I even only use my attack skill of the weapon. Bar gets locked 2), bar gets unlocked 3). Any chance to filter this out so I can just react on a player "really" changing his action bars? My current solution is: -Upon login: Get active bar and save it into global addon variable -Event is fired: Check if global variable differs from current event's active weapon pair id -> As "locked = false" and weaponbar Id differs: Update the global variable with the new variable from the event I only run my code if the last weapon bar id differs from the current one. Any better solutions? Thanks for your help. |
|
04/24/15, 12:00 PM | #2 | |
|
It was a horrible coding action, because alot of situations raised the swap-effect, where no swap was done. (like mounting up, changing maps, talking to vendors and so on) Forget the lock - use your own boolean and maybe a counter to suppress running into your routines more than two times by those raised events. Btw, the ID-Check is that, what ive done also in GearSwap and help you at least for some occouring events to stop that. Greets, Adalan Last edited by Adalan : 04/24/15 at 12:26 PM. |
|
04/25/15, 08:23 PM | #3 |
|
It sounds like you want this event instead:
Lua Code:
|
04/25/15, 09:17 PM | #4 |
You could do something like what I did with my Fix Weapon Swap Effects mod and set up a "spam catcher" for event spam:
Code:
local ActiveWeapon = 0 local catchspam = 0 local function DoStuff(WeaponPair) Stuff done here that I only want to do if a real weapon swap happened... ActiveWeapon = WeaponPair end local function CheckStatus(WeaponPair) catchspam = catchspam + 1 if catchspam == 3 then if WeaponPair ~= ActiveWeapon then DoStuff(WeaponPair) end catchspam = 0 end end local function OnWeaponSwap(eventCode, WeaponPair, locked) CheckStatus(WeaponPair) end EVENT_MANAGER:RegisterForEvent(SomeAddon.Name, EVENT_ACTIVE_WEAPON_PAIR_CHANGED, OnWeaponSwap) 1) Ignored. 2) Ignored. 3) Do stuff. I pass WeaponPair to the CheckStatus event so that I can check a global I store its value in to see if it has changed. This was important for me because Sorcerer ultimate Overcharge is considered a weapon swap for this event but keeps the current internal weapon pair ID, so I can tell not to refresh graphics which cause a Sorcerer to pull out a weapon for their ultimate which looks broken. EDIT: EVENT_ACTION_SLOTS_FULL_UPDATE is good if you don't need to know what weapon set the person equipped or if it changed. I used it before, and it is a simple Boolean if the bar change was triggered by a weapon swap. The thing is, you will still want a spam filter. That event fires 5 times instead of just 3! Last edited by Phinix : 04/25/15 at 09:44 PM. |
|
04/25/15, 10:26 PM | #5 | |
|
You can just call: Lua Code:
|
|
04/26/15, 06:29 AM | #6 | |
Lua Code:
|
||
04/26/15, 06:43 AM | #7 |
Thanks for all the info guys.
|
|
ESOUI » Developer Discussions » Lua/XML Help » EVENT_ACTIVE_WEAPON_PAIR_CHANGED always fired for every attack (even out of combat) |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|