parent
257a737f92
commit
db0afa6a4c
40
api_fast.lua
40
api_fast.lua
|
@ -328,8 +328,7 @@ function mobehavior:register_mob_fast(name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mdef = {
|
local mdef = {
|
||||||
hp_max = 1,
|
hp = 14,
|
||||||
health = 1,
|
|
||||||
rotate = 0,
|
rotate = 0,
|
||||||
reach = 3,
|
reach = 3,
|
||||||
physical = true,
|
physical = true,
|
||||||
|
@ -358,6 +357,39 @@ function mobehavior:register_mob_fast(name, def)
|
||||||
jump_timer = 0,
|
jump_timer = 0,
|
||||||
walk_timer = 0,
|
walk_timer = 0,
|
||||||
|
|
||||||
|
on_death = function(self, killer)
|
||||||
|
-- print("died")
|
||||||
|
local p = self
|
||||||
|
local obj = self.object
|
||||||
|
if not p then return end
|
||||||
|
|
||||||
|
local drops = p.drops
|
||||||
|
if not drops then return end
|
||||||
|
|
||||||
|
local pos = obj:get_pos()
|
||||||
|
|
||||||
|
if type(drops) == "string" then
|
||||||
|
minetest.add_item(pos, drops)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local total = 0
|
||||||
|
for _,d in ipairs(drops) do
|
||||||
|
if type(d) == string then
|
||||||
|
minetest.add_item(pos, d)
|
||||||
|
else
|
||||||
|
if 1 == math.random(d.chance or 1) then
|
||||||
|
minetest.add_item(pos, {name=d.name, count=d.min + math.random(d.max-d.min)})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
|
-- print("punched")
|
||||||
|
end,
|
||||||
|
|
||||||
on_step = step,
|
on_step = step,
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
|
@ -457,8 +489,8 @@ function mobehavior:register_mob_fast(name, def)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.health == 0 then
|
if not self.health or self.health == 0 then
|
||||||
self.health = math.random (self.hp_min, self.hp_max)
|
self.health = math.random(self.hp_min, self.hp_max)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_hp(self.health)
|
self.object:set_hp(self.health)
|
||||||
|
|
12
entities.lua
12
entities.lua
|
@ -3,10 +3,11 @@ function make_bunny(name, behavior_fn)
|
||||||
|
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = true,
|
passive = true,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 1,
|
hp_min = 12,
|
||||||
hp_max = 4,
|
hp_max = 14,
|
||||||
armor = 200,
|
armor = 200,
|
||||||
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -65,6 +66,7 @@ function make_wolf(name, behavior_fn)
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
|
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = false,
|
passive = false,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 12,
|
hp_min = 12,
|
||||||
|
@ -125,6 +127,7 @@ function make_sheep(name, behavior_fn)
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
|
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = false,
|
passive = false,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 12,
|
hp_min = 12,
|
||||||
|
@ -189,6 +192,7 @@ function make_bear(name, behavior_fn)
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
|
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = false,
|
passive = false,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 100,
|
hp_min = 100,
|
||||||
|
@ -251,6 +255,7 @@ function make_rat(name, behavior_fn)
|
||||||
|
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
climbs_ladders = false,
|
climbs_ladders = false,
|
||||||
passive = true,
|
passive = true,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
|
@ -301,6 +306,7 @@ function make_deer(name, behavior_fn)
|
||||||
|
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = true,
|
passive = true,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 1,
|
hp_min = 1,
|
||||||
|
@ -347,6 +353,7 @@ function make_buck(name, behavior_fn)
|
||||||
|
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
type = "animal",
|
type = "animal",
|
||||||
|
name = name,
|
||||||
passive = true,
|
passive = true,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
hp_min = 1,
|
hp_min = 1,
|
||||||
|
@ -395,6 +402,7 @@ function make_NPC(name, behavior_fn)
|
||||||
-- mobs:register_simple_mob(mn..":"..name, {
|
-- mobs:register_simple_mob(mn..":"..name, {
|
||||||
mobehavior:register_mob_fast(mn..":"..name, {
|
mobehavior:register_mob_fast(mn..":"..name, {
|
||||||
type = "monster",
|
type = "monster",
|
||||||
|
name = name,
|
||||||
climbs_ladders = true,
|
climbs_ladders = true,
|
||||||
passive = false,
|
passive = false,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
|
|
67
spawning.lua
67
spawning.lua
|
@ -65,12 +65,22 @@ minetest.register_abm({
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local nearobjs = minetest.get_objects_inside_radius(pos, 50)
|
local nearobjs = minetest.get_objects_inside_radius(pos, 40)
|
||||||
if #nearobjs > 3 then
|
if #nearobjs > 0 then
|
||||||
-- print("too many near objs")
|
-- print("------")
|
||||||
|
for _,o in ipairs(nearobjs) do
|
||||||
|
local p = o:get_luaentity()
|
||||||
|
if p and p.name == "wolf" then
|
||||||
|
count = count + 1
|
||||||
|
if count > 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("too many near objs")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--print("----------spawning rat")
|
--print("----------spawning rat")
|
||||||
local p = minetest.find_node_near(pos, 3, "air")
|
local p = minetest.find_node_near(pos, 3, "air")
|
||||||
if p then
|
if p then
|
||||||
|
@ -92,8 +102,8 @@ minetest.register_abm({
|
||||||
"default:silver_sand",
|
"default:silver_sand",
|
||||||
},
|
},
|
||||||
neighbors = {"air"},
|
neighbors = {"air"},
|
||||||
interval = 45,
|
interval = 4,
|
||||||
chance = 800,
|
chance = 80,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
@ -117,3 +127,48 @@ minetest.register_abm({
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- brown bears
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {
|
||||||
|
"default:dirt_with_grass",
|
||||||
|
"seasons:spring_default_dirt_with_grass",
|
||||||
|
"default:dirt_with_coniferous_litter",
|
||||||
|
},
|
||||||
|
neighbors = {"air"},
|
||||||
|
interval = 6,
|
||||||
|
chance = 150,
|
||||||
|
catch_up = false,
|
||||||
|
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
if active_object_count > 5 then
|
||||||
|
--print("too many local objs " .. active_object_count)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local nearobjs = minetest.get_objects_inside_radius(pos, 40)
|
||||||
|
if #nearobjs > 0 then
|
||||||
|
-- print("------")
|
||||||
|
for _,o in ipairs(nearobjs) do
|
||||||
|
local p = o:get_luaentity()
|
||||||
|
if p and p.name == "bear" then
|
||||||
|
count = count + 1
|
||||||
|
if count > 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("too many near objs")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("----------spawning rat")
|
||||||
|
local p = minetest.find_node_near(pos, 3, "air")
|
||||||
|
if p then
|
||||||
|
local mob = minetest.add_entity(p, "mobehavior:bear")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue