View Single Post
  #14  
Old 08-11-2008, 07:24 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

So far, I can only get this working on individual NPCs. The problem is here:

Code:
#Adjustable Corpse Decay Timer Script
#Decay Timer Is in Milliseconds
#This will only work on Empty corpses

my $entity_id;

sub EVENT_SPAWN {

$entity_id=$npc->GetID();

}

sub EVENT_DEATH {
   
my $corpse_id = $entity_list->GetCorpseByID($entity_id);

  if ($corpse_id->IsEmpty()) {
    my $corpse_decay = $corpse_id->CastToCorpse();
    $corpse_decay->SetDecayTimer(5000); }
 
}
That will get the entity ID when the NPC spawns and save it for use later when it dies. Unfortunately, it doesn't work right with multiple mobs yet. Without the use of "my", the variable becomes global and gets messed up when other NPCs try to use the same variable at the same time. Unfortunately "my" will limit the variable to the section that it is defined in, so if it is defined in EVENT_SPAWN, then EVENT_DEATH won't see it. I need a way for the whole quest to be able to see the variable without having ALL NPCs with the same quest sharing variables. And, I can't set "my" before the EVENTs, because at that point the Entity ID isn't set yet.

I have been able to get it working a little better by pulling the Entity ID in EVENT_ATTACK, but if you fight more than 1 at a time, only the first one to die will use the custom decay timer.

I also found that $mobid returns the entity ID as well. So, that could be used in place of:

Code:
my $corpse_id = $entity_list->GetCorpseByID($entity_id);
The only problem with this is that apparently the mobid is 0 when the EVENT_DEATH actually happens.

I would love to get something working that I can put in the default.pl file so that it is used server-wide for empty corpses. But, I will first need a way to save a variable for use later on.

At least I am making some progress lol. I have also been looking in the source to see if I can figure out how to just make a rule so we can just set a decay time for all empty corpses. But, I think that may be out of my skill range, so I am sticking with the quest way of doing it for now.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote