Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2012, 10:27 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default minor change to NPC::Death()

I was recently looking for a way to use Perl to remove a particular item from an NPC's corpse that was added to its inventory from within the same script. I had intended to use $corpse->RemoveItem($slotID) in the EVENT_DEATH sub, and found that there is currently no way to do this, as slotIDs are apparently not assigned to the items until the corpse is in the process of being looted. I have since solved the problem by moving the call to parse EVENT_DEATH in NPCeath() to a bit earlier in the function. This allows me to use $npc->RemoveItem($itemID) in EVENT_DEATH, as it is now parsed just prior to corpse creation.

Code:
Index: attack.cpp
===================================================================
--- attack.cpp	(revision 2103)
+++ attack.cpp	(working copy)
@@ -2174,7 +2174,18 @@
 	//do faction hits even if we are a merchant, so long as a player killed us
 	if(give_exp_client)
 		hate_list.DoFactionHits(GetNPCFactionID());
-	
+
+	// Parse quests even if we're killed by an NPC
+	if(killerMob) {
+		Mob *oos = killerMob->GetOwnerOrSelf();
+        parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
+		if(oos->IsNPC())
+		{
+            parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
+			killerMob->TrySpellOnKill();
+		}
+	}
+
 	if (!HasOwner() && class_ != MERCHANT && class_ != ADVENTUREMERCHANT && !GetSwarmInfo()
 		&& MerchantType == 0 && killer && (killer->IsClient() || (killer->HasOwner() && killer->GetUltimateOwner()->IsClient()) ||
 		(killer->IsNPC() && killer->CastToNPC()->GetSwarmInfo() && killer->CastToNPC()->GetSwarmInfo()->GetOwner() && killer->CastToNPC()->GetSwarmInfo()->GetOwner()->IsClient()))) {
@@ -2264,17 +2275,6 @@
 		}
 	}
 	
-	// Parse quests even if we're killed by an NPC
-	if(killerMob) {
-		Mob *oos = killerMob->GetOwnerOrSelf();
-        parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
-		if(oos->IsNPC())
-		{
-            parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
-			killerMob->TrySpellOnKill();
-		}
-	}
-	
 	this->WipeHateList();
 	p_depop = true;
 	if(killerMob && killerMob->GetTarget() == this) //we can kill things without having them targeted
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:06 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3