From 5163bf95518bcd3414b364e613c3a416a86c9991 Mon Sep 17 00:00:00 2001 From: Ombridride Date: Mon, 15 Dec 2014 00:17:29 +0100 Subject: [PATCH] MAJ mobs(redo) mod Added switch to disable mobs in protected areas --- mods/mobs/README.txt | 1 + mods/mobs/api.lua | 7 ++++ mods/mobs/cow.lua | 2 +- mods/mobs/init.lua | 2 +- mods/mobs/oerkki.lua~ | 56 ----------------------------- mods/mobs/sheep.lua~ | 73 -------------------------------------- mods/mobs/warthog.lua~ | 80 ------------------------------------------ 7 files changed, 10 insertions(+), 211 deletions(-) delete mode 100644 mods/mobs/oerkki.lua~ delete mode 100644 mods/mobs/sheep.lua~ delete mode 100644 mods/mobs/warthog.lua~ diff --git a/mods/mobs/README.txt b/mods/mobs/README.txt index b84da86a..5dcd2b8d 100644 --- a/mods/mobs/README.txt +++ b/mods/mobs/README.txt @@ -25,6 +25,7 @@ This mod contains the following additions: Changelog: +0.7 - mob.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes 0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block 0.5 - Mobs now float in water, die from falling, and some code improvements 0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 61c90485..fb3f30f0 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -1,5 +1,7 @@ mobs = {} mobs.mod = "redo" +mobs.protected = 0 -- Set to 1 if you do not wish mobs to spawn in protected areas (default: 0) + function mobs:register_mob(name, def) minetest.register_entity(name, { name = name, @@ -793,6 +795,11 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o return end + -- Check if protected area using bogus name so mobs will not spawn + if mobs.protected == 1 and minetest.is_protected(pos, "-") then + return + end + pos.y = pos.y+1 if not minetest.get_node_light(pos) diff --git a/mods/mobs/cow.lua b/mods/mobs/cow.lua index 94d3e8b0..5a78edae 100644 --- a/mods/mobs/cow.lua +++ b/mods/mobs/cow.lua @@ -35,7 +35,7 @@ mobs:register_mob("mobs:cow", { }, -- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk on_rightclick = function(self, clicker) - tool = clicker:get_wielded_item() + local tool = clicker:get_wielded_item() if tool:get_name() == "bucket:bucket_empty" then if self.milked then do return end diff --git a/mods/mobs/init.lua b/mods/mobs/init.lua index 56837fb9..795a6ffc 100644 --- a/mods/mobs/init.lua +++ b/mods/mobs/init.lua @@ -1,4 +1,4 @@ --- Mob Api (15th Oct 2014) +-- Mob Api (10th Dec 2014) dofile(minetest.get_modpath("mobs").."/api.lua") diff --git a/mods/mobs/oerkki.lua~ b/mods/mobs/oerkki.lua~ deleted file mode 100644 index 09e03e43..00000000 --- a/mods/mobs/oerkki.lua~ +++ /dev/null @@ -1,56 +0,0 @@ - --- Oerkki - -mobs:register_mob("mobs:oerkki", { - type = "monster", - hp_min = 40, - hp_max = 50, - collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, - visual = "mesh", - mesh = "mobs_oerkki.x", - --textures = {"mobs_oerkki.png"}, - available_textures = { - total = 2, - texture_1 = {"mobs_oerkki.png"}, - texture_2 = {"mobs_oerkki2.png"}, - }, - visual_size = {x=5, y=5}, - makes_footstep_sound = false, - view_range = 16, - walk_velocity = 2, - run_velocity = 4, - damage = 5, - drops = { - {name = "default:obsidian", - chance = 3, - min = 1, - max = 2,}, - {name = "maptools:silver_coin", - chance = 2, - min = 2, - max = 3,}, - }, - armor = 90, - drawtype = "front", - light_resistant = true, - water_damage = 1, - lava_damage = 1, - light_damage = 0, - attack_type = "dogfight", - animation = { - stand_start = 0, - stand_end = 23, - walk_start = 24, - walk_end = 36, - run_start = 37, - run_end = 49, - punch_start = 37, - punch_end = 49, - speed_normal = 15, - speed_run = 15, - }, - jump = true, - step = 1, - blood_texture = "mobs_blood.png", -}) -mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 6000, 1, -10) diff --git a/mods/mobs/sheep.lua~ b/mods/mobs/sheep.lua~ deleted file mode 100644 index b4bcf7f2..00000000 --- a/mods/mobs/sheep.lua~ +++ /dev/null @@ -1,73 +0,0 @@ - --- Sheep - -mobs:register_mob("mobs:sheep", { - type = "animal", - hp_min = 10, - hp_max = 15, - collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4}, - textures = {"mobs_sheep.png"}, - visual = "mesh", - mesh = "mobs_sheep.x", - makes_footstep_sound = true, - walk_velocity = 1, - armor = 200, - drops = { - {name = "mobs:meat_raw", - chance = 1, - min = 2, - max = 3,}, - }, - drawtype = "front", - water_damage = 1, - lava_damage = 5, - light_damage = 0, - sounds = { - random = "mobs_sheep", - }, - animation = { - speed_normal = 15, - stand_start = 0, - stand_end = 80, - walk_start = 81, - walk_end = 100, - }, - jump = true, - step = 1, - blood_texture = "mobs_blood.png", - passive = true, - follow = "farming:wheat", - view_range = 8, - on_rightclick = function(self, clicker) - local item = clicker:get_wielded_item() - if item:get_name() == "farming:wheat" then - if not minetest.setting_getbool("creative_mode") then - item:take_item() - clicker:set_wielded_item(item) - end - self.food = (self.food or 0) + 1 - if self.food >= 8 then - self.food = 0 - self.naked = false - self.tamed = true - self.object:set_properties({ - textures = {"mobs_sheep.png"}, - mesh = "mobs_sheep.x", - }) - minetest.sound_play("mobs_sheep", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,}) - end - return - end - if clicker:get_inventory() and not self.naked then - self.naked = true - if minetest.registered_items["wool:white"] then - clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3))) - end - self.object:set_properties({ - textures = {"mobs_sheep_shaved.png"}, - mesh = "mobs_sheep_shaved.x", - }) - end - end, -}) -mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 1, 31000) diff --git a/mods/mobs/warthog.lua~ b/mods/mobs/warthog.lua~ deleted file mode 100644 index 9871a34e..00000000 --- a/mods/mobs/warthog.lua~ +++ /dev/null @@ -1,80 +0,0 @@ --- Warthog - -mobs:register_mob("mobs:pumba", { - type = "animal", - hp_min = 10, - hp_max = 15, - collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4}, - textures = {"mobs_pumba.png"}, - visual = "mesh", - mesh = "mobs_pumba.x", - makes_footstep_sound = true, - walk_velocity = 2, - armor = 200, - drops = { - {name = "mobs:pork_raw", - chance = 1, - min = 2, - max = 3,}, - }, - drawtype = "front", - water_damage = 1, - lava_damage = 5, - light_damage = 0, - sounds = { - random = "mobs_pig", - }, - animation = { - speed_normal = 15, - stand_start = 25, - stand_end = 55, - walk_start = 70, - walk_end = 100, - }, - follow = "farming:wheat", - view_range = 8, -jump = true, -step = 1, -passive = true, -blood_texture = "mobs_blood.png", - - on_rightclick = function(self, clicker) - local item = clicker:get_wielded_item() - if item:get_name() == "farming:wheat" then - if not minetest.setting_getbool("creative_mode") then - item:take_item() - clicker:set_wielded_item(item) - end - self.food = (self.food or 0) + 1 - if self.food >= 8 then - self.food = 0 - self.tamed = true - minetest.sound_play("mobs_pig", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,}) - end - return - end - end, - -}) -mobs:register_spawn("mobs:pumba", {"default:dirt_with_grass", "default:dirt"}, 20, 8, 9000, 1, 31000) - --- Porkchops - -minetest.register_craftitem("mobs:pork_raw", { - description = "Raw Porkchop", - inventory_image = "mobs_pork_raw.png", - on_use = minetest.item_eat(4), -}) - -minetest.register_craftitem("mobs:pork_cooked", { - description = "Cooked Porkchop", - inventory_image = "mobs_pork_cooked.png", - on_use = minetest.item_eat(8), -}) - -minetest.register_craft({ - type = "cooking", - output = "mobs:pork_cooked", - recipe = "mobs:pork_raw", - cooktime = 5, -})