Page 1 of 1
Using Buff Potions
Posted: Mon Sep 27, 2010 3:30 pm
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

Re: Using Buff Potions
Posted: Mon Sep 27, 2010 10:06 pm
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
Re: Using Buff Potions
Posted: Tue Sep 28, 2010 7:33 am
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.
Re: Using Buff Potions
Posted: Tue Sep 28, 2010 4:51 pm
by horsewilly
Oh that's great, thanks a bunch for sharing!
I'll be sure to try it out
Re: Using Buff Potions
Posted: Sat Oct 09, 2010 8:44 pm
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.
Re: Using Buff Potions
Posted: Sat Oct 09, 2010 10:59 pm
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.
Re: Using Buff Potions
Posted: Sun Oct 10, 2010 6:55 am
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("clearThought");
Code: Select all
useHousemaidPotions("crazyBreakout");
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.
Re: Using Buff Potions
Posted: Sun Oct 10, 2010 9:11 am
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
Re: Using Buff Potions
Posted: Sun Oct 10, 2010 7:26 pm
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.
Re: Using Buff Potions
Posted: Mon Oct 11, 2010 4:56 am
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
}
Re: Using Buff Potions
Posted: Mon Oct 11, 2010 12:16 pm
by Administrator
It's easier to understand when you see it like this:
'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
Re: Using Buff Potions
Posted: Sun Oct 17, 2010 3:18 am
by Giram
Re: Using Buff Potions
Posted: Sun Oct 17, 2010 2:34 pm
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},
Re: Using Buff Potions
Posted: Sun Oct 17, 2010 3:14 pm
by Giram
Fixed that typo and uploaded new version even its with same name.