Page 1 of 1

item buff userfunction

Posted: Tue Feb 05, 2013 6:41 am
by lisa
This is mainly aimed at fully buffing up before a boss fight.

call it using

Code: Select all

itemBuffs()
--=== Basic explanation ===--
it will go through all of your inventory, including itemshop, transmuter bags. It will decide what items it can use and then use them.

--=== More complicated explanation ===--
it will go through all of your inventory, including itemshop, transmuter bags.
checks your existing buffs
checks which items are on cooldown
checks for buffs that will over ride other buffs
checks for items that share the same cooldown

decides to use the items of shared cooldown/buff according
housemaid items, then longer buff durations then lvl V 1.6

It then uses the items in order of longest lasting buff first.


If you do instances I suguest trying it out in the new profile event section.

Code: Select all

	<preCodeOnElite><![CDATA[
		itemBuffs()
	]]></preCodeOnElite>

At the top of the file is this

Code: Select all

--=== if you find it misses using an item that it prints it is using ===--
--=== then increase the laggallowance value in milliseconds ===--
--=== ie. 200   300   400   500 ===--
local laggallowance = 200
As it says, if you find some items arn't being used you can increase the value, or if you have a really low ping you can try it at 0, do not delete the value or the userfunction will error, just change the number.

Re: item buff userfunction

Posted: Tue Feb 05, 2013 6:48 am
by lisa
these are the items so far, if I missed any please post them here, add also Item ID if you can =)

