Empty Corpse Decay Timer with Rule
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: Code:
Insert into rule_values values (0, 'npc:EmptyCorpseDecayTime', -1); \common\ruletypes.h: Code:
RULE_INT ( NPC, EmptyCorpseDecayTime, -1 ) //Sets the Decay Time for Empty NPC Corpses in Seconds. Default value: -1 (feature disabled) And, something like this from a quest script I made: Code:
if ($corpse_id->IsEmpty()) { Needs to be added as a rule into the PlayerCorpse.cpp in this section: PlayerCorpse.cpp: Code:
// To be used on NPC death and ZoneStateLoad 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!).
|
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) { Code:
if (!HasOwner() && class_ != MERCHANT && class_ != ADVENTUREMERCHANT Code:
#if 0 // solar: commenting this out for now TODO reimplement becomenpc stuff Code:
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); Code:
npcDecayTimes_Struct npcCorpseDecayTimes[100]; Code:
// Added By Hogie zone.cpp Code:
bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes) { 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) { Code:
// To be used on NPC death and ZoneStateLoad |
Is it necessary to add a rule? From what I understand, this would simply be doing something that Live eventually did.
|
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. |
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 |
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! |
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) |
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 |
Every little bit helps, and all progress is exciting. Thanks as always =)
|
Quote:
Ignore the above and use this until KLS tells us how it's actually supposed to be done in one line probably :p~ Code:
|
Well that's actually basically it.
|
Doesn't it need the brackets around it like this?
Code:
if (IsEmpty()) { 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 |
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. |
Quote:
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. Quote:
Code:
if (mob.empty_corpse_timer != NULL) corpse_decay_timer.SetTimer(mob.empty_corpse_timer) |
All times are GMT -4. The time now is 05:28 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.