diff --git a/README.txt b/README.txt index 42548b1..444f4ec 100644 --- a/README.txt +++ b/README.txt @@ -29,6 +29,7 @@ This mod contains the following additions: Changelog: beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop +1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus 1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :) 1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc. 1.02- Sheared sheep are remembered and spawn shaven, Warthogs will attack when threatened, Api additions diff --git a/api.lua b/api.lua index c0ebda9..223e00c 100644 --- a/api.lua +++ b/api.lua @@ -57,7 +57,7 @@ function mobs:register_mob(name, def) replace_what = def.replace_what, replace_with = def.replace_with, replace_offset = def.replace_offset or 0, - + stimer = 0, timer = 0, env_damage_timer = 0, -- only if state = "attack" @@ -72,6 +72,7 @@ function mobs:register_mob(name, def) horny = false, hornytimer = 0, child = false, + gotten = false, do_attack = function(self, player, dist) if self.state ~= "attack" then @@ -182,7 +183,7 @@ function mobs:register_mob(name, def) end -- check for mob drop/replace (used for chicken egg and sheep eating grass/wheat) - if self.replace_rate and math.random(1,self.replace_rate) == 1 then + if self.replace_rate and math.random(1,self.replace_rate) == 1 and self.child == false then local pos = self.object:getpos() ; pos.y = pos.y + self.replace_offset if #minetest.find_nodes_in_area(pos,pos,self.replace_what) > 0 and self.object:getvelocity().y == 0 and self.state == "stand" then @@ -411,6 +412,8 @@ function mobs:register_mob(name, def) self.child = false self.hornytimer = 0 self.object:set_properties({ + textures = self.base_texture, + mesh = self.base_mesh, visual_size = {x=self.visual_size.x,y=self.visual_size.y}, }) end @@ -441,8 +444,13 @@ function mobs:register_mob(name, def) --print ("spawned baby:",self.name) local mob = minetest.add_entity(pos, self.name) local ent2 = mob:get_luaentity() - + local texture = self.base_texture + if def.child_texture then + print ("child texture detected") + textures = def.child_texture[1] + end mob:set_properties({ + textures = textures, visual_size = {x=self.visual_size.x/2,y=self.visual_size.y/2}, }) ent2.child = true @@ -667,7 +675,7 @@ function mobs:register_mob(name, def) if tmp.tamed then self.tamed = tmp.tamed end - if tmp.gotten then -- using this variable for obtaining something from mob (milk/wool) + if tmp.gotten then self.gotten = tmp.gotten end if tmp.child then @@ -679,6 +687,18 @@ function mobs:register_mob(name, def) if tmp.hornytimer then self.hornytimer = tmp.hornytimer end + if tmp.textures then + self.textures = tmp.textures + end + if tmp.mesh then + self.mesh = tmp.mesh + end + if tmp.base_texture then + self.base_texture = tmp.base_texture + end + if tmp.base_mesh then + self.base_mesh = tmp.base_mesh + end end end @@ -692,20 +712,31 @@ function mobs:register_mob(name, def) end, get_staticdata = function(self) - -- set mob texture and model - local textures = def.available_textures["texture_"..math.random(1,def.available_textures["total"])] - local mesh = self.mesh + -- select random texture, set model + if not self.base_texture then + self.base_texture = def.textures[math.random(1,#def.textures)] + self.base_mesh = def.mesh + end + -- set texture, model and size + local textures = self.base_texture + local mesh = self.base_mesh local vis_size = self.visual_size - -- if object is a sheared sheep then set texture and model - if self.name == "mobs:sheep" and self.gotten == true then - textures = {"mobs_sheep_shaved.png"} - mesh = "mobs_sheep_shaved.x" + -- specific texture if gotten + if self.gotten == true and def.gotten_texture then + textures = def.gotten_texture + end + -- specific mesh if gotten + if self.gotten == true and def.gotten_mesh then + mesh = def.gotten_mesh end -- if object is child then set half size if self.child == true then vis_size = {x=self.visual_size.x/2,y=self.visual_size.y/2} + if def.child_texture then + textures = def.child_texture[1] + end end - + -- remember settings local tmp = { lifetimer = self.lifetimer, tamed = self.tamed, @@ -716,6 +747,7 @@ function mobs:register_mob(name, def) mesh = mesh, textures = textures, visual_size = vis_size, + base_texture = self.base_texture, } self.object:set_properties(tmp) return minetest.serialize(tmp) diff --git a/bee.lua b/bee.lua index 69f3bc0..adb4675 100644 --- a/bee.lua +++ b/bee.lua @@ -13,9 +13,8 @@ mobs:register_mob("mobs:bee", { visual = "mesh", mesh = "mobs_bee.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_bee.png"}, + textures = { + {"mobs_bee.png"}, }, -- sounds makes_footstep_sound = false, diff --git a/bunny.lua b/bunny.lua new file mode 100644 index 0000000..bdb8ba5 --- /dev/null +++ b/bunny.lua @@ -0,0 +1,69 @@ + +-- Bunny by ExeterDad + +mobs:register_mob("mobs:bunny", { + -- animal, monster, npc + type = "animal", + -- is it aggressive + passive = true, + -- health & armor + hp_min = 1, hp_max = 4, armor = 200, + -- textures and model + collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268}, + visual = "mesh", + mesh = "mobs_bunny.b3d", + drawtype = "front", + textures = { + {"mobs_bunny_grey.png"}, + {"mobs_bunny_brown.png"}, + {"mobs_bunny_white.png"}, + }, + -- sounds + sounds = {}, + makes_footstep_sound = false, + -- speed and jump + walk_velocity = 1, + jump = true, + -- drops meat when deat + drops = { + {name = "mobs:meat_raw", + chance = 1, min = 1, max = 2,}, + }, + -- damaged by + water_damage = 1, + lava_damage = 1, + light_damage = 0, + -- model animation + animation = { + speed_normal = 15, + stand_start = 1, stand_end = 15, + walk_start = 16, walk_end = 24, + }, + -- follows carrot from farming redo + follow = "farming:carrot", + view_range = 5, + -- right click to pick up rabbit + on_rightclick = function(self, clicker) + + local item = clicker:get_wielded_item() + if item:get_name() == "farming_plus:carrot_item" or item:get_name() == "farming:carrot" 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 >= 4 then + self.food = 0 + self.tamed = true + end + return + end + if clicker:is_player() and clicker:get_inventory() then + clicker:get_inventory():add_item("main", "mobs:bunny") + self.object:remove() + end + end, +}) + +mobs:register_spawn("mobs:bunny", {"default:dirt_with_grass", "ethereal:green_dirt_top"}, 20, 8, 9000, 1, 31000) +mobs:register_egg("mobs:bunny", "bunny", "mobs_bunny_inv.png", 0) diff --git a/chicken.lua b/chicken.lua index ce9af4f..be49110 100644 --- a/chicken.lua +++ b/chicken.lua @@ -13,14 +13,15 @@ mobs:register_mob("mobs:chicken", { visual = "mesh", mesh = "chicken.x", drawtype = "front", - available_textures = { - total = 2, - texture_1 = {"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", - "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", - "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, - texture_2 = {"mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", - "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", - "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png"}, + textures = { + {"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", + "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, + {"mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", + "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png"}, + }, + child_texture = { + {"mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png", + "mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png"}, }, blood_texture = "mobs_blood.png", -- sounds @@ -51,14 +52,31 @@ mobs:register_mob("mobs:chicken", { walk_end = 40, }, -- follows wheat - follow = "farming:wheat", view_range = 5, + follow = "farming:seed_wheat", view_range = 5, -- replace air with egg (lay) replace_rate = 1000, replace_what = {"air"}, replace_with = "mobs:egg", -- right click to pick up chicken on_rightclick = function(self, clicker) - local item = clicker:get_wielded_item() + local tool = clicker:get_wielded_item() + + if tool:get_name() == "farming:seed_wheat" then -- and self.gotten then + if not minetest.setting_getbool("creative_mode") then + tool:take_item(1) + clicker:set_wielded_item(tool) + end + self.food = (self.food or 0) + 1 + if self.food >= 8 then + self.food = 0 + if self.child == false then self.horny = true end + self.gotten = false -- reset + self.tamed = true + minetest.sound_play("mobs_chicken", {object = self.object,gain = 1.0,max_hear_distance = 15,loop = false,}) + end + return tool + end + if clicker:is_player() and clicker:get_inventory() then clicker:get_inventory():add_item("main", "mobs:chicken") self.object:remove() diff --git a/cow.lua b/cow.lua index 77bf8ad..e211140 100644 --- a/cow.lua +++ b/cow.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:cow", { visual = "mesh", mesh = "mobs_cow.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_cow.png"}, + textures = { + {"mobs_cow.png"}, }, blood_texture = "mobs_blood.png", visual_size = {x=1,y=1}, diff --git a/dirtmonster.lua b/dirtmonster.lua index e80886d..0748dac 100644 --- a/dirtmonster.lua +++ b/dirtmonster.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:dirt_monster", { visual = "mesh", mesh = "mobs_stone_monster.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_dirt_monster.png"}, + textures = { + {"mobs_dirt_monster.png"}, }, visual_size = {x=3, y=2.6}, blood_texture = "default_dirt.png", diff --git a/dungeonmaster.lua b/dungeonmaster.lua index 8a735a8..42b4528 100644 --- a/dungeonmaster.lua +++ b/dungeonmaster.lua @@ -18,11 +18,10 @@ mobs:register_mob("mobs:dungeon_master", { visual = "mesh", mesh = "mobs_dungeon_master.x", drawtype = "front", - available_textures = { - total = 3, - texture_1 = {"mobs_dungeon_master.png"}, - texture_2 = {"mobs_dungeon_master2.png"}, - texture_3 = {"mobs_dungeon_master3.png"}, + textures = { + {"mobs_dungeon_master.png"}, + {"mobs_dungeon_master2.png"}, + {"mobs_dungeon_master3.png"}, }, visual_size = {x=8, y=8}, blood_texture = "mobs_blood.png", diff --git a/init.lua b/init.lua index 99835b9..886dd28 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ dofile(minetest.get_modpath("mobs").."/api.lua") --- Animals inc. Krupnovpavel's warthog/bee and JKmurray's chicken +-- Animals inc. Krupnovpavel's warthog/bee, JKmurray's chicken, ExeterDad's bunny dofile(minetest.get_modpath("mobs").."/chicken.lua") dofile(minetest.get_modpath("mobs").."/cow.lua") @@ -10,6 +10,7 @@ dofile(minetest.get_modpath("mobs").."/rat.lua") dofile(minetest.get_modpath("mobs").."/sheep.lua") dofile(minetest.get_modpath("mobs").."/warthog.lua") dofile(minetest.get_modpath("mobs").."/bee.lua") +dofile(minetest.get_modpath("mobs").."/bunny.lua") -- Monsters diff --git a/lava_flan.lua b/lava_flan.lua index 9806bd4..b119415 100644 --- a/lava_flan.lua +++ b/lava_flan.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:lava_flan", { visual = "mesh", mesh = "zmobs_lava_flan.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"zmobs_lava_flan.png"}, + textures = { + {"zmobs_lava_flan.png"}, }, blood_texture = "fire_basic_flame.png", visual_size = {x=1, y=1}, diff --git a/mese_monster.lua b/mese_monster.lua index 2e02fd2..2a35bd8 100644 --- a/mese_monster.lua +++ b/mese_monster.lua @@ -17,9 +17,8 @@ mobs:register_mob("mobs:mese_monster", { collisionbox = {-0.5, -1.5, -0.5, 0.5, 0.5, 0.5}, visual = "mesh", mesh = "zmobs_mese_monster.x", - available_textures = { - total = 1, - texture_1 = {"zmobs_mese_monster.png"}, + textures = { + {"zmobs_mese_monster.png"}, }, visual_size = {x=1, y=1}, drawtype = "front", diff --git a/models/mobs_bunny.b3d b/models/mobs_bunny.b3d new file mode 100644 index 0000000..ee053bd Binary files /dev/null and b/models/mobs_bunny.b3d differ diff --git a/npc.lua b/npc.lua index 3188ba2..ddfaa9e 100644 --- a/npc.lua +++ b/npc.lua @@ -18,9 +18,8 @@ mobs:register_mob("mobs:npc", { visual = "mesh", mesh = "character.b3d", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_npc.png"}, + textures = { + {"mobs_npc.png"}, }, visual_size = {x=1, y=1}, -- sounds diff --git a/oerkki.lua b/oerkki.lua index ff66e28..3cce524 100644 --- a/oerkki.lua +++ b/oerkki.lua @@ -15,10 +15,9 @@ mobs:register_mob("mobs:oerkki", { visual = "mesh", mesh = "mobs_oerkki.x", drawtype = "front", - available_textures = { - total = 2, - texture_1 = {"mobs_oerkki.png"}, - texture_2 = {"mobs_oerkki2.png"}, + textures = { + {"mobs_oerkki.png"}, + {"mobs_oerkki2.png"}, }, visual_size = {x=5, y=5}, blood_texture = "mobs_blood.png", diff --git a/rat.lua b/rat.lua index 6b8b520..1e103ef 100644 --- a/rat.lua +++ b/rat.lua @@ -13,10 +13,9 @@ mobs:register_mob("mobs:rat", { visual = "mesh", mesh = "mobs_rat.x", drawtype = "front", - available_textures = { - total = 2, - texture_1 = {"mobs_rat.png"}, - texture_2 = {"mobs_rat2.png"}, + textures = { + {"mobs_rat.png"}, + {"mobs_rat2.png"}, }, -- sounds makes_footstep_sound = false, diff --git a/sandmonster.lua b/sandmonster.lua index 6158334..4310327 100644 --- a/sandmonster.lua +++ b/sandmonster.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:sand_monster", { visual = "mesh", mesh = "mobs_sand_monster.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_sand_monster.png"}, + textures = { + {"mobs_sand_monster.png"}, }, visual_size = {x=8,y=8}, blood_texture = "mobs_blood.png", diff --git a/sheep.lua b/sheep.lua index 11b7efa..b931ba8 100644 --- a/sheep.lua +++ b/sheep.lua @@ -13,12 +13,14 @@ mobs:register_mob("mobs:sheep", { visual = "mesh", mesh = "mobs_sheep.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_sheep.png"}, + textures = { + {"mobs_sheep.png"}, }, blood_texture = "mobs_blood.png", visual_size = {x=1,y=1}, + -- specific texture and mesh for gotten + gotten_texture = {"mobs_sheep_shaved.png"}, + gotten_mesh = "mobs_sheep_shaved.x", -- sounds makes_footstep_sound = true, sounds = { diff --git a/spider.lua b/spider.lua index 520a6f0..2279f85 100644 --- a/spider.lua +++ b/spider.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:spider", { visual = "mesh", mesh = "mobs_spider.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_spider.png"}, + textures = { + {"mobs_spider.png"}, }, visual_size = {x=7,y=7}, -- sounds diff --git a/stonemonster.lua b/stonemonster.lua index 93be6b1..5379b41 100644 --- a/stonemonster.lua +++ b/stonemonster.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:stone_monster", { visual = "mesh", mesh = "mobs_stone_monster.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_stone_monster.png"}, + textures = { + {"mobs_stone_monster.png"}, }, visual_size = {x=3, y=2.6}, blood_texture = "mobs_blood.png", diff --git a/models/mobs_bee.png b/textures/mobs_bee.png similarity index 100% rename from models/mobs_bee.png rename to textures/mobs_bee.png diff --git a/textures/mobs_bunny_brown.png b/textures/mobs_bunny_brown.png new file mode 100644 index 0000000..eb8a682 Binary files /dev/null and b/textures/mobs_bunny_brown.png differ diff --git a/textures/mobs_bunny_grey.png b/textures/mobs_bunny_grey.png new file mode 100644 index 0000000..f1f6e25 Binary files /dev/null and b/textures/mobs_bunny_grey.png differ diff --git a/textures/mobs_bunny_inv.png b/textures/mobs_bunny_inv.png new file mode 100644 index 0000000..3d1b395 Binary files /dev/null and b/textures/mobs_bunny_inv.png differ diff --git a/textures/mobs_bunny_white.png b/textures/mobs_bunny_white.png new file mode 100644 index 0000000..752e380 Binary files /dev/null and b/textures/mobs_bunny_white.png differ diff --git a/textures/mobs_chick.png b/textures/mobs_chick.png new file mode 100644 index 0000000..b9c7764 Binary files /dev/null and b/textures/mobs_chick.png differ diff --git a/models/mobs_chicken.png b/textures/mobs_chicken.png similarity index 100% rename from models/mobs_chicken.png rename to textures/mobs_chicken.png diff --git a/models/mobs_chicken_black.png b/textures/mobs_chicken_black.png similarity index 100% rename from models/mobs_chicken_black.png rename to textures/mobs_chicken_black.png diff --git a/models/mobs_cow.png b/textures/mobs_cow.png similarity index 100% rename from models/mobs_cow.png rename to textures/mobs_cow.png diff --git a/models/mobs_dirt_monster.png b/textures/mobs_dirt_monster.png similarity index 100% rename from models/mobs_dirt_monster.png rename to textures/mobs_dirt_monster.png diff --git a/models/mobs_dungeon_master.png b/textures/mobs_dungeon_master.png similarity index 100% rename from models/mobs_dungeon_master.png rename to textures/mobs_dungeon_master.png diff --git a/models/mobs_dungeon_master2.png b/textures/mobs_dungeon_master2.png similarity index 100% rename from models/mobs_dungeon_master2.png rename to textures/mobs_dungeon_master2.png diff --git a/models/mobs_dungeon_master3.png b/textures/mobs_dungeon_master3.png similarity index 100% rename from models/mobs_dungeon_master3.png rename to textures/mobs_dungeon_master3.png diff --git a/models/mobs_npc.png b/textures/mobs_npc.png similarity index 100% rename from models/mobs_npc.png rename to textures/mobs_npc.png diff --git a/models/mobs_oerkki.png b/textures/mobs_oerkki.png similarity index 100% rename from models/mobs_oerkki.png rename to textures/mobs_oerkki.png diff --git a/models/mobs_oerkki2.png b/textures/mobs_oerkki2.png similarity index 100% rename from models/mobs_oerkki2.png rename to textures/mobs_oerkki2.png diff --git a/models/mobs_pumba.png b/textures/mobs_pumba.png similarity index 100% rename from models/mobs_pumba.png rename to textures/mobs_pumba.png diff --git a/models/mobs_rat.png b/textures/mobs_rat.png similarity index 100% rename from models/mobs_rat.png rename to textures/mobs_rat.png diff --git a/models/mobs_rat2.png b/textures/mobs_rat2.png similarity index 100% rename from models/mobs_rat2.png rename to textures/mobs_rat2.png diff --git a/models/mobs_sand_monster.png b/textures/mobs_sand_monster.png similarity index 100% rename from models/mobs_sand_monster.png rename to textures/mobs_sand_monster.png diff --git a/models/mobs_sheep.png b/textures/mobs_sheep.png similarity index 100% rename from models/mobs_sheep.png rename to textures/mobs_sheep.png diff --git a/models/mobs_sheep_shaved.png b/textures/mobs_sheep_shaved.png similarity index 100% rename from models/mobs_sheep_shaved.png rename to textures/mobs_sheep_shaved.png diff --git a/models/mobs_spider.png b/textures/mobs_spider.png similarity index 100% rename from models/mobs_spider.png rename to textures/mobs_spider.png diff --git a/models/mobs_stone_monster.png b/textures/mobs_stone_monster.png similarity index 100% rename from models/mobs_stone_monster.png rename to textures/mobs_stone_monster.png diff --git a/models/mobs_tree_monster.png b/textures/mobs_tree_monster.png similarity index 100% rename from models/mobs_tree_monster.png rename to textures/mobs_tree_monster.png diff --git a/models/zmobs_lava_flan.png b/textures/zmobs_lava_flan.png similarity index 100% rename from models/zmobs_lava_flan.png rename to textures/zmobs_lava_flan.png diff --git a/models/zmobs_mese_monster.png b/textures/zmobs_mese_monster.png similarity index 100% rename from models/zmobs_mese_monster.png rename to textures/zmobs_mese_monster.png diff --git a/treemonster.lua b/treemonster.lua index 7b7de36..e786fcf 100644 --- a/treemonster.lua +++ b/treemonster.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:tree_monster", { visual = "mesh", mesh = "mobs_tree_monster.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_tree_monster.png"}, + textures = { + {"mobs_tree_monster.png"}, }, visual_size = {x=4.5,y=4.5}, blood_texture = "default_wood.png", diff --git a/warthog.lua b/warthog.lua index 601f251..8c6505a 100644 --- a/warthog.lua +++ b/warthog.lua @@ -15,9 +15,8 @@ mobs:register_mob("mobs:pumba", { visual = "mesh", mesh = "mobs_pumba.x", drawtype = "front", - available_textures = { - total = 1, - texture_1 = {"mobs_pumba.png"}, + textures = { + {"mobs_pumba.png"}, }, visual_size = {x=1,y=1}, -- sounds