Thread Tools Display Modes
10-03-05, 02:00 AM   #1
EntropyZ
A Defias Bandit
Join Date: Oct 2005
Posts: 3
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?
  Reply With Quote
10-03-05, 04:50 AM   #2
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
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...
  Reply With Quote
10-03-05, 06:32 AM   #3
EntropyZ
A Defias Bandit
Join Date: Oct 2005
Posts: 3
So u mean CHAT_MSG_COMBAT_SELF_HITS
or something like this?

But there isn't any Crit info...
  Reply With Quote
10-03-05, 07:34 AM   #4
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
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
  Reply With Quote
10-03-05, 01:25 PM   #5
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
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
  Reply With Quote
10-03-05, 07:59 PM   #6
EntropyZ
A Defias Bandit
Join Date: Oct 2005
Posts: 3
Not at all
All done now
Thanks alot
  Reply With Quote
10-05-05, 03:53 AM   #7
Gorak
A Fallenroot Satyr
Join Date: Oct 2005
Posts: 21
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
  Reply With Quote
10-05-05, 07:05 AM   #8
Littlejohn
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 90
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.)
  Reply With Quote
10-05-05, 09:40 AM   #9
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
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...
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to detect the player making a critical hit

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off