Code: Select all

	local buffitems = {
	--=== Housemaid Potions ===--
	{itemId = 207200, buffId = 506684, types = "both"}, 		-- Unbridled Enthusiasm , faster run/walk
	{itemId = 207202, buffId = 506686, types = "magic"},		-- Clear Thought, faster spell casting
	{itemId = 207203, buffId = 506687, types = "both"},			-- Turn of Luck Powder Dust
	{itemId = 207206, buffId = 506690, types = "both", cooldown = 0},			-- Scarlet Love, increases physical defence
	{itemId = 207207, buffId = 506691, types = "both", cooldown = 0},			-- Pungent Vileness, "tank" increases agro
	{itemId = 207208, buffId = 506692, types = "both"},			-- Godspeed
	
	--=== Housemaid Food ===--
	{itemId = 207209, buffId = 506673, types = "physical"},		-- Housekeeper Special Salted Fish with Sauce
	{itemId = 207210, buffId = 506674, types = "magic"},		-- Housekeeper Special Smoked Bacon with Herbs
	{itemId = 207211, buffId = 506675, types = "physical"},		-- Housekeeper Special Caviar Sandwich
	{itemId = 207212, buffId = 506676, types = "magic"},		-- Housekeeper Special Deluxe Seafood
	{itemId = 207213, buffId = 506677, types = "physical"},		-- Housekeeper Special Spicy Meatsauce Burrito
	{itemId = 207214, buffId = 506678, types = "magic"},		-- Housekeeper Special Delicious Swamp Mix
	{itemId = 207215, buffId = 506679, types = "physical"},		-- Housekeeper Special Unimaginable Salad
	{itemId = 207216, buffId = 506680, types = "magic"},		-- Housekeeper Special Cheese Fishcake
	
	
	--=== mementos vendor ===--
	{itemId = 206874, buffId = 506271, types = "both"},			-- Grassland Mix
	{itemId = 206891, buffId = 506268, types = "both"},			-- Lizard Blood
	
	{itemId = 206875, buffId = 506272, types = "both"},			-- Fresh Fish Soup, "healer"
	{itemId = 206876, buffId = 506273, types = "physical"},		-- Roast Wolf Leg
	{itemId = 206877, buffId = 506119, types = "physical"},		-- Roast Leg of Lamb	
	{itemId = 206878, buffId = 506120, types = "magic"},		-- Crispy Chicken Drumstick
	{itemId = 206890, buffId = 506121, types = "magic"},		-- Charcoal Barbequed Beef
	
	{itemId = 207020, buffId = 506122, types = "both"},			-- Vegetable Sandwich
	{itemId = 207021, buffId = 506123, types = "both"},			-- Smoked Salmon
	
	{itemId = 207969, buffId = 507251, types = "both"},			-- Rhinoceros Blood
	{itemId = 207970, buffId = 507252, types = "physical"},		-- War Insignia
	{itemId = 207971, buffId = 507253, types = "magic"},		-- Secret Ritual Manual
	{itemId = 207675, buffId = 507077, types = "both"},			-- Madness Potion Bag, "tank". IS bag item 207921
	{itemId = 207671, buffId = 506985, types = "both"},			-- Defense Potion Bag, "tank". IS bag item 207922
	{itemId = 207673, buffId = 507075, types = "both"},			-- Cleansing Potion Bag, "healer". IS bag item 207923
	{itemId = 206892, buffId = 506269, types = "physical"},		-- Tiger Fury
	
	--=== Item shop ===--
	{itemId = 202322, buffId = 501647, types = "both"},			-- Potent Luck, might remove this.
	
	{itemId = 200056, buffId = 500999, types = "physical"},		-- Attack Sigil
	{itemId = 200927, buffId = 501002, types = "magic"},		-- Magic Attack Sigil
	{itemId = 200359, buffId = 501631, types = "physical"},		-- Hot Stew
	{itemId = 202240, buffId = 501614, types = "both"},			-- Egg Rice Dumplings
	{itemId = 204553, buffId = 503326, types = "both"},			-- Universal Potion, +100 all attributes
	
	{itemId = 204461, buffId = 503328, types = "magic"},		-- Magic Guitar (3 Days)	
	{itemId = 204462, buffId = 503327, types = "physical"},		-- Magic Lute (3 Days)
	{itemId = 204463, buffId = 503331, types = "both"},			-- Magic Tambourine (3 Days)

	--=== Crafted Items ===--
	{itemId = 207636, buffId = 495798, types = "magic"},		-- Loaf of Handmade Black Bread
	{itemId = 207645, buffId = 507064, types = "magic"},		-- Meat Sandwich
	{itemId = 207654, buffId = 507046, types = "physical"},		-- Spiced Rack of Ribs
	{itemId = 207605, buffId = 495816, types = "physical"},		-- Spiced Roast Fish, needs buff Id checked.
	{itemId = 207653, buffId = 507045, types = "physical"},		-- Lightly Burnt Ribs
	{itemId = 207635, buffId = 507054, types = "magic"},		-- Loaf of Magic Hard Bread
	{itemId = 207644, buffId = 507063, types = "magic"},		-- Lettuce Sandwich
	{itemId = 200122, buffId = 501162, types = "magic"},		-- Dinner of the Gods
	{itemId = 200115, buffId = 501155, types = "magic"},		-- Moti Blended Sausage
	{itemId = 200109, buffId = 501149, types = "magic"},		-- Delicious Swamp Mix
	{itemId = 200108, buffId = 501148, types = "magic"},		-- Seaworm Salad
	{itemId = 200096, buffId = 501136, types = "magic"},		-- Fish Egg Sandwich
	{itemId = 207596, buffId = 507028, types = "both"},			-- Ordinary Chocolate
	{itemId = 207663, buffId = 507019, types = "both"},			-- Cheesecake
	{itemId = 207662, buffId = 507018, types = "both"},			-- Chocolate Cake
	{itemId = 207595, buffId = 507027, types = "both"},			-- Bitter Dark Chocolate
	{itemId = 200192, buffId = 500112, types = "magic"},		-- Ancient Spirit Water
	{itemId = 200225, buffId = 500311, types = "both"},			-- Embrace of the Muse, mana, but knights also use mana
	{itemId = 240535, buffId = 507126, types = "magic"},		-- Extinguish Potion
	{itemId = 240533, buffId = 507122, types = "magic"},		-- Strong Magic Potion
	{itemId = 200114, buffId = 501154, types = "magic"},		-- Cheese Fishcake
	{itemId = 200194, buffId = 501213, types = "both"},			-- Life Source
	{itemId = 200113, buffId = 501153, types = "physical"},		-- General's Three-color Sausage
	{itemId = 200277, buffId = 501337, types = "both"},			-- Hero Potion, all attributes +20%
	{itemId = 200427, buffId = 501325, types = "both"},			-- Tranquility Powder, - agro for 30 seconds
	
	--=== Untested, got info from memory ===--
	{itemId = 207656, buffId = 495827, types = "both"},			-- Smoked Ribs
	{itemId = 207607, buffId = 495818, types = "physical"},		-- Smoked Fish
	{itemId = 207665, buffId = 495791, types = "both"},			-- Honey Cake
	{itemId = 207647, buffId = 495809, types = "magic"},		-- Huge Sandwich
	
	{itemId = 202895, buffId = 850473, types = "both"},			-- Meaningful Love Cake Slice, possible other buffid 623767
	{itemId = 241959, buffId = 850476, types = "physical"},		-- Vanilla Strawberry Dessert, possible other buffid 623770
	{itemId = 241965, buffId = 850482, types = "both"},			-- Elegant Cuisine Delicacy, possible other buffid 623776
	{itemId = 203024, buffId = 502704, types = "both"},			-- Blessing of the Flower God
	
	}

Re: item buff userfunction

Posted: Tue Feb 05, 2013 11:21 am
by lisa
priority check still isn't working as I want it to, V 1.0 will basically use the last item it sees in bags (for each group) because of a little miscalculation I did.

