forked from VoxeLibre/VoxeLibre
Compare commits
6 Commits
master
...
hardcore_m
Author | SHA1 | Date |
---|---|---|
MysticTempest | 605f1b4cc9 | |
MysticTempest | c1bae69844 | |
MysticTempest | def4aac944 | |
MysticTempest | bbb142cf3b | |
MysticTempest | 37f7d4b52d | |
MysticTempest | 824eccd735 |
Binary file not shown.
After Width: | Height: | Size: 953 B |
|
@ -200,7 +200,8 @@ end
|
|||
|
||||
local gamemodes = {
|
||||
"survival",
|
||||
"creative"
|
||||
"creative",
|
||||
"spectator"
|
||||
}
|
||||
|
||||
function mcl_inventory.player_set_gamemode(p,g)
|
||||
|
@ -209,8 +210,12 @@ function mcl_inventory.player_set_gamemode(p,g)
|
|||
if g == "survival" then
|
||||
mcl_experience.setup_hud(p)
|
||||
mcl_experience.update(p)
|
||||
mcl_hardcore.spectator_mode_disabled(p)
|
||||
elseif g == "creative" then
|
||||
mcl_experience.remove_hud(p)
|
||||
mcl_hardcore.spectator_mode_disabled(p)
|
||||
elseif g == "spectator" then
|
||||
mcl_hardcore.spectator_mode(p)
|
||||
end
|
||||
set_inventory(p)
|
||||
end
|
||||
|
|
|
@ -17,6 +17,20 @@ end
|
|||
|
||||
local icon_ids = {}
|
||||
|
||||
-- Hardcore mode Healthbar change
|
||||
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
||||
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "r")
|
||||
if file ~= nil then
|
||||
hardcore_world = true
|
||||
end
|
||||
|
||||
if hardcore_mode or hardcore_world then
|
||||
heart_texture_fg = "hudbars_icon_health_hardcore.png"
|
||||
else
|
||||
heart_texture_fg = "hudbars_icon_health.png"
|
||||
end
|
||||
|
||||
|
||||
local function potions_set_hudbar(player)
|
||||
|
||||
if EF.poisoned[player] and EF.regenerating[player] then
|
||||
|
@ -26,7 +40,7 @@ local function potions_set_hudbar(player)
|
|||
elseif EF.regenerating[player] then
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png")
|
||||
else
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
||||
hb.change_hudbar(player, "health", nil, nil, heart_texture_fg, nil, "hudbars_bar_health.png")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
## mcl_hardcore
|
||||
|
||||
|
||||
A fork of: YOLO - You Only Live Once by sofar
|
||||
Modified by MysticTempest
|
||||
|
||||
A simple player-based hardcore mod. Simply install and enable.
|
||||
Players will only have one life, after dying they will be placed into spectator mode.
|
||||
|
||||
As spectators; they will be be unable to interact with the world, immortal, invisible, have noclip and fly, and health/hunger hudbars will be hidden.
|
||||
|
||||
|
||||
|
||||
|
||||
Author: Copyright (C) 2019 - Auke Kok <sofar@foo-projects.org>
|
||||
License: LGPL-2.1-or-later
|
|
@ -0,0 +1,123 @@
|
|||
--[[
|
||||
Copyright (C) 2019 - Auke Kok <sofar@foo-projects.org>
|
||||
|
||||
"mcl_hardcore" a fork of "yolo", is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1
|
||||
of the license, or (at your option) any later version.
|
||||
|
||||
--]]
|
||||
|
||||
-- Spectator mode:
|
||||
-- Players are unable to interact with the world, invisible, have fast, fly & noclip, are immortal and their health/hunger hudbars are hidden.
|
||||
--
|
||||
--
|
||||
|
||||
mcl_hardcore = {}
|
||||
|
||||
-- Write Hardcore mode state to world.
|
||||
function mcl_hardcore.save()
|
||||
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "w")
|
||||
if file then
|
||||
file:write("Enabled")
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Spectator mode
|
||||
function mcl_hardcore.spectator_mode(player)
|
||||
local meta = player:get_meta()
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
meta:set_int("mcl_privs:interact_revoked", 1)
|
||||
player:set_armor_groups({immortal=1})
|
||||
minetest.set_player_privs(player_name, {fly=true,fast=true,noclip=true,interact=nil})
|
||||
|
||||
-- Have to wait since mcl_potions clears old effects on startup.
|
||||
minetest.after(3, function(player)
|
||||
mcl_potions._reset_player_effects(player, true) -- Fix some cases of not clearing.
|
||||
mcl_potions.invisiblility_func(player, null, 86400) -- Invisible for 24 hours.
|
||||
hb.hide_hudbar(player, "hunger")
|
||||
hb.change_hudbar(player, "health", nil, nil, "blank.png", nil, "hudbars_bar_health.png")
|
||||
mcl_experience.remove_hud(player)
|
||||
end, player)
|
||||
if meta:get_string("gamemode") ~= "spectator" then
|
||||
meta:set_string("gamemode","spectator")
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_hardcore.spectator_mode_disabled(player)
|
||||
local meta = player:get_meta()
|
||||
local player_name = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(player_name)
|
||||
|
||||
minetest.after(3, function(player) -- Fix startup crash conflict by waiting slightly.
|
||||
mcl_potions._reset_player_effects(player, true)
|
||||
hb.unhide_hudbar(player, "hunger")
|
||||
meta:set_int("mcl_privs:interact_revoked", 0)
|
||||
player:set_armor_groups({immortal=0})
|
||||
|
||||
-- Try to preserve privs somewhat
|
||||
if meta:get_string("gamemode") == "spectator" then
|
||||
meta:set_string("gamemode","")
|
||||
elseif meta:get_string("gamemode") == "creative" then
|
||||
privs.fast = nil
|
||||
privs.noclip = nil
|
||||
privs.fly = true
|
||||
privs.interact = true
|
||||
minetest.set_player_privs(player_name, privs)
|
||||
else -- survival; only basic privs
|
||||
minetest.set_player_privs(player_name, {basic_privs=true})
|
||||
end
|
||||
end, player)
|
||||
end
|
||||
|
||||
|
||||
-- Hardcore mode
|
||||
function mcl_hardcore.hardcore_mode(player)
|
||||
local meta = player:get_meta()
|
||||
local player_name = player:get_player_name()
|
||||
if meta:get_int("dead") == 1 then
|
||||
mcl_hardcore.spectator_mode(player)
|
||||
minetest.chat_send_player(player_name, "You died in hardcore mode; rejoining as a spectator.")
|
||||
else
|
||||
minetest.after(4, function(player)
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health_hardcore.png", nil, "hudbars_bar_health.png")
|
||||
end, player)
|
||||
end
|
||||
|
||||
minetest.register_on_dieplayer(function(player, reason)
|
||||
local name = player:get_player_name()
|
||||
local meta = player:get_meta()
|
||||
meta:set_int("dead", 1)
|
||||
end)
|
||||
|
||||
-- Make player a spectator on respawn in hardcore mode.
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local meta = player:get_meta()
|
||||
local player_name = player:get_player_name()
|
||||
if meta:get_int("dead") == 1 then
|
||||
mcl_hardcore.spectator_mode(player)
|
||||
minetest.chat_send_player(player_name, "You died in hardcore mode; respawning as a spectator.")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
||||
--Set world state:
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if minetest.get_gametime() <= 5 and hardcore_mode then
|
||||
mcl_hardcore.save()
|
||||
else
|
||||
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "r")
|
||||
if file ~= nil then
|
||||
hardcore_world = true
|
||||
end
|
||||
end
|
||||
if hardcore_mode or hardcore_world then
|
||||
mcl_hardcore.hardcore_mode(player)
|
||||
end
|
||||
|
||||
end)
|
|
@ -0,0 +1,4 @@
|
|||
name = mcl_hardcore
|
||||
license = LGPL-2.1
|
||||
description = Hardcore mode - death is permanent. A fork of sofar's YOLO mod.
|
||||
depends = mcl_potions
|
Binary file not shown.
After Width: | Height: | Size: 948 B |
|
@ -63,6 +63,9 @@ mcl_showDeathMessages (Show death messages) bool true
|
|||
# If disabled, all recipes will be shown.
|
||||
mcl_craftguide_progressive_mode (Learn crafting recipes progressively) bool true
|
||||
|
||||
# If enabled, you will only have 1 life to use. After death you will be dropped into spectator mode, and unable to interact with the world.
|
||||
hardcore_mode_enabled (Enable Hardcore mode) bool false
|
||||
|
||||
[Mobs]
|
||||
# If enabled, mobs will spawn naturally. This does not affect
|
||||
# affect mob spawners.
|
||||
|
|
Loading…
Reference in New Issue