#include ww2x\_wwx_weapons;

main(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	level.obitlog = 0;

	// do not report command monitor deaths
	if(level.wwx_cmdmonitor && isDefined(self.wwx_cmdmondeath))
	{
		self.wwx_cmdmondeath = undefined;
		return;
	}

	// do not report forced suicides
	if(isDefined(self.wwx_forcedsuicide) && self.wwx_forcedsuicide == true)
	{
		self.wwx_forcedsuicide = undefined;
		return;
	}

	// do not report forced suicide for camping
	if(isDefined(self.wwx_iscamper) && self.wwx_iscamper == true) return;
	
	// do not report forced suicide for team switch
	if(isDefined(self.switching_teams) && self.switching_teams == true) return;

	self.wwx_obmonamsg = false;
	self.wwx_obmonpmsg = false;
	self.wwx_obmonpsound = false;

	// 0 = no obituary       - with stats (---)
	// 1 = stock obituary	   - with stats (---)
	// 2 = stock obituary    - with stats and personal sounds (--S)
	// 3 = stock obituary    - with stats and personal messages (-P-)
	// 4 = stock obituary    - with stats, personal sounds and personal messages (-PS)
	// 5 = ww2x+ obituary - with stats (A--)
	// 6 = ww2x+ obituary - with stats and personal sounds (A-S)
	// 7 = ww2x+ obituary - with stats, level messages and personal message (AP-)
	// 8 = ww2x+ obituary - with stats, level messages, personal messages and personal sounds (APS)
	if(level.wwx_obituary >= 5) self.wwx_obmonamsg = true;
	if(level.wwx_obituary == 3 || level.wwx_obituary == 4 || level.wwx_obituary == 7 || level.wwx_obituary == 8) self.wwx_obmonpmsg = true;
	if(level.wwx_obituary == 2 || level.wwx_obituary == 4 || level.wwx_obituary == 6 || level.wwx_obituary == 8) self.wwx_obmonpsound = true;

	if(level.wwx_obituary >= 1 && level.wwx_obituary <= 4) obituary(self, attacker, sWeapon, sMeansOfDeath);
	thread ww2xobituary(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc);
}

ww2xobituary(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	// unknown death
	if(sMeansOfDeath == "MOD_TRIGGER_HURT") obitnad("", "unknown", false);

	// falling
	if(sMeansOfDeath == "MOD_FALLING") obitnad("fallingdeath", "falling", true);

	// sMeansOfDeath conversion
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "artillery_mp") sMeansOfDeath = "MOD_ARTILLERY";
	if(sMeansOfDeath == "MOD_GRENADE" && sWeapon == "mortar_mp") sMeansOfDeath = "MOD_MORTAR";
	if(sMeansOfDeath == "MOD_GRENADE" && sWeapon == "planebomb_mp") sMeansOfDeath = "MOD_AIRSTRIKE";
	if(sMeansOfDeath == "MOD_PROJECTILE" && sWeapon == "planebomb_mp") sMeansOfDeath = "MOD_NAPALM";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "tripwire_mp") sMeansOfDeath = "MOD_TRIPWIRE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "landmine_mp") sMeansOfDeath = "MOD_LANDMINE";

	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "smoke_grenade_american_fire_mp") sMeansOfDeath = "MOD_FIRENADE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "smoke_grenade_british_fire_mp") sMeansOfDeath = "MOD_FIRENADE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "smoke_grenade_german_fire_mp") sMeansOfDeath = "MOD_FIRENADE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "smoke_grenade_russian_fire_mp") sMeansOfDeath = "MOD_FIRENADE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && sWeapon == "fire_mp") sMeansOfDeath = "MOD_FIRENADE";

	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_american_gas_mp") sMeansOfDeath = "MOD_GASNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_british_gas_mp") sMeansOfDeath = "MOD_GASNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_german_gas_mp") sMeansOfDeath = "MOD_GASNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_russian_gas_mp") sMeansOfDeath = "MOD_GASNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "gas_mp") sMeansOfDeath = "MOD_GASNADE";

	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_american_sticky_mp") sMeansOfDeath = "MOD_STICKYNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_british_sticky_mp") sMeansOfDeath = "MOD_STICKYNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_german_sticky_mp") sMeansOfDeath = "MOD_STICKYNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_russian_sticky_mp") sMeansOfDeath = "MOD_STICKYNADE";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "sticky_mp") sMeansOfDeath = "MOD_STICKYNADE";

	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_american_satchel_mp") sMeansOfDeath = "MOD_SATCHEL";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_british_satchel_mp") sMeansOfDeath = "MOD_SATCHEL";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_german_satchel_mp") sMeansOfDeath = "MOD_SATCHEL";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "smoke_grenade_russian_satchel_mp") sMeansOfDeath = "MOD_SATCHEL";
	if(sMeansOfDeath == "MOD_GRENADE_SPLASH" && sWeapon == "satchel_mp") sMeansOfDeath = "MOD_SATCHEL";

	if(sMeansOfDeath == "MOD_PROJECTILE_SPLASH" && sWeapon == "panzerschreck_mp") sMeansOfDeath = "MOD_PANZER";
	if(sMeansOfDeath == "MOD_PROJECTILE_SPLASH" && sWeapon == "panzerschreck_allies") sMeansOfDeath = "MOD_PANZER";
	if(sMeansOfDeath == "MOD_PROJECTILE" && sWeapon == "panzerschreck_mp") sMeansOfDeath = "MOD_PANZER";
	if(sMeansOfDeath == "MOD_PROJECTILE" && sWeapon == "panzerschreck_allies") sMeansOfDeath = "MOD_PANZER";

	if(sMeansOfDeath == "MOD_GRENADE" && (sWeapon == "knife_mp" || sWeapon == "knive_mp" || sWeapon == "smoke_grenade_russian_knife_mp" || sWeapon == "smoke_grenade_british_knife_mp" || sWeapon == "smoke_grenade_american_knife_mp" || sWeapon == "smoke_grenade_german_knife_mp")) sMeansOfDeath = "MOD_KNIFE";
	if(sMeansOfDeath == "MOD_EXPLOSIVE" && (sWeapon == "knife_mp" || sWeapon == "knive_mp" || sWeapon == "smoke_grenade_russian_knife_mp" || sWeapon == "smoke_grenade_british_knife_mp" || sWeapon == "smoke_grenade_american_knife_mp" || sWeapon == "smoke_grenade_german_knife_mp")) sMeansOfDeath = "MOD_KNIFE";



	if(level.obitlog) logprint("OBITUARY LOG: " + sMeansOfDeath + ", Weapon: " + sWeapon + ", Hitloc: " + sHitLoc + "\n");

	if(isDefined(attacker) && !isPlayer(attacker)) // ambient fx deaths
	{
		switch(sMeansOfDeath)
		{
			case "MOD_EXPLOSIVE":
			{
				switch(sWeapon)
				{
					case "mortar_mp":
					obitnad("mortardeath", "mortar", false);
					break;
					
					case "plane_mp":
					obitnad("planedeath", "plane", false);
					break;
					
					case "planebomb_mp":
					obitnad("airstrikedeath", "plane_bomb", false);
					break;

					case "panzerschreck_mp":
					obitnad("panzerdeath", "panzer", false);
					break;

					case "panzerschreck_allies":
					obitnad("panzerdeath", "panzer", false);
					break;

					case "knife_mp":
					obitnad("knifedeath", "knife", true);
					break;

					case "knive_mp":
					obitnad("knifedeath", "knife", true);
					break;

					case "smoke_grenade_russian_knife_mp":
					obitnad("knifedeath", "knife", true);
					break;

					case "smoke_grenade_british_knife_mp":
					obitnad("knifedeath", "knife", true);
					break;

					case "smoke_grenade_german_knife_mp":
					obitnad("knifedeath", "knife", true);
					break;

					case "smoke_grenade_american_knife_mp":
					obitnad("knifedeath", "knife", true);
					break;

					default:
					obitnad("minefielddeath", "minefield", true);
					break;
				}
			}
		}
	}
	else if(isDefined(attacker) && isPlayer(attacker)) // real player kills/deaths
	{
		if(attacker == self) // killed themself
		{
			switch(sMeansOfDeath)
			{
				case "MOD_GRENADE_SPLASH":
				if(isWeaponType(sWeapon, "grenade")) obitnad("grenadedeath", "selfnade", false);
				break;

				case "MOD_ARTILLERY":
				obitnad("artillerydeath", "selfartillery", false);
				break;

				case "MOD_FIRENADE":
				obitnad("firenadedeath", "selffirenade", false);
				break;

				case "MOD_GASNADE":
				obitnad("gasnadedeath", "selfgasnade", false);
				break;

				case "MOD_STICKYNADE":
				obitnad("stickynadedeath", "selfstickynade", false);
				break;

				case "MOD_SATCHEL":
				obitnad("satcheldeath", "selfsatchel", false);
				break;

				case "MOD_MORTAR":
				obitnad("mortardeath", "selfmortar", false);
				break;

				case "MOD_AIRSTRIKE":
				obitnad("airstrikedeath", "selfairstrike", false);
				break;

				case "MOD_NAPALM":
				obitnad("napalmdeath", "selfnapalm", false);
				break;

				case "MOD_PANZER":
				obitnad("panzerdeath", "selfpanzer", false);
				break;

				case "MOD_TRIPWIRE":
				obitnad("tripwiredeath", "selftripwire", false);
				break;

				case "MOD_LANDMINE":
				obitnad("landminedeath", "selflandmine", false);
				break;

				case "MOD_SUICIDE":
				obitnad("grenadedeath", "selfnades", true);
				break;
				
				case "MOD_KNIFE":
				obitnad("knifedeath", "selfknife", false);
				break;
			}
		}
		else if(attacker.pers["team"] != self.pers["team"] && level.wwx_teamplay || !level.wwx_teamplay) // did not kill themself
		{
			if(isMeansOfDeath(sMeansOfDeath)) // special sMOD
			{
				switch(sMeansOfDeath)
				{
					case "MOD_MELEE":
					{
						if(sWeapon == "knife_mp" || sWeapon == "knive_mp") // register knife bash as normal kill
						{
							obitad(attacker, "knifekill", "knifedeath", "knifewhip", sMeansOfDeath, sWeapon);
							break;
						}
						else
						{
							if(sHitLoc == "head")	obitad(attacker, "bashkill", "bashdeath", "bashkill_head", sMeansOfDeath, sWeapon);
								else obitad(attacker, "bashkill", "bashdeath", "bashkill", sMeansOfDeath, sWeapon);
							break;
						}
					}

					case "MOD_GRENADE_SPLASH":
					{
						if(isWeaponType(sWeapon, "grenade"))
						{
							obitspec(attacker, "grenadekill", "grenadedeath", "explosive", &"OBITUARY_WITH_A_GRENADE");
							break;
						}
					}

					case "MOD_KNIFE":
					obitspec(attacker, "knifekill", "knifedeath", "pknife", &"OBITUARY_WITH_KNIFE");
					break;
					
					case "MOD_ARTILLERY":
					obitspec(attacker, "artillerykill", "artillerydeath", "explosive", &"OBITUARY_WITH_ARTILLERY");
					break;

					case "MOD_FIRENADE":
					obitspec(attacker, "firenadekill", "firenadedeath", "pfirenade", &"OBITUARY_WITH_FIRENADE");
					break;

					case "MOD_GASNADE":
					obitspec(attacker, "gasnadekill", "gasnadedeath", "pgasnade", &"OBITUARY_WITH_GASNADE");
					break;

					case "MOD_STICKYNADE":
					obitspec(attacker, "stickynadekill", "stickynadedeath", "pstickynade", &"OBITUARY_WITH_STICKYNADE");
					break;

					case "MOD_SATCHEL":
					obitspec(attacker, "satchelkill", "satcheldeath", "psatchel", &"OBITUARY_WITH_SATCHEL");
					break;

					case "MOD_MORTAR":
					obitspec(attacker, "mortarkill", "mortardeath", "explosive", &"OBITUARY_WITH_MORTAR");
					break;

					case "MOD_AIRSTRIKE":
					obitspec(attacker, "airstrikekill", "airstrikedeath", "explosive", &"OBITUARY_WITH_AIRSTRIKE");
					break;

					case "MOD_NAPALM":
					obitspec(attacker, "napalmkill", "napalmdeath", "pnapalm", &"OBITUARY_WITH_NAPALM");
					break;

					case "MOD_PANZER":
					obitspec(attacker, "panzerkill", "panzerdeath", "ppanzer", &"OBITUARY_WITH_PANZER");
					break;

					case "MOD_TRIPWIRE":
					obitspec(attacker, "tripwirekill", "tripwiredeath", "explosive", &"OBITUARY_WITH_TRIPWIRE");
					break;

					case "MOD_LANDMINE":
					obitspec(attacker, "landminekill", "landminedeath", "explosive", &"OBITUARY_WITH_LANDMINE");
					break;

					case "MOD_HEAD_SHOT":
					{
						obitad(attacker, "headshotkill", "headshotdeath", "", sMeansOfDeath, sWeapon);
						obitmain(attacker, sWeapon, sHitLoc, false);
						if(self.wwx_obmonpmsg) attacker iprintln(&"CUSTOM_ADMIN_NAME", &"OBITUARY_HEADSHOT");
						if(self.wwx_obmonpsound) attacker playLocalSound("headshot");
						break;
					}
				}
			}
			else // not special sMOD
			{
				// sniper kills
				if(isWeaponType(sWeapon, "sniper"))
				{
					obitad(attacker, "sniperkill", "sniperdeath", "sniper", sMeansOfDeath, sWeapon);
					sMeansOfDeath = "MOD_IGNORE";
				}
			}
		}
		else if(attacker.pers["team"] == self.pers["team"] && level.wwx_teamplay) // team kills
		{
			if(isMeansOfDeath(sMeansOfDeath)) // special sMOD
			{
				switch(sMeansOfDeath)
				{
					case "MOD_MELEE":
					{
						if(sWeapon == "knife_mp" || sWeapon == "knive_mp")
						{
							obitteam(attacker, "knifewhiptk", sMeansOfDeath, sWeapon);
							break;
						}
						else
						{
							obitteam(attacker, "bashtk", sMeansOfDeath, sWeapon);
							break;
						}
					}

					case "MOD_KNIFE":
					obitteam(attacker, "knifetk", sMeansOfDeath, sWeapon);
					break;
					
					case "MOD_GRENADE_SPLASH":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_ARTILLERY":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_FIRENADE":
					obitteam(attacker, "firenadetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_GASNADE":
					obitteam(attacker, "gasnadetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_STICKYNADE":
					obitteam(attacker, "stickynadetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_SATCHEL":
					obitteam(attacker, "satcheltk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_MORTAR":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_AIRSTRIKE":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_NAPALM":
					obitteam(attacker, "napalmtk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_PANZER":
					obitteam(attacker, "panzertk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_TRIPWIRE":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_LANDMINE":
					obitteam(attacker, "explosivetk", sMeansOfDeath, sWeapon);
					break;

					case "MOD_HEAD_SHOT":
					obitteam(attacker, "headshottk", sMeansOfDeath, sWeapon);
					break;
				}
			}
			else // not special sMOD
			{
				if(isWeaponType(sWeapon, "sniper"))
				{
					obitteam(attacker, "snmsgtk", sMeansOfDeath, sWeapon);
					sMeansOfDeath = "MOD_IGNORE";
				}
			}
		}
	}

	// standard deaths
	if(sHitLoc != "none" && !isWeapon(sWeapon) && !isMeansOfDeath(sMeansOfDeath) && isPlayer(attacker))
	{
		if(attacker.pers["team"] != self.pers["team"] && level.wwx_teamplay || !level.wwx_teamplay) obitmain(attacker, sWeapon, sHitLoc, true);
			else if(attacker.pers["team"] == self.pers["team"] && attacker != self && level.wwx_teamplay) obitteam(attacker, "teamkill", sMeansOfDeath, sWeapon);
	}
	
	self thread killspree(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc);
	if(!isWeaponType(sWeapon, "smg")) self thread weaponstreak(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc);
	if(isWeaponType(sWeapon, "smg") || isWeaponType(sWeapon, "mg")) self thread noobstreak(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc);
	self thread consecdeath(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc);
}			

isWeapon(sWeapon)
{
	switch(sWeapon)
	{
		case "mortar_mp":
		case "plane_mp":
		case "planebomb_mp":
		case "tripwire_mp":
		case "landmine_mp":
		case "knife_mp":
		case "knive_mp":
		case "smoke_grenade_american_knife_mp":
		case "smoke_grenade_british_knife_mp":
		case "smoke_grenade_german_knife_mp":
		case "smoke_grenade_russian_knife_mp":
		case "panzerschreck_mp":
		case "panzerschreck_allies":		
		case "smoke_grenade_american_fire_mp":
		case "smoke_grenade_british_fire_mp":
		case "smoke_grenade_german_fire_mp":
		case "smoke_grenade_russian_fire_mp":
		case "fire_mp":
		case "smoke_grenade_american_gas_mp":
		case "smoke_grenade_british_gas_mp":
		case "smoke_grenade_german_gas_mp":
		case "smoke_grenade_russian_gas_mp":
		case "gas_mp":
		case "smoke_grenade_american_sticky_mp":
		case "smoke_grenade_british_sticky_mp":
		case "smoke_grenade_german_sticky_mp":
		case "smoke_grenade_russian_sticky_mp":
		case "sticky_mp":
		case "smoke_grenade_american_satchel_mp":
		case "smoke_grenade_british_satchel_mp":
		case "smoke_grenade_german_satchel_mp":
		case "smoke_grenade_russian_satchel_mp":
		case "satchel_mp":
		return true;
	}
	
	return false;
}

isMeansOfDeath(sMeansOfDeath)
{
	switch(sMeansOfDeath)
	{
		case "MOD_FALLING":
		case "MOD_MELEE":
		case "MOD_KNIFE":
		case "MOD_GRENADE":
		case "MOD_GRENADE_SPLASH":
		case "MOD_EXPLOSIVE":
		case "MOD_SUICIDE":
		case "MOD_IGNORE":
		case "MOD_ARTILLERY":
		case "MOD_MORTAR":
		case "MOD_AIRSTRIKE":
		case "MOD_NAPALM":
		case "MOD_TRIPWIRE":
		case "MOD_LANDMINE":
		case "MOD_HEAD_SHOT":
		case "MOD_PROJECTILE":
		case "MOD_PANZER":		
		case "MOD_FIRENADE":
		case "MOD_GASNADE":
		case "MOD_STICKYNADE":
		case "MOD_SATCHEL":
		return true;
	}
	
	return false;
}

// special detection - no attacker defined
obitnad(vartype, amsg, issuicide)
{
	self endon("disconnected");

	self.pers["death"]++;
	if(vartype != "") self.pers[vartype]++;
	if(issuicide)
	{
		self.pers["kill"]--;
		self.pers["suicide"]++;
	}

	if(level.obitlog) logprint("OBITNAD: self skd(" + self.score + ":" + self.pers["kill"] + ":" + self.pers["death"] + ")\n");

	if(amsg != "")
	{
            if(level.wwx_linux_server >= 1)
            {
		if(self.wwx_obmonpmsg) self showpmsgs(amsg);
		if(self.wwx_obmonamsg) iprintln(getmessage(amsg), self.name);
            }
            else
            {
		if(self.wwx_obmonpmsg) self showpmsgs(amsg);
		if(self.wwx_obmonamsg) iprintln(getmessage(amsg), self);
            }
	}
}

// special detection - attacker defined
obitad(attacker, atvt, vivt, amsg, sMeansOfDeath, sWeapon)
{
	self endon("disconnected");

	attacker.pers["kill"]++;
	self.pers["death"]++;
	if(atvt != "") attacker.pers[atvt]++;
	if(vivt != "") self.pers[vivt]++;

	if(level.obitlog) logprint("OBITAD: attacker " + attacker.name + " skd(" + (attacker.score+1) + ":" + attacker.pers["kill"] + ":" + attacker.pers["death"] + "), self " + self.name + " skd(" + self.score + ":" + self.pers["kill"] + ":" + self.pers["death"] + ")\n");

	if(amsg != "")
	{
		weapon = getweaponstringname(sWeapon);
		
		if(sMeansOfDeath == "MOD_MELEE")
		{
			if(sWeapon == "colt_mp" || sWeapon == "luger_mp" || sWeapon == "webley_mp" || sWeapon == "TT30_mp")
			{
				if(self.wwx_obmonpmsg) self showpmsgs("pistolwhip");
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage("pistolwhip"), self.name);
					iprintln(&"OBITUARY_USING", attacker.name, weapon);
                              }
                              else
                              {
 					iprintln(getmessage("pistolwhip"), self);
					iprintln(&"OBITUARY_USING", attacker, weapon);
                              }
				}
			}
			else if(sWeapon == "knife_mp" || sWeapon == "knive_mp")
			{
				if(self.wwx_obmonpmsg) self showpmsgs("knifewhip");
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage("knifewhip"), self.name);
					iprintln(&"OBITUARY_USING", attacker.name, weapon);
                              }
                              else
                              {
 					iprintln(getmessage("knifewhip"), self);
					iprintln(&"OBITUARY_USING", attacker, weapon);
                              }
				}
			}
			else
			{
				if(self.wwx_obmonpmsg) self showpmsgs(amsg);
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage(amsg), self.name);
					iprintln(&"OBITUARY_USING_BUTT", attacker.name, weapon);
                              }
                              else
                              {
					iprintln(getmessage(amsg), self);
					iprintln(&"OBITUARY_USING_BUTT", attacker, weapon);
                              }
				}
			}
		}
		else
		{
			if(self.wwx_obmonpmsg) self showpmsgs(amsg);
			if(self.wwx_obmonamsg)
			{
                        if(level.wwx_linux_server >= 1)
                        {
				iprintln(getmessage(amsg), self.name);
				iprintln(&"OBITUARY_USING", attacker.name, weapon);
                        }
                        else
                        {
				iprintln(getmessage(amsg), self);
				iprintln(&"OBITUARY_USING", attacker, weapon);
                        }
			}
		}
	}
}

// killed by teammate
obitteam(attacker, amsg, sMeansOfDeath, sWeapon)
{
	self endon("disconnected");

	//attacker.pers["teamkill"]++; (DO NOT ACTIVATE! This is already handled in _wwx_main::exPlayerKilled)
	attacker.pers["kill"]--;

	if(level.obitlog) logprint("OBITTEAM: attacker " + attacker.name + " skd(" + (attacker.score-1) + ":" + attacker.pers["kill"] + ":" + attacker.pers["death"] + "), self " + self.name + " skd(" + self.score + ":" + self.pers["kill"] + ":" + self.pers["death"] + ")\n");

	if(amsg != "")
	{
		weapon = getweaponstringname(sWeapon);
	
		if(sMeansOfDeath == "MOD_MELEE")
		{
			if(sWeapon == "colt_mp" || sWeapon == "luger_mp" || sWeapon == "webley_mp" || sWeapon == "TT30_mp")
			{
				if(self.wwx_obmonpmsg) self showpmsgs("pistolwhiptk");
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage("pistolwhiptk"), self.name);
					iprintln(&"OBITUARY_USING", attacker.name, weapon);
                              }
                              else
                              {
					iprintln(getmessage("pistolwhiptk"), self);
					iprintln(&"OBITUARY_USING", attacker, weapon);
                              }
				}
			}
			else if(sWeapon == "knife_mp" || sWeapon == "knive_mp")
			{
				if(self.wwx_obmonpmsg) self showpmsgs("knifewhiptk");
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage("knifewhiptk"), self.name);
					iprintln(&"OBITUARY_USING", attacker.name, weapon);
                              }
                              else
                              {
					iprintln(getmessage("knifewhiptk"), self);
					iprintln(&"OBITUARY_USING", attacker, weapon);
                              }
				}
			}
			else
			{
				if(self.wwx_obmonpmsg) self showpmsgs(amsg);
				if(self.wwx_obmonamsg)
				{
                              if(level.wwx_linux_server >= 1)
                              {
					iprintln(getmessage(amsg), self.name);
					iprintln(&"OBITUARY_USING_BUTT", attacker.name, weapon);
                              }
                              else
                              {
					iprintln(getmessage(amsg), self);
					iprintln(&"OBITUARY_USING_BUTT", attacker, weapon);
                              }
				}
			}
		}
		else
		{
			if(self.wwx_obmonpmsg) self showpmsgs(amsg);
			if(self.wwx_obmonamsg)
			{
                        if(level.wwx_linux_server >= 1)
                        {
				iprintln(getmessage(amsg), self.name);
				iprintln(&"OBITUARY_USING", attacker.name, weapon);
                        }
                        else
                        {
				iprintln(getmessage(amsg), self);
				iprintln(&"OBITUARY_USING", attacker, weapon);
                        }
			}
		}
	}
}

// handles weapon_gramatic of mass destruction deaths
obitspec(attacker, atvt, vivt, amsg, wmd)
{
	self endon("disconnected");

	attacker.pers["kill"]++;
	self.pers["death"]++;
	if(atvt != "") attacker.pers[atvt]++;
	if(vivt != "") self.pers[vivt]++;

	if(level.obitlog) logprint("OBITSPEC: attacker " + attacker.name + " skd(" + (attacker.score+1) + ":" + attacker.pers["kill"] + ":" + attacker.pers["death"] + "), self " + self.name + " skd(" + self.score + ":" + self.pers["kill"] + ":" + self.pers["death"] + ")\n");

	if(amsg != "")
	{
		if(self.wwx_obmonpmsg) self showpmsgs(amsg);

		if(self.wwx_obmonamsg)
		{
                  if(level.wwx_linux_server >= 1)
                  {
			iprintln(getmessage(amsg), self.name);
			iprintln(wmd, attacker.name);
                  }
                  else
                  {
			iprintln(getmessage(amsg), self);
			iprintln(wmd, attacker);
                  }
		}
	}
}

// standard weapons
obitmain(attacker, sWeapon, sHitLoc, updstat)
{
	self endon("disconnected");

	if(updstat)
	{
		attacker.pers["kill"]++;
		self.pers["death"]++;
	}

	if(level.obitlog) logprint("OBITMAIN: attacker " + attacker.name + " skd(" + (attacker.score+1) + ":" + attacker.pers["kill"] + ":" + attacker.pers["death"] + "), self " + self.name + " skd(" + self.score + ":" + self.pers["kill"] + ":" + self.pers["death"] + ")\n");

	if(!self.wwx_obmonamsg) return;

	close = false;
	rangedist = undefined;
	inyards = false;
	range = int(distance(attacker.origin, self.origin));

	if(isDefined(range))
	{
		if(level.wwx_obrange == 1)
		{
			rangedist = int(range * 0.02778);		// Range in Yards
	
			if(rangedist > 9) inyards = true;
			else
			{
				close = true;
				rangedesc = &"OBITUARY_CLOSE_RANGE";
			}	
		}
		else
		{
			rangedist = int(range * 0.0254);		// Range in Metres
			
			if(rangedist > 3) inyards = false;
			else close = true;
		}
	}	

	weapon = getweaponstringname(sWeapon);
	hitloc = gethitlocstringname(sHitLoc);

	if(isDefined(rangedist))
	{
            if(level.wwx_linux_server >= 1)
            {
		if(sWeapon == "knife_mp" || sWeapon == "knive_mp" || sWeapon == "smoke_grenade_russian_knife_mp" || sWeapon == "smoke_grenade_british_knife_mp" || sWeapon == "smoke_grenade_american_knife_mp" || sWeapon == "smoke_grenade_german_knife_mp")
			iprintln(&"OBITUARY_KILLED_KNIFE", self.name);
		else
			iprintln(&"OBITUARY_KILLED_HITLOC", self.name, hitloc);
		
		if(close)
		{
			iprintln(&"OBITUARY_CLOSE_RANGE", attacker.name);
			iprintln(&"OBITUARY_USING_WEAPON", weapon);
		}
		else
		{
			iprintln(&"OBITUARY_ATTACKER_WEAPON", attacker.name, weapon);

			if(inyards) iprintln(&"OBITUARY_YARDS", rangedist);
			else iprintln(&"OBITUARY_METRES", rangedist);
		}  
            }
            else
            {
		if(sWeapon == "knife_mp" || sWeapon == "knive_mp" || sWeapon == "smoke_grenade_russian_knife_mp" || sWeapon == "smoke_grenade_british_knife_mp" || sWeapon == "smoke_grenade_american_knife_mp" || sWeapon == "smoke_grenade_german_knife_mp")
			iprintln(&"OBITUARY_KILLED_KNIFE", self);
		else
			iprintln(&"OBITUARY_KILLED_HITLOC", self, hitloc);
		
		if(close)
		{
			iprintln(&"OBITUARY_CLOSE_RANGE", attacker);
			iprintln(&"OBITUARY_USING_WEAPON", weapon);
		}
		else
		{
			iprintln(&"OBITUARY_ATTACKER_WEAPON", attacker, weapon);

			if(inyards) iprintln(&"OBITUARY_YARDS", rangedist);
			else iprintln(&"OBITUARY_METRES", rangedist);
		}
}
	}
}

killspree(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	if(!isDefined(game[self.name])) game[self.name] = [];
	if(!isDefined(game[self.name]["conseckill"])) game[self.name]["conseckill"] = 0;

	if(!isPlayer(attacker)) return;

	if(attacker.pers["team"] == self.pers["team"] && level.wwx_teamplay)
	{
		game[attacker.name]["conseckill"]--;
		attacker.pers["conseckill"]--;
		return;
	}

	if(attacker != self)
	{
		// check for end of a players killing spree	
		if(game[self.name]["conseckill"] >= 5)
		{
			if(self.wwx_obmonamsg)
			{
                        if(level.wwx_linux_server >= 1)
                        {
				if(game[self.name]["conseckill"] >= 30)
				{
					iprintln(&"KILLSPREE_HAS_SAVED_ALL_OUR_ASSES_FROM", attacker.name);
					iprintln(&"KILLSPREE_ANAL_RAPE", self.name);
				}
				else if(game[self.name]["conseckill"] >= 25)
				{
					iprintln(&"KILLSPREE_HAS_SAVED_US_ALL_FROM", attacker.name);
					iprintln(&"KILLSPREE_UNHOLY", self.name);
				}
				else if(game[self.name]["conseckill"] >= 20)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED_THE_UNSTOPPABLE", attacker.name);
					iprintln(&"KILLSPREE_CRUSADE", self.name);
				}
				else if(game[self.name]["conseckill"] >= 15)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED_THE_UNSTOPPABLE",attacker.name);
					iprintln(&"KILLSPREE_UNREAL", self.name);
				}
				else if(game[self.name]["conseckill"] >= 10)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED", attacker.name);
					iprintln(&"KILLSPREE_FLUKISH", self.name);
				}
				else if(game[self.name]["conseckill"] >= 5)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED", attacker.name);
					iprintln(&"KILLSPREE_PLURAL", self.name);
				}
                       }
                       else
                       {
				if(game[self.name]["conseckill"] >= 30)
				{
					iprintln(&"KILLSPREE_HAS_SAVED_ALL_OUR_ASSES_FROM", attacker);
					iprintln(&"KILLSPREE_ANAL_RAPE", self);
				}
				else if(game[self.name]["conseckill"] >= 25)
				{
					iprintln(&"KILLSPREE_HAS_SAVED_US_ALL_FROM", attacker);
					iprintln(&"KILLSPREE_UNHOLY", self);
				}
				else if(game[self.name]["conseckill"] >= 20)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED_THE_UNSTOPPABLE", attacker);
					iprintln(&"KILLSPREE_CRUSADE", self);
				}
				else if(game[self.name]["conseckill"] >= 15)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED_THE_UNSTOPPABLE",attacker);
					iprintln(&"KILLSPREE_UNREAL", self);
				}
				else if(game[self.name]["conseckill"] >= 10)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED", attacker);
					iprintln(&"KILLSPREE_FLUKISH", self);
				}
				else if(game[self.name]["conseckill"] >= 5)
				{
					iprintln(&"KILLSPREE_HAS_STOPPED", attacker);
					iprintln(&"KILLSPREE_PLURAL", self);
				}
                        }
			}

			game[self.name]["conseckill"] = 0;

			if(self.wwx_obmonpsound)
			{
				attacker playLocalSound("wixxer");
				self playLocalSound("monsterlache");

				players = getentarray("player", "classname");
				for(i = 0; i < players.size; i++) if(players[i] != self) players[i] playlocalsound("hallelujah");
			}
		}

		// check for a players killing spree
		if(!isDefined(game[attacker.name])) game[attacker.name] = [];
		if(!isDefined(game[attacker.name]["conseckill"])) game[attacker.name]["conseckill"] = 0;
		else if(game[attacker.name]["conseckill"] <= 0) game[attacker.name]["conseckill"] = 0;

		game[attacker.name]["conseckill"]++;
		attacker.pers["conseckill"]++;
		stp = undefined;
		pmsg = undefined;
		amsg = undefined;

		if(game[attacker.name]["conseckill"] >= 5)
		{
                  if(level.wwx_linux_server >= 1)
                  {
			if(game[attacker.name]["conseckill"] == 5)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_5", attacker.name);
				pmsg = &"KILLSPREE_KILLSPREE_PMSG";
				stp = "killingspree";
			}
			else if(game[attacker.name]["conseckill"] == 10)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_10", attacker.name);
				pmsg = &"KILLSPREE_DOMINATING_PMSG";
				stp = "dominating";
			}
			else if(game[attacker.name]["conseckill"] == 15)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_15", attacker.name);
				pmsg = &"KILLSPREE_RAMPAGE_PMSG";
				stp = "rampage";
			}
			else if(game[attacker.name]["conseckill"] == 20)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_20", attacker.name);
				pmsg = &"KILLSPREE_UNSTOPPABLE_PMSG";
				stp = "unstoppable";
			}
			else if(game[attacker.name]["conseckill"] == 25)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_25", attacker.name);
				pmsg = &"KILLSPREE_MONSTER_KILL_PMSG";
				stp = "monsterkill";
			}
			else if(game[attacker.name]["conseckill"] >= 30)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_30", attacker.name);
					ps = randomInt(100);
				if(ps <= 25) { stp = "ultrakill"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_ULTRA_KILL_PMSG"; }
				if(ps > 25 && ps <= 50) { stp = "godlike"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_GODLIKE_PMSG"; }
				if(ps > 50 && ps <= 75) { stp = "holyshit"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_HOLY_SHIT_PMSG"; }
				if(ps > 75) { stp = "slaughter"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_SLAUGHTER_PMSG"; }
			}

			if(self.wwx_obmonpmsg && isDefined(pmsg)) attacker iprintln(&"CUSTOM_ADMIN_NAME",pmsg);
			if(self.wwx_obmonpsound&& isDefined(stp)) attacker playLocalSound(stp);
                  }
                  else
                  {
			if(game[attacker.name]["conseckill"] == 5)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_5", attacker);
				pmsg = &"KILLSPREE_KILLSPREE_PMSG";
				stp = "killingspree";
			}
			else if(game[attacker.name]["conseckill"] == 10)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_10", attacker);
				pmsg = &"KILLSPREE_DOMINATING_PMSG";
				stp = "dominating";
			}
			else if(game[attacker.name]["conseckill"] == 15)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_15", attacker);
				pmsg = &"KILLSPREE_RAMPAGE_PMSG";
				stp = "rampage";
			}
			else if(game[attacker.name]["conseckill"] == 20)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_20", attacker);
				pmsg = &"KILLSPREE_UNSTOPPABLE_PMSG";
				stp = "unstoppable";
			}
			else if(game[attacker.name]["conseckill"] == 25)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_25", attacker);
				pmsg = &"KILLSPREE_MONSTER_KILL_PMSG";
				stp = "monsterkill";
			}
			else if(game[attacker.name]["conseckill"] >= 30)
			{
				if(self.wwx_obmonamsg) iprintln(&"KILLSPREE_MSG_30", attacker);
					ps = randomInt(100);
				if(ps <= 25) { stp = "ultrakill"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_ULTRA_KILL_PMSG"; }
				if(ps > 25 && ps <= 50) { stp = "godlike"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_GODLIKE_PMSG"; }
				if(ps > 50 && ps <= 75) { stp = "holyshit"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_HOLY_SHIT_PMSG"; }
				if(ps > 75) { stp = "slaughter"; if(self.wwx_obmonpmsg) pmsg = &"KILLSPREE_SLAUGHTER_PMSG"; }
			}

			if(self.wwx_obmonpmsg && isDefined(pmsg)) attacker iprintln(&"CUSTOM_ADMIN_NAME",pmsg);
			if(self.wwx_obmonpsound&& isDefined(stp)) attacker playLocalSound(stp);
              }
		}
	}
}

weaponstreak(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	if(!isPlayer(attacker)) return;
	
	if(attacker.pers["team"] == self.pers["team"] && level.wwx_teamplay) return;

	if(isDefined(attacker.pers["weaponname"]) && sWeapon == attacker.pers["weaponname"]) attacker.pers["weaponstreak"]++;
	else
	{
		attacker.pers["weaponstreak"] = 1;
		attacker.pers["weaponname"] = sWeapon;
	}

	attacker_weapon = getweaponstringname(attacker.pers["weaponname"]);

	if(attacker.pers["weaponstreak"] >= 5 && self.wwx_obmonamsg)
	{
            if(level.wwx_linux_server >= 1)
            {
		if(attacker.pers["weaponstreak"] == 5) iprintln(&"WEAPONSTREAK_MSG_5", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 10) iprintln(&"WEAPONSTREAK_MSG_10", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 15) iprintln(&"WEAPONSTREAK_MSG_15", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 20) iprintln(&"WEAPONSTREAK_MSG_20", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 25) iprintln(&"WEAPONSTREAK_MSG_25", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 30) iprintln(&"WEAPONSTREAK_MSG_30", attacker.name, attacker_weapon);
		else if(attacker.pers["weaponstreak"] >= 35)
		{
			iprintln(&"WEAPONSTREAK_MSG_35A", attacker.name, attacker_weapon);
			iprintln(&"WEAPONSTREAK_MSG_35B", attacker.pers["weaponstreak"]);
		}
          }
          else
          {
		if(attacker.pers["weaponstreak"] == 5) iprintln(&"WEAPONSTREAK_MSG_5", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 10) iprintln(&"WEAPONSTREAK_MSG_10", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 15) iprintln(&"WEAPONSTREAK_MSG_15", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 20) iprintln(&"WEAPONSTREAK_MSG_20", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 25) iprintln(&"WEAPONSTREAK_MSG_25", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] == 30) iprintln(&"WEAPONSTREAK_MSG_30", attacker, attacker_weapon);
		else if(attacker.pers["weaponstreak"] >= 35)
		{
			iprintln(&"WEAPONSTREAK_MSG_35A", attacker, attacker_weapon);
			iprintln(&"WEAPONSTREAK_MSG_35B", attacker.pers["weaponstreak"]);
		}
          }
	}
}

noobstreak(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	if(!isPlayer(attacker)) return;

	if(attacker.pers["team"] == self.pers["team"] && level.wwx_teamplay) return;

	if(isDefined(attacker.pers["weaponname"]) && sWeapon == attacker.pers["weaponname"]) attacker.pers["noobstreak"]++;
	else
	{
		attacker.pers["noobstreak"] = 1;
		attacker.pers["weaponname"] = sWeapon;
	}

	attacker_weapon = getweaponstringname(attacker.pers["weaponname"]);
	if(attacker.pers["noobstreak"]%5==0) attacker.pers["spamkill"]++;

	if(attacker.pers["noobstreak"] >= 5 && self.wwx_obmonamsg)
	{
            if(level.wwx_linux_server >= 1)
            {
		if(attacker.pers["noobstreak"] == 5) iprintln(&"NOOBSTREAK_MSG_5", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 10) iprintln(&"NOOBSTREAK_MSG_10", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 15) iprintln(&"NOOBSTREAK_MSG_15", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 20) iprintln(&"NOOBSTREAK_MSG_20", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 25) iprintln(&"NOOBSTREAK_MSG_25", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 30) iprintln(&"NOOBSTREAK_MSG_30", attacker.name, attacker_weapon);
		else if(attacker.pers["noobstreak"] >= 35)
		{
			iprintln(&"NOOBSTREAK_MSG_35A", attacker.name, attacker_weapon);
			iprintln(&"NOOBSTREAK_MSG_35B", attacker.pers["noobstreak"]);
		}
           }
           else
           {
		if(attacker.pers["noobstreak"] == 5) iprintln(&"NOOBSTREAK_MSG_5", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 10) iprintln(&"NOOBSTREAK_MSG_10", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 15) iprintln(&"NOOBSTREAK_MSG_15", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 20) iprintln(&"NOOBSTREAK_MSG_20", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 25) iprintln(&"NOOBSTREAK_MSG_25", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] == 30) iprintln(&"NOOBSTREAK_MSG_30", attacker, attacker_weapon);
		else if(attacker.pers["noobstreak"] >= 35)
		{
			iprintln(&"NOOBSTREAK_MSG_35A", attacker, attacker_weapon);
			iprintln(&"NOOBSTREAK_MSG_35B", attacker.pers["noobstreak"]);
		}
          }
	}
}

consecdeath(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc)
{
	self endon("disconnected");

	if(!isPlayer(attacker)) return;

	if(attacker.pers["team"] == self.pers["team"] && level.wwx_teamplay) return;

	if(game[self.name]["conseckill"] > 0) game[self.name]["conseckill"] = 0;
				
	game[self.name]["conseckill"]--;

	if(game[self.name]["conseckill"] <= -5 && self.wwx_obmonamsg)
	{
            if(level.wwx_linux_server >= 1)
            {
		if(game[self.name]["conseckill"] == -5) iprintln(&"CONSECDEATHS_MSG_5", self.name);
		else if(game[self.name]["conseckill"] == -8) iprintln(&"CONSECDEATHS_MSG_8", self.name);
		else if(game[self.name]["conseckill"] == -10) iprintln(&"CONSECDEATHS_MSG_10", self.name);
		else if(game[self.name]["conseckill"] == -13) iprintln(&"CONSECDEATHS_MSG_13", self.name);
		else if(game[self.name]["conseckill"] <= -16) iprintln(&"CONSECDEATHS_MSG_16", self.name);
            }
            else
            {
		if(game[self.name]["conseckill"] == -5) iprintln(&"CONSECDEATHS_MSG_5", self);
		else if(game[self.name]["conseckill"] == -8) iprintln(&"CONSECDEATHS_MSG_8", self);
		else if(game[self.name]["conseckill"] == -10) iprintln(&"CONSECDEATHS_MSG_10", self);
		else if(game[self.name]["conseckill"] == -13) iprintln(&"CONSECDEATHS_MSG_13", self);
		else if(game[self.name]["conseckill"] <= -16) iprintln(&"CONSECDEATHS_MSG_16", self);
            }
	}
}

getmessage(var)
{
	self endon("disconnected");

	if(!isDefined(var)) return undefined;

	msg = [];

	switch(var)
	{
		case "unknown":
			msg[0] = &"OBITUARY_UNKNOWN_MSG_0";
			msg[1] = &"OBITUARY_UNKNOWN_MSG_1";
			msg[2] = &"OBITUARY_UNKNOWN_MSG_2";
			break;

		case "falling":
			msg[0] = &"OBITUARY_FALLING_MSG_0";
			msg[1] = &"OBITUARY_FALLING_MSG_1";
			msg[2] = &"OBITUARY_FALLING_MSG_2";
			break;

		// mortar
		case "mortar":
			msg[0] = &"OBITUARY_MORTAR_MSG_0";
			msg[1] = &"OBITUARY_MORTAR_MSG_1";
			break;

		case "selfmortar":
			msg[0] = &"OBITUARY_MORTARSELF_MSG_0";
			break;

		// Napalm grenades
		case "firenade":
			msg[0] = &"OBITUARY_FIRENADE_MSG_0";
			msg[1] = &"OBITUARY_FIRENADE_MSG_1";
			msg[2] = &"OBITUARY_FIRENADE_MSG_2";
			break;

		case "pfirenade":
			msg[0] = &"OBITUARY_PFIRENADE_MSG_0";
			msg[1] = &"OBITUARY_PFIRENADE_MSG_1";
			break;

		case "firenadetk":
			msg[0] = &"OBITUARY_FIRENADETK_MSG_0";
			msg[1] = &"OBITUARY_FIRENADETK_MSG_1";
			break;

		case "selffirenade":
			msg[0] = &"OBITUARY_FIRENADESELF_MSG_0";
			break;

		// gas grenades
		case "gasnade":
			msg[0] = &"OBITUARY_GASNADE_MSG_0";
			msg[1] = &"OBITUARY_GASNADE_MSG_1";
			msg[2] = &"OBITUARY_GASNADE_MSG_2";
			break;

		case "pgasnade":
			msg[0] = &"OBITUARY_PGASNADE_MSG_0";
			msg[1] = &"OBITUARY_PGASNADE_MSG_1";
			break;

		case "gasnadetk":
			msg[0] = &"OBITUARY_GASNADETK_MSG_0";
			msg[1] = &"OBITUARY_GASNADETK_MSG_1";
			break;

		case "selfgasnade":
			msg[0] = &"OBITUARY_GASNADESELF_MSG_0";
			break;

		// sticky grenades
		case "stickynade":
			msg[0] = &"OBITUARY_STICKYNADE_MSG_0";
			msg[1] = &"OBITUARY_STICKYNADE_MSG_1";
			msg[2] = &"OBITUARY_STICKYNADE_MSG_2";
			break;

		case "pstickynade":
			msg[0] = &"OBITUARY_PSTICKYNADE_MSG_0";
			msg[1] = &"OBITUARY_PSTICKYNADE_MSG_1";
			break;

		case "stickynadetk":
			msg[0] = &"OBITUARY_STICKYNADETK_MSG_0";
			msg[1] = &"OBITUARY_STICKYNADETK_MSG_1";
			break;

		case "selfstickynade":
			msg[0] = &"OBITUARY_STICKYNADESELF_MSG_0";
			break;

		// satchels
		case "satchel":
			msg[0] = &"OBITUARY_SATCHEL_MSG_0";
			msg[1] = &"OBITUARY_SATCHEL_MSG_1";
			msg[2] = &"OBITUARY_SATCHEL_MSG_2";
			break;

		case "psatchel":
			msg[0] = &"OBITUARY_PSATCHEL_MSG_0";
			msg[1] = &"OBITUARY_PSATCHEL_MSG_1";
			break;

		case "satcheltk":
			msg[0] = &"OBITUARY_SATCHELTK_MSG_0";
			msg[1] = &"OBITUARY_SATCHELTK_MSG_1";
			break;

		case "selfsatchel":
			msg[0] = &"OBITUARY_SATCHELSELF_MSG_0";
			break;

		// panzer
		case "panzer":
			msg[0] = &"OBITUARY_PANZER_MSG_0";
			msg[1] = &"OBITUARY_PANZER_MSG_1";
			break;

		case "ppanzer":
			msg[0] = &"OBITUARY_PPANZER_MSG_0";
			msg[1] = &"OBITUARY_PPANZER_MSG_1";
			break;

		case "panzertk":
			msg[0] = &"OBITUARY_PANZERTK_MSG_0";
			msg[1] = &"OBITUARY_PANZERTK_MSG_1";
			break;

		case "selfpanzer":
			msg[0] = &"OBITUARY_PANZERSELF_MSG_0";
			break;

		// knife
		case "knife":
			msg[0] = &"OBITUARY_KNIFE_MSG_0";
			msg[1] = &"OBITUARY_KNIFE_MSG_1";
			break;

		case "knifetk":
			msg[0] = &"OBITUARY_KNIFETK_MSG_0";
			msg[1] = &"OBITUARY_KNIFETK_MSG_1";
			break;

		case "selfknife":
			msg[0] = &"OBITUARY_KNIFESELF_MSG_0";
			break;

		case "knifewhip":
			msg[0] = &"OBITUARY_KNIFE_WHIP";
			break;

		case "knifewhiptk":
			msg[0] = &"OBITUARY_KNIFE_WHIP_TK";
			break;

		// plane
		case "plane":
			msg[0] = &"OBITUARY_PLANE_MSG_0";
			msg[1] = &"OBITUARY_PLANE_MSG_1";
			break;

		case "plane_bomb":
			msg[0] = &"OBITUARY_PLANE_BOMB_MSG_0";
			msg[1] = &"OBITUARY_PLANE_BOMB_MSG_1";
			break;

		// artillery
		case "selfartillery":
			msg[0] = &"OBITUARY_ARTILLERYSELF_MSG_0";
			break;

		// airstrike
		case "selfairstrike":
			msg[0] = &"OBITUARY_AIRSTRIKESELF_MSG_0";
			break;

		// napalm
		case "pnapalm":
			msg[0] = &"OBITUARY_PNAPALM_MSG_0";
			msg[1] = &"OBITUARY_PNAPALM_MSG_1";
			break;

		case "napalmtk":
			msg[0] = &"OBITUARY_NAPALMTK_MSG_0";
			msg[1] = &"OBITUARY_NAPALMTK_MSG_1";
			break;

		case "selfnapalm":
			msg[0] = &"OBITUARY_NAPALMSELF_MSG_0";
			break;

		// explosive
		case "explosive":
			msg[0] = &"OBITUARY_EXPLOSIVE_MSG_0";
			msg[1] = &"OBITUARY_EXPLOSIVE_MSG_1";
			break;

		case "explosivetk":
			msg[0] = &"OBITUARY_EXPLOSIVETK_MSG_0";
			msg[1] = &"OBITUARY_EXPLOSIVETK_MSG_1";
			break;

		// mine
		case "minefield":
			msg[0] = &"OBITUARY_MINEFIELD_MSG_0";
			msg[1] = &"OBITUARY_MINEFIELD_MSG_1";
			msg[2] = &"OBITUARY_MINEFIELD_MSG_2";
			break;

		// grenade
		case "selfnade":
			msg[0] = &"OBITUARY_SELFNADE_MSG_0";
			msg[1] = &"OBITUARY_SELFNADE_MSG_1";
			break;

		case "selfnades":
			msg[0] = &"OBITUARY_SELFNADES_MSG_0";
			msg[1] = &"OBITUARY_SELFNADES_MSG_1";
			break;

		// tripwire
		case "tripwire":
			msg[0] = &"OBITUARY_TRIPWIRE_MSG_0";
			msg[1] = &"OBITUARY_TRIPWIRE_MSG_1";
			break;

		case "tripwiretk":
			msg[0] = &"OBITUARY_TRIPWIRETK_MSG_0";
			msg[1] = &"OBITUARY_TRIPWIRETK_MSG_1";
			break;

		case "selftripwire":
			msg[0] = &"OBITUARY_TRIPWIRESELF_MSG_0";
			break;

		// landmine
		case "selflandmine":
			msg[0] = &"OBITUARY_LANDMINESELF_MSG_0";
			break;

		// pistol
		case "pistolwhip":
			msg[0] = &"OBITUARY_PISTOL_WHIP";
			break;

		case "pistolwhiptk":
			msg[0] = &"OBITUARY_PISTOL_WHIP_TK";
			break;

		// specials
		case "headshottk":
			msg[0] = &"OBITUARY_HEADSHOT_TK_MSG_0";
			msg[1] = &"OBITUARY_HEADSHOT_TK_MSG_1";
			break;

		case "sniper":
			msg[0] = &"OBITUARY_SNIPER_MSG_0";
			msg[1] = &"OBITUARY_SNIPER_MSG_1";
			break;

		case "snipertk":
			msg[0] = &"OBITUARY_SNIPER_TK_MSG_0";
			msg[1] = &"OBITUARY_SNIPER_TK_MSG_1";
			break;

		default:
			msg[0] = &"OBITUARY_WAS_KILLED_BY";
			break;

		// general bash
		case "bashkill_head":
			msg[0] = &"OBITUARY_BASHKILL_HEAD_MSG";
			break;

		case "bashkill":
			msg[0] = &"OBITUARY_BASHKILL_MSG_0";
			msg[1] = &"OBITUARY_BASHKILL_MSG_1";
			break;

		case "bashtk":
			msg[0] = &"OBITUARY_BASHTK_MSG_0";
			msg[1] = &"OBITUARY_BASHTK_MSG_1";
			break;

		// general teamkill
		case "teamkill":
			msg[0] = &"OBITUARY_TEAMKILL_MSG";
			break;

	}
	
	wm = randomInt(msg.size);
	return msg[wm];
}

