commit
98e00b074f
131
init.lua
131
init.lua
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
local abr = minetest.get_mapgen_setting('active_block_range')
|
local abr = minetest.get_mapgen_setting('active_block_range')
|
||||||
|
local nodename_water = minetest.registered_aliases.mapgen_water_source
|
||||||
|
|
||||||
local zombiestrd = {}
|
local zombiestrd = {}
|
||||||
--zombiestrd.spawn_rate = 0.4 -- less is more
|
--zombiestrd.spawn_rate = 0.4 -- less is more
|
||||||
|
@ -128,6 +129,25 @@ local function zombie_brain(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function shark_brain(self)
|
||||||
|
if self.hp <= 0 then
|
||||||
|
mobkit.clear_queue_high(self)
|
||||||
|
mobkit.hq_die(self)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if mobkit.timer(self,1) then
|
||||||
|
local prty = mobkit.get_queue_priority(self)
|
||||||
|
if prty < 20 then
|
||||||
|
local target = mobkit.get_nearby_player(self)
|
||||||
|
if target and mobkit.is_alive(target) and mobkit.is_in_deep(target) then
|
||||||
|
mobkit.clear_queue_high(self)
|
||||||
|
mobkit.hq_aqua_attack(self,20,target,7)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if mobkit.is_queue_empty_high(self) then mobkit.hq_aqua_roam(self,10,5) end
|
||||||
|
end
|
||||||
-- spawning is too specific to be included in the api, this is an example.
|
-- spawning is too specific to be included in the api, this is an example.
|
||||||
-- a modder will want to refer to specific names according to games/mods they're using
|
-- a modder will want to refer to specific names according to games/mods they're using
|
||||||
-- in order for mobs not to spawn on treetops, certain biomes etc.
|
-- in order for mobs not to spawn on treetops, certain biomes etc.
|
||||||
|
@ -153,17 +173,36 @@ local function spawnstep(dtime)
|
||||||
pos2.y=pos2.y-5
|
pos2.y=pos2.y-5
|
||||||
local height, liquidflag = mobkit.get_terrain_height(pos2,32)
|
local height, liquidflag = mobkit.get_terrain_height(pos2,32)
|
||||||
|
|
||||||
if height and height >= 0 and not liquidflag -- and math.abs(height-pos2.y) <= 30 testin
|
if height and --height >= 0 and
|
||||||
and mobkit.nodeatpos({x=pos2.x,y=height-0.01,z=pos2.z}).is_ground_content then
|
mobkit.nodeatpos({x=pos2.x,y=height-0.01,z=pos2.z}).is_ground_content then
|
||||||
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos,abr*16+5)
|
local objs = minetest.get_objects_inside_radius(pos,abr*16+5)
|
||||||
local wcnt=0
|
local wcnt=0
|
||||||
local dcnt=0
|
local dcnt=0
|
||||||
for _,obj in ipairs(objs) do -- count mobs in abrange
|
local mobname = 'zombiestrd:zombie'
|
||||||
if not obj:is_player() then
|
if liquidflag then -- sharks
|
||||||
local entity = obj:get_luaentity()
|
local spnode = mobkit.nodeatpos({x=pos2.x,y=height+0.01,z=pos2.z})
|
||||||
if entity and entity.name:find('zombiestrd:') then
|
local spnode2 = mobkit.nodeatpos({x=pos2.x,y=height+1.01,z=pos2.z}) -- node above to make sure won't spawn in shallows
|
||||||
chance=chance + (1-chance)*spawn_reduction -- chance reduced for every mob in range
|
nodename_water = nodename_water or minetest.registered_aliases.mapgen_water_source
|
||||||
|
if spnode and spnode2 and spnode.name == nodename_water and spnode2.name == nodename_water then
|
||||||
|
for _,obj in ipairs(objs) do
|
||||||
|
if not obj:is_player() then
|
||||||
|
local entity = obj:get_luaentity()
|
||||||
|
if entity and entity.name=='zombiestrd:shark' then return end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mobname = 'zombiestrd:shark'
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif height >= 0 then --zombies
|
||||||
|
for _,obj in ipairs(objs) do -- count mobs in abrange
|
||||||
|
if not obj:is_player() then
|
||||||
|
local entity = obj:get_luaentity()
|
||||||
|
if entity and entity.name:find('zombiestrd:') then
|
||||||
|
chance=chance + (1-chance)*spawn_reduction -- chance reduced for every mob in range
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -173,14 +212,7 @@ local function spawnstep(dtime)
|
||||||
for _,obj in ipairs(objs) do -- do not spawn if another player around
|
for _,obj in ipairs(objs) do -- do not spawn if another player around
|
||||||
if obj:is_player() then return end
|
if obj:is_player() then return end
|
||||||
end
|
end
|
||||||
local obj=minetest.add_entity(pos2,'zombiestrd:zombie') -- ok spawn it already damnit
|
local obj=minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
|
||||||
--[[ local props = obj:get_properties()
|
|
||||||
if #props.textures > 1 then
|
|
||||||
-- local hp=obj:get_hp() --wth?
|
|
||||||
props.textures[1]=props.textures[math.random(#props.textures)]
|
|
||||||
obj:set_properties(props)
|
|
||||||
-- obj:set_hp(hp) --wth?
|
|
||||||
end --]]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -230,13 +262,6 @@ minetest.register_entity("zombiestrd:zombie",{
|
||||||
walk={range={x=41,y=101},speed=40,loop=true},
|
walk={range={x=41,y=101},speed=40,loop=true},
|
||||||
stand={range={x=0,y=40},speed=1,loop=true},
|
stand={range={x=0,y=40},speed=1,loop=true},
|
||||||
},
|
},
|
||||||
-- animation = {
|
|
||||||
-- walk={
|
|
||||||
-- {range={x=41,y=101},speed=30,loop=true},
|
|
||||||
-- {range={x=41,y=101},speed=90,loop=true},
|
|
||||||
-- },
|
|
||||||
-- stand={range={x=0,y=40},speed=1,loop=true},
|
|
||||||
-- },
|
|
||||||
|
|
||||||
sounds = {
|
sounds = {
|
||||||
misc='zombie',
|
misc='zombie',
|
||||||
|
@ -288,4 +313,64 @@ minetest.register_entity("zombiestrd:zombie",{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("zombiestrd:shark",{
|
||||||
|
-- common props
|
||||||
|
physical = true,
|
||||||
|
stepheight = 0.1, --EVIL!
|
||||||
|
collide_with_objects = true,
|
||||||
|
collisionbox = {-0.5, -0.3, -0.5, 0.5, 0.3, 0.5},
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "shark.b3d",
|
||||||
|
textures = {"shark3tex.png"},
|
||||||
|
visual_size = {x = 1.5, y = 1.5},
|
||||||
|
static_save = true,
|
||||||
|
makes_footstep_sound = true,
|
||||||
|
on_step = mobkit.stepfunc, -- required
|
||||||
|
on_activate = mobkit.actfunc, -- required
|
||||||
|
get_staticdata = mobkit.statfunc,
|
||||||
|
-- api props
|
||||||
|
springiness=0,
|
||||||
|
buoyancy = 0.98, -- portion of hitbox submerged
|
||||||
|
max_speed = 5,
|
||||||
|
jump_height = 1.26,
|
||||||
|
view_range = 24,
|
||||||
|
-- lung_capacity = 0, -- seconds
|
||||||
|
max_hp = 20,
|
||||||
|
timeout=600,
|
||||||
|
attack={range=0.8,damage_groups={fleshy=7}},
|
||||||
|
sounds = {
|
||||||
|
attack='sharkattack',
|
||||||
|
},
|
||||||
|
animation = {
|
||||||
|
def={range={x=1,y=59},speed=40,loop=true},
|
||||||
|
fast={range={x=1,y=59},speed=80,loop=true},
|
||||||
|
back={range={x=15,y=1},speed=-15,loop=false},
|
||||||
|
},
|
||||||
|
|
||||||
|
brainfunc = shark_brain,
|
||||||
|
|
||||||
|
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
|
if mobkit.is_alive(self) then
|
||||||
|
local hvel = vector.multiply(vector.normalize({x=dir.x,y=0,z=dir.z}),4)
|
||||||
|
self.object:set_velocity({x=hvel.x,y=2,z=hvel.z})
|
||||||
|
|
||||||
|
mobkit.hurt(self,tool_capabilities.damage_groups.fleshy or 1)
|
||||||
|
|
||||||
|
if type(puncher)=='userdata' and puncher:is_player() then -- if hit by a player
|
||||||
|
mobkit.clear_queue_high(self) -- abandon whatever they've been doing
|
||||||
|
mobkit.hq_aqua_attack(self,20,puncher,6) -- get revenge
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
--[[
|
||||||
|
minetest.register_on_chat_message(
|
||||||
|
function(name, message)
|
||||||
|
if message == 'doit' then
|
||||||
|
minetest.chat_send_all(dump(minetest.registered_aliases.mapgen_water_source))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
) --]]
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
name = zombiestrd
|
||||||
|
description = Zombies - The real Deal - Now With Sharks
|
||||||
|
depends = mobkit
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue