Thread: Player Death
View Single Post
  #9  
Old 01-20-2014, 02:21 AM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,603
Default

With some help from Akkadius I managed to create four new variables:
$killer_id, $killer_damage, $killer_spell, $killer_skill
These are valid in EVENT_DEATH and EVENT_DEATH_COMPLETE, here's a diff of the code.
Code:
--- "zone/attack.cpp"	
+++ "zone/attack.cpp"	
@@ -2042,8 +2042,8 @@
 	if(killerMob) {
 		oos = killerMob->GetOwnerOrSelf();
 
-		char buffer[32] = { 0 };
-		snprintf(buffer, 31, "%d %d %d", damage, spell, static_cast<int>(attack_skill));
+		char buffer[48] = { 0 };
+		snprintf(buffer, 47, "%d %d %d %d", killerMob ? killerMob->GetID() : 0, damage, spell, static_cast<int>(attack_skill));
 		if(parse->EventNPC(EVENT_DEATH, this, oos, buffer, 0) != 0)
 		{
 			if(GetHP() < 0) {
@@ -2058,8 +2058,8 @@
 				killerMob->GetCleanName(), GetCleanName(), ConvertArray(damage, val1));
 		}
 	} else {
-		char buffer[32] = { 0 };
-		snprintf(buffer, 31, "%d %d %d", damage, spell, static_cast<int>(attack_skill));
+		char buffer[48] = { 0 };
+		snprintf(buffer, 47, "%d %d %d %d", killerMob ? killerMob->GetID() : 0, damage, spell, static_cast<int>(attack_skill));
 		if(parse->EventNPC(EVENT_DEATH, this, nullptr, buffer, 0) != 0)
 		{
 			if(GetHP() < 0) {
@@ -2401,8 +2401,8 @@
 
 	entity_list.UpdateFindableNPCState(this, true);
 
-	char buffer[32] = { 0 };
-	snprintf(buffer, 31, "%d %d %d", damage, spell, static_cast<int>(attack_skill));
+	char buffer[48] = { 0 };
+	snprintf(buffer, 47, "%d %d %d %d", killerMob ? killerMob->GetID() : 0, damage, spell, static_cast<int>(attack_skill));
 	parse->EventNPC(EVENT_DEATH_COMPLETE, this, oos, buffer, 0);
 	return true;
 }
@@ -4496,4 +4496,3 @@
 		return damage;
 	}
 }
-

--- "zone/embparser.cpp"	
+++ "zone/embparser.cpp"	
@@ -1307,6 +1307,18 @@
 			break;
 		}
 
+		case EVENT_DEATH: 
+		case EVENT_DEATH_COMPLETE:
+		{ 
+			Seperator sep(data);
+			ExportVar(package_name.c_str(), "killer_id", sep->arg[0]);
+			ExportVar(package_name.c_str(), "killer_damage", sep->arg[1]);
+			ExportVar(package_name.c_str(), "killer_spell", sep->arg[2]);
+			ExportVar(package_name.c_str(), "killer_skill", sep->arg[3]);
+			break;
+		}
+
 		default: {
 			break;
 		}
Here is a script so you can test it on your server.
Code:
sub EVENT_DEATH_COMPLETE
{
	quest::gmsay("Killer ID: " . $entity_list->GetClientByID($killer_id)->GetName() . " Killer Damage: $killer_damage Killer Spell: $killer_spell Killer Skill: $killer_skill", 335, 1, 0, 250);
}
$killer_id: The entity ID of your Killer.
$killer_damage: The damage of the last hit your Killer did to you.
$killer_spell: The ID of the last spell your Killer hit you with.
$killer_skill: The skill used by the spell or weapon your Killer killed you with.
Reply With Quote