From eff6c4c476a1ad4948dce1a623e2a0a4bea1fc67 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 13 Aug 2020 19:20:52 +0200 Subject: [PATCH] Clean up poisonous foods --- mods/ITEMS/mcl_farming/potatoes.lua | 10 +++++++++- mods/ITEMS/mcl_fishing/init.lua | 2 +- mods/ITEMS/mcl_mobitems/init.lua | 20 ++++++++++++-------- mods/PLAYER/mcl_hunger/register_foods.lua | 12 ++++-------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index 2d8978df4e..871d679634 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -122,7 +122,6 @@ minetest.register_craftitem("mcl_farming:potato_item_poison", { _doc_items_longdesc = S("This potato doesn't look too healthy. You can eat it to restore hunger points, but there's a 60% chance it will poison you briefly."), stack_max = 64, inventory_image = "farming_potato_poison.png", - -- TODO: Cause status effects on_place = minetest.item_eat(2), on_secondary_use = minetest.item_eat(2), groups = { food = 2, eatable = 2 }, @@ -138,4 +137,13 @@ minetest.register_craft({ mcl_farming:add_plant("plant_potato", "mcl_farming:potato", {"mcl_farming:potato_1", "mcl_farming:potato_2", "mcl_farming:potato_3", "mcl_farming:potato_4", "mcl_farming:potato_5", "mcl_farming:potato_6", "mcl_farming:potato_7"}, 19.75, 20) +minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) + -- 60% chance of poisoning with poisonous potato + if itemstack:get_name() == "mcl_farming:potato_item_poison" then + if math.random(1,10) >= 6 then + mcl_potions.poison_func(user, 1, 5) + end + end + +end ) diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index b705d318fa..514cd6cf47 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -434,7 +434,7 @@ minetest.register_craftitem("mcl_fishing:pufferfish_raw", { minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) if itemstack:get_name() == "mcl_fishing:pufferfish_raw" then - mcl_potions.poison_func(user, 1.25, 7) + mcl_potions.poison_func(user, 1/3, 60) end end ) diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 5c52fdf11e..42c8c9f377 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -1,5 +1,3 @@ --- TODO: Add special status effects for raw flesh - local S = minetest.get_translator("mcl_mobitems") minetest.register_craftitem("mcl_mobitems:rotten_flesh", { @@ -136,6 +134,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { stack_max = 64, }) +-- Reset food poisoning and status effects local drink_milk = function(itemstack, player, pointed_thing) local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing) -- Check if we were allowed to drink this (eat delay check) @@ -146,7 +145,6 @@ local drink_milk = function(itemstack, player, pointed_thing) return bucket end --- TODO: Clear *all* status effects minetest.register_craftitem("mcl_mobitems:milk_bucket", { description = S("Milk"), _tt_help = minetest.colorize("#00FF00", S("Cures poison and removes all potion effects")), @@ -154,7 +152,6 @@ minetest.register_craftitem("mcl_mobitems:milk_bucket", { _doc_items_usagehelp = "Rightclick to drink the milk.", inventory_image = "mcl_mobitems_bucket_milk.png", wield_image = "mcl_mobitems_bucket_milk.png", - -- Clear poisoning when used on_place = drink_milk, on_secondary_use = drink_milk, stack_max = 1, @@ -223,8 +220,7 @@ minetest.register_craftitem("mcl_mobitems:ghast_tear", { _doc_items_longdesc = S("Place this item in an item frame as decoration."), wield_image = "mcl_mobitems_ghast_tear.png", inventory_image = "mcl_mobitems_ghast_tear.png", - -- TODO: Reveal item when it's useful - groups = { brewitem = 1, not_in_creative_inventory = 0 }, + groups = { brewitem = 1 }, stack_max = 64, }) @@ -270,8 +266,7 @@ minetest.register_craftitem("mcl_mobitems:rabbit_foot", { _doc_items_longdesc = S("Must be your lucky day! Place this item in an item frame for decoration."), wield_image = "mcl_mobitems_rabbit_foot.png", inventory_image = "mcl_mobitems_rabbit_foot.png", - -- TODO: Reveal item when it's useful - groups = { brewitem = 1, not_in_creative_inventory = 0 }, + groups = { brewitem = 1 }, stack_max = 64, }) @@ -440,3 +435,12 @@ minetest.register_craft({ {"mcl_mobitems:slimeball","mcl_mobitems:slimeball","mcl_mobitems:slimeball",}, {"mcl_mobitems:slimeball","mcl_mobitems:slimeball","mcl_mobitems:slimeball",}}, }) + +minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) + + -- poisoning with spider eye + if itemstack:get_name() == "mcl_mobitems:spider_eye" then + mcl_potions.poison_func(user, 1, 4) + end + +end ) diff --git a/mods/PLAYER/mcl_hunger/register_foods.lua b/mods/PLAYER/mcl_hunger/register_foods.lua index d4c933169d..a68dde1c18 100644 --- a/mods/PLAYER/mcl_hunger/register_foods.lua +++ b/mods/PLAYER/mcl_hunger/register_foods.lua @@ -1,11 +1,7 @@ --- Apply simple poison effect as long there are no real status effect --- TODO: Remove this when status effects are in place --- TODO: Consider moving these to the respective mods - -mcl_hunger.register_food("mcl_farming:potato_item_poison", 2, "", 4, 1, 0, 60) +-- Apply food poisoning effect as long there are no real status effect. +-- TODO: Remove this when food poisoning a status effect in mcl_potions. +-- Normal poison damage is set to 0 because it's handled elsewhere. mcl_hunger.register_food("mcl_mobitems:rotten_flesh", 4, "", 30, 0, 100, 80) mcl_hunger.register_food("mcl_mobitems:chicken", 2, "", 30, 0, 100, 30) -mcl_hunger.register_food("mcl_mobitems:spider_eye", 2, "", 4, 1, 0) - --- mcl_hunger.register_food("mcl_fishing:pufferfish_raw", 1, "", 60, 1, 300) +mcl_hunger.register_food("mcl_fishing:pufferfish_raw", 1, "", 15, 0, 300)