Page 1 of 1

player:hasDebuff

Posted: Thu Mar 24, 2011 5:42 pm
by WhiteTiger
hi,
can anyone confirm if player:hasDebuff is working or not? or if its just me. cuz i tried this

Code: Select all

		if player:hasDebuff("Blind") then
			print("yes")
		end
and yeah I had the debuff on me, I got this response in micromacro:
blabla/pawn.lua:534: bad argument #1 to 'gmatch' (string expected, got nil)
apriciation for any help

Re: player:hasDebuff

Posted: Thu Mar 24, 2011 8:55 pm
by WhiteTiger
nvm my post, could use player:hasBuff() instead

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 1:38 am
by rock5
Except hasDebuff runs hasBuff. So if hasBuff works so should hasDebuff.

Code: Select all

function CPawn:hasDebuff(deBuff, count)
	return self:hasBuff(debuff, count)
end

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 10:05 am
by BlueNitro
I was trying to write a skill sequence for rogue depending on the debuffs on the target, and I found that it was not working for me either. So I executed the following code whenever my target had bleed. See attached screen shot also.

Code: Select all

target=player:getTarget();print(target:hasDebuff("Bleed"));

It would always return false when the target clearly had the debuff. I also tried using hasBuff since I see it is the same thing. I also tried it with other deBuffs like, Blind and Grievous Wound. Still returned false.

Below is my onPreSkillCast that I'm trying to get working in my profile.

Code: Select all

	<onPreSkillCast>
		player:update()

		local target = player:getTarget()

		if arg1 == "ROGUE_BLIND_STAB" and target:hasDebuff("Blind") then
    			return false

		elseif arg1 == "ROGUE_SHADOWSTAB" and target:hasDebuff("Bleed") then
    			return false

		elseif arg1 == "ROGUE_LOW_BLOW" and target:hasDebuff("Grievous Wound") then
    			return false

		elseif arg1 == "ROGUE_WOUND_ATTACK" and not target:hasDebuff("Grievous Wound") then
    			return false
		end

		return true
	</onPreSkillCast>

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 10:18 am
by lisa
you need to use

Code: Select all

arg1.Name
As an example

Code: Select all

	<onPreSkillCast><![CDATA[

      		if( arg1.Name == "WARRIOR_SURPRISE_ATTACK" ) then
local cooldown, remaining = RoMScript("GetSkillCooldown(4,7);")
      			if remaining > 3 then 
      			return false
      			end
local target = player:getTarget()
           		if 60 > distance(player.X, player.Z, target.X, target.Z) then
               		return false -- doesn't use the skill
           		end
       		return true
       		end

	]]></onPreSkillCast>

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 10:38 am
by rock5
Ah I found the problem. I misspelt the buff variable when I passed it to the hasBuff function. Should be

Code: Select all

function CPawn:hasDebuff(debuff, count)
	return self:hasBuff(debuff, count)
end
Fixed in rev 583.

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 11:16 am
by lisa
lol you and your typo's ;)

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 11:26 am
by rock5
Where were you? Why didn't you catch me up on that one?

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 11:41 am
by BlueNitro
Thank you very much for the response.

I updated to 583 and changed to arg1.Name. It's still not working. I even verified that the debuff variable's name is correct when passing to hasBuff in hasDebuff function.

So I tried it at the command line and it's returning false with hasDebuff and hasBuff when my target has the debuffs.

Code: Select all

        RomBot command line
Type in 'q' (without quotes) to quit.
Command> target = player:getTarget();print(target:hasDebuff("Bleed"));
false
Command> target = player:getTarget();print(target:hasDebuff("Bleed"));
false
Command> target = player:getTarget();print(target:hasDebuff("Grievous Wound"));
false
Command> target = player:getTarget();print(target:hasBuff("Bleed"));
false
Command>

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 11:47 am
by rock5
Forgot to say. You need to do a player:update after targeting the mob or the bot wont know you have a target.

Try;

Code: Select all

player:update() target = player:getTarget() print(target:hasDebuff("Bleed"))

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 12:19 pm
by BlueNitro
Thanks Rock, update() made it work. And thanks Lisa, for letting me know I need to use "Name".

Re: player:hasDebuff

Posted: Fri Mar 25, 2011 8:15 pm
by lisa
rock5 wrote:Where were you? Why didn't you catch me up on that one?
lol I did actually notice it yet yesterday but thought nah Rock couldn't have done yet another typo lol