1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-01-11 18:40:25 +01:00

MAJ mobs(redo) mod

Added switch to disable mobs in protected areas
This commit is contained in:
Ombridride 2014-12-15 00:17:29 +01:00
parent 2e3f86aaa2
commit 5163bf9551
7 changed files with 10 additions and 211 deletions

View File

@ -25,6 +25,7 @@ This mod contains the following additions:
Changelog:
0.7 - mob.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block
0.5 - Mobs now float in water, die from falling, and some code improvements
0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :)

View File

@ -1,5 +1,7 @@
mobs = {}
mobs.mod = "redo"
mobs.protected = 0 -- Set to 1 if you do not wish mobs to spawn in protected areas (default: 0)
function mobs:register_mob(name, def)
minetest.register_entity(name, {
name = name,
@ -793,6 +795,11 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
return
end
-- Check if protected area using bogus name so mobs will not spawn
if mobs.protected == 1 and minetest.is_protected(pos, "-") then
return
end
pos.y = pos.y+1
if not minetest.get_node_light(pos)

View File

@ -35,7 +35,7 @@ mobs:register_mob("mobs:cow", {
},
-- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk
on_rightclick = function(self, clicker)
tool = clicker:get_wielded_item()
local tool = clicker:get_wielded_item()
if tool:get_name() == "bucket:bucket_empty" then
if self.milked then
do return end

View File

@ -1,4 +1,4 @@
-- Mob Api (15th Oct 2014)
-- Mob Api (10th Dec 2014)
dofile(minetest.get_modpath("mobs").."/api.lua")

View File

@ -1,56 +0,0 @@
-- Oerkki
mobs:register_mob("mobs:oerkki", {
type = "monster",
hp_min = 40,
hp_max = 50,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh",
mesh = "mobs_oerkki.x",
--textures = {"mobs_oerkki.png"},
available_textures = {
total = 2,
texture_1 = {"mobs_oerkki.png"},
texture_2 = {"mobs_oerkki2.png"},
},
visual_size = {x=5, y=5},
makes_footstep_sound = false,
view_range = 16,
walk_velocity = 2,
run_velocity = 4,
damage = 5,
drops = {
{name = "default:obsidian",
chance = 3,
min = 1,
max = 2,},
{name = "maptools:silver_coin",
chance = 2,
min = 2,
max = 3,},
},
armor = 90,
drawtype = "front",
light_resistant = true,
water_damage = 1,
lava_damage = 1,
light_damage = 0,
attack_type = "dogfight",
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,
},
jump = true,
step = 1,
blood_texture = "mobs_blood.png",
})
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 6000, 1, -10)

View File

@ -1,73 +0,0 @@
-- Sheep
mobs:register_mob("mobs:sheep", {
type = "animal",
hp_min = 10,
hp_max = 15,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
textures = {"mobs_sheep.png"},
visual = "mesh",
mesh = "mobs_sheep.x",
makes_footstep_sound = true,
walk_velocity = 1,
armor = 200,
drops = {
{name = "mobs:meat_raw",
chance = 1,
min = 2,
max = 3,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
sounds = {
random = "mobs_sheep",
},
animation = {
speed_normal = 15,
stand_start = 0,
stand_end = 80,
walk_start = 81,
walk_end = 100,
},
jump = true,
step = 1,
blood_texture = "mobs_blood.png",
passive = true,
follow = "farming:wheat",
view_range = 8,
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if item:get_name() == "farming:wheat" 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 >= 8 then
self.food = 0
self.naked = false
self.tamed = true
self.object:set_properties({
textures = {"mobs_sheep.png"},
mesh = "mobs_sheep.x",
})
minetest.sound_play("mobs_sheep", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
end
return
end
if clicker:get_inventory() and not self.naked then
self.naked = true
if minetest.registered_items["wool:white"] then
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
end
self.object:set_properties({
textures = {"mobs_sheep_shaved.png"},
mesh = "mobs_sheep_shaved.x",
})
end
end,
})
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 1, 31000)

View File

@ -1,80 +0,0 @@
-- Warthog
mobs:register_mob("mobs:pumba", {
type = "animal",
hp_min = 10,
hp_max = 15,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
textures = {"mobs_pumba.png"},
visual = "mesh",
mesh = "mobs_pumba.x",
makes_footstep_sound = true,
walk_velocity = 2,
armor = 200,
drops = {
{name = "mobs:pork_raw",
chance = 1,
min = 2,
max = 3,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
sounds = {
random = "mobs_pig",
},
animation = {
speed_normal = 15,
stand_start = 25,
stand_end = 55,
walk_start = 70,
walk_end = 100,
},
follow = "farming:wheat",
view_range = 8,
jump = true,
step = 1,
passive = true,
blood_texture = "mobs_blood.png",
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if item:get_name() == "farming:wheat" 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 >= 8 then
self.food = 0
self.tamed = true
minetest.sound_play("mobs_pig", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
end
return
end
end,
})
mobs:register_spawn("mobs:pumba", {"default:dirt_with_grass", "default:dirt"}, 20, 8, 9000, 1, 31000)
-- Porkchops
minetest.register_craftitem("mobs:pork_raw", {
description = "Raw Porkchop",
inventory_image = "mobs_pork_raw.png",
on_use = minetest.item_eat(4),
})
minetest.register_craftitem("mobs:pork_cooked", {
description = "Cooked Porkchop",
inventory_image = "mobs_pork_cooked.png",
on_use = minetest.item_eat(8),
})
minetest.register_craft({
type = "cooking",
output = "mobs:pork_cooked",
recipe = "mobs:pork_raw",
cooktime = 5,
})