Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Added "player killed player" and "Bone coordinates"-messages #5

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
death_messages
==============
```
____ _ _ __ __
| _ \ ___ __ _| |_| |__ | \/ | ___ ___ ___ __ _ __ _ ___ ___
| | | |/ _ \/ _` | __| '_ \ | |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \/ __|
| |_| | __/ (_| | |_| | | | | | | | __/\__ \__ \ (_| | (_| | __/\__ \
|____/ \___|\__,_|\__|_| |_| |_| |_|\___||___/___/\__,_|\__, |\___||___/
|___/
```
![alt text](https://github.com/bark10/death_messages/blob/master/screenshot-2.png)

A Minetest mod which sends a chat message when a player dies
A Minetest mod that sends chat messages when players die.

Types of messages are:
* Bone coordinates sent to the player by PM upon death.
* Public announcement when player dies.
* Public announcement when player kills another player "Player killed player with weapon or node".

Version: 0.1.3
License: GPL v3 (see LICENSE.txt)

Dependencies:
none

Please report bugs at the github issue tracker:
https://github.com/4Evergreen4/death_messages/issues
Empty file added depends.txt
Empty file.
1 change: 1 addition & 0 deletions description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A Minetest mod which sends a chat message when a player dies.
157 changes: 157 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
--[[
death_messages - A Minetest mod which sends a chat message when a player dies.
Copyright (C) 2017 bark

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]

-----------------------------------------------------------------------------------------------
local title = "Death Messages"
local version = "0.1.4"
local mname = "death_messages"
-----------------------------------------------------------------------------------------------
dofile(minetest.get_modpath("death_messages").."/settings.txt")
-----------------------------------------------------------------------------------------------

-- PM from server with death coordinates
minetest.register_on_dieplayer(function(player)
local name=player:get_player_name()
local playerpos = player:getpos()
local x = tostring(math.floor(playerpos["x"]))
local y = tostring(math.floor(playerpos["y"]))
local z = tostring(math.floor(playerpos["z"]))
minetest.chat_send_player(player:get_player_name(), core.colorize("#dbdbdb", "PM from Server: ").. core.colorize("#dbdbdb", "Your bones are located at ") .. core.colorize("#fdff9a", x .. ", " .. y .. ", " .. z) .. core.colorize("#dbdbdb",". Better go get them before someone else does!"))
print("****** " .. player:get_player_name() .. " died at " .. x .. ", " .. y .. ", " .. z .. " ******")
end)

-- "PLAYER KILLED PLAYER"-messages
minetest.register_on_punchplayer(function(player, hitter)
if not (player or hitter) then
return false
end
if not hitter:get_player_name() == "" then
return false
end
minetest.after(0, function()
-- When player kills player with registered_tool
if player:get_hp() == 0 and hitter:get_player_name() ~= "" and hitter:get_wielded_item() and hitter:get_wielded_item():get_name() and minetest.registered_tools[hitter:get_wielded_item():get_name()] then
minetest.chat_send_all(core.colorize("#ae0c13", player:get_player_name().." was killed by "..hitter:get_player_name().." with a "..minetest.registered_tools[hitter:get_wielded_item():get_name()].description.."."))
print(player:get_player_name().." was killed by "..hitter:get_player_name().." with "..minetest.registered_tools[hitter:get_wielded_item():get_name()].description..".")
return true
-- When player kills player with node
elseif player:get_hp() == 0 and hitter:get_player_name() ~= "" and hitter:get_wielded_item() and hitter:get_wielded_item():get_name() and minetest.registered_nodes[hitter:get_wielded_item():get_name()] then
minetest.chat_send_all(core.colorize("#ae0c13", hitter:get_player_name().." killed "..player:get_player_name().. " with a " ..minetest.registered_nodes[hitter:get_wielded_item():get_name()].description.."."))
print(player:get_player_name().." was killed by "..hitter:get_player_name().." with a node.")
return true
-- When player kills player with bare fists
elseif player:get_hp() == 0 and hitter:get_player_name() ~= "" and hitter:get_wielded_item() then
minetest.chat_send_all(core.colorize("#8ae0c13", hitter:get_player_name().." killed "..player:get_player_name().." with bare fists!"))
print(player:get_player_name().." was killed by "..hitter:get_player_name().." with bare fists.")
return true
-- When player kills entity or vv
elseif hitter:get_player_name() == "" and player:get_hp() == 0 then
minetest.chat_send_all(core.colorize("#ae0c13", player:get_player_name().." was killed by "..hitter:get_luaentity().name.."."))
print(player:get_player_name().." was killed by "..hitter:get_luaentity().name..".")
else
return false
end
end)
end)
--[[
-- Teleport dead players to limbo location, to prevent chat spam when player is takin
g damage after death.
DOESN'T WORK .. PLAYERS ARE TELEPORTED TO LIMBO BEFORE BONES ARE GENERATED. BONES END UP IN LIMBO INSTEAD OF DEATH LOCATION

minetest.register_on_dieplayer(function(player)
if minetest.registered_nodes contains "bones:bones" then
local player_name = player:get_player_name()
local LIMBO = "18, -24, 30"
minetest.get_player_by_name(player_name):setpos(minetest.string_to_pos(LIMBO))
end)
]]--

-- A table of quips for death messages. The first item in each sub table is the
-- default message used when RANDOM_MESSAGES is disabled.
local messages = {}

-- Lava death messages
messages.lava = {
" melted into a ball of fire.",
" thought lava was cool.",
" melted into a ball of fire.",
" couldn't resist that warm glow of lava.",
" dug straight down.",
" didn't know lava was hot."
}

-- Drowning death messages
messages.water = {
" drowned.",
" ran out of air.",
" failed at swimming lessons.",
" tried to impersonate an anchor.",
" forgot he wasn't a fish.",
" blew one too many bubbles."
}

-- Burning death messages
messages.fire = {
" burned to a crisp.",
" got a little too warm.",
" got too close to the camp fire.",
" just got roasted, hotdog style.",
" gout burned up. More light that way."
}

-- Other death messages
messages.other = {
" died.",
" did something fatal.",
" died.",
" wasn't meant for this world."
}
--[[
function get_message(mtype)
if RANDOM_MESSAGES then
return messages[mtype][math.random(1, #messages[mtype])]
else
return messages[1] -- 1 is the index for the non-random message
end
end

minetest.register_on_dieplayer(function(player)
local player_name = player:get_player_name()
local node = minetest.registered_nodes[minetest.get_node(player:getpos()).name]
if minetest.is_singleplayer() then
player_name = "You"
end
-- Death by lava
if node.groups.lava ~= nil then
minetest.chat_send_all(player_name .. get_message("lava"))
-- Death by drowning
elseif player:get_breath() == 0 then
minetest.chat_send_all(player_name .. get_message("water"))
-- Death by fire
elseif node.name == "fire:basic_flame" then
minetest.chat_send_all(player_name .. get_message("fire"))
-- Death by something else
else
minetest.chat_send_all(player_name .. get_message("other"))
end

end)
]]--
-----------------------------------------------------------------------------------------------
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
-----------------------------------------------------------------------------------------------
1 change: 1 addition & 0 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = death_messages
Binary file added screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RANDOM_MESSAGES = true
LIMBO = "18, -24, 30"