PDA

View Full Version : NPC Loot bugfix


alkrun
01-31-2002, 06:12 PM
This is to correct corpses from poofing even when you leave items on the corpse. It's just a check to see if the loot count is zero.


client_process.cpp - line(1226) - OP_EndLootRequest handler


APPLAYER* outapp = new APPLAYER;
outapp->opcode = OP_LootComplete;
outapp->size = 0;
QueuePacket(outapp);
delete outapp;

//NEW CODE
if(entity->IsNPC()){
NPC *pNpc = (NPC*)entity;
if(pNpc->CountLoot() == 0){
outapp = new APPLAYER;
outapp->opcode = OP_DeleteSpawn;
outapp->size = sizeof(DeleteSpawn_Struct);
outapp->pBuffer = new uchar[outapp->size];
DeleteSpawn_Struct* delspawn = (DeleteSpawn_Struct*)outapp->pBuffer;
delspawn->spawn_id = entity->GetID();
delspawn->ds_unknown1 = 0;
entity_list.QueueClients(this, outapp, false);
delete outapp;
entity_list.RemoveEntity(entity->GetID());
}
}
//END NEW CODE

outapp = new APPLAYER;
outapp->opcode = OP_SpawnAppearance;
outapp->size = sizeof(SpawnAppearance2_Struct);
outapp->pBuffer = new uchar[outapp->size];
SpawnAppearance2_Struct* sa_out = (SpawnAppearance2_Struct*)outapp->pBuffer;
sa_out->spawn_id = id;
sa_out->type = 0x0e;
sa_out->parameter = 110; // stand...
entity_list.QueueClients(this, app);
delete outapp;

break;
}

Drawde
02-01-2002, 05:46 AM
Another looting-related bug I noticed is when you loot more than one stackable item of the same type (e.g 2 bat wings) from the same corpse, the zone server crashes. If you just loot one of each type it doesn't crash, even if you already have items of that type in your inventory.

Also - though this isn't really a major issue since #spawn is meant only for testing - if a NPC created with #spawn has stackable items in its randomly-generated inventory, the stacks always contain 0 items. When you loot them, though, they still take up space in your inventory even though they don't show up.

Anyway, good work with fixing that "disappearing corpse" bug though.

alkrun
02-01-2002, 06:31 AM
I'll take a look at that. All sounds related to the lootlist. I crashed last night testing this out and couldn't reproduce but now that I think about it, it was 2 items of the same type.