View Full Version : Empty Corpse Decay Timer with Rule
trevius
08-12-2008, 02:28 AM
This code still needs most of the important code to be written, but I don't think it will be anything too complex to finish. The Required SQL and Rule is easy enough to set, and are posted below. But, the actual part where the NPC dies and checks if the corpse is empty or not is not yet done. I am pretty sure that it needs to be added to the section of the PlayerCorpse.cpp posted below.
Required SQL:
Insert into rule_values values (0, 'npc:EmptyCorpseDecayTime', -1);
\common\ruletypes.h:
RULE_INT ( NPC, EmptyCorpseDecayTime, -1 ) //Sets the Decay Time for Empty NPC Corpses in Seconds. Default value: -1 (feature disabled)
----Below is where the work needs to be done to get this code finished----
And, something like this from a quest script I made:
if ($corpse_id->IsEmpty()) {
my $corpse_decay = $corpse_id->CastToCorpse();
$corpse_decay->SetDecayTimer(5000); }
Needs to be added as a rule into the PlayerCorpse.cpp in this section:
PlayerCorpse.cpp:
// 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;
}
So, basically it should be:
NPC Dies
If Rule EmptyCorpseDecayTime >= 0
If Corpse is empty
Set the decay timer in seconds to the integer that the rule is set to
Continue other steps in the NPC death process
My coding skills are still very weak, so the only way I can get this completed is with help or by searching the source for similar examples of what I want to do. What I have done so far is barely anything, but I don't think the rest would be too bad if I only knew code lol. I will definitely continue to work on getting this done, but if anyone else has any input, it would be greatly appreciated :)
I was actually considering putting something similar in my next patch based on several suggestions here(So no one accuse me of stealing the idea!).
trevius
08-12-2008, 05:08 AM
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
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
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);
}
}
}
}
}
}
#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
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
net.cpp
npcDecayTimes_Struct npcCorpseDecayTimes[100];
_log(ZONE__INIT, "Loading corpse timers");
database.GetDecayTimes(npcCorpseDecayTimes);
database.h
// 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
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
extern npcDecayTimes_Struct npcCorpseDecayTimes[100];
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;
}
// 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! :D
So_1337
08-12-2008, 08:14 AM
Is it necessary to add a rule? From what I understand, this would simply be doing something that Live eventually did.
trevius
08-12-2008, 04:04 PM
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.
Theeper
08-13-2008, 09:11 PM
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.
// 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.
trevius
08-13-2008, 09:27 PM
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!
Theeper
08-13-2008, 09:40 PM
I didn't think about coin, good catch Trev. Use this instead.
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);
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
So_1337
08-13-2008, 09:43 PM
Every little bit helps, and all progress is exciting. Thanks as always =)
Theeper
08-13-2008, 10:06 PM
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~
if (IsEmpty())
corpse_decay_timer.SetTimer(5000);
Well that's actually basically it.
trevius
08-13-2008, 10:33 PM
Doesn't it need the brackets around it like this?
if (IsEmpty()) {
corpse_decay_timer.SetTimer(5000); }
Or am I still too much of a coding newbie? :P
The only reason I ask is because I will probably just add this in manually on my server until more of the features I have to add in manually each time get added into the Official Source(Lore Aug, Chaotic Potential and new MQ Detection are the most important ones, and they all seem to be working perfectly). Or, at least until there are some significant changes in the source that I want to have on my server.
Currently, I also add these each time I update:
Lore Aug Fix:
http://www.eqemulator.net/forums/showthread.php?t=24572
CotH limiting per zone (I think live is per zone)
http://www.eqemulator.net/forums/showthread.php?t=25643
MQ Illegal Item Equip Detection
http://www.eqemulator.net/forums/showthread.php?t=25783
Chaotic Potential Fix
http://www.eqemulator.net/forums/showthread.php?t=25717
Spell And Skill Rule for Above MaxLevel Players
http://www.eqemulator.net/forums/showthread.php?t=25937
Minor NPC Spells Recast Delay Adjustment
http://www.eqemulator.net/forums/showthread.php?t=25877
Removing Non-Titanium Version Checks - Mostly to change Titanium to be checked first
http://www.eqemulator.net/forums/showthread.php?t=25569
trevius
08-13-2008, 10:39 PM
Oh, and the main reason I think it would be nice to have as a rule would be to have the option to make corpses poof immediately without even starting a timer. This would probably reduce some of the load on servers after a large AE pull is killed. I know when I have 30ish mobs all die at once, it almost always crashes the zone.
One thing I was thinking is that instead of a rule, it might be nice to have the decay timer be an actual setting in the Zones table similar to canbind, accept the number would be the time in seconds of how long the corpse would last. In most zones, I would like the 5 second timer to be set, because I think it would just be a little weird for corpses to disapear immediately. But there are definitely a couple of zones where I would prefer to have them vanish immediately, mostly because there are often AE groups in those zones and the server needs any help it can get to reduce performance issues from AEing.
AndMetal
08-14-2008, 12:39 AM
Doesn't it need the brackets around it like this?
if (IsEmpty()) {
corpse_decay_timer.SetTimer(5000); }
Or am I still too much of a coding newbie? :P
If you have only 1 thing to process in an if, else, etc, statement, you don't need brackets. I know this is true for C++ & Perl, pretty sure it's the same for other languages including PHP.
I know there's another weird function using : and ? for a very simple if/else statement, but I never really paid attention to the syntax.
Oh, and the main reason I think it would be nice to have as a rule would be to have the option to make corpses poof immediately without even starting a timer. This would probably reduce some of the load on servers after a large AE pull is killed. I know when I have 30ish mobs all die at once, it almost always crashes the zone.
One thing I was thinking is that instead of a rule, it might be nice to have the decay timer be an actual setting in the Zones table similar to canbind, accept the number would be the time in seconds of how long the corpse would last. In most zones, I would like the 5 second timer to be set, because I think it would just be a little weird for corpses to disapear immediately. But there are definitely a couple of zones where I would prefer to have them vanish immediately, mostly because there are often AE groups in those zones and the server needs any help it can get to reduce performance issues from AEing.
You could set it up one of many different ways. Unfortunately, I don't know if there's really one "best" way to do it. You could do it on a per-mob basis, per zone basis, per server basis, or a combination of the above. If you really want to add flexibility, I would say all of the above, using mob, zone, then server as the priority using an if, else if, else statement. I'm not sure of the exact code needed, but the idea would be something like this:
if (mob.empty_corpse_timer != NULL) corpse_decay_timer.SetTimer(mob.empty_corpse_timer )
else if (zone.empty_corpse_timer != NULL) corpse_decay_timer.SetTimer(zone.empty_corpse_time r)
else corpse_decay_timer.SetTimer(RuleI(NPC,EmptyNPCCorp seDecayTimeMS)+1000)
trevius
09-06-2008, 07:12 AM
I don't know why, but I am running 1129 which should have this code in it (and I see it in the source), but even after I set the rule, it doesn't seem to actually work. Corpses still wait 20 minutes to decay.
Maybe the code for the IsEmpty check needs to go after the normal decay timer checks? I know it was working that way when I tried the code that Theeper posted.
trevius
09-07-2008, 06:52 PM
Unless the new corpse decay timer is working for people and I just have something set incorrectly (let me know if so), then I am going to try moving it the next time I do a build. I am planning to move it from here (noted in RED):
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(RuleI(NPC, CorpseUnlockTimer)),
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());
if(IsEmpty())
{
corpse_decay_timer.SetTimer(RuleI(NPC,EmptyNPCCorp seDecayTimeMS)+1000);
}
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;
}
To here:
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(RuleI(NPC, CorpseUnlockTimer)),
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
if(IsEmpty())
{
corpse_decay_timer.SetTimer(RuleI(NPC,EmptyNPCCorp seDecayTimeMS)+1000);
}
for (int i=0; i<MAX_LOOTERS; i++)
looters[i] = 0;
this->rezzexp = 0;
}
This is my only guess as to why the new decay timer code isn't currently working for me. Especially since it was working perfectly when I added Theeper's code in manually before this was added into the official source. My guess is that the following code that currently comes after the IsEmpty check is still being used even if the corpse is empty and the decay timer is being overwritten to follow these rules instead of using the new IsEmpty rule:
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;
}
}
I will try out the move of the IsEmpty check code and see if that resolves the problem.
Flare83
09-07-2008, 08:20 PM
it's working for me on 1129 and peq cvs /shrug
trevius
09-07-2008, 09:23 PM
Weird, I can't tell why it isn't working for me then... I have the rule set and it appears to be loading the rule:
[Debug] [RULES__CHANGE] Set rule NPC:EmptyNPCCorpseDecayTimeMS to value 2000
Anyone know why this might not be working for me, please? I guess this should probably be something I post in the support section. But since I had already discussed it here, I will leave it here for now. I will keep checking for why it is happening if no one else can think of why it might be.
No money on the corpses right? Does it work if you delete the rule from your DB?
If not what other rules pertaining to corpses are set and what to?
trevius
09-08-2008, 07:22 AM
NPC:CorpseUnlockTimer 300000
NPC:EmptyNPCCorpseDecayTimeMS 2000
NPC:MajorNPCCorpseDecayTimeMS 1200000
NPC:MinorNPCCorpseDecayTimeMS 600000
Removing the rule doesn't seem to make any difference.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.