Item Sets (Part 2) unpacking

Code pertaining to the server

Moderator: Team Members

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Item Sets (Part 2) unpacking

Post by Ememjr » Sat Nov 11, 2017 4:50 am

So now that we have a way to create Item Sets, you need a way to unpack them, well that's easy just right click the item and select unpack, "right after this"

you will need to add the code from the post i attached first in order for this to work
http://www.eq2emulator.net/phpBB3/viewt ... =88&t=4339

Items.h

add this ( there seems to be another menu settings packet that works in conjunction with the first

Code: Select all

#define ITEM_MENU_TYPE2_TEST1			1 //0 auto consume on
#define ITEM_MENU_TYPE2_TEST2			2 //1
#define ITEM_MENU_TYPE2_UNPACK			4//2 unpack
#define ITEM_MENU_TYPE2_TEST4			8 //3 
#define ITEM_MENU_TYPE2_TEST5			16	//4
#define ITEM_MENU_TYPE2_TEST6			32//5
#define ITEM_MENU_TYPE2_TEST7			64//6
#define ITEM_MENU_TYPE2_TEST8			128//7
#define ITEM_MENU_TYPE2_TEST9			256//8
#define ITEM_MENU_TYPE2_TEST10			512//9
#define ITEM_MENU_TYPE2_TEST11			1024//10
#define ITEM_MENU_TYPE2_TEST12			2048//11
#define ITEM_MENU_TYPE2_TEST13			4096//12 
#define ITEM_MENU_TYPE2_TEST14				8192//13
#define ITEM_MENU_TYPE2_TEST15		 16384//14
#define ITEM_MENU_TYPE2_TEST16			32768//15
Items.cpp

add

Code: Select all

if (item->generic_info.item_type == 18){
			packet->setSubstructArrayDataByName("items", "unknown3", ITEM_MENU_TYPE2_UNPACK, 0, i);
	}
just before

Code: Select all

if(item->generic_info.condition == 0)
		menu_data += ITEM_MENU_TYPE_BROKEN;
Commands.cpp

add

Code: Select all

else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
		{
			if (client->GetPlayer()->EngagedInCombat())
				client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
			else {
				int16 index = atoi(sep->arg[1]);
				Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
				if (item){
				//	client->GetPlayer()->item_list.DestroyItem(index);
					if (item->item_sets.size() > 0){
						for (int32 i = 0; i < item->item_sets.size(); i++){
							ItemSet* set = item->item_sets[i];
							if (set->item_stack_size == 0)
								set->item_stack_size += 1;
							client->AddItem(set->item_id, set->item_stack_size);							
						}
					}
					
				}
				client->RemoveItem(item, 1);

			}

		}
right before

Code: Select all

else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
		{
			if(client->GetPlayer()->EngagedInCombat())
Edited: with Jab's suggestions

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sat Nov 11, 2017 9:41 pm

What do I need to do to test this code out?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Item Sets (Part 2) unpacking

Post by Jabantiz » Sat Nov 11, 2017 10:37 pm

A couple things I noticed on this one

Code: Select all

							Item* new_item = new Item(master_item_list.GetItem(set->item_id));
							new_item->details.count = set->item_stack_size;
							client->AddItem(new_item);
First while not wrong there is an AddItem function that will handle this for you so all you needed to do was

Code: Select all

client->AddItem(set->item_id, set->item_stack_size);
Also keeps the code cleaner and does error checks in the event the item id was invalid, in this case your code will likely cause a crash if the id is invalid.

Next is this one

Code: Select all

					database.DeleteItem(client->GetCharacterID(), item, 0);
This should really be

Code: Select all

client->RemoveItem(item, 1);
As RemoveItem will delete from the DB if needed but it will also produce the inventory packets to update the players inventory, your code just nukes the items server side but until the player gets an inventory update the item could still be visible in their inventory as well as error checking and triggering a lua function in the event the item has a lua script.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 4:38 am

Zcoretri wrote: Sat Nov 11, 2017 9:41 pm What do I need to do to test this code out?
in your you item_details_itemset table change the items for id # 22513 to the following item_id's, delete any extras

49101,46307,66547
then summon item 22523,
if it examines properly, then right click and unpack

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 4:39 am

Thanks JAB, those 2 part were my biggest headaches, i will modify
with so much code, sometimes it is hard to find just the piece you need that already exists


i took the database .delete one from destroy item
took the other one from the code that added starting items to the player

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sun Nov 12, 2017 10:16 am

Ememjr wrote: Sun Nov 12, 2017 4:38 am
Zcoretri wrote: Sat Nov 11, 2017 9:41 pm What do I need to do to test this code out?
in your you item_details_itemset table change the items for id # 22513 to the following item_id's, delete any extras

49101,46307,66547
then summon item 22523,
if it examines properly, then right click and unpack
It does not examine properly
Item22513.png
You do not have the required permissions to view the files attached to this post.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 10:24 am

what server, if your on emu, thats becuase they never implented my examine item changes
http://www.eq2emulator.net/phpBB3/viewt ... f=3&t=4230

i get the same thing on emu

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sun Nov 12, 2017 10:35 am

Yes I am on my own server.
I will add this code to mine and see what happens :mrgreen:

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sun Nov 12, 2017 12:06 pm

Zcoretri wrote: Sun Nov 12, 2017 10:35 am Yes I am on my own server.
I will add this code to mine and see what happens :mrgreen:
No change...to me this is a struct issue.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 12:16 pm

here is my current struct, code very well be my changes were not added their either

ItemStructs1112.zip
You do not have the required permissions to view the files attached to this post.

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sun Nov 12, 2017 5:30 pm

Still getting same result with those structs you posted.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 5:56 pm

are other item examines working for you

very strange, i know stich was my changes and his examines pretty much work,
what client are you using
i notices those itemsets not working on dov, i need to look at thos

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 6:24 pm

looks like ill need a Dov log that someone did a vet reward claim on, and ill hopefully be able to fx the struct
for Dov

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Item Sets (Part 2) unpacking

Post by Zcoretri » Sun Nov 12, 2017 7:13 pm

Client Version: 13602L
Data Version: 63194

Spell examines look ok

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Item Sets (Part 2) unpacking

Post by Ememjr » Sun Nov 12, 2017 8:14 pm

Zcoretri wrote: Sun Nov 12, 2017 7:13 pm Client Version: 13602L
Data Version: 63194

Spell examines look ok
What about items in general

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests