How to detect the player making a critical hit
Code:
if( event == "UNIT_COMBAT") then What should i do if i want to detect the player making a crit hit? |
There is no easy way to do this without risking errors (as in sometimes not getting the right info you wanted).
UNIT_COMBAT returns with it the following arguments: arg1 - the uniID of the entity (usually target, the entity RECEIVING the damage) arg2 - dmg type (DODGE, WOUND, MISS, PARRY, etc...) arg3 - critical indicator (e.g. CRITICAL) arg4 - numeric damage arg5 - damage type in numeric format (0 = physical; 1= holy; 6= arcane; etc...) Unfortunately the info you need isn't exposed without maybe parsing the chat log for criticals instead of waiting for the UNIT_COMBAT event... |
So u mean CHAT_MSG_COMBAT_SELF_HITS
or something like this? But there isn't any Crit info... |
Quote:
if (event=="CHAT_MSG_COMBAT_SELF_HITS" or event=="CHAT_MSG_SPELL_SELF_DAMAGE") and string.find(arg1,"^You.- crit.+for %d+") then -- player performed a crit by melee or non-melee end |
nice one Gello, string.find was exactly what I was thinking.
You could parse out the result too if you wanted, I am not sure exactly what you are doing with this, such as parsing out the damage amount, where getting the data from the regex Gello posted would be useful. On the other hand if you are just trying to make a sound or popup "Critical!" in a scroll frame then you probably don't need to get the data from the search string... Sorry if I totally lost you. Post back here if you need help from any of us |
Not at all
All done now Thanks alot |
Regarding this issue, I feel something needs clarification.
The combat log chat frame sits there on it's place and can be configured to display specific messages. Now, how is this configuration related to the messages other add-ons can receive ? What I mean by this, is that if my add-on registers to receive a specific CHAT_ message, and the player has disabled from viewing these, will the add-on still receive an event notification and the text as arg1 ? - Gorak |
Yes.
Individual frames register interest in events. (This is both an excellent feature and a cause of performance problems when scaling to large number of frames. Choose your event registrations carefully.) |
in other words:
It doesn't matter if you hide everything in your chat window and nothing is displayed. The event is ALWAYS fired, it is merely your chat log you have configured to ignore them. So if you register the event, your frame will get notified that the event was fired, regardless of what your chat window is doing... |
All times are GMT -6. The time now is 06:00 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI