PDA

View Full Version : Alternate Version of Quest Code..


darvik
01-28-2002, 05:04 PM
OK, this is something I thought might be neat to try to fix up.. but it's going to be much more complicated than it would look like at face value. The problem is that when a client gives an item to an NPC, the client destroys the item, calling the OP_MoveItem to the destroy button .. so, a flag needs to be set on the player that they are in an NPC trade, and itercept the move on the server side, and send it to the NPC's inventory. This is probably what allows MultiQuesting - since it stays on the NPC's inventory for 8 minutes. Quest database also needs to be implemented in a way that is more realistic to the way EQ is.. such as text spoken when an item is turned in, etc..
Currently you can give any item to any NPC and you get 1000 xp.. dont hold your breath for this in the real EQ :P

This is just raw stuff currently - but it's a start in the right direction of how Quests *should* work :)

code for client_process.cpp (overwriting the current OP_GiveItem case) - the struct that was being used here is not quite right.. while I can't claim that I know what is right, I know that it's not 4 int16's.

case OP_GiveItem:
{
cout << name << " is trying to give an item to an npc. " << endl;
DumpPacketHex(app);

NPC_Identity_Struct* nis=(NPC_Identity_Struct*)app->pBuffer;

// not sure what this is..
APPLAYER* outapp = new APPLAYER;
outapp->opcode = 0x1020;
outapp->pBuffer = new uchar[2];
outapp->size = 2;
outapp->pBuffer[0] = 0x67;
outapp->pBuffer[1] = 0x13;
QueuePacket(outapp);
delete outapp;

// This tells client to open the npc trade window.
outapp = new APPLAYER;
outapp->opcode = 0xe620;
outapp->size = sizeof(NPC_Identity_Struct);
outapp->pBuffer = new uchar[outapp->size];
NPC_Identity_Struct* nis_out=(NPC_Identity_Struct*)outapp->pBuffer;
nis_out->unknown001 = nis->npcid; // these two values get swapped on return
nis_out->npcid = nis->unknown001; // from the server - dunno why.
QueuePacket(outapp);
delete outapp;
break;
}

case 0xda20:
{
cout << name << " gave some crap to an NPC." << endl;
DumpPacketHex(app);

// TODO: check quest table..

// message from NPC - again, dont know c well enough :(
// single null terminated string.
APPLAYER* outapp = new APPLAYER;
outapp->opcode = OP_ShopWelcome; // This opCode should be a general NPC speaking.
outapp->pBuffer = new uchar[7];
outapp->size = 7;
outapp->pBuffer[0] = 0x74;
outapp->pBuffer[1] = 0x68;
outapp->pBuffer[2] = 0x61;
outapp->pBuffer[3] = 0x6e;
outapp->pBuffer[4] = 0x6b;
outapp->pBuffer[5] = 0x73;
outapp->pBuffer[6] = 0x00;
QueuePacket(outapp);
delete outapp;

// Not sure what these next 2 opCodes are for.. neither of them have CRC checks.
// but are definetly required to close the NPC trade window.
outapp = new APPLAYER;
outapp->opcode = 0x1020;
outapp->pBuffer = new uchar[4];
outapp->size = 4;
outapp->pBuffer[0] = 0xa0;
outapp->pBuffer[1] = 0x1c;
outapp->pBuffer[2] = 0x48;
outapp->pBuffer[3] = 0x4d;
cout << "sending end NPC-Trade Packet 1 to: " << name << endl;
QueuePacket(outapp);
delete outapp;

outapp = new APPLAYER;
outapp->opcode = 0xdc20;
outapp->pBuffer = new uchar[4];
outapp->size = 4;
outapp->pBuffer[0] = 0x5d;
outapp->pBuffer[1] = 0x86;
outapp->pBuffer[2] = 0x98;
outapp->pBuffer[3] = 0x3c;
cout << "sending end NPC-Trade Packet 2 to: " << name << endl;
QueuePacket(outapp);
delete outapp;

AddEXP(1000);

break;
}

case 0xdb20:
{
// This occurs when client walks away from trade or hits cancel..
// when walking away, box is automaticly closed.

cout << name << " ending trade.." << endl;
DumpPacketHex(app);

// TODO: give items / cash back..

// Not sure what these next 2 opCodes are for.. neither of them have CRC checks.
// but are definetly required to close the NPC trade window.
APPLAYER* outapp = new APPLAYER;
outapp->opcode = 0x1020;
outapp->pBuffer = new uchar[4];
outapp->size = 4;
outapp->pBuffer[0] = 0xa0;
outapp->pBuffer[1] = 0x1c;
outapp->pBuffer[2] = 0x48;
outapp->pBuffer[3] = 0x4d;
cout << "sending end NPC Trade Packet 1 to: " << name << endl;
QueuePacket(outapp);
delete outapp;

outapp = new APPLAYER;
outapp->opcode = 0xdc20;
outapp->pBuffer = new uchar[4];
outapp->size = 4;
outapp->pBuffer[0] = 0x5d;
outapp->pBuffer[1] = 0x86;
outapp->pBuffer[2] = 0x98;
outapp->pBuffer[3] = 0x3c;
cout << "sending end NPC Trade Packet 2 to: " << name << endl;
QueuePacket(outapp);
delete outapp;

Message(0, "The trade was canceled. Giving back items is NYI.");
break;
}

case 0x2d21:
{
cout << name << " is moving cash.." << endl;
DumpPacketHex(app);
break;
}


Code for eq_packet_structs.h - this struct seems to be a general identity struct for all NPC interaction - including merchant interaction - I'll be updating my previous merchant code to work with this struct.

// Darvik: this is used with most NPC interaction.
struct NPC_Identity_Struct {
uint32 unknown001; // this may have something to do with zone.
uint32 npcid;
};

Gunder
01-28-2002, 11:08 PM
Great darvik!!!

I try to mix our code ( when can patch my eq client and can test it ) with my news, now i can talk with the npc, and ask for a quest.

:D

Mr Bitterness
01-30-2002, 07:53 AM
nice code =) i noticed you say turning in an item gives you 1000 exp, it might be nice to implement in the EMU a way to display your exp in numbers, that would be crazy nice... just for future reference, i am not the brightest tool in the knife shop so if this is undoable please disregard :D