PDA

View Full Version : Merchant fix


Merkur
03-13-2002, 12:33 AM
// Edited Merkur 03/12
case OP_ShopPlayerBuy: {
cout << name << " is attempting to purchase an item.. " << endl;
Merchant_Purchase_Struct* mp=(Merchant_Purchase_Struct*)app->pBuffer;
int merchantid;
Mob* tmp = entity_list.GetMob(mp->npcid);
if (tmp != 0)
merchantid=tmp->CastToNPC()->MerchantType;
else
break;
uint16 item_nr = database.GetMerchantData(merchantid, mp->itemslot+1);
if (item_nr == 0)
break;
Item_Struct* item = database.GetItem(item_nr);
APPLAYER* outapp = new APPLAYER(OP_ShopPlayerBuy, sizeof(Merchant_Purchase_Struct));
Merchant_Purchase_Struct* mpo=(Merchant_Purchase_Struct*)outapp->pBuffer;
mpo->quantity = mp->quantity;
mpo->playerid = mp->playerid;
mpo->npcid = mp->npcid;
mpo->itemslot = mp->itemslot;
mpo->IsSold = 0x00;
mpo->unknown001 = 0x00;
mpo->unknown002 = 0x00;
mpo->unknown003 = 0x00;
mpo->unknown004 = 0x00;
mpo->unknown005 = 0x00;
// well i don't know how to calculate merchant prices exact, but *12 seems pretty near so it will do for now -Merkur
mpo->itemcost = item->cost*mp->quantity*12;
cout << "taking " << item->cost*mp->quantity*12 << " copper from " << name << "." << endl;
// DumpPacketHex(app);
QueuePacket(outapp);
delete outapp;
PutItemInInventory(FindFreeInventorySlot(0, (item->type==0x01), false), item, mp->quantity);
Save();
break;
}
case OP_ShopPlayerSell: {
cout << name << " is trying to sell an item." << endl;
Merchant_Purchase_Struct* mp=(Merchant_Purchase_Struct*)app->pBuffer;
pp.inventory[mp->itemslot] = 0xFFFF;
cout << " Inv Slot: " << int(mp->itemslot) << endl;
QueuePacket(app); // Just send it back to accept the deal
Save();
cout << "response from sell action.." << endl;
break;
}

struct:

struct Merchant_Purchase_Struct {
/*000*/ int16 npcid; // Merchant NPC's entity id
/*004*/ int16 playerid; // Player's entity id
/*008*/ int8 itemslot;
int8 IsSold; // Already sold
/*009*/ int8 unknown001; // always 0x0b, 0x7c, 0x00 ??
/*009*/ int8 unknown002;
/*013*/ int8 quantity; // Qty - when used in Merchant_Purchase_Struct
int8 unknown003;
int8 unknown004;
int8 unknown005;
sint32 itemcost;
};

:)

DeletedUser
03-13-2002, 07:17 AM
Hey Merker, come to #eqemu on irc.trifocus.net, I wanna talk to you! (or PM me here).

PaulieWalnutz
03-13-2002, 07:18 AM
You rock Merkur!

Lyenu X`Arie
03-13-2002, 07:42 AM
Good job Merkur, you're a excellent coder =).

Drawde
03-13-2002, 08:13 AM
Great job on fixing the merchant code!
Now I can finally use 2.4 (with the next beta at least) :)

Have you also fixed the bug with purchasing stackable items? (they default to 0 items in the stack no matter how many you choose)

Merkur
03-13-2002, 09:04 AM
umm i just changed some minor things in this part, its not that big heh.

@ Hogie
i'm in this channel since 2 days ;)

@Draw
yup should work