Thread Tools Display Modes
07-29-08, 04:39 AM   #1
Mahiro
A Murloc Raider
 
Mahiro's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 9
Enemy or Friendly spell?

hi, im trying to seperate enemy from friendly spells with range, but the only way i found to do this is with inRange=IsSpellInRange(spellname/ID, unit) (0= out of range, 1= in range, nil= invalid target)

the idea was to check all the range spells wether inRange is nil or not and if they are nil they are declared as enemy spells, otherwise as friendly spells.

would this work or are there some problems with this method? or is there a function i missed to check if a spell can be casted on eney or on friendly units?
  Reply With Quote
08-01-08, 09:14 AM   #2
Mahiro
A Murloc Raider
 
Mahiro's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 9
since nobody answered to this im gona write an answer myself
so far the method is working without problems and no wrong spell has passed the check so far.
  Reply With Quote
08-01-08, 09:50 AM   #3
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Priest's Dispell Magic can be casted on friends and enemies.

Would break it, or not?
  Reply With Quote
08-04-08, 12:27 PM   #4
Mahiro
A Murloc Raider
 
Mahiro's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 9
it is, also hunters mark is recognized as friendly spell
  Reply With Quote
08-12-08, 01:52 AM   #5
Olvar
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 10
Maybe IsHarmfulSpell() is what you are looking for?

For some reason I didn't find it on WoWwiki, just WoWprogramming. I hope this function actually works, because I didn't test it:

http://wowprogramming.com/docs/api/IsHarmfulSpell

Depending on when you want to distinguish spells you might also do so with the new combat log event. Here is an excerpt from my Pull Warning that decides if an enemy was the target of someone in my party or raid:

Code:
function PullWarning_OnEvent(self, event, ...)
  -- Check if a non-outsider performed a cast onto a hostile target
  if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    -- Get more information from the combat log event
    local _, _, _, srcName, srcFlags, _, destName, destFlags, spellID, spellName = ...
    -- Is the spell on the ignore list?
    if IgnoreSpell[spellID] then
      return
    end
    -- Isn't the target hostile?
    if bitand(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == 0 then
      return
    end
    -- If pull warning was forced only my own spells with hostile targets are interesting
    if PullWarningForced then
      if bitand(srcFlags,  COMBATLOG_OBJECT_AFFILIATION_MINE) ~= 0 then
        PullWarningForced = false
        PullWarningInProgress = true
        PullWarning_DisplayWarning(PullWarningTargetFormat, srcName, destName)
        frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
      end
    -- Was the spell cast onto an enemy by me or someone in my party or raid?
    elseif bitand(srcFlags, ( COMBATLOG_OBJECT_AFFILIATION_MINE +
                              COMBATLOG_OBJECT_AFFILIATION_PARTY +
                              COMBATLOG_OBJECT_AFFILIATION_RAID )) ~= 0 then
      PullWarningInProgress = true
      PullWarning_DisplayWarning(PullWarningTargetFormat, srcName, destName)
      frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    end
  Reply With Quote
08-18-08, 04:28 AM   #6
Mahiro
A Murloc Raider
 
Mahiro's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 9
thanks a lot for that info, i will try it when i find some time and report back if it works

edit: seems thats working a lot better than IsSpellInRange, thanks a lot

Last edited by Mahiro : 08-18-08 at 12:44 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Enemy or Friendly spell?

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