Using Buff Potions

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
horsewilly
Posts: 25
Joined: Tue Aug 17, 2010 6:41 am

Using Buff Potions

#1 Post by horsewilly »

I was just wondering if there was any way to make the bot automatically use potions such as housekeeper speed potions? I've tried the addon ntBuff, but it somehow manages to use up one stack of potions within a few minutes for me.
Thanks :mrgreen:
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Using Buff Potions

#2 Post by rock5 »

I guess you could check for the buff in one of the event sections eg. onLeaveCombat, and if the buff is missing use a potion.

Something like;

Code: Select all

player:updateBuffs("player")
if player:hasBuff("Speed") then -- the name of the buff
    inventory:useItem("Speed Potion") -- the name of the potion
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#3 Post by Giram »

Hellou

I have created this little code to use housemaid potions. I have been using this inside <onLeaveCombat></onLeaveCombat> but i think it can be placed on others too. This works for english version but those names are easy to change after each section. This is still in progress but has been working well. Hope you guys enjoy it :)

Code: Select all

<!--     [Housemaid potions]
    
            This checks if we have housemaid potion buff. 
            If we dont have that buff then bot drinks potion if we have
            potions on inventory and it is set to use it.
            
            Bugs:
            - It  uses luck potion randomly sometimes.
                - Maybe add timer into check so it would try to use another in 1.45h or so.

            Version history:
            1.2 -    New food: Special Spicy Meatsauce Burrito and little remade code. 
                    Buff names can all be seen once and change if needed.
            1.1    -    Corrected Luck potion buff name
            1.0    -    Added time after using potions so it would use all potions after first kill. 
                    It was using all too fast. Potions get cooldown after using one so it skips others.
            0.9    -    Added Housekeeper Special Caviar Sandwich to list
            0.8    -     Remade code. Now it uses only 1 if to check all and if all conditions are true then it uses potion.
                    Its easier to add potions later if needed.
            
    -->
    <!-- User setting starts here -->
    <!-- Define these if you want to use something. True uses it and false ignores it. -->
    local useSpeed = true;    -- Housemaid speed potion
    local useFrog = false;     -- Housemaid frog potion
    local useLuck = true;    -- Housemaid luck potion
    local useSaltedFish = true; -- Housemaid food
    local useCaviarSandwich = true; -- Housemaid food
    local useSpecialMeatsauceBurrito = true; -- Housemaid food
    
    <!-- Potions id and its buff name. If using other than english client then change buff name. -->
    local pot1ID = 207200;    -- Unbridled Enthusiasm
    local buff1Name = "Unbridled Enthusiasm";
    
    local pot2ID = 207201;    -- Princely Look
    local buff2Name = "Princely Look";
    
    local pot3ID = 207203;    -- Turn of Luck Powder Dust
    local buff3Name = "Turn of Luck Powder Dust";
    
    local pot4ID = 207213; -- Special Spicy Meatsauce Burrito
    local buff4Name = "Spicy Meatsauce Burrito";
    
    local pot5ID = 207211;
    local buff5Name = "Caviar Sandwich";
    
    local pot6ID = 207209;
    local buff6Name = "Salted Fish with Sauce";
    <!-- User settings end here -->
    
    <!-- Unbridled Enthusiasm potion -->
    if not player:hasBuff(buff1Name) and inventory:itemTotalCount(pot1ID) >= 1 and useSpeed == true then
        inventory:useItem(pot1ID);
        inventory:update();
        yrest(750);
    end
    
    <!-- Princely looking potion -->
    if not player:hasBuff(buff2Name) and inventory:itemTotalCount(pot2ID) >= 1 and useFrog == true then
        inventory:useItem(pot2ID);
        yrest(900); -- Lets wait till we cast. After that we loot. I don't know if we could loot before casting.
        inventory:update();
    end

    <!-- Lucky Target potion -->
    if not player:hasBuff(buff3Name) and inventory:itemTotalCount(pot3ID) >= 1 and useLuck == true then
        inventory:useItem(pot3ID);
        inventory:update();
        yrest(750);
    end
    
    <!-- Special Spicy Meatsauce Burrito -->
    if not player:hasBuff(buff4Name) and inventory:itemTotalCount(pot4ID) >= 1 and useSpecialMeatsauceBurrito == true then
        inventory:useItem(pot4ID);
        inventory:update();
        yrest(750);
    end

    <!-- Special Caviar Sandwich -->
    if not player:hasBuff(buff5Name) and inventory:itemTotalCount(pot5ID) >= 1 and useCaviarSandwich == true then
        inventory:useItem(pot5ID);
        inventory:update();
        yrest(750);
    end
    
    <!-- Special Salted Fish with Sauce -->
    if not player:hasBuff(buff6Name) and inventory:itemTotalCount(pot6ID) >= 1 and useSaltedFish == true then
        inventory:useItem(pot6ID);
        inventory:update();
        yrest(750);
    end
Ps. Feel free to leave comments on improving this in anyway.

Edit: Updated code.
Last edited by Giram on Sat Oct 09, 2010 9:07 pm, edited 3 times in total.
horsewilly
Posts: 25
Joined: Tue Aug 17, 2010 6:41 am

Re: Using Buff Potions

#4 Post by horsewilly »

Oh that's great, thanks a bunch for sharing! :D
I'll be sure to try it out
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#5 Post by Giram »

Not really sure if anyone is interested about this but i updated my code. I hope self bumb is allowed here :)

http://www.solarstrike.net/phpBB3/viewt ... 690#p13690

Edit: There was typo in code but i fixed it.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Using Buff Potions

#6 Post by rock5 »

Can I make a suggestion? Put this code in a function in an lua file to be placed in the userfunctions file. That way people can just put the file in the userfunctions folder and use the function wherever they like.

eg.
addon_housemaidpots.lua

Code: Select all

function useMaidPots()
    your code
end
Profile

Code: Select all

<onLeaveCombat>
    useMaidPots()
</onLeaveCombat>
You could even increase it's functionality to accept an argument eg.

Code: Select all

useMaidPots("speed")
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#7 Post by Giram »

Here is new and improved version of my housemaid potion and food script. Download attachment and place it to userfunctions folder. I hope names explain them self what they do.

These command are now available. More to come if needed.
These are crafting potions:

Code: Select all

useHousemaidPotions("speed");

Code: Select all

useHousemaidPotions("frog");

Code: Select all

useHousemaidPotions("luck");

Code: Select all

useHousemaidPotions("clearThought");

Code: Select all

useHousemaidPotions("crazyBreakout");

Code: Select all

useHousemaidPotions("fullness");

Code: Select all

useHousemaidPotions("gallopingGale");
These are housemaid foods:

Code: Select all

useHousemaidPotions("MeatsauceBurrito");

Code: Select all

useHousemaidPotions("caviarSandwich");

Code: Select all

useHousemaidPotions("saltedFish");

Code: Select all

useHousemaidPotions("deliciousSwampMix");
How to use these command? Copy line that you want the bot to use.

Example:

Code: Select all

<onLeaveCombat><![CDATA[
        -- Additional Lua code to execute after killing an enemy
    ]]>
    
    useHousemaidPotions("speed");
    useHousemaidPotions("luck");
    useHousemaidPotions("MeatsauceBurrito");

    </onLeaveCombat>
Edit:
Improved code and added potions.

Not really sure if Crazy Breakout works. Haven't got change to test it.
Attachments
addon_housemaidPotions_V2.lua
(1.54 KiB) Downloaded 204 times
Last edited by Giram on Sun Oct 17, 2010 3:13 pm, edited 2 times in total.
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#8 Post by Giram »

I would appriciate if someone could help me get buff names for few potion / food. Them this addon would cover caster items to.

I miss buff names for these items:
- Housekeeper Special Smoked Bacon with Herbs 207210
- Housekeeper Special Deluxe Seafood 207212
- Housekeeper Special Delicious Swamp Mix 207214
- Housekeeper Special Unimaginable Salad 207215
- Galloping Gale 207204
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Using Buff Potions

#9 Post by rock5 »

Good work.

You could probably further optimize it by having it accept a table of items too.

eg.

Code: Select all

    useHousemaidPotions({"speed","luck","MeatsauceBurrito"});
Also instead of repeating the same bit of code 6 time or more, you could create a loop and use an item table.

eg.

Code: Select all

itemTable ={
  [1]={optionName = "speed", potID = 207200, buffName = "Unbridled Enthusiams"},
  [2]={optionName = "frog", potID = 207200, buffName = "Princely Look"},
  [3]={optionName = "luck", potID = 207200, buffName = "Turn of Luck Powder Dust"},
  [4]={optionName = "MeatsauceBurrito", potID = 207200, buffName = "Spicy Meatsauce Burrito"},
  [5]={optionName = "caviarSandwich", potID = 207200, buffName = "Caviar Sandwich"},
  [6]={optionName = "saltedFish", potID = 207200, buffName = "Salted Fish with Sauce"},
}
Then your function would look like.

Code: Select all

function useHousemaidPotions(_potionName)

for __, option in pairs(itemTable) do
	if _potionName == option.optionName then
		if not player:hasBuff(option.buffName) and inventory:itemTotalCount(option.potID) >= 1 then
			inventory:useItem(option.potID);
			inventory:update();
			yrest(750);
		end
	end
end

end
The benefits of this is, to add an item you just have to add it to the table and to change your function code you only have to change it once, not once for every item.

Hope this helps.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#10 Post by Giram »

Thanks for the tips how to optimize it.

Could you explain how this part works? I have never seen that kind of for for loop.

Code: Select all

for __, option in pairs(itemTable) do
This kind of for loop i am familiar with:

Code: Select all

for (x = 0; x < 10; x++) {
    code here
}
User avatar
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: Using Buff Potions

#11 Post by Administrator »

It's easier to understand when you see it like this:

Code: Select all

for i,v in pairs(someTable) do
'i' is the index, and 'v' is the value. It will go everything in someTable and give the proper index and value for each. For example:

Code: Select all

someTable = {1 = "red", 2 = "green", 3 = "blue"};
for i,v in pairs(someTable) do
  print(i, v);
end
-- this will print:
-- 1     red
-- 2     green
-- 3     blue
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#12 Post by Giram »

User avatar
ezgitaran
Posts: 25
Joined: Tue Sep 14, 2010 8:47 am

Re: Using Buff Potions

#13 Post by ezgitaran »

Fix for typo on 3rd line in addon_housemaidPotions_V2.lua ;)

Code: Select all

[1] = {optionName = "speed", potID = 207200, buffName = "Unbridled Enthusiasm", castTime = 0},
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: Using Buff Potions

#14 Post by Giram »

Fixed that typo and uploaded new version even its with same name.
Post Reply