HAHA! Well, if you can get this feature coded and added in, I will stop working on it right now lol. Saves me a ton of work trying to figure out how to code by reading source examples :P
Just for reference, in case it may be useful, here are the code snippets of anything I thought might help me figure out how to add this in.
entity.cpp
Code:
void EntityList::AddCorpse(Corpse* corpse, int32 in_id) {
if (corpse == 0)
return;
if (in_id == 0xFFFFFFFF)
corpse->SetID(GetFreeID());
else
corpse->SetID(in_id);
corpse->CalcCorpseName();
corpse_list.Insert(corpse);
if(!net.corpse_timer.Enabled())
net.corpse_timer.Start();
}
attack.cpp
Code:
if (!HasOwner() && class_ != MERCHANT && class_ != ADVENTUREMERCHANT
&& MerchantType == 0 && killer && (killer->IsClient() || (killer->HasOwner() && killer->GetOwner()->IsClient()) ||
(killer->IsNPC() && killer->CastToNPC()->GetSwarmInfo() && killer->CastToNPC()->GetSwarmInfo()->owner && killer->CastToNPC()->GetSwarmInfo()->owner->IsClient()))) {
Corpse* corpse = new Corpse(this, &itemlist, GetNPCTypeID(), &NPCTypedata,level>54?RuleI(NPC,MajorNPCCorpseDecayTimeMS):RuleI(NPC,MinorNPCCorpseDecayTimeMS));
entity_list.LimitRemoveNPC(this);
entity_list.AddCorpse(corpse, this->GetID());
this->SetID(0);
if(killer->GetOwner() != 0 && killer->GetOwner()->IsClient())
killer = killer->GetOwner();
if(killer != 0 && killer->IsClient()) {
corpse->AllowMobLoot(killer, 0);
if(killer->IsGrouped()) {
Group* group = entity_list.GetGroupByClient(killer->CastToClient());
if(group != 0) {
for(int i=0;i<6;i++) { // Doesnt work right, needs work
if(group->members[i] != NULL) {
corpse->AllowMobLoot(group->members[i],i);
}
}
}
}
}
}
Code:
#if 0 // solar: commenting this out for now TODO reimplement becomenpc stuff
if (IsBecomeNPC() == true)
{
if (other != NULL && other->IsClient()) {
if (other->CastToClient()->isgrouped && entity_list.GetGroupByMob(other) != 0)
entity_list.GetGroupByMob(other->CastToClient())->SplitExp((uint32)(level*level*75*3.5f), this);
else
other->CastToClient()->AddEXP((uint32)(level*level*75*3.5f)); // Pyro: Comment this if NPC death crashes zone
//hate_list.DoFactionHits(GetNPCFactionID());
}
Corpse* corpse = new Corpse(this->CastToClient(), 0);
entity_list.AddCorpse(corpse, this->GetID());
this->SetID(0);
if(other->GetOwner() != 0 && other->GetOwner()->IsClient())
other = other->GetOwner();
if(other != 0 && other->IsClient()) {
corpse->AllowMobLoot(other, 0);
if(other->CastToClient()->isgrouped) {
Group* group = entity_list.GetGroupByClient(other->CastToClient());
if(group != 0) {
for(int i=0; i < MAX_GROUP_MEMBERS; i++) { // Doesnt work right, needs work
if(group->members[i] != NULL) {
corpse->AllowMobLoot(group->members[i],i);
}
}
}
}
}
}
#endif
zonedb.h
Code:
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
net.cpp
Code:
npcDecayTimes_Struct npcCorpseDecayTimes[100];
_log(ZONE__INIT, "Loading corpse timers");
database.GetDecayTimes(npcCorpseDecayTimes);
database.h
Code:
// Added By Hogie
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
// IE: decaytime 1 54 = Levels 1 through 54
// decaytime 55 100 = Levels 55 through 100
// It will always put the LAST time for the level (I think) from the Database
struct npcDecayTimes_Struct {
int16 minlvl;
int16 maxlvl;
int32 seconds;
};
// Added By Hogie -- End
zone.cpp
Code:
bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
int i = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT varname, value FROM variables WHERE varname like 'decaytime%%' ORDER BY varname"), errbuf, &result)) {
safe_delete_array(query);
while((row = mysql_fetch_row(result))) {
Seperator sep(row[0]);
npcCorpseDecayTimes[i].minlvl = atoi(sep.arg[1]);
npcCorpseDecayTimes[i].maxlvl = atoi(sep.arg[2]);
if (atoi(row[1]) > 7200)
npcCorpseDecayTimes[i].seconds = 720;
else
npcCorpseDecayTimes[i].seconds = atoi(row[1]);
i++;
}
mysql_free_result(result);
}
else {
safe_delete_array(query);
return false;
}
return true;
}// Added By Hogie -- End
PlayerCorpse.cpp
Code:
extern npcDecayTimes_Struct npcCorpseDecayTimes[100];
Code:
Corpse* Corpse::LoadFromDBData(int32 in_dbid, int32 in_charid, char* in_charname, uchar* in_data, int32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed, bool wasAtGraveyard) {
if (in_datasize < sizeof(DBPlayerCorpse_Struct)) {
cout << "Corpse::LoadFromDBData: Corrupt data: in_datasize < sizeof(DBPlayerCorpse_Struct)" << endl;
return 0;
}
DBPlayerCorpse_Struct* dbpc = (DBPlayerCorpse_Struct*) in_data;
if (in_datasize != (sizeof(DBPlayerCorpse_Struct) + (dbpc->itemcount * sizeof(ServerLootItem_Struct)))) {
cout << "Corpse::LoadFromDBData: Corrupt data: in_datasize != expected size" << endl;
return 0;
}
if (dbpc->crc != CRC32::Generate(&((uchar*) dbpc)[4], in_datasize - 4)) {
cout << "Corpse::LoadFromDBData: Corrupt data: crc failure" << endl;
return 0;
}
ItemList itemlist;
ServerLootItem_Struct* tmp = 0;
for (unsigned int i=0; i < dbpc->itemcount; i++) {
tmp = new ServerLootItem_Struct;
memcpy(tmp, &dbpc->items[i], sizeof(ServerLootItem_Struct));
itemlist.push_back(tmp);
}
Corpse* pc = new Corpse(in_dbid, in_charid, in_charname, &itemlist, dbpc->copper, dbpc->silver, dbpc->gold, dbpc->plat, in_x, in_y, in_z, in_heading, dbpc->size, dbpc->gender, dbpc->race, dbpc->class_, dbpc->deity, dbpc->level, dbpc->texture, dbpc->helmtexture,dbpc->exp, wasAtGraveyard);
if (dbpc->locked)
pc->Lock();
// load tints
memcpy(pc->item_tint, dbpc->item_tint, sizeof(pc->item_tint));
// appearance
pc->haircolor = dbpc->haircolor;
pc->beardcolor = dbpc->beardcolor;
pc->eyecolor1 = dbpc->eyecolor1;
pc->eyecolor2 = dbpc->eyecolor2;
pc->hairstyle = dbpc->hairstyle;
pc->luclinface = dbpc->face;
pc->beard = dbpc->beard;
pc->Rezzed(rezzed);
pc->become_npc = false;
return pc;
}
Code:
// To be used on NPC death and ZoneStateLoad
// Mongrel: added see_invis and see_invis_undead
Corpse::Corpse(NPC* in_npc, ItemList* in_itemlist, int32 in_npctypeid, const NPCType** in_npctypedata, int32 in_decaytime)
// vesuvias - appearence fix
: Mob("Unnamed_Corpse","",0,0,in_npc->GetGender(),in_npc->GetRace(),in_npc->GetClass(),BT_Humanoid//bodytype added
,in_npc->GetDeity(),in_npc->GetLevel(),in_npc->GetNPCTypeID(),in_npc->GetSize(),0,
in_npc->GetHeading(),in_npc->GetX(),in_npc->GetY(),in_npc->GetZ(),0,
in_npc->GetTexture(),in_npc->GetHelmTexture(),
0,0,0,0,0,0,0,0,0,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0,0,0,0,0,0,0),
corpse_decay_timer(in_decaytime),
corpse_delay_timer(in_decaytime/2),
corpse_graveyard_timer(0)
{
corpse_graveyard_timer.Disable();
memset(item_tint, 0, sizeof(item_tint));
pIsChanged = false;
p_PlayerCorpse = false;
pLocked = false;
BeingLootedBy = 0xFFFFFFFF;
if (in_itemlist) {
itemlist = *in_itemlist;
in_itemlist->clear();
}
SetCash(in_npc->GetCopper(), in_npc->GetSilver(), in_npc->GetGold(), in_npc->GetPlatinum());
npctype_id = in_npctypeid;
SetPKItem(0);
charid = 0;
dbid = 0;
p_depop = false;
strcpy(orgname, in_npc->GetName());
strcpy(name, in_npc->GetName());
// Added By Hogie
for(int count = 0; count < 100; count++) {
if ((level >= npcCorpseDecayTimes[count].minlvl) && (level <= npcCorpseDecayTimes[count].maxlvl)) {
corpse_decay_timer.SetTimer(npcCorpseDecayTimes[count].seconds*1000);
break;
}
}
// Added By Hogie -- End
for (int i=0; i<MAX_LOOTERS; i++)
looters[i] = 0;
this->rezzexp = 0;
}
And don't worry, I don't deserve or want any credit lol. I am just glad to see the feature get added. Thanks KLS! 
Last edited by trevius; 08-12-2008 at 01:11 PM..
|