Page 1 of 2

Debuff macro

Posted: Sat Aug 10, 2013 6:36 am
by Draakje
Hi, i have got here an addon macro which allows to announce party chat what debuff i got below u can see the one i normaly use for myself

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope
local frame = _G.VNfear_Frame -- made in the XML

function VNfear.VN()
   if (chkDebuff("player", "Enter Nightmare") == true) then
	  SendChatMessage(">>FEAR INCOMING ON ME<<", "Say")
	  SendChatMessage(">>FEAR INCOMING ON ME<<", "Party")
	elseif
	(chkDebuff("player", "Deadly Nightmare") == true) then
	 SendChatMessage(">>FEAR,CLEAN ME PLEASE!!!<<", "Say")
	 SendChatMessage(">>FEAR,CLEAN ME PLEASE!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Blood Poison") == true) then
	 SendChatMessage("player" has dead debuff!!!<<", "Party")
	 	 elseif
	(chkDebuff("player", "Venom's Wound") == true) then
	 SendChatMessage(">>"player" is bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Fear") == true) then
	 UseEmote("Kneel")
	 SendChatMessage(">>"player" is Feared!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Terror") == true) then
	UseEmote("Kneel")
	 SendChatMessage(">>"player" is Feared!!!<<", "Say")
	 SendChatMessage(">>"player" is Feared!!!<<", "Party")
               elseif
	(chkDebuff("player", "Light Lock") == true) then
	 SendChatMessage("player" Is Locked", "Party")
	 elseif
	(chkDebuff("player", "Body Freeze") == true) then
	 SendChatMessage("player" is Frozen!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Shattered Armor") == true) then
	 SendChatMessage("player" defense is broken!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Shout") == true) then
	 SendChatMessage(">>"player" is Stunned!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Stun") == true) then
	 SendChatMessage(">>"player"is Stunned!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Charge") == true) then
	 SendChatMessage(">>"player" is Stunned!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Low Roar") == true) then
	UseEmote("Kneel")
	 SendChatMessage(">>"player" is Feared!!!<<", "Party")
	 elseif
	(chkDebuff("player", "Bleed") == true) then
	 SendChatMessage("player" is Bleeding!!!<<", "Party")
	 DoEmote(21)
   end
end;

function chkDebuff(player,debuffName)
  local i = 1;
  local r = false;
  while (UnitDebuff(player,i) ~= nil) do
    if (UnitDebuff(player, i) == debuffName) then
      r = true;
    end
    i = i + 1;
  end
  return r;
end

frame:RegisterEvent("UNIT_BUFF_CHANGED")

function VNfear:OnEvent(event, arg1, arg2, arg3)
    self[event](self, arg1, arg2, arg3)
end



local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end
and now i was trying to rewrite the addon macro, so it could check the debuff of my raid( so group 1 and group2 at least) and announce what player has debuff to party. So far i can't seem get it to work :/ any help? :)

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope
local frame = _G.VNfear_Frame -- made in the XML

function VNfear.VN()
   if 	(chkDebuff("raid1", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid2", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	elseif
	(chkDebuff("raid3", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	elseif
	(chkDebuff("raid4", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	elseif
	(chkDebuff("raid5", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid6", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid7", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid8", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid9", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid10", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid11", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 elseif
	(chkDebuff("raid12", "Bleed") == true) then
	 SendChatMessage("player name" is Bleeding!!!<<", "Party")
	 DoEmote(21)
   end
end;

function chkDebuff(raidn,debuffName)

  local i = 1;
  local r = false;
  while (UnitDebuff(raidn,i) ~= nil) do
    if (UnitDebuff(raidn, i) == debuffName) then
      r = true;
    end
    i = i + 1;
  end
  return r;
end

frame:RegisterEvent("UNIT_BUFF_CHANGED")

function VNfear:OnEvent(event, arg1, arg2, arg3)
    self[event](self, arg1, arg2, arg3)
end



local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end

Re: Debuff macro

Posted: Tue Aug 13, 2013 7:09 pm
by Bill D Cat
This may not help you solve your problem, but one suggestion comes to mind right away.

Rather than having a bunch of individual checks for "raid1", "raid2", etc, you might consider consolidating it into a loop where you do something like this instead:

Code: Select all

function VNfear.VN()
  for xx = 1 , 36 do
    if (chkDebuff("raid"..xx, "Bleed") == true) then
      SendChatMessage("player name" is Bleeding!!!<<", "Party")
    end
  end
This will cut the size of your code down quite a bit, and make it easier to edit. At least I think it's easier to edit one set of commands than it would be for 36 if a full raid was involved.

Re: Debuff macro

Posted: Wed Aug 14, 2013 3:03 am
by rock5
This line looks wrong

Code: Select all

SendChatMessage("player name" is Bleeding!!!<<", "Party")
Wrong number of quotes. Plus it doesn't include the name of the player. I assume it's supposed to. I think it should be something like.

Code: Select all

SendChatMessage(UnitName("raid"..xx) .. " is Bleeding!!!<<", "Party")

Re: Debuff macro

Posted: Wed Aug 14, 2013 4:17 pm
by Draakje
hi, so far I used this.

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope
local frame = _G.VNfear_Frame -- made in the XML

function VNfear.VN()
for xx =1,36 do
   	if (chkDebuff("raid"xx, "Bleed") == true) then
	 SendChatMessage("test test test", "Party")
	 DoEmote(21)
	   end
end;

function chkDebuff(raid,debuffName)
  local i = 1;
  local r = false;
  while (UnitDebuff(raid,i) ~= nil) do
    if (UnitDebuff(raid, i) == debuffName) then
      r = true;
    end
    i = i + 1;
  end
  return r;
end

frame:RegisterEvent("UNIT_BUFF_CHANGED")

function VNfear:OnEvent(event, arg1, arg2, arg3)
    self[event](self, arg1, arg2, arg3)
end



local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end
I tried first with

Code: Select all

SendChatMessage(UnitName("raid"..xx) .. " is Bleeding!!!<<", "Party")
and with ..xx, without them, then i just written in tekst, to see if this code above could be causing it, but still no text ingame coming after Bleed.

Next, any chance my function is not right?

Code: Select all

function chkDebuff(raid,debuffName)
  local i = 1;
  local r = false;
  while (UnitDebuff(raid,i) ~= nil) do
    if (UnitDebuff(raid, i) == debuffName) then
      r = true;
    end
    i = i + 1;
  end
  return r;
end

Re: Debuff macro

Posted: Wed Aug 14, 2013 4:35 pm
by Bill D Cat
I think you forgot to concatenate the strings in your function.

Code: Select all

for xx =1,36 do
    if (chkDebuff("raid"..xx, "Bleed") == true) then -- You need the .. to make raid1, raid2, etc.
      SendChatMessage("test test test", "Party")
      DoEmote(21)
    end
end;

Re: Debuff macro

Posted: Wed Aug 14, 2013 4:52 pm
by rock5
Maybe party and raid are different. Are you in a party or a raid? Did you try "party"..xx?

Re: Debuff macro

Posted: Wed Aug 14, 2013 5:25 pm
by Draakje
I tried this at first:

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope
local frame = _G.VNfear_Frame -- made in the XML

function VNfear.VN()
for xx =1,36 do
      if (chkDebuff("raid"..xx, "Bleed") == true) then
    SendChatMessage("test test test", "Party")
    DoEmote(21)
      end
end;

function chkDebuff(raid,debuffName)
  local i = 1;
  local r = false;
  while (UnitDebuff(raid,i) ~= nil) do
    if (UnitDebuff(raid, i) == debuffName) then
      r = true;
    end
    i = i + 1;
  end
  return r;
end

frame:RegisterEvent("UNIT_BUFF_CHANGED")

function VNfear:OnEvent(event, arg1, arg2, arg3)
    self[event](self, arg1, arg2, arg3)
end



local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end 
also tried "party"..xx doesnt work

Re: Debuff macro

Posted: Wed Aug 14, 2013 6:25 pm
by Bill D Cat
This is my function to check debuffs on a player or target. It works for me in every situation that I've tested.

Code: Select all

-- Searches the target for a specified debuff. 
-- Use "player", "target", "party3", "raid1" etc. for tgt parameter.
function ChkDebuff(tgt,debuffname)
  local counter=1
  local currentbuff="none"
  while currentbuff ~= nil do
    currentbuff=UnitDebuff(tgt,counter)
	if currentbuff ~= nil then
      if string.find(string.lower(currentbuff),string.lower(debuffname)) then
        return true
      else
        counter=counter+1
      end
    end
  end
  return false
end

Re: Debuff macro

Posted: Thu Aug 15, 2013 12:03 am
by rock5
Maybe there is something wrong with your xml file. What does that look like?

Re: Debuff macro

Posted: Thu Aug 15, 2013 3:31 am
by Draakje
this is .xml file

Code: Select all

<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
    <Frame name="VNfear_Frame">
        <Scripts>
            <OnEvent>
                VNfear:OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
            </OnEvent>
            
            <OnUpdate>
                VNfear:OnUpdate(elapsedTime)
            </OnUpdate>
        </Scripts>
    </Frame>
</Ui>

Re: Debuff macro

Posted: Thu Aug 15, 2013 5:15 am
by rock5
Do you realize that you are not using the OnEvent code? Are you intending to use it in the future?

I did some testing and found that the chkDebuff function is missing an 'end'. After that, the OnEvent code seems incomplete so that causes an error. So I commented that out and then it worked.

Re: Debuff macro

Posted: Thu Aug 15, 2013 7:35 am
by Draakje
so how should my xml file look like then?

Re: Debuff macro

Posted: Thu Aug 15, 2013 7:59 am
by Draakje
Tried:

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope
local frame = _G.VNfear_Frame -- made in the XML

function VNfear.VN()
  for xx = 1 , 36 do
    if (chkDebuff("raid"..xx, "Bleed") == true) then
      SendChatMessage(Bleeding Bleeding, "Party")
	 DoEmote(21)
	   end
end;

function ChkDebuff("raid"..xx,debuffname)
  local counter=1
  local currentbuff="none"
  while currentbuff ~= nil do
    currentbuff=UnitDebuff("raid"..xx,counter)
   if currentbuff ~= nil then
      if string.find(string.lower(currentbuff),string.lower(debuffname)) then
        return true
      else
        counter=counter+1
      end
    end
  end
  return false
end

frame:RegisterEvent("UNIT_BUFF_CHANGED")

local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end
also tried again with change in function: (not sure does ..xx have to be in here too or not?)

Code: Select all

function ChkDebuff(raid,debuffname)
  local counter=1
  local currentbuff="none"
  while currentbuff ~= nil do
    currentbuff=UnitDebuff(raid,counter)
   if currentbuff ~= nil then
      if string.find(string.lower(currentbuff),string.lower(debuffname)) then
        return true
      else
        counter=counter+1
      end
    end
  end
  return false
end
with my xml file that is this atm

Code: Select all

<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
    <Frame name="VNfear_Frame">
        <Scripts>
       
            <OnUpdate>
                VNfear:OnUpdate(elapsedTime)
            </OnUpdate>
        </Scripts>
    </Frame>
</Ui>

Re: Debuff macro

Posted: Thu Aug 15, 2013 8:29 am
by rock5
This is wrong

Code: Select all

function ChkDebuff("raid"..xx,debuffname)
The original is correct. This is where it declares the function. It accepts whatever values are passed to it and saves them in the (in this case) raid and debuffname variables. Bill D Cat's function is actually slightly better than yours. Leave it as it is. You only need to make sure the function name is the same as you use in the rest of your code. Bill D Cat used a capital C but you are using a small c.

This

Code: Select all

 SendChatMessage(Bleeding Bleeding, "Party")
should be

Code: Select all

SendChatMessage("Bleeding Bleeding", "Party")
You don't need this line

Code: Select all

frame:RegisterEvent("UNIT_BUFF_CHANGED")
Actually you don't need 'frame' at all so you can remove this line too.

Code: Select all

local frame = _G.VNfear_Frame -- made in the XML
The xml looks correct.

Re: Debuff macro

Posted: Thu Aug 15, 2013 9:40 am
by Draakje
getting irritating by it ^.^ tried with raid and party, seen in other addon scripts they use often "party" but still none of both working >.>

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope

function VNfear.VN()
  for xx = 1 , 36 do
    if (ChkDebuff("raid"..xx, "Bleed") == true) then
      SendChatMessage("Bleeding Bleeding", "party")
	 DoEmote(21)
	   end
end;

function ChkDebuff("raid",debuffname)
  local counter=1
  local currentbuff="none"
  while currentbuff ~= nil do
    currentbuff=UnitDebuff("raid",counter)
   if currentbuff ~= nil then
      if string.find(string.lower(currentbuff),string.lower(debuffname)) then
        return true
      else
        counter=counter+1
      end
    end
  end
  return false
end


local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end

Code: Select all

local VNfear = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.VNfear = VNfear -- expose it to the global scope

function VNfear.VN()
  for xx = 1 , 36 do
    if (ChkDebuff("party"..xx, "Bleed") == true) then
      SendChatMessage("Bleeding Bleeding", "Party")
	 DoEmote(21)
	   end
end;

function ChkDebuff("party",debuffname)
  local counter=1
  local currentbuff="none"
  while currentbuff ~= nil do
    currentbuff=UnitDebuff("party",counter)
   if currentbuff ~= nil then
      if string.find(string.lower(currentbuff),string.lower(debuffname)) then
        return true
      else
        counter=counter+1
      end
    end
  end
  return false
end


local time_remaining = 0.5 -- in seconds
function VNfear:OnUpdate(elapsed)
    -- elapsed is the amount of time in seconds since the last frame tick

    time_remaining = time_remaining - elapsed
    if time_remaining > 0 then
        -- cut out early, we're not ready yet
        return
    end
    time_remaining = 0.5 -- reset to 2 seconds
    self.VN()
end

Re: Debuff macro

Posted: Thu Aug 15, 2013 12:01 pm
by rock5
Let me give you a little lesson on variables, strings and functions.

"raid" is a string. If you print it, it prints raid

Code: Select all

SendSystemChat("raid")
raid
raid is a variable. If you haven't assigned a value to it, it will equal nil. If you assign a value to it then print it, it will print the value you assigned to it. Eg.

Code: Select all

raid = "Raid1"
SendSystemChat(raid)
Raid1
It prints Raid1 because "Raid1" was the value assigned to the variable raid.


A function is a block of code you can call at any time. You can pass values to functions. The values get stored in the argument variables.

This is a function being declared. It wont run until called.

Code: Select all

function testfunc(val)
    SendSystemChat(val)
end
val is a variable and will hold what ever is passed to the function.
This is the function being called.

Code: Select all

testfunc("Hello")
It will run the function and passing the value "Hello" which will be stored in the variable val and then get printed.

So when declaring a function you only put variables as arguments, not values. These variables will hold the values passed to the function. When using a function you pass values, or variables that hold values, as arguments.

I hope that helps.


Now... you didn't follow the instructions I gave you in my previous post. I said use Bill D Cat's function without making any changes to it except the name. Just change the function name from ChkDebuff to chkDebuff and it should work. Don't change the variables.

Oops, I just notice I made a mistake in a previous post. It's "VNfear.VN()" that is missing an 'end'. Add an 'end' to the end of the function.

Re: Debuff macro

Posted: Thu Aug 15, 2013 4:04 pm
by Draakje
Its working :) tyvm
now check if i need place next debuff check after an end of previous?

i don't use to write macro's but starting learn it ^^

Re: Debuff macro

Posted: Thu Aug 15, 2013 4:17 pm
by Draakje
yep up and running, all debuffs go now :) tyvm again :D

can close this thread

Re: Debuff macro

Posted: Thu Aug 15, 2013 4:30 pm
by Bubi
Do you want to share it?
Probably useful for finding out the tactic of Bethomia B2.

Re: Debuff macro

Posted: Fri Aug 16, 2013 3:53 am
by Draakje
Bubi wrote:Do you want to share it?
Probably useful for finding out the tactic of Bethomia B2.
B2 from bethomia its tactic is still bugged, rom has fix it, but for now u can try rogues use vanish to remove debuff, some scout combo's have hide scents, champions can use remoled body and for rest need use Phoenix. This give u some extra time if taking to long on boss fight, just nuke nuke with both groups full music and dmg stuff =)