09-18-14, 03:32 PM | #1 |
Set raid icons with successful spell
Hello everybody, I've been using the addon "Arena Raid Icons" or scripts to put raid icons on party members in arena. I modified the script trying to make it set icons when I use an ability (for abilities that remove raid icons, I think vanish,shadowmeld,etc. still do this).
If I use a macro with "SetRaidTarget" it doesn't toggle the icon, "SetRaidTargetIcon" does. I'm using SetRaidTarget in the script but it keeps toggling on and off whenever I use an ability, I'd like any help in order to avoid this. Here's the code: Code:
local f = CreateFrame("Frame") local MAGE = GetSpellInfo(61316) --Dalaran Brilliance local ROGUE = GetSpellInfo(1784) --Stealth local MONK = GetSpellInfo(115921) --Legacy of the White Tiger local PRIEST = GetSpellInfo(21562) --Power Word: Fortitude local SHAMAN = GetSpellInfo(52127) --Water Shield local DRUID = GetSpellInfo(1126) --Mark of the Wild local PALADIN = GetSpellInfo(20217) --Blessing of Kings local DEATHKNIGHT = GetSpellInfo(57330) --Horn of Winter local WARLOCK = GetSpellInfo(109773) --Dark Intent local WARRIOR = GetSpellInfo(6673) --Battle Shout local HUNTER = GetSpellInfo(13165) --Aspect of the Hawk f:RegisterEvent("UNIT_SPELLCAST_SENT") f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") f:SetScript("OnEvent", function(self, event, arg1, arg2) if arg1 == "player" and (arg2 == MAGE) then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=6,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == ROGUE then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == MONK then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == PRIEST then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=6,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == SHAMAN then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == DRUID then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == PALADIN then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=2,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == DEATHKNIGHT then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == WARLOCK then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=6,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == WARRIOR then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end elseif arg1 == "player" and arg2 == HUNTER then if event == "UNIT_SPELLCAST_SUCCEEDED" then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=2,PALADIN=3,HUNTER=4,MONK=2,PRIEST=5,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end end end ) |
|
09-18-14, 03:45 PM | #2 |
Calling SetRaidTarget on a unit that already has that particular icon above its head will clear its icon.
You can check whether it already has an icon set using GetRaidTargetIndex(unit), and if the icon number returned matches the one you're trying to set then your script needs to bail out. Either you're calling SetRaidTarget before the icon is cleared, or it isn't actually being cleared in the first place. There's an event called RAID_TARGET_UPDATE that fires when an icon changes, you might want to just watch that and reassign your icons if they need it. Last edited by semlar : 09-18-14 at 03:47 PM. |
|
09-18-14, 05:22 PM | #3 |
So it would be something like this? (I'm terrible at lua, sorry in advance )
Code:
function icons() if(GetRaidTargetIndex("player")~=5) then members = GetNumGroupMembers(); ci={ROGUE=1,DRUID=2,WARLOCK=3,PALADIN=3,HUNTER=4,MONK=4,PRIEST=6,MAGE=5,SHAMAN=6,WARRIOR=7,DEATHKNIGHT=8} SetRaidTarget('player',ci[select(2,UnitClass('player'))]) for i=1,(members-1) do SetRaidTarget('party'..i,ci[select(2,UnitClass('party'..i))]) end end end local f = CreateFrame("Frame") local MAGE = GetSpellInfo(61316) --Dalaran Brilliance f:RegisterEvent("UNIT_SPELLCAST_SENT") f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") f:RegisterEvent("RAID_TARGET_UPDATE") f:SetScript("OnEvent", function(self, event, arg1, arg2) if arg1 == "player" and (arg2 == MAGE) then if event == "UNIT_SPELLCAST_SUCCEEDED" then icons() end end) |
|
09-18-14, 06:19 PM | #4 |
You can try this, it's dry-coded so I might have missed something.
Lua Code:
edit: I may have misunderstood what you're trying to do. I wrote this based on your code, which sets icons on every arena member based on their class, but your description makes it sound like you want to set an icon on someone when they cast a specific spell. Maybe you can clarify what you're after. Also some of the classes have the same raid icon, and of course you can have two of the same class in the group, so I'm not sure how you want it to behave if there's a conflict. Last edited by semlar : 09-18-14 at 06:41 PM. |
|
WoWInterface » Developer Discussions » Lua/XML Help » Set raid icons with successful spell |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|