Item Check for Dailyquests

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
TheRedVex
Posts: 5
Joined: Wed Aug 19, 2009 1:39 am

Item Check for Dailyquests

#1 Post by TheRedVex » Wed Aug 19, 2009 1:42 am

Can the bot handle a itemcheck? Where i have to include it?

I want to write a Waypointfile for the Dailyquests and so i need the item check for the Fungi or whe Wolfs at the Pioneers.
Would be nice if you could help me.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Item Check for Dailyquests

#2 Post by Administrator » Wed Aug 19, 2009 2:17 am

Not at this time, no. Someone would need to find static pointers to inventory slots first. I actually haven't bothered doing this myself, so I'm not sure how it is structured.

TheRedVex
Posts: 5
Joined: Wed Aug 19, 2009 1:39 am

Re: Item Check for Dailyquests

#3 Post by TheRedVex » Mon Aug 31, 2009 2:22 am

okay i have writen a working ItemInventoryscan where u can search the inventory for a itemid.
Now is my question can i write an Fightvariable for each mob?

like

Code: Select all

fights.fungi
fights.wolfs
...
it would be better to do it with each own Variable for the Dailyquests and itemscan.

TheRedVex

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: Item Check for Dailyquests

#4 Post by droppen » Mon Aug 31, 2009 2:49 am

TheRedVex wrote:okay i have writen a working ItemInventoryscan where u can search the inventory for a itemid.
Now is my question can i write an Fightvariable for each mob?

like

Code: Select all

fights.fungi
fights.wolfs
...
it would be better to do it with each own Variable for the Dailyquests and itemscan.

TheRedVex
care to share the code?

TheRedVex
Posts: 5
Joined: Wed Aug 19, 2009 1:39 am

Re: Item Check for Dailyquests

#5 Post by TheRedVex » Mon Aug 31, 2009 2:57 am

droppen wrote:
TheRedVex wrote:okay i have writen a working ItemInventoryscan where u can search the inventory for a itemid.
Now is my question can i write an Fightvariable for each mob?

like

Code: Select all

fights.fungi
fights.wolfs
...
it would be better to do it with each own Variable for the Dailyquests and itemscan.

TheRedVex
care to share the code?
if the codes with fungi and wolfs ... are find out i would like to share it yes

TheRedVex
Posts: 5
Joined: Wed Aug 19, 2009 1:39 am

Re: Item Check for Dailyquests

#6 Post by TheRedVex » Mon Aug 31, 2009 4:44 am

okay i´ve got it. here is my Code



this is the advanced killingfunction

add this to the pawn.lua like this

Code: Select all

CPawn = class(function (self, ptr)
		self.Address = ptr;
		self.Name = "<UNKNOWN>";
		self.Id = 0;
		self.Type = PT_NONE;
		self.Guild = "<UNKNOWN>";
		self.Level = 1;
		self.Level2 = 1;
		self.HP = 1000;
		self.MaxHP = 1000;
		self.MP = 1000;
		self.MaxMP = 1000;
		self.MP2 = 1000;
		self.MaxMP2 = 1000;
		self.X = 0.0;
		self.Y = 0.0;
		self.Z = 0.0;
		self.TargetPtr = 0;
		self.Direction = 0.0;
		self.Attackable = false;
		self.Alive = true;


		-- Directed more at player, but may be changed later.
		self.Battling = false; -- The actual "in combat" flag.
		self.Fighting = false; -- Internal use, does not depend on the client's battle flag
		self.Casting = false;
		self.Mana = 0;
		self.MaxMana = 0;
		self.Rage = 0;
		self.MaxRage = 0;
		self.Energy = 0;
		self.MaxEnergy = 0;
		self.Concentration = 0;
		self.MaxConcentration = 0;
		self.PotionLastUseTime = 0;
		self.Returning = false;		-- Whether following the return path, or regular waypoints
		self.BotStartTime = os.time(); -- Records when the bot was started.
		self.BotStartTime_nr = 0; -- Records when the bot was started, will not return at pause
		self.Unstick_counter = 0;	-- counts unstick tries, resets if waypoint reached
		self.Success_waypoints = 0; -- count consecutively successfull reached waypoints 
		self.Cast_to_target = 0;	-- count casts to our enemy target
		self.LastAggroTimout = 0;	-- remeber last time we wait in vain for an aggro mob
		self.Sleeping = false;		-- sleep mode with fight back if attacked
		self.Sleeping_time = 0;		-- counts the sleeping time
		self.Fights = 0;			-- counts the fights
		self.Death_counter = 0;		-- counts deaths / automatic reanimation
		self.MP_counter = 0;		-- counts use of mana potions
		self.HP_counter = 0;		-- counts use of HP potions
		self.Current_waypoint_type = WPT_NORMAL;	-- remember current waypoint type global
		self.Last_ignore_target_ptr = 0;		-- last target to ignore
		self.Last_ignore_target_time = 0;		-- last target to ignore
		self.lastHitTime = 0;				-- last time the HP of the target changed
		self.ranged_pull = false;			-- ranged pull phase active
		self.free_field1 = nil;				-- free field for user use
		self.free_field2 = nil;				-- free field for user use
		self.free_field3 = nil;				-- free field for user use
		self.free_counter1 = 0;				-- free counter for user use
		self.free_counter2 = 0;				-- free counter for user use
		self.free_counter3 = 0;				-- free counter for user use		
		self.free_flag1 = false;			-- free flag for user use
		self.free_flag2 = false;			-- free flag for user use
		self.free_flag3 = false;			-- free flag for user use
		
		------------------ New attach for specific Mobkilling --------------------------
		--------------------------------------------------------------------------------
		
		self.mobs = {};
		
		--------------------------------------------------------------------------------
		--------------------------------------------------------------------------------

		
		if( self.Address ~= 0 and self.Address ~= nil ) then self:update(); end
	end
);
and then add this to the end of the fightfunction of player.lua

Code: Select all

------------------ New attach for specific Mobkilling --------------------------
	--------------------------------------------------------------------------------
	local mobid = string.format("%s",target.Name);
	if(self.mobs[mobid] == nil) then
		self.mobs[mobid] = 0
	end
	self.mobs[mobid] = self.mobs[mobid] + 1
	cprintf(cli.lightblue, "%s kills : %s\n",mobid,self.mobs[mobid]);
	
	--------------------------------------------------------------------------------
	--------------------------------------------------------------------------------
	
	self.Fighting = false;
	self:clearTarget();
and comment the clearTarget line under Self:loot();

add this to the end of the Player.lua

Code: Select all

function CPlayer:ScanForItem(itemid)
	local item;
	local anzahl;
	local slot;
	local gesamt = 0;
	for i=0, 29 do
		slot = i + 1
		item = memoryReadInt(getProc(), Inv[i]);
		if(item == itemid) then
			anzahl = memoryReadInt(getProc(), Anzahl[i]);
			gesamt = anzahl + gesamt
			cprintf(cli.yellow,"Slot %s: %sx %s\n",slot,anzahl,item);
		end
		
	end
	if(gesamt >=1) then
		cprintf(cli.yellow,"Gesamt %s: %sx\n",itemid,gesamt);
		return gesamt
	else
		return 0
	end
end
add this to the adresses.lua

Code: Select all

Inv = {
	[0] = 0x008EEB78,
	[1] = 0x008EEB38,
	[2] = 0x008EED58,
	[3] = 0x008EEAB0,
	[4] = 0x008EE7C0,
	[5] = 0x008EEAF0,
	[6] = 0x008EE5E4,
	[7] = 0x008EE9E0,
	[8] = 0x008EE5A0,
	[9] = 0x008EE804,
	[10] = 0x008EE848,
	[11] = 0x008EE890,
	[12] = 0x008EE8D0,
	[13] = 0x008EE918,
	[14] = 0x008EE958,
	[15] = 0x008EE9A0,
	[16] = 0x008EE628,
	[17] = 0x008EEA28,
	[18] = 0x008EEA68,
	[19] = 0x008EE670,
	[20] = 0x008EE6B0,
	[21] = 0x008EE6F8,
	[22] = 0x008EE738,
	[23] = 0x008EEBC0,
	[24] = 0x008EEC00,
	[25] = 0x008EEC48,
	[26] = 0x008EEC88,
	[27] = 0x008EECD0,
	[28] = 0x008EED10,
	[29] = 0x008EE780,
};
Anzahl = {
	[0] = 0x008EEB88,
	[1] = 0x008EEB44,
	[2] = 0x008EED64,
	[3] = 0x008EEABC,
	[4] = 0x008EE5F4,
	[5] = 0x008EEB00,
	[6] = 0x008EE5F4,
	[7] = 0x008EE9F0,
	[8] = 0x008EE5B0,
	[9] = 0x008EE814,
	[10] = 0x008EE858,
	[11] = 0x008EE89C,
	[12] = 0x008EE8E0,
	[13] = 0x008EE924,
	[14] = 0x008EE968,
	[15] = 0x008EE9AC,
	[16] = 0x008EE638,
	[17] = 0x008EEA34,
	[18] = 0x008EEA78,
	[19] = 0x008EE67C,
	[20] = 0x008EE6C0,
	[21] = 0x008EE704,
	[22] = 0x008EE748,
	[23] = 0x008EEBCC,
	[24] = 0x008EEC10,
	[25] = 0x008EEC54,
	[26] = 0x008EEC98,
	[27] = 0x008EECDC,
	[28] = 0x008EED20,
	[29] = 0x008EE78C,
};
you will not die if you thank me for that.

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: Item Check for Dailyquests

#7 Post by droppen » Mon Aug 31, 2009 5:48 am

Wow! nice coding there! The item checking is now possible though too. I made this function for you

Code: Select all

function countItemTotal(itemName)
	local itemTotal = 0;
	for i = 1, 60, 1 do
		local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo("..i..");");
		if (itemName == name) then
			itemTotal = itemTotal + itemCount;
		end
	end
	return itemTotal;