Just can't seem to make it work the way I want it to.

dug a lot deeper with a lot of prints, turns out the item cooldown is failing and also the buffTimeLeft is failing =(

Re: item buff userfunction

Posted: Tue Feb 05, 2013 12:09 pm
by rock5
Is it just failing to read or are some items not returning the values expected?

With my study of the skills memory in my excel sheet nearly every value that I'm sure what it means has exceptions. Just a few skills that don't have the correct value there.

Re: item buff userfunction

Posted: Tue Feb 05, 2013 6:43 pm
by lisa
I need to look at it a bit more but my theory atm is there are more items like the Scarlet Love that the memory isn't what is true for the item. In memory Scarlet Love says it has a cooldown but when you use the item it has no cooldown.
I did allow for this but I never looked to see if other items were like this as it would mean going through every single item in the list, which would be kind of painful but also I don't have access to every item in order to test it.

Theory I am going with atm is to return 2 things from the getcooldown.

Code: Select all

return (memoryReadRepeat("int", getProc(), addresses.staticCooldownsBase + 0x80C + (offset+1)*4) or 0)/10, "success"
if it actually gets to this return then it succeeded, otherwise if it fails then return this

Code: Select all

return 0, "failed"
So atleast I can see on screen which items are failing to read this memory and manually adjust the cooldown like I did for the other items.

Code: Select all

	{itemId = 207206, buffId = 506690, types = "both", cooldown = 0},			-- Scarlet Love, increases physical defence
	{itemId = 207207, buffId = 506691, types = "both", cooldown = 0},			-- Pungent Vileness, "tank" increases agro

So yeah basically I spent hours trying to work out why my decision making code wasn't working when in fact it was the memory reads failing before even getting to that point =(

I also find it interesting that there have been 8 downloads of the userfunction but not 1 person has posted about it, I just realised that without the CItem:getRemainingCooldown() (not in bot yet) it would just error for people.

Do those google search bots also download files for some reason?

Re: item buff userfunction

Posted: Tue Feb 05, 2013 7:35 pm
by lisa
these items always fail the getcooldown mem reads

Code: Select all

	{itemId = 240535, buffId = 507126, types = "magic"},		-- Extinguish Potion
	{itemId = 240533, buffId = 507122, types = "magic"},		-- Strong Magic Potion
Ok worked it out, some items have 1 instead of 3, if they have 1 then the + offset is 0, if they have 3 then then + offset is 0x80C

This works

Code: Select all

			local val = memoryReadRepeat("int", getProc(), skillItemAddress + 0xE0)
			local plusoffset
			if val == 1 then plusoffset = 0 elseif val == 3 then plusoffset = 0x80C else return 0, "failed" end 
			if memoryReadRepeat("int", getProc(), skillItemAddress + 0xE0) ~= 0 then
				local offset = memoryReadRepeat("int", getProc(), skillItemAddress + addresses.skillRemainingCooldown_offset)
				return (memoryReadRepeat("int", getProc(), addresses.staticCooldownsBase + plusoffset + (offset+1)*4) or 0)/10, "success"

Code: Select all

success  41.7   Extinguish Potion
success  41.7   Strong Magic Potion

Ok that is all working perfectly now.

Next question.
If a buff has less than say 10 seconds remaining should we just use the item again or leave it as is with that 10 seconds to go?
I am thinking just buff again as 10 seconds isn't long, by the time you fully buff up you might only have a few seconds left on that buff.

Added a

Code: Select all

 if v.Id > 207200 and 207220 > v.Id then score = 500 end 
so housekeeper items will always be used as a preference to other items.

Re: item buff userfunction

Posted: Tue Feb 05, 2013 9:31 pm
by lisa
ok V 1.1 posted, also update to rev 749 + to actually be able to use it.

Re: item buff userfunction

Posted: Tue Feb 05, 2013 11:39 pm
by lisa
I'll tidy it up tonight, finally worked out how to make it work and be pretty.

A table inside a table, *slaps forehead* so obvious.

So I can have my tmptable and then do a table.insert(tmptable[1],item) and change the number for each group.

So you end up with
tmptable[1] = {item1,item2,item3}
tmptable[2] = {item4,item5}
tmptable[3] = {item6}

each [#] is a different group.

Re: item buff userfunction

Posted: Tue Feb 05, 2013 11:46 pm
by rock5
lisa wrote:Ok worked it out, some items have 1 instead of 3, if they have 1 then the + offset is 0, if they have 3 then then + offset is 0x80C
LoL. Didn't I mention my theory that that number meant which section of the cooldown to read from? Because skills all use 1 and are the first section and wings use 2 and read from a section between the skills and item cooldowns. Well if I forgot to mention it, there it is. :D

We could probably even do a general purpose getcooldown function.

Re: item buff userfunction

Posted: Wed Feb 06, 2013 12:58 am
by lisa
rock5 wrote:We could probably even do a general purpose getcooldown function.
yeah that is what I was thinking,

The 1, skills
2 wings
3 items
didn't hold true though because there were items with 1, even just doing the check ~= 0 like you said wouldn't get the cooldown because you also need to change the + offset, all that would have happened would be you would get the cooldown of a different item/skill because it would add the value to the wrong base address.

Re: item buff userfunction

Posted: Wed Feb 06, 2013 2:17 am
by rock5
So we could have a function that accepts the id of a skill, or realItemId in the case of items, and gets the val and offset then gets the appropriate cooldown. Except you wouldn't want CSkill:getRemainingCooldown to be looking up the baseitemaddress every time it checks the cooldown when it already has the baseitemaddress in skill.BaseItemAddress. So maybe make the function accept the baseitemaddress instead.

We could go the other way and make it so it could accept any id and it works out what type of id it is and proceeds from there but I think it would become to unnecessarily complex. Hm... maybe not so complex. I'll have a little stab at it and see how I go.

Re: item buff userfunction

Posted: Wed Feb 06, 2013 2:43 am
by lisa
updated V 1.6

I have learned alot about tables in the last 2 days ;)

Current code is so simple it's not funny.

I replaced 40 lines of code with just 13, which includes descriptions.

Code: Select all

	-- add groups into their own table of tables
	local groups = {}
	for k,v in ipairs(workingtable) do
		if tmptable[v.group] == nil then tmptable[v.group] = {} table.insert(groups,v.group) end
		table.insert(tmptable[v.group],v)
	end
	
	workingtable = {}
	-- sort items by score, within their own groups
	for k,v in pairs(groups) do
		table.sort(tmptable[v], function(a,b) return a.score > b.score end)
		-- first item will be best score item because of the sorting
		table.insert(workingtable,tmptable[v][1])
	end

Re: item buff userfunction

Posted: Wed Feb 06, 2013 3:09 am
by rock5
Congratz.

The function I was working on is not so simple. I unthinkingly thought I was dealing with 3 ids but it's 2 ids(item or skill id) and an address (baseitemaddress). That makes it too messy.

So the simpler idea would be this

Code: Select all

function getRemainingCooldown(skillBaseAddress)
	if ( skillBaseAddress ~= nil and skillBaseAddress ~= 0 ) then
		local val = memoryReadRepeat("int", getProc(), skillBaseAddress + 0xE0)
		local plusoffset
		if val == 1 then plusoffset = 0 elseif val == 3 then plusoffset = 0x80C else return 0, false end 
		local offset = memoryReadRepeat("int", getProc(), skillItemAddress + addresses.skillRemainingCooldown_offset)
		
		return (memoryReadRepeat("int", getProc(), addresses.staticCooldownsBase + plusoffset + (offset+1)*4) or 0)/10, true
	end
end
Then both the skills and item functions could use it. And possibly other things in the future.

Re: item buff userfunction

Posted: Wed Feb 06, 2013 10:01 pm
by wilifox
Lisa Goodnight, how I can add your function in my code?

I added in my profile:

<preCodeOnElite> <! [CDATA [
itemBuffs ()
]]> </ preCodeOnElite>

but when I farm the first boss Grafu not work any food or instruments. As I have to add to my waypoint?

Re: item buff userfunction

Posted: Wed Feb 06, 2013 10:10 pm
by lisa
If you are using the latest bot revision, 749, I would say it would be an elite factor issue.

Default elite factor is 5, so if the grafu boss max hp is less than 5 times your maxhp then it won't be concidered elite.

use this in your profile

Code: Select all

<option name="AUTO_ELITE_FACTOR"    value="2" />
I personally put in near the combat options

Code: Select all

		<!-- Combat options -->
		<option name="COMBAT_TYPE"        	value="" />				<!-- leave empty or choose ranged/melee if not using class default -->
		<option name="COMBAT_RANGED_PULL" 	value="true" /> 		<!-- only important for melees -->
		<option name="COMBAT_DISTANCE"    	value="160" />
		<option name="MAX_FIGHT_TIME"     	value="20" />			<!-- Max time without damage before break -->
		<option name="DOT_PERCENT"        	value="90" />
		<option name="ANTI_KS"            	value="false" />
		<option name="MAX_TARGET_DIST"    	value="200" />
		<option name="AUTO_ELITE_FACTOR"    value="2" />
to make sure the event is actually working you can add a simple print in it.

Code: Select all

<preCodeOnElite> <! [CDATA [
print("The pre code elite is working, mob name is ".._arg1.Name)
itemBuffs()
]]> </ preCodeOnElite>

Seems you have a space in the function call aswell, itemBuffs"space"(), have a look and remove the space.