1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-29 12:10:34 +01:00
server-nalc/mods/death_messages/init.lua

273 lines
11 KiB
Lua
Raw Normal View History

2014-10-28 18:01:32 +01:00
-----------------------------------------------------------------------------------------------
local title = "Death Messages"
local version = "0.1.2"
local mname = "death_messages"
-----------------------------------------------------------------------------------------------
dofile(minetest.get_modpath("death_messages").."/settings.txt")
-----------------------------------------------------------------------------------------------
-- A table of quips for death messages
local messages = {}
-- Another one to avoid double death messages
local whacked = {}
local logfile = minetest.get_worldpath() .. "/death_logs.txt"
-- Fill this table with sounds
local sounds = {
[1] = "death_messages_player_1",
2015-06-15 12:16:01 +02:00
[2] = "death_messages_player_2",
}
2014-10-28 18:01:32 +01:00
-- Lava death messages
messages.lava = {
2015-09-05 14:28:47 +02:00
"%s thought lava was cool. / %s pensait que la lave etait cool.",
"%s felt an urgent need to touch lava. / %s s'est senti oblige de toucher la lave.",
2015-09-05 14:28:47 +02:00
"%s fell in lava. / %s est tombe dans la lave.",
"%s died in lava. / %s est mort(e) dans de la lave.",
"%s didn't know lava was very hot. / %s ne savait pas que la lave etait vraiment chaude.",
"%s destroyed Sauron's ring. / %s a detruit l'anneau de Sauron.",
"%s melted into a ball of fire. / %s est devenu une boule de feu",
"%s couldn't resist that warm glow of lava. / %s n'a pas pu se retenir face a cette chaude lueur de lave.",
"%s dug straight down. / %s a creusé a la verticale.",
2014-10-28 18:01:32 +01:00
}
-- Drowning death messages
messages.water = {
2015-09-05 14:28:47 +02:00
"%s lacked oxygen. / %s a manque d'air.",
"%s ran out of air. / %s n'avait plus d'air.",
2015-09-05 14:28:47 +02:00
"%s tried to impersonate an anchor. / %s a essaye d'usurper l'identite d'une ancre.",
"%s forgot they were not a fish. / %s a oublie qu'il/elle n'etait pas un poisson.",
"%s forgot they needed to breath underwater. / %s a oublie qu'il lui fallait respirer sous l'eau.",
"%s isn't good at swimming. / %s n'est pas bon(ne) en natation.",
2015-09-05 14:28:47 +02:00
"%s looked for the secret of the Unicorn. / %s a cherche le secret de la licorne.",
"%s forgot their scaphander. / %s a oublie son scaphandre.",
"%s failed at swimming lessons. / %s a rate ses cours de natation.",
"%s blew one too many bubbles. / %s a expiré une bulle de trop.",
2014-10-28 18:01:32 +01:00
}
-- Burning death messages
messages.fire = {
"%s was a bit too hot. / %s a eu un peu trop chaud.",
2015-09-05 14:28:47 +02:00
"%s was too close to the fire. / %s a ete trop pres du feu.",
"%s just got roasted. / %s vient de se faire rotir.",
"%s got burnt. / %s a ete carbonise.",
"%s thought they were the human torch. / %s s'est prit pour la torche.",
"%s started a fire. / %s a allume le feu.",
"%s burned to a crisp. / %s a brulé comme une chips.",
"%s got a little too warm. / %s a eu un peu trop chaud.",
"%s got too close to the camp fire. / %s s'est approche(e) trop pres du feu de camp.",
"%s just got roasted, hotdog style. / %s vient de se faire rotir facon hotdog.",
"%s was set aflame. More light that way. / %s s'est embrase(e). Ca fait plus de lumiere.",
}
-- Acid death messages
messages.acid = {
"%s has now parts of them missing. / %s a desormais des parties en moins.",
"%s discovered that acid is fun. / %s a decouvert que l'acide, c'est fun.",
"%s put their head where it melted. / %s a mis sa tete la ou elle a fondu.",
"%s discovered that their body in acid, it's like sugar in water. / %s a decouvert que son corps dans l'acide, c'est comme du sucre dans de l'eau.",
"%s thought they were swimming in apple juice. / %s a cru qu'il/elle se baignait dans du jus de pomme.",
"%s gave their body to make an infusion / %s a donne son corps pour faire une infusion.",
2015-09-05 15:48:01 +02:00
"%s drowned into the wrong liquid. / %s a bu la mauvaise tasse.",
"%s tried to test their body's solubility in acid. / %s a voulu tester la solubilite de son corps dans l'acide."
2014-10-28 18:01:32 +01:00
}
-- Quicksands death messages
messages.sand = {
"%s learnt that sand is less fluid than water. / %s a appris que le sable est moins fluide que l'eau.",
2015-09-05 14:28:47 +02:00
"%s joined the mummies. / %s a rejoint les momies.",
"%s got themselves buried. / %s s'est fait(e) ensevelir.",
"%s chose to become a fossil. / %s a choisi la voie de la fossilisation."
}
2014-10-28 18:01:32 +01:00
-- Other death messages
messages.other = {
2015-09-07 09:59:47 +02:00
"%s did something fatal to them. / %s a fait quelque chose qui lui a ete fatal.",
2015-09-05 15:48:01 +02:00
"%s died. / %s est mort(e).",
2015-09-05 14:28:47 +02:00
"%s left this world. / %s n'est plus de ce monde.",
"%s reached miner's heaven. / %s a rejoint le paradis des mineurs.",
"%s lost their life. / %s a perdu la vie.",
2015-09-08 20:52:17 +02:00
"%s saw the light. / %s a vu la lumiere.",
"%s fell from a bit too high. / %s est tombe d'un peu trop haut.",
"%s slipped on a banana skin. / %s a glisse sur une peau de banane.",
"%s wanted to test their super powers. / %s a voulu tester ses super pouvoirs.",
"%s gave up on life. / %s a decide de mourir.",
"%s is somewhat dead now. / %s est plus ou moins mort(e) maintenant.",
"%s passed out -permanently. / %s s'est evanoui(e) -pour toujours.",
2014-10-28 18:01:32 +01:00
}
-- Whacking death messages
messages.whacking = {
"%s got whacked by %s. / %s s'est pris une raclee de la part de %s.",
"%s's grave was dug by %s. / La tombe de %s a ete creusee par %s.",
2015-09-09 19:12:40 +02:00
"%s got recycled by %s. / %s s'est fait recycler par %s.",
"%s surely annoyed %s. / %s embetait surement %s."
-- Need to fill
}
messages.monsters_whacking = {
"%s got whacked by a %s. / %s s'est pris une raclee de la part d'un %s.",
2015-09-17 17:02:51 +02:00
"Darwin said : %s was less adapted than a %s. / Darwin a dit : %s etait moins adapte qu'un %s.",
2015-09-07 09:59:47 +02:00
"%s was transformed into a doormat by a %s. / %s s'est fait transformer en paillasson par un %s.",
-- Need to fill
}
-- Monsters
local monsters = {
["mobs:fireball"] = "dungeon master",
["mobs:dungeon_master"] = "dungeon master",
["mobs:spider"] = "spider",
["mobs:sand_monster"] = "sand monster",
["mobs:cow"] = "cow",
["mobs:creeper"] = "creeper",
["mobs:dog"] = "dog",
2016-08-21 22:38:44 +02:00
["mobs:greenbig"] = "big green slim",
["mobs:greenmedium"] = "medium green slim",
["mobs:greensmall"] = "small green slim",
["mobs:lavabig"] = "big lava slim",
["mobs:lavamedium"] = "medium lava slim",
["mobs:lavasmall"] = "small lava slim",
["mobs:yeti"] = "yeti",
["mobs:snowball"] = "yeti",
["mobs:npc"] = "npc",
["mobs:npc_female"] = "female npc",
["mobs:oerkki"] = "oerkki",
["mobs:stone_monster"] = "stone monster",
["mobs:dirt_monster"] = "dirt monster",
["mobs:goat"] = "goat",
["mobs:wolf"] = "wolf",
["mobs:tree_monster"] = "tree monster",
["mobs:mese_arrow"] = "mese monster",
["mobs:zombie"] = "zombie",
["mobs:minotaur"] = "minotaur",
["mobs:pumba"] = "warthog",
2015-09-18 19:52:32 +02:00
["tsm_pyramids:mummy"] = "mummy",
["mobs:shark_lg"] = "large shark",
["mobs:shark_md"] = "medium shark",
["mobs:pumpking"] = "pumpking",
["mobs:pumpboom"] = "pumpboom",
["mobs:mese_dragon"] = "mese_dragon",
}
2015-09-05 14:28:47 +02:00
local function broadcast_death(msg)
minetest.chat_send_all(msg)
local logfilep = io.open(logfile, "a")
logfilep:write(os.date("[%Y-%m-%d %H:%M:%S] ") .. msg .. "\n")
logfilep:close()
2015-09-05 14:28:47 +02:00
if irc then
irc:say(msg)
end
end
local function sound_play_all(dead)
for _, p in ipairs(minetest.get_connected_players()) do
local player_name = p:get_player_name()
if player_name and player_name ~= dead then
minetest.sound_play("death_messages_people_1",{to_player=player_name, gain=soundset.get_gain(player_name,"other")})
end
end
end
minetest.register_on_punchplayer(function(player, hitter, time,
tool_caps, dir, damage)
if player:get_hp() - damage <= 0 and not whacked[player:get_player_name()] then
local player_name = player:get_player_name()
2015-09-18 00:33:06 +02:00
local death_message
if hitter:is_player() then
death_message = string.format(messages.whacking[math.random(1,#messages.whacking)], player_name, hitter:get_player_name(), player_name, hitter:get_player_name())
else
2015-09-08 18:52:10 +02:00
local entity_name = monsters[hitter:get_luaentity().name] or "monster"
death_message = string.format(messages.monsters_whacking[math.random(1, #messages.monsters_whacking)], player_name, entity_name, player_name, entity_name)
end
2015-09-05 14:28:47 +02:00
broadcast_death(death_message)
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=soundset.get_gain(player:get_player_name(),"other")})
sound_play_all(player:get_player_name())
whacked[player_name] = true
end
end)
2015-09-05 14:28:47 +02:00
minetest.register_on_leaveplayer(function(player)
whacked[player:get_player_name()] = nil
end)
minetest.register_on_respawnplayer(function(player)
whacked[player:get_player_name()] = nil
end)
2014-10-28 18:01:32 +01:00
if RANDOM_MESSAGES == true then
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
local death_message = ""
2015-09-05 14:28:47 +02:00
if not whacked[player_name] then
-- Death by lava
if node.groups.lava ~= nil then
death_message = messages.lava[math.random(1,#messages.lava)]
-- Death by acid
elseif node.groups.acid ~= nil then
death_message = messages.acid[math.random(1,#messages.acid)]
-- Death by drowning
elseif player:get_breath() == 0 and node.groups.water then
death_message = messages.water[math.random(1,#messages.water)]
-- Death by fire
2016-08-21 22:38:44 +02:00
elseif node.name == "fire:basic_flame" then
2015-09-05 14:28:47 +02:00
death_message = messages.fire[math.random(1,#messages.fire)]
-- Death in quicksand
2016-08-21 22:38:44 +02:00
elseif player:get_breath() == 0 and node.name == "default:sand_source" or node.name == "default:sand_flowing" then
2015-09-05 14:28:47 +02:00
death_message = messages.sand[math.random(1,#messages.sand)]
-- Death by something else
else
death_message = messages.other[math.random(1,#messages.other)]
end
-- Actually tell something
death_message = string.format(death_message, player_name, player_name)
broadcast_death(death_message)
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player_name,gain=soundset.get_gain(player_name, "other")})
sound_play_all(player_name)
whacked[player_name] = true
2015-06-22 22:18:33 +02:00
end
2014-10-28 18:01:32 +01:00
end)
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
else
2015-09-05 14:28:47 +02:00
-- Should we keep that part?
2014-10-28 18:01:32 +01:00
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
2015-09-05 14:28:47 +02:00
if not whacked[player_name] then
-- Death by lava
if node.groups.lava ~= nil then
minetest.chat_send_all(player_name .. " melted into a ball of fire")
-- Death by drowning
elseif player:get_breath() == 0 then
minetest.chat_send_all(player_name .. " ran out of air.")
-- Death by fire
2016-08-21 22:38:44 +02:00
elseif node.name == "fire:basic_flame" then
2015-09-05 14:28:47 +02:00
minetest.chat_send_all(player_name .. " burned to a crisp.")
-- Death by something else
else
minetest.chat_send_all(player_name .. " died.")
end
2014-10-28 18:01:32 +01:00
end
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player:get_player_name(),gain=soundset.get_gain(player:get_player_name(),"other")})
sound_play_all(player:get_player_name())
2014-10-28 18:01:32 +01:00
end)
end
-----------------------------------------------------------------------------------------------
minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
2014-10-28 18:01:32 +01:00
-----------------------------------------------------------------------------------------------