EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bug Reports (https://www.eqemulator.org/forums/forumdisplay.php?f=591)
-   -   HUGE Bug - Attuneable items don't work (https://www.eqemulator.org/forums/showthread.php?t=25575)

ChaosSlayer 06-27-2008 04:16 PM

HUGE Bug - Attuneable items don't work
 
I just discovered that Attuneable items revert to dropeable state as soon as you zone after been attuned.

this is realy bad. my entire server is build on attuneable items actualy becomign no drop - as they should - as global part fo server economy, in order for whoel thing to function.

could you guys look into this please?

AndMetal 06-27-2008 04:24 PM

Off the top of my head, because making a specific item NODROP where the global item is not, it would require something being defined, probably in the inventory table in the database, that says so.

Checking the Wiki for the inventory table, there is a column called instnodrop:

Quote:

instnodrop

* This might keep a record of whether an attunable item has been attuned so that it is now no trade. But not completely certain on that.
I would start by checking the item in your inventory table to see if that is set. If not, we'd have to start look through the source to find out why not.

Theeper 07-01-2008 10:07 AM

I don't think attuneable items work at all. They will attune, but once you zone, it's not attuned anymore. It doesn't appear to set the "instnodrop" field in the inventory table when you attune the item. Even manually setting the field doesn't seem to do anything .. unless it's supposed to be some odd value that I didn't try.

I can't find anything about attuneable items in the opcodes, so either it's called something else, or it's not there at all.

AndMetal 07-01-2008 02:26 PM

Well, it looks like it was added into the source:

Quote:

==01/15/2005
Doodman: Fixed charges/quantity
Doodman: Fixed IsStackable()
Doodman: Fixed some empty Handle() functons.
Doodman: Added instance level nodrop.
Required SQL:
alter table inventory add instnodrop tinyint(1) unsigned default 0 not null;
The following is where instnodrop is referenced in the source:

common/patches/Titanium.cpp
common/Item.h
common/Item.cpp
common/shareddb.cpp

Looking at all of that, it seems the main issue is that SetInstNodrop() is never called anywhere, but it seems like the client sets it, which is probably why it shows as nodrop until you zone. I have a feeling this probably is related to a missing OpCode or some other packet telling the server it's now nodrop.

ChaosSlayer 01-24-2009 01:17 PM

BUMP!
So guys- any new info on this one? :cool:

Theeper 02-25-2009 09:21 AM

Here's a start on getting attuneable items working. Items are flagged as No Trade and remain No Trade when zoning
and logging off.

This is with rev 361 compiled Windows XP.

Set the instnodrop flag when an item is placed into a gear slot that has it's attuneable flag set. (This probably needs to be done somewhere else).

In zone\inventory.cpp around line 901 change

Code:

                // Not dealing with charges - just do direct swap
                if(src_inst && dst_slot_id<22 && dst_slot_id>0)
                        SetMaterial(dst_slot_id,src_inst->GetItem()->ID);
                mlog(INVENTORY__SLOTS, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
                m_inv.SwapItem(src_slot_id, dst_slot_id);

to

Code:

                // Not dealing with charges - just do direct swap
                if(src_inst && dst_slot_id<22 && dst_slot_id>0) {
                        if (src_inst->GetItem()->Attuneable) {
                                src_inst->SetInstNoDrop(true);
                        }

                        SetMaterial(dst_slot_id,src_inst->GetItem()->ID);
                }
                mlog(INVENTORY__SLOTS, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
                m_inv.SwapItem(src_slot_id, dst_slot_id);


Then, move the instnodrop field in the item serialization code a couple spots over in the Titanium patch file.

In patches\Titanium.cpp near line 871, change

Code:

        MakeAnyLenString(&instance,
                "%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|",
                stackable ? charges : 0,
                0,
                (merchant_slot==0) ? slot_id : merchant_slot,
                inst->GetPrice(),
                (merchant_slot==0) ? 1 : inst->GetMerchantCount(),
                0,
                //merchant_slot,        //instance ID, bullshit for now
                (merchant_slot==0) ? inst->GetSerialNumber() : merchant_slot,
                inst->IsInstNoDrop() ? 1 : 0,                //not sure where this field is
                (stackable ? ((inst->GetItem()->ItemType == ItemTypePotion) ? 1 : 0) : charges),
                0,
                0
        );

to

Code:

        MakeAnyLenString(&instance,
                "%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|",
                stackable ? charges : 0,
                0,
                (merchant_slot==0) ? slot_id : merchant_slot,
                inst->GetPrice(),
                (merchant_slot==0) ? 1 : inst->GetMerchantCount(),
                0,
                //merchant_slot,        //instance ID, bullshit for now
                (merchant_slot==0) ? inst->GetSerialNumber() : merchant_slot,
                0,
                (stackable ? ((inst->GetItem()->ItemType == ItemTypePotion) ? 1 : 0) : charges),
                inst->IsInstNoDrop() ? 1 : 0,
                0
        );

- You can still trade attuned items to NPC's and maybe sell in the bazaar, but you can't trade to players or sell to vendors. I will put in some checks for these later.
- When items are autoequipped from loot, it bypasses the "Attune" popup that happens when you manually equip stuff. Need to at least put a check on startup to flag the items. I'm not sure of the popup behaviour on Live though.
- I didn't look into the other client serializations because I can't test them.

I thought ChaosSlayer might want to test it out now though.

ChaosSlayer 02-25-2009 07:12 PM

Thank you for this submission Theeper
Unfortunately I can't realy test any new code myself at this time due to number of reasons, So I am hopping that Trev, Cavedude or KLS can try this fix and hopefuly it will work :cool:

Theeper 02-25-2009 07:54 PM

After looking through the nodrop checks, it looks like in most places, it's just reading the pointer to the base item flag directly.

It seems like it would make sense to create an IsNoDrop() function inside the ItemInst class to check both flags. Then replace all the existing nodrop checks throughout ... as opposed to adding an instance no drop check each time a normal no drop check is done.

Also, any thoughts on how it worked when you looted an attuneable item on Live ? .. If the item auto equipped, did the "Are you sure you want to attune?" popup window work?

It seems like there was some odd issue with attuneable items back then, but It's been too long.

As usual, there's probably a function somewhere I missed and KLS will rewrite the whole thing in one line.

ChaosSlayer 02-25-2009 08:27 PM

as far as I can tell on LIVE attuneable item did not tried to auto-equip itself - it went directly into your bags

Theeper 02-25-2009 10:55 PM

Good point. Here is a simple change to make them not auto equip.

In zone\inventory.cpp around line 381

Change

Code:

        // #1: Try to auto equip
        if (try_worn && inst.IsEquipable(GetBaseRace(), GetClass()) && inst.GetItem()->ReqLevel<=level)

to

Code:

        // #1: Try to auto equip
        if (try_worn && inst.IsEquipable(GetBaseRace(), GetClass()) && inst.GetItem()->ReqLevel<=level && !inst.GetItem()->Attuneable)


And this will set the instnodrop flag upon zoning if the item was equipped somehow (like with MQ) and bypasses the popup window.

in common\shareddb.cpp around line 483

Change
Code:

                        if (item) {
                                sint16 put_slot_id = SLOT_INVALID;
                               
                                ItemInst inst(item, charges);
                                if (instnodrop)
                                                inst.SetInstNoDrop(true);
                                if (color > 0)
                                        inst.SetColor(color);
                                if(charges==255)
                                        inst.SetCharges(-1);
                                else

to

Code:

                        if (item) {
                                sint16 put_slot_id = SLOT_INVALID;
                               
                                ItemInst inst(item, charges);
                                if (instnodrop || (slot_id >= 0 && slot_id <= 21 && inst.GetItem()->Attuneable))
                                                inst.SetInstNoDrop(true);
                                if (color > 0)
                                        inst.SetColor(color);
                                if(charges==255)
                                        inst.SetCharges(-1);
                                else


cavedude 02-26-2009 12:19 AM

I just tested this out, attuneable items do persist over zoning/camping and no longer auto-loot. However, they lose their no drop flag when you loot the item off your corpse. We're probably losing the flag when it gets transferred to the corpse.

Also, I confirmed that you can trade them to NPCs, however you can't sell them in bazaar. Since they are no drop, they won't appear in your item list after placing in the trader's satchel.

So, all that needs to be done is put in a NPC trade check, and correct the transfer to corpses and back then this will be 100%.

Secrets 02-26-2009 12:30 AM

Have not tested this, but this should work hopefully. I probably messed it up but something along the lines of this should work, heh.

PlayerCorpse.cpp

Code:

void Corpse::MoveItemToCorpse(Client *client, ItemInst *item, sint16 equipslot)
{
        int bagindex;
        sint16 interior_slot;
        ItemInst *interior_item;

        AddItem(item->GetItem()->ID, item->GetCharges(),  equipslot, item->GetAugmentItemID(0), item->GetAugmentItemID(1), item->GetAugmentItemID(2), item->GetAugmentItemID(3), item->GetAugmentItemID(4));
        if(item->IsType(ItemClassContainer))
        {
                for(bagindex = 0; bagindex <= 10; bagindex++)
                {
                        interior_slot = Inventory::CalcSlotId(equipslot, bagindex);
                        interior_item = client->GetInv().GetItem(interior_slot);
                        if(interior_item->IsInstNoDrop)
                        {
                                interior_item->SetInstNoDrop(true);
                        }
                        if(interior_item)
                        {
                                AddItem(interior_item->GetItem()->ID, interior_item->GetCharges(), interior_slot, interior_item->GetAugmentItemID(0), interior_item->GetAugmentItemID(1), interior_item->GetAugmentItemID(2), interior_item->GetAugmentItemID(3), interior_item->GetAugmentItemID(4));
                                client->DeleteItemInInventory(interior_slot);
                        }
                }
        }
        client->DeleteItemInInventory(equipslot);
}


Theeper 02-26-2009 10:25 AM

Thanks guys, I'll try to get the NPC trade thing and the corpse flag done when I get home tonite.

Secrets, this doesn't look proper though. You're setting a flag that is already set.

Code:

                        if(interior_item->IsInstNoDrop)
                        {
                                interior_item->SetInstNoDrop(true);
                        }

I'm wondering if you meant to do..

Code:

                        if(item->IsInstNoDrop())
                        {
                                interior_item->SetInstNoDrop(true);
                        }


cavedude 02-26-2009 03:06 PM

The PlayerCorpse change is a bad, bad change! :) I accidentally put it up on TGC without testing and it caused players to lose all but 1 bag in their top inventory slot when they died, and caused a zone crash. That'll teach me to upload files when I am half asleep. Good thing we keep daily backups.

Theeper: Yes, if the change was good that's the syntax you'd use.

Secrets 02-26-2009 09:43 PM

Quote:

Originally Posted by cavedude (Post 165295)
The PlayerCorpse change is a bad, bad change! :) I accidentally put it up on TGC without testing and it caused players to lose all but 1 bag in their top inventory slot when they died, and caused a zone crash. That'll teach me to upload files when I am half asleep. Good thing we keep daily backups.

Theeper: Yes, if the change was good that's the syntax you'd use.

Heh, yeah. I'm still learning C++. Sorry about that.

I guess that doesn't work, then. Back to the drawing board!


All times are GMT -4. The time now is 03:41 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.