Page 1 of 1

Possible bug in EquipmentItem Class?

Posted: Sun Jul 26, 2015 5:13 pm
by Bill D Cat
Using this code to test something out, and it seems that the head slot is not accounted for in the equipment class. Slot 0 is shown as unused and I'm not sure where slot 20 is pointing to. Am I missing something? Should I be using a different class to figure out the equipment durability?

Code: Select all

function checkDurability()
--[[ This is what the slots seem to relate to. None report stats for the Head slot.
Slot 1: Hands		 Slot 6: Belt			Slot 11: Ring 1			Slot 16: Off Hand		Slot 21: Wings
Slot 2: Feet		 Slot 7: Shoulders		Slot 12: Ring 2			Slot 17: Amulet
Slot 3: Upper Body	 Slot 8: Necklace		Slot 13: Earring 1		Slot 18: Amulet
Slot 4: Lower Body	 Slot 9: Ammunition		Slot 14: Earring 2		Slot 19: Amulet
Slot 5: Cape		Slot 10: Ranged Weapon	Slot 15: Main Hand		Slot 20: ???
]]--
	for loop = 0, 21 do
		printf("Slot [%d]: %s (%d/%d)\n", loop, equipment.BagSlot[loop].Name, equipment.BagSlot[loop].Durability, equipment.BagSlot[loop].MaxDurability)
	end
end
Equipment.png

Re: Possible bug in Equipment Class?

Posted: Sun Jul 26, 2015 6:08 pm
by Bill D Cat
Narrowed it down to the EquipmentItem class.

Changed this function as shown, and I can get the information for the head slot.

Code: Select all

CEquipmentItem = class(CItem,
	function( self, slot )
		self.Location = "equipment"
		self.SlotNumber = slot
		self.BagId = slot

		-- if ( self.SlotNumber ~= nil and self.SlotNumber ~= 0 ) then -- Changed this line to read as below.
		if ( self.SlotNumber ~= nil ) then
			self:update();
		end;
	end
);
Equip2.png

Re: Possible bug in EquipmentItem Class?

Posted: Sun Jul 26, 2015 8:38 pm
by lisa
I did your code and got exact same results as you, then I did this and it printed hat info.

Code: Select all

table.print(equipment.BagSlot[0])
I think there is an update missing as doing update before your code it worked fine.

Code: Select all

Command> equipment:update() checkdura()
Slot [0]: Tabokake's Mask (111/83)
Slot [1]: Salioca Vengeance Gloves (118/88)
Slot [2]: Yinajo's Wave (108/112)
Slot [3]: Yinajo's Conch (107/111)
Slot [4]: Salioca Vengeance Leather Pants (119/89)
Slot [5]: Salioca Vengeance Cloak (71/75)
Slot [6]: Energy Boost Belt (155/115)
Slot [7]: Lava Shoulder Armor of Glittering (102/106)
Slot [8]: Forgotten Necklace (148/100)
Slot [9]: Tooth Arrow (100/100)
Slot [10]: Cross of Desperation (99/75)
Slot [11]: Water Fire Ring (119/89)
Slot [12]: <EMPTY> (0/0)
Slot [13]: Lekani Earring (105/79)
Slot [14]: Tinc Earring (101/76)
Slot [15]: Bulwark of Death (101/105)
Slot [16]: Dagger of Invasion (101/105)
Slot [17]: <EMPTY> (0/0)
Slot [18]: <EMPTY> (0/0)
Slot [19]: <EMPTY> (0/0)
Slot [20]: <EMPTY> (0/0)
Slot [21]: Little Devil's Wings (134/100)

Re: Possible bug in EquipmentItem Class?

Posted: Sun Jul 26, 2015 9:08 pm
by Bill D Cat
Okay, so adding an equipment:update() ahead of the loop prints out the head slot information. But that just plays back to my second post where the bot function does NOT issue the update if the slot is 0. So my fix would probably be correct, because in the case of any other slot, the update is run.

EquipmentItem.lua line 9:

Code: Select all

if ( self.SlotNumber ~= nil and self.SlotNumber ~= 0 ) then
That's the culprit right there. Adding an equipment:update() to my function would just be a work around.

Re: Possible bug in EquipmentItem Class?

Posted: Sun Jul 26, 2015 11:20 pm
by lisa
To be honest your post wasn't on my screen when I did mine, my comment about the update wasn't aimed at your code but at the fact there must be an update missing somewhere.

It seems what you pointed out is that the bot was deliberately made to not update the hat slot (0), I have no idea why it was set up like that but there must have been a reason to deliberately add it in.
Maybe Rock knows about it.

Re: Possible bug in EquipmentItem Class?

Posted: Mon Jul 27, 2015 3:21 am
by rock5
Maybe there was a reason for it but it's definitely a bug. I'll change it. If anything crops up we'll deal with it then.

Edit: It may just have been a copy and paste issue. Other item classes start at slot 1.

Re: Possible bug in EquipmentItem Class?

Posted: Mon Jul 27, 2015 6:55 am
by Bill D Cat
rock5 wrote:Edit: It may just have been a copy and paste issue. Other item classes start at slot 1.
Which is interesting, considering the in-game function for RoM macros also starts with 1 for the equipment slots. I guess at some time in the development of the bot it was decided to start these at 0 instead. Changing it now might break existing scripts, especially those that equip or repair items.

Re: Possible bug in EquipmentItem Class?

Posted: Mon Jul 27, 2015 9:00 am
by rock5
I think they started at 0 because that was the values found in memory. It probably should have originally had 1 added to it. I think that was before my time though.