Version MFF.

This commit is contained in:
sys4-fr 2018-09-07 22:21:43 +02:00
parent 030c9f489f
commit 52f2ced1c6
8 changed files with 157 additions and 40 deletions

0
README.txt Normal file → Executable file
View File

0
changelog.txt Normal file → Executable file
View File

0
depends.txt Normal file → Executable file
View File

158
hunger.lua Normal file → Executable file
View File

@ -17,7 +17,7 @@ local function poisenp(tick, time, time_left, player)
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
end
function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
@ -71,16 +71,17 @@ end
if minetest.get_modpath("mobs") ~= nil then
if mobs.mod ~= nil and mobs.mod == "redo" then
overwrite("mobs:cheese", 4)
overwrite("mobs:meat", 8)
overwrite("mobs:meat_raw", 4)
overwrite("mobs:rat_cooked", 4)
overwrite("mobs:honey", 2)
overwrite("mobs:pork_raw", 3, "", 3)
overwrite("mobs:pork_cooked", 8)
overwrite("mobs:chicken_cooked", 6)
overwrite("mobs:meat", 5)
overwrite("mobs:meat_raw", 3)
overwrite("mobs:rat_cooked", 5)
overwrite("mobs:honey", 6)
overwrite("mobs:pork_raw", 4, "", 3)
overwrite("mobs:pork_cooked", 7)
overwrite("mobs:chicken_cooked", 4)
overwrite("mobs:chicken_raw", 2, "", 3)
overwrite("mobs:egg", 1)
overwrite("mobs:chicken_egg_fried", 2)
if minetest.get_modpath("bucket") then
if minetest.get_modpath("bucket") then
overwrite("mobs:bucket_milk", 3, "bucket:bucket_empty")
end
else
@ -125,12 +126,21 @@ end
if minetest.get_modpath("fishing") ~= nil then
overwrite("fishing:fish_raw", 2)
overwrite("fishing:fish_cooked", 5)
overwrite("fishing:fish_cooked", 4)
overwrite("fishing:sushi", 6)
overwrite("fishing:shark", 4)
overwrite("fishing:shark_cooked", 8)
overwrite("fishing:pike", 4)
overwrite("fishing:pike_cooked", 8)
overwrite("fishing:shark", 2)
overwrite("fishing:shark_cooked", 6)
overwrite("fishing:pike", 2)
overwrite("fishing:pike_cooked", 6)
overwrite("fishing:clownfish_raw", 2) --new fishing
overwrite("fishing:bluewhite_raw", 2) --new fishing
overwrite("fishing:shark_raw", 2) --new fishing
overwrite("fishing:pike_raw", 2) --new fishing
overwrite("fishing:carp_raw", 2) --new fishing
overwrite("fishing:perch_raw", 2) --new fishing
overwrite("fishing:catfish_raw", 2) --new fishing
overwrite("fishing:exoticfish_raw", 2) --new fishing
end
if minetest.get_modpath("glooptest") ~= nil then
@ -164,6 +174,11 @@ if minetest.get_modpath("bushes_classic") then
end
end
if minetest.get_modpath("flowers") ~= nil then
overwrite("flowers:mushroom_brown", 1)
overwrite("flowers:mushroom_red", 1, "", 3)
end
if minetest.get_modpath("mushroom") ~= nil then
overwrite("mushroom:brown", 1)
overwrite("mushroom:red", 1, "", 3)
@ -281,40 +296,47 @@ if minetest.get_modpath("ethereal") then
overwrite("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
end
overwrite("ethereal:fish_raw", 2)
overwrite("ethereal:fish_cooked", 5)
overwrite("ethereal:fish_cooked", 4)
overwrite("ethereal:seaweed", 1)
overwrite("ethereal:yellowleaves", 1, "", nil, 1)
overwrite("ethereal:sashimi", 4)
end
if minetest.get_modpath("farming") and farming.mod == "redo" then
overwrite("farming:bread", 6)
overwrite("farming:bread", 5)
overwrite("farming:potato", 1)
overwrite("farming:baked_potato", 6)
overwrite("farming:cucumber", 4)
overwrite("farming:tomato", 4)
overwrite("farming:orange", 4)
overwrite("farming:baked_potato", 5)
overwrite("farming:cucumber", 3)
overwrite("farming:tomato", 3)
overwrite("farming:carrot", 3)
overwrite("farming:carrot_gold", 6, "", nil, 8)
overwrite("farming:carrot_gold", 6, "", nil, 10)
overwrite("farming:corn", 3)
overwrite("farming:corn_cob", 5)
overwrite("farming:melon_slice", 2)
overwrite("farming:pumpkin_slice", 1)
overwrite("farming:pumpkin_bread", 9)
overwrite("farming:pumpkin_bread", 7)
overwrite("farming:coffee_cup", 2, "farming:drinking_cup")
overwrite("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
overwrite("farming:cookie", 2)
overwrite("farming:chocolate_dark", 3)
overwrite("farming:donut", 4)
overwrite("farming:donut_chocolate", 6)
overwrite("farming:donut_apple", 6)
overwrite("farming:donut_chocolate", 5)
overwrite("farming:donut_apple", 5)
overwrite("farming:raspberries", 1)
overwrite("farming:blueberries", 1)
overwrite("farming:muffin_blueberry", 4)
overwrite("farming:beans", 1)
overwrite("farming:grapes", 2)
if minetest.get_modpath("vessels") then
overwrite("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
end
overwrite("farming:rhubarb", 1)
overwrite("farming:rhubarb_pie", 6)
overwrite("farming:rhubarb_pie", 5)
end
if minetest.get_modpath("maptools") then
overwrite("maptools:superapple", 10, "", nil, 20) -- valeur perso pour "Super Apple" => 10 coeurs, 5 pains
end
if minetest.get_modpath("kpgmobs") ~= nil then
@ -363,13 +385,84 @@ if minetest.get_modpath("ferns") ~= nil then
overwrite("ferns:horsetail_01", 1)
end
-- Food mod by Rubenwardy ( https://github.com/rubenwardy/food )
if minetest.get_modpath("food") ~= nil then
overwrite("food:apple_juice", 1)
overwrite("food:rainbow_juice", 6)
overwrite("food:cheese", 4)
overwrite("food:cactus_juice", 3)
overwrite("food:cake", 5)
overwrite("food:cake_carrot", 6)
overwrite("food:cake_choco", 7)
overwrite("food:milk", 3)
overwrite("food:milk_chocolate", 4)
overwrite("food:pasta_bake", 7)
overwrite("food:soup_chicken", 4)
overwrite("food:soup_tomato", 4)
end
-- player-action based hunger changes
local exhausting_items = {
["helmet"] = {
["wood"] = 1,
["cactus"] = 2,
["steel"] = 4,
["bronze"] = 5,
["gold"] = 6,
["diamond"] = 3,
["mithril"] = 1,
["blackmithril"] = 2
},
["chestplate"] = {
["wood"] = 1,
["cactus"] = 2,
["steel"] = 4,
["bronze"] = 5,
["gold"] = 6,
["diamond"] = 3,
["mithril"] = 1,
["blackmithril"] = 2
},
["leggings"] = {
["wood"] = 1,
["cactus"] = 2,
["steel"] = 4,
["bronze"] = 5,
["gold"] = 6,
["diamond"] = 3,
["mithril"] = 1,
["blackmithril"] = 2
},
["boots"] = {
["wood"] = 1,
["cactus"] = 2,
["steel"] = 4,
["bronze"] = 5,
["gold"] = 6,
["diamond"] = 3,
["mithril"] = 1,
["blackmithril"] = 2
},
["shield"] = {
["wood"] = 1,
["cactus"] = 2,
["steel"] = 4,
["bronze"] = 5,
["gold"] = 6,
["diamond"] = 3,
["mithril"] = 1,
["blackmithril"] = 2
}
}
function hbhunger.handle_node_actions(pos, oldnode, player, ext)
if not player or not player:is_player() then
return
end
local name = player:get_player_name()
local exhaus = hbhunger.exhaustion[name]
if exhaus == nil then return end -- fix for nodebreaker, if owner has not logged in since the launch of the server, hunger stat is nil,then crash
local new = HUNGER_EXHAUST_PLACE
-- placenode event
if not ext then
@ -380,6 +473,23 @@ function hbhunger.handle_node_actions(pos, oldnode, player, ext)
new = HUNGER_EXHAUST_MOVE
end
exhaus = exhaus + new
-- Armor's exhaus
if minetest.get_modpath("3d_armor") then
local name, inv, arminv, pos = armor:get_valid_player(player, "[exhaus]")
local armorinv = arminv:get_list("armor")
-- table.foreach(armorinv, print)
for index, stack in ipairs(armorinv) do
if stack:get_count() > 0 and (stack:get_name():split(":")[1] == "3d_armor" or stack:get_name():split(":")[1] == "shields") then
local itemname = stack:get_name():split(":")[2]:split("_")[1]
local itemmaterial = stack:get_name():split(":")[2]:split("_")[2]
exhaus = exhaus + ((exhausting_items[itemname] and exhausting_items[itemname][itemmaterial]) or 0)/10 -- 0 is admin armor
-- Value is divided by 5 to give a larger scale to our values, without having to high nor
-- too low exhausting factor
end
end
end
if exhaus > HUNGER_EXHAUST_LVL then
exhaus = 0
local h = tonumber(hbhunger.hunger[name])

39
init.lua Normal file → Executable file
View File

@ -9,12 +9,12 @@ hbhunger.hunger_out = {}
-- HUD item ids
local hunger_hud = {}
HUNGER_HUD_TICK = 0.1
HUNGER_HUD_TICK = 1.0
--Some hunger settings
hbhunger.exhaustion = {} -- Exhaustion is experimental!
HUNGER_HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
HUNGER_HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
HUNGER_EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
HUNGER_EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
@ -23,7 +23,7 @@ HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd
--load custom settings
local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r")
if set then
if set then
dofile(minetest.get_modpath("hbhunger").."/hbhunger.conf")
set:close()
end
@ -69,7 +69,7 @@ hbhunger.set_hunger = function(player)
if not inv or not value then return nil end
if value > 30 then value = 30 end
if value < 0 then value = 0 end
inv:set_stack("hunger", 1, ItemStack({name=":", count=value+1}))
return true
@ -94,21 +94,26 @@ minetest.register_on_respawnplayer(function(player)
hbhunger.exhaustion[name] = 0
end)
local main_timer = 0
local timer = 0
local timer2 = 0
minetest.register_globalstep(function(dtime)
main_timer = main_timer + dtime
timer = timer + dtime
timer2 = timer2 + dtime
if main_timer > HUNGER_HUD_TICK or timer > 4 or timer2 > HUNGER_HUNGER_TICK then
if main_timer > HUNGER_HUD_TICK then main_timer = 0 end
local function hunger_step()
timer = timer + HUNGER_HUD_TICK
timer2 = timer2 + HUNGER_HUD_TICK
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local h = tonumber(hbhunger.hunger[name])
local hp = player:get_hp()
if timer > 4 then
local timerquot = 1 -- By default regen 0.5 hearth every 10sec
if pclasses.api.get_player_class(name) == "warrior" then
timerquot = 1.42 -- Black_Mithril armor = 0.5 hearth every 7.0sec
elseif pclasses.api.util.does_wear_full_armor(name, "mithril", false) then
timerquot = 1.17 -- Mithril armor = 0.5 hearth every 8.5sec
end
if timer > 10/timerquot then
-- heal player by 1 hp if not dead and satiation is > 15 (of 30)
if h > 15 and hp > 0 and player:get_breath() > 0 then
player:set_hp(hp+1)
@ -128,16 +133,18 @@ minetest.register_globalstep(function(dtime)
-- update all hud elements
update_hud(player)
local controls = player:get_player_control()
-- Determine if the player is walking
if controls.up or controls.down or controls.left or controls.right then
hbhunger.handle_node_actions(nil, nil, player)
end
end
end
if timer > 4 then timer = 0 end
--end
if timer > 10 then timer = 0 end
if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
end)
minetest.after(HUNGER_HUD_TICK, hunger_step)
end
minetest.after(0, hunger_step)
end

BIN
sounds/hbhunger_eat_generic.ogg Normal file → Executable file

Binary file not shown.

0
textures/hbhunger_bar.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 80 B

After

Width:  |  Height:  |  Size: 80 B

0
textures/hbhunger_icon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 522 B