|
|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
| Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum) |
 |
|
 |

08-12-2008, 05:08 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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..
|
 |
|
 |

08-12-2008, 08:14 AM
|
|
Dragon
|
|
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
|
|
Is it necessary to add a rule? From what I understand, this would simply be doing something that Live eventually did.
|

08-12-2008, 04:04 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Well, you probably don't NEED a rule, but I think it would be nice to have the option. Some people might not want corpses to be poofing while the mob is still doing the death animation. I wouldn't mind having corpses not get made at all if it they are empty. But, I also wouldn't mind the option to set it to 5 or 10 seconds so that they at least see a corpse for a few seconds.
Rules aren't really all that hard to add, and I think they only further customize-ability of servers. Though, I think it might be a good idea to have a "Notes" column added to the Rule_Values table. It would be only for reference when setting the rule, and would be a brief description of what the rule does and how to set it. There are already descriptions for most rules directly in the ruletypes.h file, so maybe those could be pulled and put in the notes column.
|
 |
|
 |

08-13-2008, 09:11 PM
|
|
Discordant
|
|
Join Date: May 2004
Posts: 290
|
|
I didn't think it needed to be a rule, so I just hardcoded a 5 sec decay on empty corpses.
In zone/PlayerCorpse.cpp, near line 150 after Hogie's variable decay loop, add this.
Code:
// 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
if (itemlist.size() < 1)
corpse_decay_timer.SetTimer(5000);
for (int i=0; i<MAX_LOOTERS; i++)
looters[i] = 0;
this->rezzexp = 0;
I can put it into a rule if that's how it should be.
|

08-13-2008, 09:27 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
LOL, I figured it would be something simple like that! I will test it out on my server tonight. My only question is if this takes coin loot into consideration, or only items?
I think you guys are right. This really doesn't have much reason to be set as a rule. I guess I just like to have as many options as possible :P
Thanks Theeper!
|

08-13-2008, 09:40 PM
|
|
Discordant
|
|
Join Date: May 2004
Posts: 290
|
|
I didn't think about coin, good catch Trev. Use this instead.
Code:
if (itemlist.size() < 1 && in_npc->GetCopper() == 0 && in_npc->GetSilver()== 0 && in_npc->GetGold()== 0 && in_npc->GetPlatinum() == 0)
corpse_decay_timer.SetTimer(5000);
|

08-13-2008, 09:41 PM
|
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
It doesn't have to be set as a rule but it is; there will be a rule in tonight's build along with some other stuff that's probably not as exciting for some people.
btw there's already a function to tell if the corpse is empty: Corpse::IsEmpty() =p
|

08-13-2008, 09:43 PM
|
|
Dragon
|
|
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
|
|
Every little bit helps, and all progress is exciting. Thanks as always =)
|

08-13-2008, 10:06 PM
|
|
Discordant
|
|
Join Date: May 2004
Posts: 290
|
|
Quote:
Originally Posted by KLS
btw there's already a function to tell if the corpse is empty: Corpse::IsEmpty() =p
|
LOL, that's what I get for not looking through the function list very carefully. It seems as though IsEmpty() is only used for the PERL interface right now.
Ignore the above and use this until KLS tells us how it's actually supposed to be done in one line probably :p~
Code:
if (IsEmpty())
corpse_decay_timer.SetTimer(5000);
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 09:14 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |