summaryrefslogtreecommitdiffstats
path: root/Core/ondeath.lua
blob: 47a7532a6c5bc01a7a7f7de681a397e0c055292a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function OnKilling(Victim, Killer)
	if Victim:IsPlayer() then
		SetBackCoordinates( Victim )
		Server = cRoot:Get():GetServer()
		if Killer == nil then
			if Victim:IsOnFire() then
				Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was burnt to a cinder" )
				CheckHardcore(Victim)
				return false
			end
			if Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 10 or Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 11 then
				Server:SendMessage( cChatColor.Red ..  Victim:GetName() .. " tried to swim in lava (and failed)" )
				CheckHardcore(Victim)
				return false
			end
		else
			if Killer:IsPlayer() then
				Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was terminated by " .. Killer:GetName() )
				CheckHardcore(Victim)
				return false
			elseif Killer:IsMob() then
				if Killer:IsA("cZombie") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was eaten by a Zombie")
				elseif Killer:IsA("cSkeleton") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was shot by a Skeleton" )
				elseif Killer:IsA("cCreeper") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was blown up by a Creeper")
				elseif Killer:IsA("cSpider") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was ripped apart by a giant Spider")
				elseif Killer:IsA("cCaveSpider") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was poisoned by a giant Cave Spider")
				elseif Killer:IsA("cBlaze") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was flamed by a Blaze")
				elseif Killer:IsA("cEnderman") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was " .. cChatColor.Random .. " by an Enderman")
				elseif Killer:IsA("cSilverfish") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was... DERPED by a Silverfish!")
				elseif Killer:IsA("cSlime") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was stuck fast and killed by a Slime")
				elseif Killer:IsA("cWitch") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was enchanted (to death) by a Witch")
				elseif Killer:IsA("cZombiepigman") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was slain by a Zombie Pigman")
				elseif Killer:IsA("cMagmacube") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was incinerated by a Magmacube")
				elseif Killer:IsA("cWolf") then
					Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was savaged by a Wolf")					
				end
				CheckHardcore(Victim)
				return false
			end
		end
		Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " died of mysterious circumstances")
		CheckHardcore(Victim)
	end
end

function CheckHardcore(Victim)
	if HardCore == "true" then
		if Victim:IsPlayer() == true then
			local KilledPlayer = tolua.cast(Victim, "cPlayer")
			BanPlayer(KilledPlayer:GetName(), "You died, haha. Good game, bro.")
		end
	end
end