1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 01:30:38 +01:00

Update mobs

add bunny, changed api.lua, other smalls changes
This commit is contained in:
Ombridride 2015-03-19 00:10:30 +01:00
parent 2c9927dfbf
commit 3be8905b12
49 changed files with 126 additions and 33 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

View File

@ -59,7 +59,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"
@ -74,6 +74,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
@ -184,7 +185,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
@ -413,6 +414,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
@ -443,8 +446,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
@ -772,7 +780,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
@ -784,6 +792,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
@ -797,20 +817,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,
@ -821,6 +852,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)
@ -927,11 +959,6 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
pos.y = pos.y - 0.5
minetest.add_entity(pos, name)
-- set mob health (randomly between min and max)
if mob then
mob = mob:get_luaentity()
mob.object:set_hp( math.random(mob.hp_min, mob.hp_max) )
end
end
})
end

View File

@ -45,9 +45,6 @@ mobs:register_mob("mobs:bee", {
walk_start = 35,
walk_end = 65,
},
sounds = {
random = "mobs_bee",
},
-- right click to pick up bee
on_rightclick = function(self, clicker)
if clicker:is_player() and clicker:get_inventory() then
@ -56,7 +53,6 @@ mobs:register_mob("mobs:bee", {
end
end,
})
-- spawn on group:flowers between 4 and 20 light, 1 in 5000 chance, 1 bee in area up to 31000 in height
mobs:register_spawn("mobs:bee", {"default:dirt_with_grass"}, 20, 4, 7500, 1, 31000)

69
mods/mobs/bunny.lua Executable 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

@ -22,6 +22,10 @@ mobs:register_mob("mobs:chicken", {
"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
makes_footstep_sound = true,
@ -52,7 +56,7 @@ mobs:register_mob("mobs:chicken", {
walk_end = 40,
},
-- follows wheat
follow = "farming:wheat", view_range = 8,
follow = "farming:seed_wheat", view_range = 8,
-- replace air with egg (lay)
replace_rate = 1000,
replace_what = {"air"},
@ -60,7 +64,8 @@ mobs:register_mob("mobs:chicken", {
-- right click to pick up chicken
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()
if tool:get_name() == "farming:wheat" then
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)

View File

@ -88,7 +88,6 @@ mobs:register_spawn("mobs:cow", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31
mobs:register_egg("mobs:cow", "Cow", "default_grass.png", 1)
-- Bucket of Milk
minetest.register_craftitem("mobs:bucket_milk", {
description = "Bucket of Milk",
inventory_image = "mobs_bucket_milk.png",
@ -97,7 +96,6 @@ minetest.register_craftitem("mobs:bucket_milk", {
})
-- Cheese Wedge
minetest.register_craftitem("mobs:cheese", {
description = "Cheese",
inventory_image = "mobs_cheese.png",
@ -113,7 +111,6 @@ minetest.register_craft({
})
-- Cheese Block
minetest.register_node("mobs:cheeseblock", {
description = "Cheese Block",
tiles = {"mobs_cheeseblock.png"},

View File

@ -44,7 +44,6 @@ mobs:register_mob("mobs:dirt_monster", {
max = 8,},
},
-- damaged by
light_resistant = false,
water_damage = 1,
lava_damage = 5,
light_damage = 2,

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")
-- Animals/Kittens from Jordach BFD subgame
dofile(minetest.get_modpath("mobs").."/kitten.lua")

View File

@ -41,7 +41,6 @@ mobs:register_mob("mobs:lava_flan", {
chance = 15, min = 1, max = 1,},
},
-- damaged by
light_resistant = true,
water_damage = 5,
lava_damage = 0,
light_damage = 0,

View File

@ -49,7 +49,6 @@ mobs:register_mob("mobs:mese_monster", {
chance = 50, min = 1, max = 1,},
},
-- damaged by
light_resistant = true,
water_damage = 0,
lava_damage = 0,
light_damage = 0,
@ -68,7 +67,6 @@ mobs:register_spawn("mobs:mese_monster", {"default:stone", }, 20, -1, 6000, 1, -
mobs:register_egg("mobs:mese_monster", "Mese Monster", "default_mese_block.png", 1)
-- Mese Monster Crystal Shards (weapon)
mobs:register_arrow("mobs:mese_arrow", {
visual = "sprite",
visual_size = {x=.5, y=.5},

BIN
mods/mobs/models/mobs_bunny.b3d Executable file

Binary file not shown.

View File

@ -42,7 +42,6 @@ mobs:register_mob("mobs:oerkki", {
chance = 2, min = 2, max = 3,},
},
-- damaged by
light_resistant = true,
water_damage = 1,
lava_damage = 1,
light_damage = 0,

View File

@ -19,6 +19,9 @@ mobs:register_mob("mobs:sheep", {
},
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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
mods/mobs/textures/mobs_chick.png Executable 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: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 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: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 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.8 KiB

After

Width:  |  Height:  |  Size: 1.8 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: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 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.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.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

@ -69,7 +69,6 @@ mobs:register_mob("mobs:pumba", {
return
end
end,
})
-- spawns on normal or shroom dirt, between 8 and 20 light, 1 in 10000 chance, 1 in area up to 31000 in height
mobs:register_spawn("mobs:pumba", {"default:dirt_with_grass", "default:dirt"}, 20, 8, 10000, 1, 31000)