Added bunny's and fixed api texture handling

master
tenplus1 2015-03-18 20:55:50 +00:00
parent 54540d2ed2
commit b7a097ff7c
48 changed files with 181 additions and 72 deletions

View File

@ -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

56
api.lua
View File

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

View File

@ -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,

69
bunny.lua Normal file
View File

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

View File

@ -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()

View File

@ -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},

View File

@ -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",

View File

@ -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",

View File

@ -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

View File

@ -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},

View File

@ -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",

BIN
models/mobs_bunny.b3d Normal file

Binary file not shown.

View File

@ -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

View File

@ -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",

View File

@ -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,

View File

@ -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",

View File

@ -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 = {

View File

@ -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

View File

@ -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",

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/mobs_bunny_inv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/mobs_chick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 948 B

After

Width:  |  Height:  |  Size: 948 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 901 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 834 B

After

Width:  |  Height:  |  Size: 834 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View File

@ -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",

View File

@ -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