From b5e8b52218f60d515e585ff4ec86251e1ffd4b87 Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Sun, 7 Jan 2018 04:02:07 +0100 Subject: [PATCH] [Fix Issue #11] Rotten flesh has more uses --- mods/hbhunger/depends.txt | 1 + mods/hbhunger/init.lua | 18 ++-- mods/mobs | 2 +- mods/pmobs/depends.txt | 4 +- mods/pmobs/wolf.lua | 29 ++++-- mods/zombie/depends.txt | 5 +- mods/zombie/init.lua | 190 ++++++++++++++++++++++++-------------- 7 files changed, 161 insertions(+), 88 deletions(-) diff --git a/mods/hbhunger/depends.txt b/mods/hbhunger/depends.txt index d46748ae..6015079c 100755 --- a/mods/hbhunger/depends.txt +++ b/mods/hbhunger/depends.txt @@ -26,3 +26,4 @@ mtfoods? mush45? mushroom? seaplants? +pclasses? diff --git a/mods/hbhunger/init.lua b/mods/hbhunger/init.lua index 8369d557..dba3d813 100755 --- a/mods/hbhunger/init.lua +++ b/mods/hbhunger/init.lua @@ -20,6 +20,11 @@ HUNGER_EXHAUST_PLACE = 1 -- exhaustion increased this value after placed HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd +-- NALC : Fix MFF pclasses behaviour +local pc = false +if minetest.get_modpath("pclasses") and pclasses then + pc = true +end --load custom settings local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r") @@ -106,13 +111,14 @@ local function hunger_step() local hp = player:get_hp() 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 + if pc then -- NALC : Fix MFF modif + 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 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 diff --git a/mods/mobs b/mods/mobs index 71aa7b6d..2e77df9a 160000 --- a/mods/mobs +++ b/mods/mobs @@ -1 +1 @@ -Subproject commit 71aa7b6d83f3e7edeac72678eedbeb002cd639e6 +Subproject commit 2e77df9a8cee745ac2ce28a2aaa4fb4e3bfe02d2 diff --git a/mods/pmobs/depends.txt b/mods/pmobs/depends.txt index cbfbcdbe..676c66a0 100644 --- a/mods/pmobs/depends.txt +++ b/mods/pmobs/depends.txt @@ -1,2 +1,4 @@ default -mobs \ No newline at end of file +mobs +maptools? +zombie? diff --git a/mods/pmobs/wolf.lua b/mods/pmobs/wolf.lua index 5562f1be..c45f3d95 100644 --- a/mods/pmobs/wolf.lua +++ b/mods/pmobs/wolf.lua @@ -1,10 +1,19 @@ -- Wolf by KrupnoPavel +local drop_coin = nil -- NALC : Drop silver coin by chance if maptools mod loaded +if minetest.get_modpath("maptools") then + drop_coin = { + name = "maptools:silver_coin", + chance = 4, min = 1, max = 1, + } +end + mobs:register_mob( "pmobs:wolf", { type = "monster", + docile_by_day = true, passive = false, pathfinding = false, reach = 2, @@ -30,21 +39,23 @@ mobs:register_mob( damage = 3, attack_type = "dogfight", drops = { - {name = "mobs:meat_raw", - chance = 1, - min = 2, - max = 3,}, - {name = "maptools:silver_coin", - chance = 4, min = 1, max = 1,}, + { + name = "mobs:meat_raw", + chance = 1, + min = 2, + max = 3, + }, + drop_coin -- NALC }, drawtype = "front", water_damage = 0, lava_damage = 5, light_damage = 0, on_rightclick = function(self, clicker) - local tool = clicker:get_wielded_item() - if tool:get_name() == "mobs:meat_raw" then - clicker:get_inventory():remove_item("main", "mobs:meat_raw") + local tool = clicker:get_wielded_item():get_name() + if tool == "mobs:meat_raw" or + (minetest.get_modpath("zombie") and tool == "zombie:rotten_flesh") then + clicker:get_inventory():remove_item("main", tool) minetest.add_entity(self.object:getpos(), "pmobs:dog") self.object:remove() end diff --git a/mods/zombie/depends.txt b/mods/zombie/depends.txt index cbfbcdbe..c92b3f4e 100644 --- a/mods/zombie/depends.txt +++ b/mods/zombie/depends.txt @@ -1,2 +1,5 @@ default -mobs \ No newline at end of file +mobs +nether? +maptools? +hbhunger? diff --git a/mods/zombie/init.lua b/mods/zombie/init.lua index d0e89502..521559a0 100755 --- a/mods/zombie/init.lua +++ b/mods/zombie/init.lua @@ -1,81 +1,131 @@ -- Zombie by BlockMen -mobs:register_mob("zombie:zombie", { - -- animal, monster, npc, barbarian - type = "monster", - -- aggressive, deals 6 damage to player when hit - passive = false, - attack_type = "dogfight", - pathfinding = false, - damage = 3, - -- health & armor - hp_min = 12, - hp_max = 35, - armor = 150, - -- textures and model - collisionbox = {-0.25, -1, -0.3, 0.25, 0.75, 0.3}, - visual = "mesh", - mesh = "mobs_zombie.x", - textures = { - {"mobs_zombie.png"}, - }, - visual_size = {x=1, y=1}, - blood_texture = "mobs_blood.png", - -- sounds - makes_footstep_sound = true, - sounds = { - random = "mobs_zombie", - damage = "mobs_zombie_hit", - attack = "mobs_zombie_attack", - death = "mobs_zombie_death", - }, - -- speed and jump - view_range = 10, - walk_velocity = 1, - run_velocity = 3, - jump = true, - floats = 0, --- drops nether fruit and silver coin when dead - drops = { - {name = "nether:apple", - chance = 2, min = 1, max = 2,}, - {name = "zombie:zombie_tibia", - chance = 10, min = 1, max = 1,}, - {name = "maptools:silver_coin", - chance = 1, min = 1, max = 1,}, - {name = "zombie:rotten_flesh", - chance = 2, min = 3, max = 5,}, - }, - -- damaged by - water_damage = 1, - lava_damage = 5, - light_damage = 2, - -- model animation - animation = { - speed_normal = 10, speed_run = 15, - stand_start = 0, stand_end = 79, - walk_start = 168, walk_end = 188, - run_start = 168, run_end = 188, --- punch_start = 168, punch_end = 188, - }, -}) +local drop_coin = nil -- NALC : Drop silver coin if maptools mod +local drop_napple = nil -- NALC : Drop nether apple if nether + +if minetest.get_modpath("maptools") then + drop_coin = { + name = "maptools:silver_coin", + chance = 1, min = 1, max = 1 + } +end + +if minetest.get_modpath("nether") then + drop_napple = { + name = "nether:apple", + chance = 8, min = 1, max = 1 + } +end + +mobs:register_mob( + "zombie:zombie", + { + -- animal, monster, npc, barbarian + type = "monster", + -- aggressive, deals 6 damage to player when hit + passive = false, + attack_type = "dogfight", + pathfinding = false, + damage = 3, + -- health & armor + hp_min = 12, + hp_max = 35, + armor = 150, + -- textures and model + collisionbox = {-0.25, -1, -0.3, 0.25, 0.75, 0.3}, + visual = "mesh", + mesh = "mobs_zombie.x", + textures = { + {"mobs_zombie.png"}, + }, + visual_size = {x=1, y=1}, + blood_texture = "mobs_blood.png", + -- sounds + makes_footstep_sound = true, + sounds = { + random = "mobs_zombie", + damage = "mobs_zombie_hit", + attack = "mobs_zombie_attack", + death = "mobs_zombie_death", + }, + -- speed and jump + view_range = 10, + walk_velocity = 1, + run_velocity = 3, + jump = true, + floats = 0, + -- drops nether fruit and silver coin when dead + drops = { + {name = "zombie:rotten_flesh", + chance = 2, min = 3, max = 5,}, + {name = "zombie:zombie_tibia", + chance = 10, min = 1, max = 1,}, + drop_napple, -- NALC + drop_coin -- NALC + }, + -- damaged by + water_damage = 1, + lava_damage = 5, + light_damage = 2, + -- model animation + animation = { + speed_normal = 10, speed_run = 15, + stand_start = 0, stand_end = 79, + walk_start = 168, walk_end = 188, + run_start = 168, run_end = 188, + -- punch_start = 168, punch_end = 188, + }, + }) mobs:alias_mob("mobs:zombie", "zombie:zombie") --- spawn in nether forest between -1 and 5 light, 1 in 7000 change, 1 zombie in area up to 31000 in height -mobs:spawn_specific("zombie:zombie", {"nether:dirt_top", "default:dirt_with_grass", "default:stone"}, {"air"}, -1, 5, 30, 7000, 1, -31000, 31000, false) +-- spawn in nether forest between -1 and 5 light, 1 in 7000 chance, 1 zombie in area up to 31000 in height +mobs:spawn_specific("zombie:zombie", {"nether:dirt_top", "default:dirt_with_grass", "default:dirt", "default:stone"}, {"air"}, -1, 5, 30, 7000, 1, -31000, 31000, false) -- register spawn egg mobs:register_egg("zombie:zombie", "Zombie", "mobs_zombie_inv.png", 1) -minetest.register_craftitem("zombie:zombie_tibia", { - description = "Zombie Tibia", - inventory_image = "mobs_zombie_tibia.png", - groups = {magic = 1}, -}) +minetest.register_craftitem( + "zombie:zombie_tibia", + { + description = "Zombie Tibia", + inventory_image = "mobs_zombie_tibia.png", + groups = {magic = 1}, + }) minetest.register_alias("mobs:zombie_tibia", "zombie:zombie_tibia") -minetest.register_craftitem("zombie:rotten_flesh", { - description = "Rotten Flesh", - inventory_image = "mobs_rotten_flesh.png", - on_use = minetest.item_eat(1), +minetest.register_craftitem( + "zombie:rotten_flesh", + { + description = "Rotten Flesh", + inventory_image = "mobs_rotten_flesh.png", + + on_use = function(itemstack, user) -- NALC : Augmente la faim de 5 points mais augmente la vie de 1 point + local inv = user:get_inventory() + if not inv then return end + itemstack:take_item() + + -- Augmente la vie de 1 point + user:set_hp(user:get_hp() + 1) + + -- Si hbhunger alors augmente la faim de 5 points (Réduction de la barre de faim) + if minetest.get_modpath("hbhunger") then + local p_hunger = tonumber(hbhunger.hunger[user:get_player_name()]) + if not p_hunger then return end + p_hunger = p_hunger - 5 + if p_hunger < 0 then p_hunger = 0 end + hbhunger.hunger[user:get_player_name()] = p_hunger + local save_hunger = hbhunger.save_hunger + if not save_hunger then save_hunger = hbhunger.set_hunger end + save_hunger(user) + end + + return itemstack + end + }) + +minetest.register_craft({ + type = "cooking", + output = "mobs:meat", + recipe = "zombie:rotten_flesh", + cooktime = 5, })