1
0
mirror of git://repo.or.cz/minetest_hbhunger.git synced 2025-06-29 21:31:01 +02:00

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

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])