// show personal message
showpmsgs(message)
{
	self endon("disconnected");

	if(!isDefined(message)) return undefined;
	
	pmsg = undefined;
	switch(message)
	{
		case "unknown":
			pmsg = &"OBITUARY_UNKNOWN_PMSG";
			break;

		case "falling":
			pmsg = &"OBITUARY_FALLING_PMSG";
			break;

		// mortars
		case "mortar":
		case "pmortar":
			pmsg = &"OBITUARY_MORTAR_PMSG";
			break;

		case "mortartk":
			pmsg = &"OBITUARY_MORTARTK_PMSG";
			break;

		case "selfmortar":
			pmsg = &"OBITUARY_MORTARSELF_PMSG";
			break;

		// Napalm grenades
		case "firenade":
		case "pfirenade":
			pmsg = &"OBITUARY_FIRENADE_PMSG";
			break;

		case "firenadetk":
			pmsg = &"OBITUARY_FIRENADETK_PMSG";
			break;

		case "selffirenade":
			pmsg = &"OBITUARY_FIRENADESELF_PMSG";
			break;

		// gas grenades
		case "gasnade":
		case "pgasnade":
			pmsg = &"OBITUARY_GASNADE_PMSG";
			break;

		case "gasnadetk":
			pmsg = &"OBITUARY_GASNADETK_PMSG";
			break;

		case "selfgasnade":
			pmsg = &"OBITUARY_GASNADESELF_PMSG";
			break;

		// sticky grenades
		case "stickynade":
		case "pstickynade":
			pmsg = &"OBITUARY_STICKYNADE_PMSG";
			break;

		case "stickynadetk":
			pmsg = &"OBITUARY_STICKYNADETK_PMSG";
			break;

		case "selfstickynade":
			pmsg = &"OBITUARY_STICKYNADESELF_PMSG";
			break;

		// satchels
		case "satchel":
		case "psatchel":
			pmsg = &"OBITUARY_SATCHEL_PMSG";
			break;

		case "satcheltk":
			pmsg = &"OBITUARY_SATCHELTK_PMSG";
			break;

		case "selfsatchel":
			pmsg = &"OBITUARY_SATCHELSELF_PMSG";
			break;

		// panzer
		case "panzer":
		case "ppanzer":
			pmsg = &"OBITUARY_PANZER_PMSG";
			break;

		case "panzertk":
			pmsg = &"OBITUARY_PANZERTK_PMSG";
			break;

		case "selfpanzer":
			pmsg = &"OBITUARY_PANZERSELF_PMSG";
			break;

		// knife
		case "knife":
		case "pknife":
			pmsg = &"OBITUARY_KNIFE_PMSG";
			break;

		case "knifetk":
			pmsg = &"OBITUARY_KNIFETK_PMSG";
			break;

		case "selfknife":
			pmsg = &"OBITUARY_KNIFESELF_PMSG";
			break;

		case "knifewhip":
			pmsg = &"OBITUARY_KNIFE_WHIP_PMSG";
			break;

		case "knifewhiptk":
			pmsg = &"OBITUARY_KNIFE_WHIP_TK_PMSG";
			break;

		// plane bomb
		case "plane":
			pmsg = &"OBITUARY_PLANE_PMSG";
			break;

		case "plane_bomb":
			pmsg = &"OBITUARY_PLANE_BOMB_PMSG";
			break;

		// artillery
		case "artillery":
			pmsg = &"OBITUARY_ARTILLERY_PMSG";
			break;

		case "artillerytk":
			pmsg = &"OBITUARY_ARTILLERYTK_PMSG";
			break;

		case "selfartillery":
			pmsg = &"OBITUARY_ARTILLERYSELF_PMSG";
			break;

		// airstrike
		case "pairstrike":
			pmsg = &"OBITUARY_AIRSTRIKE_PMSG";
			break;

		case "airstriketk":
			pmsg = &"OBITUARY_AIRSTRIKETK_PMSG";
			break;

		case "selfairstrike":
			pmsg = &"OBITUARY_AIRSTRIKESELF_PMSG";
			break;

		// napalm
		case "pnapalm":
			pmsg = &"OBITUARY_NAPALM_PMSG";
			break;

		case "napalmtk":
			pmsg = &"OBITUARY_NAPALMTK_PMSG";
			break;

		case "selfnapalm":
			pmsg = &"OBITUARY_NAPALMSELF_PMSG";
			break;

		// explosive
		case "explosive":
			pmsg = &"OBITUARY_EXPLOSIVE_PMSG";
			break;
			
		case "explosivetk":
			pmsg = &"OBITUARY_EXPLOSIVETK_PMSG";
			break;

		// mine
		case "minefield":
			pmsg = &"OBITUARY_MINEFIELD_PMSG";
			break;
		
		// grenade
		case "selfnade":
			pmsg = &"OBITUARY_SELFNADE_PMSG";
			break;
			
		case "selfnades":
			pmsg = &"OBITUARY_SELFNADES_PMSG";
			break;

		// tripwire
		case "tripwire":
			pmsg = &"OBITUARY_TRIPWIRE_PMSG";
			break;

		case "tripwiretk":
			pmsg = &"OBITUARY_TRIPWIRETK_PMSG";
			break;

		case "selftripwire":
			pmsg = &"OBITUARY_TRIPWIRESELF_PMSG";
			break;

		// pistol
		case "pistolwhip":
			pmsg = &"OBITUARY_PISTOL_WHIP_PMSG";
			break;

		case "pistolwhiptk":
			pmsg = &"OBITUARY_PISTOL_WHIP_TK_PMSG";
			break;

		// specials
		case "headshottk":
			pmsg = &"OBITUARY_HEADSHOT_TK_PMSG";
			break;

		case "sniper":
			pmsg = &"OBITUARY_SNIPER_PMSG";
			break;

		case "snipertk":
			pmsg = &"OBITUARY_SNIPER_TK_PMSG";
			break;

		// general bashes
		case "bashkill":
			pmsg = &"OBITUARY_BASHKILL_PMSG";
			break;
		
		case "bashkill_head":
			pmsg = &"OBITUARY_BASHKILL_HEAD_PMSG";
			break;

		case "bashtk":
			pmsg = &"OBITUARY_BASHTK_PMSG";
			break;

		// general teamkill
		case "teamkill":
			pmsg = &"OBITUARY_TEAMKILL_PMSG";
			break;

		default:
			return;
	}

	self iprintln(&"CUSTOM_ADMIN_NAME", pmsg);
}

gethitlocstringname(location)
{
	switch(location)
	{
		case "right_hand":      return &"HITLOC_RIGHT_HAND";
		case "left_hand":       return &"HITLOC_LEFT_HAND";
		case "right_arm_upper": return &"HITLOC_RIGHT_UPPER_ARM";
		case "right_arm_lower": return &"HITLOC_RIGHT_FOREARM";
		case "left_arm_upper":  return &"HITLOC_LEFT_UPPER_ARM";
		case "left_arm_lower":  return &"HITLOC_LEFT_FOREARM";
		case "head":            return &"HITLOC_HEAD";
		case "neck":            return &"HITLOC_NECK";
		case "right_foot":      return &"HITLOC_RIGHT_FOOT";
		case "left_foot":       return &"HITLOC_LEFT_FOOT";
		case "right_leg_lower": return &"HITLOC_RIGHT_LOWER_LEG";
		case "left_leg_lower":  return &"HITLOC_LEFT_LOWER_LEG";
		case "right_leg_upper": return &"HITLOC_RIGHT_UPPER_LEG";
		case "left_leg_upper":  return &"HITLOC_LEFT_UPPER_LEG";
		case "torso_upper":     return &"HITLOC_UPPER_TORSO";
		case "torso_lower":     return &"HITLOC_LOWER_TORSO";
		case "none":            return &"HITLOC_UNKNOWN";
		default:                return location;
	}
}

getweaponstringname(weapon)
{
	switch(weapon)
	{
		// american
		case "m1carbine_mp":    return &"GWEAPON_CARBINE";
		case "m1garand_mp":     return &"GWEAPON_GARAND";
		case "thompson_mp":     return &"GWEAPON_THOMPSON";
		case "bar_mp":          return &"GWEAPON_BAR";
		case "springfield_mp":  return &"GWEAPON_SPRINGFIELD";
		case "greasegun_mp":    return &"GWEAPON_GREASEGUN";
		case "shotgun_mp":      return &"GWEAPON_SHOTGUN";
		case "colt_mp":         return &"GWEAPON_COLT";

		// british
		case "enfield_mp":      return &"GWEAPON_ENFIELD";
		case "sten_mp":         return &"GWEAPON_STEN";
		case "bren_mp":         return &"GWEAPON_BREN";
		case "enfield_scope_mp":return &"GWEAPON_ENFIELD_SCOPED";
		case "webley_mp":       return &"GWEAPON_WEBLEY";

		// russian
		case "mosin_nagant_mp": return &"GWEAPON_MOSIN_NAGANT";
		case "svt40_mp":        return &"GWEAPON_SVT40";
		case "pps42_mp":        return &"GWEAPON_PPS42";
		case "ppsh_mp":         return &"GWEAPON_PPSH";
		case "mosin_nagant_sniper_mp": return &"GWEAPON_MOSIN_NAGANT_SCOPED";
		case "tt30_mp":         return &"GWEAPON_TT30";

		// german
		case "kar98k_mp":       return &"GWEAPON_KAR98K";
		case "g43_mp":          return &"GWEAPON_GEWEHR43";
		case "g43_sniper":      return &"GWEAPON_GEWEHR43_SCOPED";
		case "mp40_mp":         return &"GWEAPON_MP40";
		case "mp44_mp":         return &"GWEAPON_MP44";
		case "kar98k_sniper_mp":return &"GWEAPON_KAR98K_SCOPED";
		case "luger_mp":        return &"GWEAPON_LUGER";
		case "panzerschreck_mp":return &"GWEAPON_PANZER";
		case "panzerschreck_allies": return &"GWEAPON_PANZER";

		// frag grenades
		case "frag_grenade_american_mp":
		case "frag_grenade_british_mp":
		case "frag_grenade_german_mp":
		case "frag_grenade_russian_mp":
			return &"GWEAPON_FRAG_GRENADE";

		// turrets
		case "30cal_duck_mp":
		case "30cal_prone_mp":
		case "30cal_stand_mp":
		case "mobile_30cal":
			return &"GWEAPON_30CAL";

		case "mg42_bipod_duck_mp":
		case "mg42_bipod_prone_mp":
		case "mg42_bipod_stand_mp":
		case "mobile_mg42":
			return &"GWEAPON_MG42";

		// Gas grenades
		case "smoke_grenade_american_gas_mp":
		case "smoke_grenade_british_gas_mp":
		case "smoke_grenade_german_gas_mp":
		case "smoke_grenade_russian_gas_mp":
		case "gas_mp":
			return &"GWEAPON_GAS_GRENADE";

		// Sticky grenades
		case "smoke_grenade_american_sticky_mp":
		case "smoke_grenade_british_sticky_mp":
		case "smoke_grenade_german_sticky_mp":
		case "smoke_grenade_russian_sticky_mp":
		case "sticky_mp":
			return &"GWEAPON_STICKY_GRENADE";

		// Satchels
		case "smoke_grenade_american_satchel_mp":
		case "smoke_grenade_british_satchel_mp":
		case "smoke_grenade_german_satchel_mp":
		case "smoke_grenade_russian_satchel_mp":
		case "satchel_mp":
			return &"GWEAPON_SATCHEL";

		// Napalm grenades
		case "smoke_grenade_american_fire_mp":
		case "smoke_grenade_british_fire_mp":
		case "smoke_grenade_german_fire_mp":
		case "smoke_grenade_russian_fire_mp":
		case "fire_mp":
			return &"GWEAPON_FIRE_GRENADE";

		// knife
		case "knife_mp":
		case "knive_mp":
		case "smoke_grenade_american_knife_mp":
		case "smoke_grenade_british_knife_mp":
		case "smoke_grenade_german_knife_mp":
		case "smoke_grenade_russian_knife_mp":
			return &"GWEAPON_KNIFE";

		// landmine
		case "landmine_mp":
			return &"GWEAPON_LANDMINE";

		default: return &"GWEAPON_UNKNOWN";
	}
}
