forked from VoxeLibre/VoxeLibre
Compare commits
3 Commits
master
...
hardcore_m
Author | SHA1 | Date |
---|---|---|
MysticTempest | 03e2f444cc | |
MysticTempest | aa6b9d3089 | |
MysticTempest | feab15bd3b |
|
@ -199,7 +199,8 @@ end
|
||||||
|
|
||||||
local gamemodes = {
|
local gamemodes = {
|
||||||
"survival",
|
"survival",
|
||||||
"creative"
|
"creative",
|
||||||
|
"spectator"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mcl_inventory.player_set_gamemode(p,g)
|
function mcl_inventory.player_set_gamemode(p,g)
|
||||||
|
@ -208,8 +209,12 @@ function mcl_inventory.player_set_gamemode(p,g)
|
||||||
if g == "survival" then
|
if g == "survival" then
|
||||||
mcl_experience.setup_hud(p)
|
mcl_experience.setup_hud(p)
|
||||||
mcl_experience.update(p)
|
mcl_experience.update(p)
|
||||||
|
mcl_hardcore.spectator_mode_disabled(p)
|
||||||
elseif g == "creative" then
|
elseif g == "creative" then
|
||||||
mcl_experience.remove_hud(p)
|
mcl_experience.remove_hud(p)
|
||||||
|
mcl_hardcore.spectator_mode_disabled(p)
|
||||||
|
elseif g == "spectator" then
|
||||||
|
mcl_hardcore.spectator_mode(p)
|
||||||
end
|
end
|
||||||
mcl_meshhand.update_player(p)
|
mcl_meshhand.update_player(p)
|
||||||
set_inventory(p)
|
set_inventory(p)
|
||||||
|
|
|
@ -18,7 +18,30 @@ end
|
||||||
|
|
||||||
local icon_ids = {}
|
local icon_ids = {}
|
||||||
|
|
||||||
|
-- Hardcore mode Healthbar change
|
||||||
|
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "r")
|
||||||
|
if file ~= nil then
|
||||||
|
hardcore_world = true
|
||||||
|
end
|
||||||
|
|
||||||
local function potions_set_hudbar(player)
|
local function potions_set_hudbar(player)
|
||||||
|
local meta = player:get_meta()
|
||||||
|
|
||||||
|
if hardcore_world and meta:get_int("dead") == 1 then
|
||||||
|
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "blank.png", nil, "hudbars_bar_health.png")
|
||||||
|
elseif hardcore_world then
|
||||||
|
|
||||||
|
if EF.poisoned[player] and EF.regenerating[player] then
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison_hardcore.png", nil, "hudbars_bar_health.png")
|
||||||
|
elseif EF.poisoned[player] then
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison_hardcore.png", nil, "hudbars_bar_health.png")
|
||||||
|
elseif EF.regenerating[player] then
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate_hardcore.png", nil, "hudbars_bar_health.png")
|
||||||
|
else
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health_hardcore.png", nil, "hudbars_bar_health.png")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
|
||||||
if EF.poisoned[player] and EF.regenerating[player] then
|
if EF.poisoned[player] and EF.regenerating[player] then
|
||||||
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
|
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
|
||||||
|
@ -29,7 +52,7 @@ local function potions_set_hudbar(player)
|
||||||
else
|
else
|
||||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function potions_init_icons(player)
|
local function potions_init_icons(player)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
## mcl_hardcore
|
||||||
|
|
||||||
|
|
||||||
|
A fork of: YOLO - You Only Live Once by sofar
|
||||||
|
Heavily modified by MysticTempest for MineClone2
|
||||||
|
|
||||||
|
A simple player-based hardcore mod.
|
||||||
|
|
||||||
|
Players will only have one life in hardcore mode, 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.
|
||||||
|
|
||||||
|
|
||||||
|
Enabling:
|
||||||
|
Enabled via a "Settings" option; newly created worlds will be set to Hardcore Mode.
|
||||||
|
|
||||||
|
Extra Note:
|
||||||
|
You only need to toggle it on when creating a hardcore world.
|
||||||
|
|
||||||
|
After doing so; you may 'disable' it again to create non-hardcore worlds.
|
||||||
|
Hardcore mode for that world will persist after world creation, and across any "Settings" change.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---------
|
||||||
|
Code:
|
||||||
|
Author: Copyright (C) 2019 - Auke Kok <sofar@foo-projects.org>
|
||||||
|
Copyright (C) 2022 - MysticTempest
|
||||||
|
License: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
Texture:
|
||||||
|
"*_hardcore.png" - derivative of PixelPerfection heart textures: CC-By SA 4.0
|
|
@ -0,0 +1,143 @@
|
||||||
|
--[[
|
||||||
|
Copyright (C) 2019 - Auke Kok <sofar@foo-projects.org>
|
||||||
|
Copyright (C) 2022 - MysticTempest
|
||||||
|
|
||||||
|
"mcl_hardcore" is 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.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
|
||||||
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
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
|
||||||
|
hardcore_world = true
|
||||||
|
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})
|
||||||
|
player:set_properties({pointable = false})
|
||||||
|
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) -- 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)
|
||||||
|
player:hud_set_hotbar_image("blank.png")
|
||||||
|
player:hud_set_hotbar_selected_image("blank.png")
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
if meta:get_int("dead") == 1 and hardcore_world==true then
|
||||||
|
meta:set_string("gamemode","spectator")
|
||||||
|
minetest.chat_send_player(player_name, S("You died in hardcore mode; spectator mode not disabled."))
|
||||||
|
return
|
||||||
|
else
|
||||||
|
minetest.after(3, function(player) -- Fix startup crash conflict by waiting slightly.
|
||||||
|
mcl_potions._reset_player_effects(player)
|
||||||
|
mcl_potions.invisiblility_func(player, null, 0)
|
||||||
|
hb.unhide_hudbar(player, "hunger")
|
||||||
|
player:hud_set_hotbar_image("mcl_inventory_hotbar.png")
|
||||||
|
player:hud_set_hotbar_selected_image("mcl_inventory_hotbar_selected.png")
|
||||||
|
meta:set_int("mcl_privs:interact_revoked", 0)
|
||||||
|
player:set_properties({pointable = true})
|
||||||
|
player:set_armor_groups({fleshy=100})
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
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, S("You died in hardcore mode; rejoining as a spectator."))
|
||||||
|
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, S("You died in hardcore mode; respawning as a spectator."))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local hardcore_mode = minetest.settings:get_bool("enable_hardcore_mode", 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_world then
|
||||||
|
mcl_hardcore.hardcore_mode(player)
|
||||||
|
else
|
||||||
|
local meta = player:get_meta()
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if meta:get_string("gamemode") == "spectator" then
|
||||||
|
minetest.chat_send_player(player_name, S("Gamemode last login was Spectator; rejoining as a spectator."))
|
||||||
|
mcl_hardcore.spectator_mode(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
|
@ -0,0 +1,5 @@
|
||||||
|
# textdomain: mcl_hardcore
|
||||||
|
You died in hardcore mode; spectator mode not disabled.=
|
||||||
|
You died in hardcore mode; rejoining as a spectator.=
|
||||||
|
You died in hardcore mode; respawning as a spectator.=
|
||||||
|
Gamemode last login was Spectator; rejoining as a spectator.=
|
|
@ -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, hudbars, mcl_inventory
|
Binary file not shown.
After Width: | Height: | Size: 281 B |
Binary file not shown.
After Width: | Height: | Size: 299 B |
Binary file not shown.
After Width: | Height: | Size: 948 B |
Binary file not shown.
After Width: | Height: | Size: 292 B |
|
@ -45,6 +45,16 @@ mcl_disabled_structures (Disabled structures) string
|
||||||
# Comma separated list of disabled event names
|
# Comma separated list of disabled event names
|
||||||
mcl_disabled_events (Disabled events) string
|
mcl_disabled_events (Disabled events) string
|
||||||
|
|
||||||
|
# If enabled, newly created worlds will be in Hardcore Mode.
|
||||||
|
#
|
||||||
|
# In this mode; you will only have 1 life to use.
|
||||||
|
# After death you will be dropped into spectator mode, and will be unable to interact with the world.
|
||||||
|
#
|
||||||
|
# Extra Note:
|
||||||
|
# After creating your HC world; you may set this back to disabled to create non-HC worlds.
|
||||||
|
# As Hardcore Mode is saved to the world, and will persist across any settings change.
|
||||||
|
enable_hardcore_mode (Enable Hardcore mode) bool false
|
||||||
|
|
||||||
[Players]
|
[Players]
|
||||||
# If enabled, players respawn at the bed they last lay on instead of normal
|
# If enabled, players respawn at the bed they last lay on instead of normal
|
||||||
# spawn.
|
# spawn.
|
||||||
|
|
Loading…
Reference in New Issue