WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to detect the player making a critical hit (https://www.wowinterface.com/forums/showthread.php?t=1870)

EntropyZ 10-03-05 02:00 AM

How to detect the player making a critical hit
 
Code:

if( event == "UNIT_COMBAT") then
              if (arg1=="target") and (arg3=="CRITICAL") then
            --do something
        end
  end

This can only detect a crit hit.
What should i do if i want to detect the player making a crit hit?

Beladona 10-03-05 04:50 AM

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...

EntropyZ 10-03-05 06:32 AM

So u mean CHAT_MSG_COMBAT_SELF_HITS
or something like this?

But there isn't any Crit info...

Gello 10-03-05 07:34 AM

Quote:

But there isn't any Crit info...
arg1 is the line that would go to a window if that combat spam is enabled. It says if it crits or not. If you're only worried about the player making critical damage hits and unconcerned with how often or with what effects (which can be lifted from combat spam too), use this filter:

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

Beladona 10-03-05 01:25 PM

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

EntropyZ 10-03-05 07:59 PM

Not at all
All done now
Thanks alot

Gorak 10-05-05 03:53 AM

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

Littlejohn 10-05-05 07:05 AM

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.)

Beladona 10-05-05 09:40 AM

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