Saturday, April 21, 2012

Newbie Question: How to detect de-cloak events of monsters?

Hello,

This is my first attempt at an addon for WoW. I intend to develop a simple mod that provides a visual alternative (visual feedback) whenever the de-cloak sound is played ("Sound\\Spells\\Stealth.wav"). My reason: I know a number of players who miss the auditory cue due to a hearing impairment and therefore would appreciate a caption of some sort that communicates the stealth-sound visually.

I spend some time browsing tutorials and http://www.wowwiki.com/World_of_Warcraft_API but so far I haven't figured out how I can detect whether or not this sound file is triggered because of an enemy de-cloaking (like for instance Fen Creepers do - http://wow.allakhazam.com/db/mob.html?wmob=1040). Can anyone help me out?

Thank you!|||I don't think there is a way to detect sound events with the Blizzard API. If there is a message in the combat log about the mob becoming visible then you might be able to use that, but I don't know if there is.|||I just checked the combat log while walking around a Shadowmaw Panther (http://wow.allakhazam.com/db/mob.html?wmob=684) that was cloaking and de-cloaking, but there is nothing in the combat log unfortunately. I was thinking about maybe trying to use Unitfunctions (http://www.wowwiki.com/World_of_Warc...Unit_Functions) if that is possible. Does anyone know if this "cloaking"-behaviour (don't really what else to call it - "invisibility / stealth state"?) can be found using UnitBuff (http://www.wowwiki.com/API_UnitBuff) in some sort of way?

Thank you!|||You might able to do it in 2.3 when all target buffs will show up, but even then it'd still need to be your target/focus or a group member's target/focus (or some combination chain of targets from one of these units). And if it's stealthed then you generally can't target it so that won't really help.|||It may be possible to hook PlaySound(), have it check what sound is being played and do whatever you want if its the stealth sound.

I haven't tried hooking functions before, but this should give you the general idea:


Code:
local oldPlaySound;
function MyAddonLoad()
oldPlaySound = PlaySound;
PlaySound = MyAddonsNewPlaySound;
end
function MyAddonsNewPlaySound(sound)
if sound == "Sound\\Spells\\Stealth.wav" then
DEFAULT_CHAT_FRAME:AddMessage("Someone entered/left stealth!");
end
oldPlaySound(sound);
end

(Note this code is untested, may not work)

This assumes that blizz uses PlaySound() to play the stealth function, which I doubt they do.

No comments:

Post a Comment