Colored chat, more death options and mob attacks.

Colored chat, more death options and mob attacks.
master
maikerumine 2017-07-13 01:19:54 -04:00
parent d33ad44ab5
commit 9f2eb67031
3 changed files with 168 additions and 8 deletions

View File

@ -0,0 +1 @@
chat2?

175
init.lua
View File

@ -28,6 +28,19 @@ dofile(minetest.get_modpath("death_messages").."/settings.txt")
-- default message used when RANDOM_MESSAGES is disabled.
local messages = {}
-- Toxic death messages
messages.toxic = {
" melted into a ball of radioactivity.",
" thought chemical waste was cool.",
" melted into a jittering pile of flesh.",
" couldn't resist that warm glow of toxic water.",
" dug straight down.",
" went into the toxic curtain.",
" thought it was a toxic-tub.",
" is radioactive.",
" didn't know toxic water was radioactive."
}
-- Lava death messages
messages.lava = {
" melted into a ball of fire.",
@ -35,6 +48,9 @@ messages.lava = {
" melted into a ball of fire.",
" couldn't resist that warm glow of lava.",
" dug straight down.",
" went into the lava curtain.",
" thought it was a hottub.",
" is melted.",
" didn't know lava was hot."
}
@ -45,7 +61,7 @@ messages.water = {
" failed at swimming lessons.",
" tried to impersonate an anchor.",
" forgot he wasn't a fish.",
" blew one too many bubbles."
" blew one too many bubbles.",
}
-- Burning death messages
@ -54,7 +70,7 @@ messages.fire = {
" got a little too warm.",
" got too close to the camp fire.",
" just got roasted, hotdog style.",
" gout burned up. More light that way."
" got burned up. More light that way."
}
-- Other death messages
@ -63,9 +79,46 @@ messages.other = {
" did something fatal.",
" gave up on life.",
" is somewhat dead now.",
" passed out -permanently."
" passed out -permanently.",
" kinda screwed up.",
" couldn't fight very well.",
" got 0wn3d.",
" got SMOKED.",
" got hurted by Oerkki.",
" got blowed up."
}
-- PVP Messages
messages.pvp = {
" fisted",
" sliced up",
" rekt",
" punched",
" hacked",
" skewered",
" blasted",
" tickled",
" gotten",
" hurted",
" pooped on"
}
-- MOB Messages
messages.pvp = {
" fisted",
" sliced up",
" rekt",
" punched",
" hacked",
" skewered",
" blasted",
" tickled",
" gotten",
" hurted",
" pooped on"
}
function get_message(mtype)
if RANDOM_MESSAGES then
return messages[mtype][math.random(1, #messages[mtype])]
@ -74,28 +127,134 @@ function get_message(mtype)
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]
local pos = player:getpos()
local death = {x=0, y=-2, z=0}
--local holding = player:get_wielded_item() --added to fix?
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"))
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("lava"))
-- Death by drowning
elseif player:get_breath() == 0 then
minetest.chat_send_all(player_name .. get_message("water"))
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("water"))
-- Death by fire
elseif node.name == "fire:basic_flame" then
minetest.chat_send_all(player_name .. get_message("fire"))
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("fire"))
-- Death by Toxic water
elseif node.name == "es:toxic_water_source" then
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
player:setpos(death)
elseif node.name == "es:toxic_water_flowing" then
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
player:setpos(death)
elseif node.name == "groups:radioactive" then
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
player:setpos(death)
-- Death by something else
else
minetest.chat_send_all(player_name .. get_message("other"))
--minetest.chat_send_all(
--string.char(0x1b).."(c@#ffffff)"..player_name ..
--string.char(0x1b).."(c@#ff0000)"..get_message("other")) --toospammy
end
--player:setpos(death)
minetest.sound_play("pacmine_death", { gain = 0.35})
end)
--bigfoot code
-- bigfoot547's death messages
-- hacked by maikerumine
-- get tool/item when hitting get_name() returns item name (e.g. "default:stone")
minetest.register_on_punchplayer(function(player, hitter)
local pos = player:getpos()
local death = {x=0, y=-2, z=0}
if not (player or hitter) then
return false
end
if not hitter:get_player_name() == "" then
return false
end
minetest.after(0, function(holding)
if player:get_hp() == 0 and hitter:get_player_name() ~= "" and holding == hitter:get_wielded_item() ~= "" then
local holding = hitter:get_wielded_item()
if holding:to_string() ~= "" then
local weap = holding:get_name(holding:get_name())
if holding then
player:setpos(death)
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player:get_player_name()..
string.char(0x1b).."(c@#ff0000)".." was"..
string.char(0x1b).."(c@#ff0000)"..get_message("pvp")..
string.char(0x1b).."(c@#ff0000)".." by "..
string.char(0x1b).."(c@#ffffff)"..hitter:get_player_name()..
string.char(0x1b).."(c@#ffffff)".." with "..
string.char(0x1b).."(c@#00bbff)"..weap)
end
end
if player=="" or hitter=="" then return end -- no killers/victims
return true
elseif hitter:get_player_name() == "" and player:get_hp() == 0 then
minetest.chat_send_all(
string.char(0x1b).."(c@#ffffff)"..player:get_player_name()..
string.char(0x1b).."(c@#ff0000)".." was"..
string.char(0x1b).."(c@#ff0000)"..get_message("pvp")..
string.char(0x1b).."(c@#ff0000)".." by "..
string.char(0x1b).."(c@#ffffff)"..hitter:get_luaentity().name..
string.char(0x1b).."(c@#00bbff)".." and was eaten with a gurgling growl.") --TODO: make custom mob death messages
if player=="" or hitter=="" then return end -- no mob killers/victims
else
return false
end
end)
end)
--Carbone death coords
--License of media (textures and sounds) From carbone subgame
--------------------------------------
--mods/default/sounds/player_death.ogg: from OpenArena GNU GPL v2.
minetest.register_on_dieplayer(function(player)
local pos = player:getpos()
minetest.sound_play("player_death", {pos = pos, gain = 1})
pos.x = math.floor(pos.x + 0.5)
pos.y = math.floor(pos.y + 0.5)
pos.z = math.floor(pos.z + 0.5)
local param2 = minetest.dir_to_facedir(player:get_look_dir())
local player_name = player:get_player_name()
minetest.chat_send_all(string.char(0x1b).."(c@#000000)".."[DEATH COORDINATES] "..string.char(0x1b).."(c@#ffffff)" .. player_name .. string.char(0x1b).."(c@#000000)".." left a corpse full of diamonds here: " ..
minetest.pos_to_string(pos) .. string.char(0x1b).."(c@#aaaaaa)".." Come and get them!")
end)
-----------------------------------------------------------------------------------------------
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
-----------------------------------------------------------------------------------------------

BIN
sounds/player_death.ogg Normal file

Binary file not shown.