end
Usage:

Code: Select all

countItemTotal("Barbarian Herbs")
it returns the total number of any one item in your backpack.


Thanks for the address list!

TheRedVex
Posts: 5
Joined: Wed Aug 19, 2009 1:39 am

Re: Item Check for Dailyquests

#8 Post by TheRedVex » Mon Aug 31, 2009 6:05 am

ive got it allready

but the adresslist is only for the first 30 inventarslots

Code: Select all

function CPlayer:ScanForItem(itemid)
   local item;
   local anzahl;
   local slot;
   local gesamt = 0;
   for i=0, 29 do
      slot = i + 1
      item = memoryReadInt(getProc(), Inv[i]);
      if(item == itemid) then
         anzahl = memoryReadInt(getProc(), Anzahl[i]);
         gesamt = anzahl + gesamt
         cprintf(cli.yellow,"Slot %s: %sx %s\n",slot,anzahl,item);
      end
      
   end
   if(gesamt >=1) then
      cprintf(cli.yellow,"Gesamt %s: %sx\n",itemid,gesamt);
      return gesamt
   else
      return 0
   end
end
there u add the itemid

EDIT: CODE tag added.

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: Item Check for Dailyquests

#9 Post by droppen » Mon Aug 31, 2009 6:16 am

Yep, impressive.

master121
Posts: 45
Joined: Mon Dec 29, 2008 10:40 am

Re: Item Check for Dailyquests

#10 Post by master121 » Tue Sep 01, 2009 8:07 am

ItemCount function doesn´t work
Tried this :

Code: Select all

for k = 1, 60 , 1 do
    local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo(k);");
end
MicroMacro writes this into the RoM macro :: a={GetBagItemInfo(k);}
So the coders must find a way to write what the variable holds instead of writing the variable name.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Item Check for Dailyquests

#11 Post by Administrator » Tue Sep 01, 2009 8:15 am

master121 wrote:ItemCount function doesn´t work
Tried this :

Code: Select all

for k = 1, 60 , 1 do
    local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo(k);");
end
MicroMacro writes this into the RoM macro :: a={GetBagItemInfo(k);}
So the coders must find a way to write what the variable holds instead of writing the variable name.
String concatenation.

Code: Select all

    local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo(" .. k .. ");");

master121
Posts: 45
Joined: Mon Dec 29, 2008 10:40 am

Re: Item Check for Dailyquests

#12 Post by master121 » Tue Sep 01, 2009 9:54 am

I get this error:
functions.lua:371 bad argument #1 to 'char' (invalid value)

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Item Check for Dailyquests

#13 Post by Administrator » Tue Sep 01, 2009 10:12 am

Debug it by placing a print statement right above that line. What is the value of 'byte' when it gives that error?

master121
Posts: 45
Joined: Mon Dec 29, 2008 10:40 am

Re: Item Check for Dailyquests

#14 Post by master121 » Tue Sep 01, 2009 10:15 am

Code: Select all

for k = 1, 60, 1 do
    local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo(" .. k .. ");");
end
With loop :
byte = plenty of numbers with a negative number at the end
Without loop
byte = plenty of numbers WITHOUT a negative number at the end

// So it has to do something with the negative number and the loop ... but what ?
readsz = readsz .. string.char(byte); causes the error

Code: Select all

string.char(i1, i2, ...)

Generate a string representing the character codes passed as arguments. Numerical codes are not necessarily portable across platforms.

    > = string.char(65,66,67)
    ABC
    > = string.char()  -- empty string
So i think in the function you shouldn´t use negative numbers.

// But why is there a negativ number ?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Item Check for Dailyquests

#15 Post by Administrator » Tue Sep 01, 2009 3:12 pm

What exactly is the negitive number that it dies on? What is the number directly before it?

I assume it's a problem with signed vs. unsigned on line 356. Change memoryReadByte() to memoryReadUByte() and see if that works.

master121
Posts: 45
Joined: Mon Dec 29, 2008 10:40 am

Re: Item Check for Dailyquests

#16 Post by master121 » Wed Sep 02, 2009 6:54 am

It works with memoryReadUByte()
Thanks champ ;)

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: Item Check for Dailyquests

#17 Post by d003232 » Sat Sep 05, 2009 4:59 pm

TheRedVex wrote:this is the advanced killingfunction

add this to the pawn.lua like this

Code: Select all

CPawn = class(function (self, ptr)
...		
		------------------ New attach for specific Mobkilling --------------------------
		--------------------------------------------------------------------------------
		
		self.mobs = {};
		
		--------------------------------------------------------------------------------
		--------------------------------------------------------------------------------

		
		if( self.Address ~= 0 and self.Address ~= nil ) then self:update(); end
	end
);
I added the player.mobs array to SVN 213. Kills will now be counted per target name.

@TheRedVex: THX for your help and suggestions.
The RoM Bot Online Wiki needs your help!

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests