1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-05 10:00:26 +01:00

update mobs mod

This commit is contained in:
crabman77 2015-12-18 21:13:20 +01:00
parent 76e04ab1ae
commit 220d4f9f60
20 changed files with 211 additions and 90 deletions

View File

@ -28,6 +28,7 @@ This mod contains the following additions:
Changelog:
1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
1.18- Added docile_by_day flag so that monsters will not attack automatically during daylight hours unless hit first

View File

@ -1,4 +1,4 @@
-- Mobs Api (15th December 2015)
-- Mobs Api (18th December 2015)
mobs = {}
mobs.mod = "redo"
@ -234,6 +234,30 @@ function within_limits(pos, radius)
return false -- beyond limits
end
-- is mob facing a cliff
local function is_at_cliff(self)
if self.fear_height == 0 then -- if 0, no falling protection!
return false
end
local yaw = self.object:getyaw()
local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)
local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)
local pos = self.object:getpos()
local ypos = pos.y + self.collisionbox[2] -- just above floor
if minetest.line_of_sight(
{x = pos.x + dir_x, y = ypos, z = pos.z + dir_z},
{x = pos.x + dir_x, y = ypos - self.fear_height, z = pos.z + dir_z}
, 1) then
return true
end
return false
end
-- environmental damage (water, lava, fire, light)
do_env_damage = function(self)
@ -307,9 +331,10 @@ do_jump = function(self)
end
local pos = self.object:getpos()
local temp_Y = pos.y
-- what is mob standing on?
pos.y = (pos.y + self.collisionbox[2]) - 0.2
pos.y = (temp_Y + self.collisionbox[2]) - 0.2
local nod = node_ok(pos)
@ -340,6 +365,9 @@ do_jump = function(self)
local v = self.object:getvelocity()
-- move back a bit - allows jump velocity to carry it forward and succeed better
self.object:setpos({x=pos.x - self.direction.x/2, y=temp_Y, z=pos.z - self.direction.z/2})
v.y = self.jump_height + 1
v.x = v.x * 2.2
v.z = v.z * 2.2
@ -619,6 +647,8 @@ minetest.register_entity(name, {
stepheight = def.stepheight or 0.6,
name = name,
type = def.type,
attack_type = def.attack_type,
fly = def.fly,
fly_in = def.fly_in or "air",
owner = def.owner or "",
@ -650,8 +680,6 @@ minetest.register_entity(name, {
drops = def.drops or {},
armor = def.armor,
on_rightclick = def.on_rightclick,
type = def.type,
attack_type = def.attack_type,
arrow = def.arrow,
shoot_interval = def.shoot_interval,
sounds = def.sounds or {},
@ -688,6 +716,7 @@ minetest.register_entity(name, {
child_texture = def.child_texture,
docile_by_day = def.docile_by_day or false,
time_of_day = 0.5,
fear_height = def.fear_height or 0,
on_step = function(self, dtime)
@ -1102,15 +1131,12 @@ minetest.register_entity(name, {
set_animation(self, "stand")
-- npc's ordered to stand stay standing
if self.type == "npc"
and self.order == "stand" then
if self.type ~= "npc"
or self.order ~= "stand" then
set_velocity(self, 0)
self.state = "stand"
set_animation(self, "stand")
else
if self.walk_chance ~= 0
and math.random(1, 100) <= self.walk_chance then
and math.random(1, 100) <= self.walk_chance
and is_at_cliff(self) == false then
set_velocity(self, self.walk_velocity)
self.state = "walk"
@ -1168,8 +1194,13 @@ minetest.register_entity(name, {
self.object:setyaw(yaw)
end
-- stand for great fall in front
local temp_is_cliff = is_at_cliff(self)
-- jump when walking comes to a halt
if self.jump and get_velocity(self) <= 0.5
if temp_is_cliff == false
and self.jump
and get_velocity(self) <= 0.5
and self.object:getvelocity().y == 0 then
self.direction = {
@ -1181,14 +1212,15 @@ minetest.register_entity(name, {
do_jump(self)
end
set_velocity(self, self.walk_velocity)
set_animation(self, "walk")
if math.random(1, 100) <= 30 then
if temp_is_cliff
or math.random(1, 100) <= 30 then
set_velocity(self, 0)
self.state = "stand"
set_animation(self, "stand")
else
set_velocity(self, self.walk_velocity)
set_animation(self, "walk")
end
-- attack routines (explode, dogfight, shoot, dogshoot)
@ -1406,8 +1438,14 @@ minetest.register_entity(name, {
do_jump(self)
end
set_velocity(self, self.run_velocity)
set_animation(self, "run")
if is_at_cliff(self) then
set_velocity(self, 0)
set_animation(self, "stand")
else
set_velocity(self, self.run_velocity)
set_animation(self, "run")
end
else

View File

@ -35,12 +35,16 @@ mobs:register_mob("mobs:bunny", {
water_damage = 1,
lava_damage = 4,
light_damage = 0,
fear_height = 2,
-- model animation
animation = {
speed_normal = 15,
stand_start = 1, stand_end = 15,
walk_start = 16, walk_end = 24,
punch_start = 16, punch_end = 24,
stand_start = 1,
stand_end = 15,
walk_start = 16,
walk_end = 24,
punch_start = 16,
punch_end = 24,
},
-- follows carrot from farming redo
follow = {"farming:carrot", "farming_plus:carrot_item"},

View File

@ -157,7 +157,7 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
local ent = obj:get_luaentity()
local dir = player:get_look_dir()
ent.velocity = egg_VELOCITY -- needed for api internal timing
ent.switch = 1
ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({
x = dir.x * egg_VELOCITY,
y = dir.y * egg_VELOCITY,

View File

@ -64,6 +64,7 @@ mobs:register_mob("mobs:cow", {
replace_rate = 10,
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
replace_with = "air",
fear_height = 2,
on_rightclick = function(self, clicker)
if not mobs:feed_tame(self, clicker, 8, true, true) then
local tool = clicker:get_wielded_item()

View File

@ -45,11 +45,16 @@ mobs:register_mob("mobs:creeper", {
light_damage = 0,
-- model animation
animation = {
stand_start = 0, stand_end = 24,
walk_start = 25, walk_end = 47,
run_start = 48, run_end = 62,
punch_start = 48, punch_end = 62,
speed_normal = 15, speed_run = 15,
stand_start = 0,
stand_end = 24,
walk_start = 25,
walk_end = 47,
run_start = 48,
run_end = 62,
punch_start = 48,
punch_end = 62,
speed_normal = 15,
speed_run = 15,
},
})
mobs:spawn_specific("mobs:creeper", {"default:dirt_with_grass"}, {"air"}, 8, 20, 30, 20000, 1, -31000, 31000, false)

View File

@ -42,15 +42,22 @@ mobs:register_mob("mobs:dirt_monster", {
water_damage = 1,
lava_damage = 5,
light_damage = 2,
fear_height = 3,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 14,
walk_start = 15, walk_end = 38,
run_start = 40, run_end = 63,
punch_start = 40, punch_end = 63,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 14,
walk_start = 15,
walk_end = 38,
run_start = 40,
run_end = 63,
punch_start = 40,
punch_end = 63,
},
})
-- spawn on dirt_with_grass and drygrass between -1 and 5 light, 1 in 10000 change, 1 dirt monster in area up to 31000 in height
mobs:spawn_specific("mobs:dirt_monster", {"default:dirt_with_grass", "default:dirt_with_dry_grass"}, {"air"}, -1, 5, 30, 10000, 1, -31000, 31000, false)
-- register spawn egg

View File

@ -60,12 +60,17 @@ mobs:register_mob("mobs:dungeon_master", {
water_damage = 1,
lava_damage = 1,
light_damage = 0,
fear_height = 3,
-- model animation
animation = {
stand_start = 0, stand_end = 19,
walk_start = 20, walk_end = 35,
punch_start = 36, punch_end = 48,
speed_normal = 15, speed_run = 15,
stand_start = 0,
stand_end = 19,
walk_start = 20,
walk_end = 35,
punch_start = 36,
punch_end = 48,
speed_normal = 15,
speed_run = 15,
},
})
-- spawn on stone between 20 and -1 light, 1 in 7000 chance, 1 dungeon master in area starting at -100 and below

View File

@ -36,11 +36,14 @@ mobs:register_mob("mobs:kitten", {
-- damaged by
water_damage = 1,
lava_damage = 5,
fear_height = 3,
-- model animation
animation = {
speed_normal = 42,
stand_start = 97, stand_end = 192,
walk_start = 0, walk_end = 96,
stand_start = 97,
stand_end = 192,
walk_start = 0,
walk_end = 96,
},
-- follows Rat and Raw Fish
follow = {"mobs:rat", "ethereal:fish_raw"},

View File

@ -45,11 +45,16 @@ mobs:register_mob("mobs:lava_flan", {
light_damage = 0,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 8,
walk_start = 10, walk_end = 18,
run_start = 20, run_end = 28,
punch_start = 20, punch_end = 28,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 8,
walk_start = 10,
walk_end = 18,
run_start = 20,
run_end = 28,
punch_start = 20,
punch_end = 28,
},
-- do things when die
on_die = function(self, pos)

View File

@ -65,16 +65,23 @@ mobs:register_mob("mobs:npc", {
-- set owner and order
owner = "",
order = "follow",
fear_height = 3,
-- model animation
animation = {
speed_normal = 30, speed_run = 30,
stand_start = 0, stand_end = 79,
walk_start = 168, walk_end = 187,
run_start = 168, run_end = 187,
punch_start = 200, punch_end = 219,
speed_normal = 30,
speed_run = 30,
stand_start = 0,
stand_end = 79,
walk_start = 168,
walk_end = 187,
run_start = 168,
run_end = 187,
punch_start = 200,
punch_end = 219,
},
-- right clicking with "cooked meat" or "bread" will give npc more health
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
local name = clicker:get_player_name()
if item:get_name() == "default:diamond" then --/MFF (Crabman|07/14/2015) tamed with diamond
@ -102,7 +109,7 @@ mobs:register_mob("mobs:npc", {
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {
name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]
name = mobs.npc_drops[math.random(1, #mobs.npc_drops)]
})
return
-- if owner switch between follow and stand

View File

@ -69,16 +69,23 @@ mobs:register_mob("mobs:npc_female", {
-- set owner and order
owner = "",
order = "follow",
fear_height = 3,
-- model animation
animation = {
speed_normal = 30, speed_run = 30,
stand_start = 0, stand_end = 79,
walk_start = 168, walk_end = 187,
run_start = 168, run_end = 187,
punch_start = 200, punch_end = 219,
speed_normal = 30,
speed_run = 30,
stand_start = 0,
stand_end = 79,
walk_start = 168,
walk_end = 187,
run_start = 168,
run_end = 187,
punch_start = 200,
punch_end = 219,
},
-- right clicking with "cooked meat" or "bread" will give npc more health
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
local name = clicker:get_player_name()
if item:get_name() == "default:diamond" then --/MFF (Crabman|07/14/2015) tamed with diamond
@ -105,7 +112,9 @@ mobs:register_mob("mobs:npc_female", {
end
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
minetest.add_item(pos, {
name = mobs.npc_drops[math.random(1, #mobs.npc_drops)]
})
return
-- if owner switch between follow and stand
elseif self.owner and self.owner == clicker:get_player_name() then

View File

@ -46,11 +46,16 @@ mobs:register_mob("mobs:oerkki", {
light_damage = 1,
-- model animation
animation = {
stand_start = 0, stand_end = 23,
walk_start = 24, walk_end = 36,
run_start = 37, run_end = 49,
punch_start = 37, punch_end = 49,
speed_normal = 15, speed_run = 15,
stand_start = 0,
stand_end = 23,
walk_start = 24,
walk_end = 36,
run_start = 37,
run_end = 49,
punch_start = 37,
punch_end = 49,
speed_normal = 15,
speed_run = 15,
},
-- replace torch with air (remove)
replace_rate = 50,

View File

@ -33,6 +33,7 @@ mobs:register_mob("mobs:rat", {
water_damage = 0,
lava_damage = 4,
light_damage = 0,
fear_height = 2,
-- right click to pick up rat
on_rightclick = function(self, clicker)
mobs:capture_mob(self, clicker, 25, 80, 0, true, nil)

View File

@ -43,13 +43,19 @@ mobs:register_mob("mobs:sand_monster", {
water_damage = 3,
lava_damage = 4,
light_damage = 0,
fear_height = 3,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 39,
walk_start = 41, walk_end = 72,
run_start = 74, run_end = 105,
punch_start = 74, punch_end = 105,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 39,
walk_start = 41,
walk_end = 72,
run_start = 74,
run_end = 105,
punch_start = 74,
punch_end = 105,
},
})
-- spawns on desert sand between -1 and 20 light, 1 in 15000 chance, 1 sand monster in area up to 31000 in height

View File

@ -18,7 +18,8 @@ for _, col in ipairs(all_colours) do
hp_max = 15,
armor = 200,
-- textures and model
collisionbox = {-0.4, -1, -0.4, 0.4, 0.3, 0.4},
--collisionbox = {-0.4, -1, -0.4, 0.4, 0.3, 0.4},
collisionbox = {-0.5, -1, -0.5, 0.5, 0.3, 0.5},
visual = "mesh",
mesh = "mobs_sheep.b3d",
textures = {
@ -49,9 +50,12 @@ for _, col in ipairs(all_colours) do
light_damage = 0,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 80,
walk_start = 81, walk_end = 100,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 80,
walk_start = 81,
walk_end = 100,
},
follow = {"farming:wheat", "default:grass_5"},
view_range = 8,
@ -61,6 +65,7 @@ for _, col in ipairs(all_colours) do
replace_with = "air",
-- right click sheep to shear sheep and get wood, feed 8 wheat for wool to grow back
replace_offset = -1,
fear_height = 3,
on_rightclick = function(self, clicker)
local shpcolor = string.split(self.name,"_")[2]
if shpcolor =="dark" then
@ -89,7 +94,7 @@ for _, col in ipairs(all_colours) do
if minetest.get_modpath("wool") then
local pos = self.object:getpos()
pos.y = pos.y + 0.5
local obj = minetest.add_item(pos, ItemStack("wool:"..shpcolor.." "..math.random(2,3)))
local obj = minetest.add_item(pos, ItemStack("wool:"..shpcolor.." "..math.random(1,3)))
if obj then
obj:setvelocity({
x = math.random(-1,1),

View File

@ -20,7 +20,7 @@ mobs:register_mob("mobs:spider", {
textures = {
{"mobs_spider.png"},
},
visual_size = {x=7,y=7},
visual_size = {x = 7, y = 7},
blood_texture = "mobs_blood.png",
-- sounds
makes_footstep_sound = true,
@ -37,7 +37,7 @@ mobs:register_mob("mobs:spider", {
view_range = 16,
floats = 0,
-- drops string with a chance of sandstone or crystal spike if Ethereal installed
drops = {
drops = {
{name = "farming:string",
chance = 2, min = 1, max = 3,},
{name = "mobs:meat_raw",
@ -51,11 +51,16 @@ mobs:register_mob("mobs:spider", {
light_damage = 0,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 1, stand_end = 1,
walk_start = 20, walk_end = 40,
run_start = 20, run_end = 40,
punch_start = 50, punch_end = 90,
speed_normal = 15,
speed_run = 15,
stand_start = 1,
stand_end = 1,
walk_start = 20,
walk_end = 40,
run_start = 20,
run_end = 40,
punch_start = 50,
punch_end = 90,
},
})
-- spawn on jungleleaves/jungletree, between 0 and 5 light, 1 in 10000 chance, 1 in area up to 31000 in height

View File

@ -50,11 +50,16 @@ mobs:register_mob("mobs:stone_monster", {
light_damage = 0,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 14,
walk_start = 15, walk_end = 38,
run_start = 40, run_end = 63,
punch_start = 40, punch_end = 63,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 14,
walk_start = 15,
walk_end = 38,
run_start = 40,
run_end = 63,
punch_start = 40,
punch_end = 63,
},
})
-- spawns on stone between -1 and 5 light, 1 in 7000 chance, 1 in area below -25

View File

@ -51,11 +51,16 @@ mobs:register_mob("mobs:tree_monster", {
fall_damage = 0,
-- model animation
animation = {
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 24,
walk_start = 25, walk_end = 47,
run_start = 48, run_end = 62,
punch_start = 48, punch_end = 62,
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 24,
walk_start = 25,
walk_end = 47,
run_start = 48,
run_end = 62,
punch_start = 48,
punch_end = 62,
},
})
-- spawn on leaves and beech_leaves, between 0 and 5 light, 1 in 8000 chance, 1 in area up to 31000 in height

View File

@ -47,12 +47,16 @@ mobs:register_mob("mobs:pumba", {
water_damage = 1,
lava_damage = 5,
light_damage = 0,
fear_height = 2,
-- model animation
animation = {
speed_normal = 15,
stand_start = 25, stand_end = 55,
walk_start = 70, walk_end = 100,
punch_start = 70, punch_end = 100,
stand_start = 25,
stand_end = 55,
walk_start = 70,
walk_end = 100,
punch_start = 70,
punch_end = 100,
},
-- can be tamed by feeding 8 wheat (will not attack when tamed)
on_rightclick = function(self, clicker)