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

Update mods mod

- npc's follow and stand by order
- mob shoot attack rehauled
- velocity changes
- fixed shoot bug
- mob shoot timings fixed
- dungeon master plasma balls less laggy
- DM plama ball less laggy
- added on_die function and jump_height
- Added jump_chance for jumping mods, set walk_chance to 0 when in use
- added jump mobs, footstep nodes, api tweaks
- fixed jump follow and follow jump glitch
- Added rotate to mob definition
- Reworked breeding
- tidied code
- added mobs_enable_blood flag in minetest.conf (true/false)
- tidied code
- Fixed selftimer issue
- beehive cannot be eaten (oops)
- fixed lifetimer bug
- added magic lasso to pick up animals
- pets and chicken can be picked up without magic lasso
- update version
This commit is contained in:
Ombridride 2015-04-11 21:45:03 +02:00
parent a0f14f35f8
commit 4e402c7d3b
21 changed files with 384 additions and 390 deletions

View File

@ -29,6 +29,9 @@ This mod contains the following additions:
Changelog: Changelog:
beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop
1.09- reworked breeding routine, added mob rotation value, added footstep feature, added jumping mobs with sounds feature, added magic lasso for picking up animals
1.08- Mob throwing attack has been rehauled so that they can damage one another, also drops and on_die function added
1.07- Npc's can now be set to follow player or stand by using self.order and self.owner variables
1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal) 1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten 1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten
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.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 :)

View File

@ -1,13 +1,14 @@
-- Mobs Api (2nd April 2015) -- Mobs Api (11th April 2015)
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
-- Do mobs spawn in protected areas (0=yes, 1=no) -- Do mobs spawn in protected areas (0=yes, 1=no)
mobs.protected = 0 mobs.protected = 0
-- Initial check to see if damage is enabled and peaceful mode active -- Initial settings check
local damage_enabled = minetest.setting_getbool("enable_damage") local damage_enabled = minetest.setting_getbool("enable_damage")
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs") local peaceful_only = minetest.setting_getbool("only_peaceful_mobs")
local enable_blood = minetest.setting_getbool("mobs_enable_blood") or true
function mobs:register_mob(name, def) function mobs:register_mob(name, def)
minetest.register_entity(name, { minetest.register_entity(name, {
@ -15,7 +16,12 @@ function mobs:register_mob(name, def)
owner = def.owner, owner = def.owner,
order = def.order or "", order = def.order or "",
on_die = def.on_die,
jump_height = def.jump_height or 6,
jump_chance = def.jump_chance or 0,
footstep = def.footstep,
rotate = def.rotate or 0, -- 0=front, 1.5=side, 3.0=back, 4.5=side2
lifetimer = def.lifetimer or 600,
hp_min = def.hp_min or 5, hp_min = def.hp_min or 5,
hp_max = def.hp_max or 10, hp_max = def.hp_max or 10,
physical = true, physical = true,
@ -23,19 +29,19 @@ function mobs:register_mob(name, def)
visual = def.visual, visual = def.visual,
visual_size = def.visual_size or {x=1, y=1}, visual_size = def.visual_size or {x=1, y=1},
mesh = def.mesh, mesh = def.mesh,
makes_footstep_sound = def.makes_footstep_sound, makes_footstep_sound = def.makes_footstep_sound or true,
view_range = def.view_range or 5, view_range = def.view_range or 5,
walk_velocity = def.walk_velocity, walk_velocity = def.walk_velocity or 1,
run_velocity = def.run_velocity, run_velocity = def.run_velocity or 2,
damage = def.damage, damage = def.damage,
light_damage = def.light_damage, light_damage = def.light_damage,
water_damage = def.water_damage, water_damage = def.water_damage,
lava_damage = def.lava_damage, lava_damage = def.lava_damage,
fall_damage = def.fall_damage or 1, fall_damage = def.fall_damage or 1,
fall_speed = def.fall_speed or -10, -- must be lower than -2 fall_speed = def.fall_speed or -10, -- must be lower than -2
drops = def.drops, drops = def.drops or {},
armor = def.armor, armor = def.armor,
drawtype = def.drawtype, --drawtype = def.drawtype,
on_rightclick = def.on_rightclick, on_rightclick = def.on_rightclick,
type = def.type, type = def.type,
attack_type = def.attack_type, attack_type = def.attack_type,
@ -60,17 +66,11 @@ function mobs:register_mob(name, def)
replace_what = def.replace_what, replace_what = def.replace_what,
replace_with = def.replace_with, replace_with = def.replace_with,
replace_offset = def.replace_offset or 0, replace_offset = def.replace_offset or 0,
stimer = 0,
timer = 0, timer = 0,
env_damage_timer = 0, -- only if state = "attack" env_damage_timer = 0, -- only if state = "attack"
attack = {player=nil, dist=nil}, attack = {player=nil, dist=nil},
state = "stand", state = "stand",
v_start = false,
old_y = nil,
lifetimer = 600,
tamed = false, tamed = false,
last_state = nil,
pause_timer = 0, pause_timer = 0,
horny = false, horny = false,
hornytimer = 0, hornytimer = 0,
@ -80,7 +80,8 @@ function mobs:register_mob(name, def)
do_attack = function(self, player, dist) do_attack = function(self, player, dist)
if self.state ~= "attack" then if self.state ~= "attack" then
if math.random(0,100) < 90 and self.sounds.war_cry then if math.random(0,100) < 90 and self.sounds.war_cry then
minetest.sound_play(self.sounds.war_cry,{ object = self.object }) minetest.sound_play(self.sounds.war_cry,{object = self.object})
print ("attack sound")
end end
self.state = "attack" self.state = "attack"
self.attack.player = player self.attack.player = player
@ -90,10 +91,8 @@ function mobs:register_mob(name, def)
set_velocity = function(self, v) set_velocity = function(self, v)
if not v then v = 0 end -- added if not v then v = 0 end -- added
local yaw = self.object:getyaw() if def.drawtype and def.drawtype == "side" then self.rotate = 1.5 end
if self.drawtype == "side" then local yaw = self.object:getyaw() + self.rotate
yaw = yaw+(math.pi/2)
end
local x = math.sin(yaw) * -v local x = math.sin(yaw) * -v
local z = math.cos(yaw) * v local z = math.cos(yaw) * v
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z}) self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
@ -106,10 +105,7 @@ function mobs:register_mob(name, def)
--[[ --[[
in_fov = function(self,pos) in_fov = function(self,pos)
-- checks if POS is in self's FOV -- checks if POS is in self's FOV
local yaw = self.object:getyaw() local yaw = self.object:getyaw() + self.rotate
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
local vx = math.sin(yaw) local vx = math.sin(yaw)
local vz = math.cos(yaw) local vz = math.cos(yaw)
local ds = math.sqrt(vx^2 + vz^2) local ds = math.sqrt(vx^2 + vz^2)
@ -168,29 +164,31 @@ function mobs:register_mob(name, def)
if self.type == "monster" and peaceful_only then if self.type == "monster" and peaceful_only then
self.object:remove() self.object:remove()
return
end end
self.lifetimer = self.lifetimer - dtime -- if lifetimer run out and not npc, tamed or attacking then remove mob
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then if self.type ~= "npc" and not self.tamed then
local player_count = 0 self.lifetimer = self.lifetimer - dtime
for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do if self.lifetimer <= 0 and self.state ~= "attack" then
if obj:is_player() then for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
player_count = player_count + 1 if obj:is_player() then
break -- only really need 1 player to be found minetest.log("action","lifetimer expired, removed mob "..self.name)
self.object:remove()
return
end
end end
end end
if player_count == 0 and self.state ~= "attack" then
minetest.log("action","lifetimer expired, removed mob "..self.name)
self.object:remove()
return
end
end end
-- check for mob drop/replace (used for chicken egg and sheep eating grass/wheat) -- 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 and self.child == false 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 local pos = self.object:getpos() ; pos.y = pos.y + self.replace_offset
if self.footstep and self.object:getvelocity().y == 0 then minetest.set_node(pos, {name = self.footstep}) end
if #minetest.find_nodes_in_area(pos,pos,self.replace_what) > 0 if #minetest.find_nodes_in_area(pos,pos,self.replace_what) > 0
and self.object:getvelocity().y == 0 and self.state == "stand" then and self.object:getvelocity().y == 0
and self.replace_what
and self.state == "stand" then
minetest.set_node(pos, {name = self.replace_with}) minetest.set_node(pos, {name = self.replace_with})
end end
end end
@ -216,8 +214,7 @@ function mobs:register_mob(name, def)
self.old_y = self.object:getpos().y self.old_y = self.object:getpos().y
end end
-- if pause state then this is where the loop ends -- knock back timer
-- pause is only set after a monster is hit
if self.pause_timer > 0 then if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime self.pause_timer = self.pause_timer - dtime
if self.pause_timer < 1 then if self.pause_timer < 1 then
@ -226,6 +223,7 @@ function mobs:register_mob(name, def)
return return
end end
-- attack timer
self.timer = self.timer + dtime self.timer = self.timer + dtime
if self.state ~= "attack" then if self.state ~= "attack" then
if self.timer < 1 then if self.timer < 1 then
@ -234,7 +232,7 @@ function mobs:register_mob(name, def)
self.timer = 0 self.timer = 0
end end
if self.sounds and self.sounds.random and math.random(1, 100) <= 1 then if self.sounds.random and math.random(1, 100) <= 1 then
minetest.sound_play(self.sounds.random, {object = self.object}) minetest.sound_play(self.sounds.random, {object = self.object})
end end
@ -268,6 +266,22 @@ function mobs:register_mob(name, def)
check_for_death(self) check_for_death(self)
end end
local do_jump = function(self)
local pos = self.object:getpos()
pos.y = pos.y - (-self.collisionbox[2] + self.collisionbox[5])
local nod = minetest.get_node(pos)
if not nod or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == false then return end
local v = self.object:getvelocity()
v.y = self.jump_height
if self.following then v.y = v.y + 1 end
self.object:setvelocity(v)
if self.sounds.jump then
minetest.sound_play(self.sounds.jump, {object = self.object})
end
end
-- environmental damage timer
self.env_damage_timer = self.env_damage_timer + dtime self.env_damage_timer = self.env_damage_timer + dtime
if self.state == "attack" and self.env_damage_timer > 1 then if self.state == "attack" and self.env_damage_timer > 1 then
self.env_damage_timer = 0 self.env_damage_timer = 0
@ -276,7 +290,7 @@ function mobs:register_mob(name, def)
do_env_damage(self) do_env_damage(self)
end end
-- FIND SOMEONE TO ATTACK -- find someone to attack
if self.type == "monster" and damage_enabled and self.state ~= "attack" then if self.type == "monster" and damage_enabled and self.state ~= "attack" then
local s = self.object:getpos() local s = self.object:getpos()
@ -314,7 +328,7 @@ function mobs:register_mob(name, def)
end end
end end
-- NPC FIND A MONSTER TO ATTACK -- npc, find monster to attack
if self.type == "npc" and self.attacks_monsters and self.state ~= "attack" then if self.type == "npc" and self.attacks_monsters and self.state ~= "attack" then
local s = self.object:getpos() local s = self.object:getpos()
local obj = nil local obj = nil
@ -357,25 +371,17 @@ function mobs:register_mob(name, def)
-- if animal is horny, find another same animal who is horny and mate -- if animal is horny, find another same animal who is horny and mate
if self.horny == true and self.hornytimer <= 40 then if self.horny == true and self.hornytimer <= 40 then
local pos = self.object:getpos() local pos = self.object:getpos() ; pos.y = pos.y + 1
effect(pos, 4, "heart.png") effect(pos, 4, "heart.png") ; pos.y = pos.y - 1
local ents = minetest.get_objects_inside_radius(pos, self.view_range) local ents = minetest.get_objects_inside_radius(pos, self.view_range)
local num = 0 local num = 0
local ent = nil local ent = nil
for i,obj in ipairs(ents) do for i,obj in ipairs(ents) do
ent = obj:get_luaentity() ent = obj:get_luaentity()
if ent and ent.name == self.name and ent.horny == true and ent.hornytimer <= 40 then num = num + 1 end if ent and ent.name == self.name and ent.horny == true and ent.hornytimer <= 40 then num = num + 1 end
if num > 1 then if num > 1 then
self.following = ent self.hornytimer = 41
ent.following = self ent.hornytimer = 41
self.horny = false
self.hornytimer = 0
self.following = nil
ent.horny = false
ent.following = nil
ent.hornytimer = 0
minetest.after(7, function(dtime) minetest.after(7, function(dtime)
local mob = minetest.add_entity(pos, self.name) local mob = minetest.add_entity(pos, self.name)
local ent2 = mob:get_luaentity() local ent2 = mob:get_luaentity()
@ -399,6 +405,7 @@ function mobs:register_mob(name, def)
end end
end end
-- find player to follow
if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack" then if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack" then
local s, p, dist local s, p, dist
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
@ -416,18 +423,16 @@ function mobs:register_mob(name, def)
-- npc stop following player if not owner -- npc stop following player if not owner
if self.following and self.type == "npc" and self.owner and self.owner ~= self.following:get_player_name() then if self.following and self.type == "npc" and self.owner and self.owner ~= self.following:get_player_name() then
self.following = nil self.following = nil
self.v_start = false
end end
else else
-- stop following player if not holding specific item -- stop following player if not holding specific item
if self.following and self.following.is_player and self.following:get_wielded_item():get_name() ~= self.follow then if self.following and self.following.is_player and self.following:get_wielded_item():get_name() ~= self.follow then
self.following = nil self.following = nil
self.v_start = false
end end
end end
-- follow player or mob
if self.following then if self.following then
local s = self.object:getpos() local s = self.object:getpos()
local p local p
@ -441,13 +446,9 @@ function mobs:register_mob(name, def)
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist > self.view_range then if dist > self.view_range then
self.following = nil self.following = nil
self.v_start = false
else else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2 local yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if p.x > s.x then if p.x > s.x then
yaw = yaw+math.pi yaw = yaw+math.pi
end end
@ -455,23 +456,17 @@ function mobs:register_mob(name, def)
-- anyone but standing npc's can move along -- anyone but standing npc's can move along
if dist > 2 and self.order ~= "stand" then if dist > 2 and self.order ~= "stand" then
if not self.v_start then if (self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0)
self.v_start = true or (self.object:getvelocity().y == 0 and self.jump_chance > 0) then
self.set_velocity(self, self.walk_velocity) do_jump(self)
else end
if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then self.set_velocity(self, self.walk_velocity)
local v = self.object:getvelocity() if self.walk_chance ~= 0 then
v.y = 7 -- 6/6.5 (in older api.lua version) self:set_animation("walk")
self.object:setvelocity(v)
end
self.set_velocity(self, self.walk_velocity)
end end
self:set_animation("walk")
else else
self.v_start = false
self.set_velocity(self, 0) self.set_velocity(self, 0)
self:set_animation("stand") self:set_animation("stand")
end end
return return
end end
@ -499,10 +494,7 @@ function mobs:register_mob(name, def)
if lp ~= nil then if lp ~= nil then
local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z} local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z}
yaw = math.atan(vec.z/vec.x)+math.pi/2 yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if lp.x > s.x then if lp.x > s.x then
yaw = yaw+math.pi yaw = yaw+math.pi
end end
@ -521,11 +513,17 @@ function mobs:register_mob(name, def)
self.state = "stand" self.state = "stand"
self:set_animation("stand") self:set_animation("stand")
else else
if math.random(1, 100) <= self.walk_chance then if self.walk_chance ~= 0 and math.random(1, 100) <= self.walk_chance then
self.set_velocity(self, self.walk_velocity) self.set_velocity(self, self.walk_velocity)
self.state = "walk" self.state = "walk"
self.set_animation(self, "walk") self.set_animation(self, "walk")
end end
-- jumping mobs only
if self.jump_chance ~= 0 and math.random(1, 100) <= self.jump_chance then
do_jump(self)
self.set_velocity(self, self.walk_velocity)
end
end end
elseif self.state == "walk" then elseif self.state == "walk" then
@ -534,10 +532,9 @@ function mobs:register_mob(name, def)
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi)) self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
end end
if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
local v = self.object:getvelocity() do_jump(self)
v.y = 5
self.object:setvelocity(v)
end end
self:set_animation("walk") self:set_animation("walk")
self.set_velocity(self, self.walk_velocity) self.set_velocity(self, self.walk_velocity)
if math.random(1, 100) <= 30 then if math.random(1, 100) <= 30 then
@ -545,7 +542,7 @@ function mobs:register_mob(name, def)
self.state = "stand" self.state = "stand"
self:set_animation("stand") self:set_animation("stand")
end end
elseif self.state == "attack" and self.attack_type == "kamicaze" then elseif self.state == "attack" and self.attack_type == "kamicaze" then --Modif MFF, attack type Creeper
if not self.attack.player or not self.attack.player:is_player() then if not self.attack.player or not self.attack.player:is_player() then
self.state = "stand" self.state = "stand"
self:set_animation("stand") self:set_animation("stand")
@ -684,7 +681,6 @@ function mobs:register_mob(name, def)
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist > self.view_range or self.attack.player:get_hp() <= 0 then if dist > self.view_range or self.attack.player:get_hp() <= 0 then
self.state = "stand" self.state = "stand"
self.v_start = false
self.set_velocity(self, 0) self.set_velocity(self, 0)
self.attack = {player=nil, dist=nil} self.attack = {player=nil, dist=nil}
self:set_animation("stand") self:set_animation("stand")
@ -694,31 +690,22 @@ function mobs:register_mob(name, def)
end end
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2 local yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if p.x > s.x then if p.x > s.x then
yaw = yaw+math.pi yaw = yaw+math.pi
end end
self.object:setyaw(yaw) self.object:setyaw(yaw)
if self.attack.dist > 2 then if self.attack.dist > 2 then
if not self.v_start then -- jump attack
self.v_start = true if (self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0)
self.set_velocity(self, self.run_velocity) or (self.object:getvelocity().y == 0 and self.jump_chance > 0) then
else do_jump(self)
if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
local v = self.object:getvelocity()
v.y = 5
self.object:setvelocity(v)
end
self.set_velocity(self, self.run_velocity)
end end
self.set_velocity(self, self.run_velocity)
self:set_animation("run") self:set_animation("run")
else else
self.set_velocity(self, 0) self.set_velocity(self, 0)
self:set_animation("punch") self:set_animation("punch")
self.v_start = false
if self.timer > 1 then if self.timer > 1 then
self.timer = 0 self.timer = 0
local p2 = p local p2 = p
@ -726,7 +713,7 @@ function mobs:register_mob(name, def)
p2.y = p2.y + 1.5 p2.y = p2.y + 1.5
s2.y = s2.y + 1.5 s2.y = s2.y + 1.5
if minetest.line_of_sight(p2,s2) == true then if minetest.line_of_sight(p2,s2) == true then
if self.sounds and self.sounds.attack then if self.sounds.attack then
minetest.sound_play(self.sounds.attack, {object = self.object}) minetest.sound_play(self.sounds.attack, {object = self.object})
end end
self.attack.player:punch(self.object, 1.0, { self.attack.player:punch(self.object, 1.0, {
@ -755,7 +742,6 @@ function mobs:register_mob(name, def)
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist > self.view_range or self.attack.player:get_hp() <= 0 then if dist > self.view_range or self.attack.player:get_hp() <= 0 then
self.state = "stand" self.state = "stand"
self.v_start = false
self.set_velocity(self, 0) self.set_velocity(self, 0)
if self.type ~= "npc" then if self.type ~= "npc" then
self.attack = {player=nil, dist=nil} self.attack = {player=nil, dist=nil}
@ -767,22 +753,19 @@ function mobs:register_mob(name, def)
end end
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2 local yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if p.x > s.x then if p.x > s.x then
yaw = yaw+math.pi yaw = yaw+math.pi
end end
self.object:setyaw(yaw) self.object:setyaw(yaw)
self.set_velocity(self, 0) self.set_velocity(self, 0)
if self.timer > self.shoot_interval and math.random(1, 100) <= 60 then if self.shoot_interval and self.timer > self.shoot_interval and math.random(1, 100) <= 60 then
self.timer = 0 self.timer = 0
self:set_animation("punch") self:set_animation("punch")
if self.sounds and self.sounds.attack then if self.sounds.attack then
minetest.sound_play(self.sounds.attack, {object = self.object}) minetest.sound_play(self.sounds.attack, {object = self.object})
end end
@ -803,6 +786,7 @@ function mobs:register_mob(name, def)
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
local pos = self.object:getpos() local pos = self.object:getpos()
self.object:set_hp( math.random(self.hp_min, self.hp_max) ) -- set HP self.object:set_hp( math.random(self.hp_min, self.hp_max) ) -- set HP
self.oldhp = self.object:get_hp(self)
self.object:set_armor_groups({fleshy=self.armor}) self.object:set_armor_groups({fleshy=self.armor})
self.object:setacceleration({x=0, y= self.fall_speed, z=0}) self.object:setacceleration({x=0, y= self.fall_speed, z=0})
self.state = "stand" self.state = "stand"
@ -811,14 +795,14 @@ function mobs:register_mob(name, def)
if self.type == "monster" and peaceful_only then if self.type == "monster" and peaceful_only then
self.object:remove() self.object:remove()
end end
if self.type ~= "npc" then -- if self.type ~= "npc" then
self.lifetimer = 600 - dtime_s -- self.lifetimer = self.lifetimer - dtime_s
end -- end
if staticdata then if staticdata then
local tmp = minetest.deserialize(staticdata) local tmp = minetest.deserialize(staticdata)
if tmp then if tmp then
if tmp.lifetimer then if tmp.lifetimer then
self.lifetimer = tmp.lifetimer - dtime_s self.lifetimer = tmp.lifetimer -- - dtime_s
end end
if tmp.tamed then if tmp.tamed then
self.tamed = tmp.tamed self.tamed = tmp.tamed
@ -853,9 +837,9 @@ function mobs:register_mob(name, def)
if self.type == "monster" and self.tamed == true then if self.type == "monster" and self.tamed == true then
self.type = "npc" self.type = "npc"
end end
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then -- if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
self.object:remove() -- self.object:remove()
end -- end
end, end,
get_staticdata = function(self) get_staticdata = function(self)
@ -911,8 +895,8 @@ function mobs:register_mob(name, def)
--blood_particles --blood_particles
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = pos.y + (self.collisionbox[2] + self.collisionbox[5]) / 2 pos.y = pos.y + (-self.collisionbox[2] + self.collisionbox[5]) / 2
if self.blood_amount > 0 and pos then if self.blood_amount > 0 and pos and enable_blood == true then
effect(pos, self.blood_amount, self.blood_texture) effect(pos, self.blood_amount, self.blood_texture)
end end
@ -920,18 +904,13 @@ function mobs:register_mob(name, def)
-- https://github.com/BlockMen/pyramids -- https://github.com/BlockMen/pyramids
local kb = self.knock_back local kb = self.knock_back
local r = self.recovery_time local r = self.recovery_time
local ykb = 2
local v = self.object:getvelocity()
if tflp < tool_capabilities.full_punch_interval then if tflp < tool_capabilities.full_punch_interval then
kb = kb * ( tflp / tool_capabilities.full_punch_interval ) kb = kb * ( tflp / tool_capabilities.full_punch_interval )
r = r * ( tflp / tool_capabilities.full_punch_interval ) r = r * ( tflp / tool_capabilities.full_punch_interval )
end end
if v.y ~= 0 then ykb = 0 end
local ykb=2
local v = self.object:getvelocity()
if v.y ~= 0 then
ykb = 0
end
self.object:setvelocity({x=dir.x*kb,y=ykb,z=dir.z*kb}) self.object:setvelocity({x=dir.x*kb,y=ykb,z=dir.z*kb})
self.pause_timer = r self.pause_timer = r
@ -958,12 +937,13 @@ function mobs:register_mob(name, def)
end end
mobs.spawning_mobs = {} mobs.spawning_mobs = {}
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height)
mobs.spawning_mobs[name] = true mobs.spawning_mobs[name] = true
minetest.register_abm({ minetest.register_abm({
nodenames = nodes, nodenames = nodes,
neighbors = {"air"}, neighbors = neighbors,
interval = 30, interval = interval,
chance = chance, chance = chance,
action = function(pos, node, _, active_object_count_wider) action = function(pos, node, _, active_object_count_wider)
@ -985,7 +965,7 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
-- check if light and height levels are ok to spawn -- check if light and height levels are ok to spawn
local light = minetest.get_node_light(pos) local light = minetest.get_node_light(pos)
if not light or light > max_light or light < min_light if not light or light > max_light or light < min_light
or pos.y > max_height then or pos.y > max_height or pos.y < min_height then
return return
end end
@ -1005,11 +985,17 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
-- spawn mob half block higher -- spawn mob half block higher
pos.y = pos.y - 0.5 pos.y = pos.y - 0.5
minetest.add_entity(pos, name) minetest.add_entity(pos, name)
--print ("Spawned "..name.." at "..minetest.pos_to_string(pos))
end end
}) })
end end
-- compatibility with older mob registration
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30, chance, active_object_count, -32000, max_height)
end
-- particle effects -- particle effects
function effect(pos, amount, texture) function effect(pos, amount, texture)
minetest.add_particlespawner({ minetest.add_particlespawner({
@ -1031,7 +1017,14 @@ end
-- on mob death drop items -- on mob death drop items
function check_for_death(self) function check_for_death(self)
if self.object:get_hp() > 0 then return end local hp = self.object:get_hp()
if hp > 0 then
if self.sounds.damage ~= nil and hp < self.oldhp then
minetest.sound_play(self.sounds.damage,{object = self.object})
self.oldhp = hp
end
return
end
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = pos.y + 0.5 -- drop items half a block higher pos.y = pos.y + 0.5 -- drop items half a block higher
self.object:remove() self.object:remove()
@ -1045,10 +1038,14 @@ function check_for_death(self)
end end
end end
if self.sounds.death ~= nil then if self.sounds.death ~= nil then
minetest.sound_play(self.sounds.death,{object = self.object,}) minetest.sound_play(self.sounds.death,{object = self.object})
end
if self.on_die then
pos.y = pos.y - 0.5
self.on_die(self, pos)
end end
end end
-- Modif MFF "fonction TNT" des creepers /DEBUT
function do_tnt_physics(tnt_np,tntr,entity) function do_tnt_physics(tnt_np,tntr,entity)
local objs = minetest.get_objects_inside_radius(tnt_np, tntr) local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
@ -1068,9 +1065,10 @@ function do_tnt_physics(tnt_np,tntr,entity)
end end
end end
end end
--MODIFICATION MADE BY MFF -- Modif MFF "fonction TNT" des creepers /FIN
function mobs:register_arrow(name, def) function mobs:register_arrow(name, def)
if not name or not def then return end -- errorcheck
minetest.register_entity(name, { minetest.register_entity(name, {
physical = false, physical = false,
visual = def.visual, visual = def.visual,
@ -1079,23 +1077,44 @@ function mobs:register_arrow(name, def)
velocity = def.velocity, velocity = def.velocity,
hit_player = def.hit_player, hit_player = def.hit_player,
hit_node = def.hit_node, hit_node = def.hit_node,
hit_mob = def.hit_mob,
drop = def.drop or false,
collisionbox = {0,0,0,0,0,0}, -- remove box around arrows collisionbox = {0,0,0,0,0,0}, -- remove box around arrows
on_step = function(self, dtime) on_step = function(self, dtime)
self.timer = (self.timer or 0) + 1
if self.timer > 150 then self.object:remove() return end
local engage = 10 - (self.velocity / 2) -- clear entity before arrow becomes active
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.get_node(self.object:getpos()).name local node = minetest.get_node(self.object:getpos()).name
if minetest.registered_nodes[node].walkable then -- hit node you can walk on
if self.hit_node and node and minetest.registered_nodes[node] and minetest.registered_nodes[node].walkable then
self.hit_node(self, pos, node) self.hit_node(self, pos, node)
if self.drop == true then
pos.y = pos.y + 1 ; self.lastpos = (self.lastpos or pos)
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
end
self.object:remove() self.object:remove()
return return
end end
for _,player in pairs(minetest.get_objects_inside_radius(pos, 1)) do if self.hit_player or self.hit_mob then
if player:is_player() then for _,player in pairs(minetest.get_objects_inside_radius(pos, 1)) do
self.hit_player(self, player) -- hit player
self.object:remove() if self.hit_player and self.timer > engage and player:is_player() then
return self.hit_player(self, player)
self.object:remove()
return
end
-- hit mob
if self.hit_mob and self.timer > engage and player:get_luaentity().name ~= self.object:get_luaentity().name
and player:get_luaentity().name ~= "__builtin:item" then
self.hit_mob(self, player)
self.object:remove()
return
end
end end
self.lastpos = pos
end end
end end
}) })

View File

@ -7,12 +7,13 @@ mobs:register_mob("mobs:bee", {
-- it is aggressive -- it is aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 1, hp_max = 2, armor = 200, hp_min = 1,
hp_max = 2,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2}, collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2},
visual = "mesh", visual = "mesh",
mesh = "mobs_bee.x", mesh = "mobs_bee.x",
drawtype = "front",
textures = { textures = {
{"mobs_bee.png"}, {"mobs_bee.png"},
}, },
@ -45,7 +46,10 @@ mobs:register_mob("mobs:bee", {
}, },
-- right click to pick up bee -- right click to pick up bee
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if clicker:is_player() and clicker:get_inventory() and clicker:get_inventory():room_for_item("main", "mobs:bee") then if clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:bee") then
clicker:get_inventory():add_item("main", "mobs:bee") clicker:get_inventory():add_item("main", "mobs:bee")
self.object:remove() self.object:remove()
end end
@ -53,18 +57,17 @@ mobs:register_mob("mobs:bee", {
}) })
-- spawn on group:flowers between 4 and 20 light, 1 in 5000 chance, 1 bee in area up to 31000 in height -- 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", {"group:flower"}, 20, 4, 5000, 1, 31000) mobs:register_spawn("mobs:bee", {"group:flower"}, 20, 4, 5000, 1, 31000)
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:bee", "Bee", "mobs_bee_inv.png", 0) mobs:register_egg("mobs:bee", "Bee", "mobs_bee_inv.png", 0)
-- Honey -- honey
minetest.register_craftitem("mobs:honey", { minetest.register_craftitem("mobs:honey", {
description = "Honey", description = "Honey",
inventory_image = "mobs_honey_inv.png", inventory_image = "mobs_honey_inv.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
}) })
-- Beehive (when placed, bee appears) -- beehive (when placed spawns bee)
minetest.register_node("mobs:beehive", { minetest.register_node("mobs:beehive", {
description = "Beehive", description = "Beehive",
drawtype = "plantlike", drawtype = "plantlike",
@ -93,7 +96,7 @@ minetest.register_craft({
} }
}) })
-- Honey Block -- honey block
minetest.register_node("mobs:honey_block", { minetest.register_node("mobs:honey_block", {
description = "Honey Block", description = "Honey Block",
tiles = {"mobs_honey_block.png"}, tiles = {"mobs_honey_block.png"},

View File

@ -7,12 +7,13 @@ mobs:register_mob("mobs:bunny", {
-- is it aggressive -- is it aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 3, hp_max = 6, armor = 200, hp_min = 3,
hp_max = 6,
armor = 200,
-- textures and model -- textures and model
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",
mesh = "mobs_bunny.b3d", mesh = "mobs_bunny.b3d",
drawtype = "front",
textures = { textures = {
{"mobs_bunny_grey.png"}, {"mobs_bunny_grey.png"},
{"mobs_bunny_brown.png"}, {"mobs_bunny_brown.png"},
@ -31,7 +32,7 @@ mobs:register_mob("mobs:bunny", {
}, },
-- damaged by -- damaged by
water_damage = 1, water_damage = 1,
lava_damage = 1, lava_damage = 4,
light_damage = 0, light_damage = 0,
-- model animation -- model animation
animation = { animation = {
@ -48,9 +49,9 @@ mobs:register_mob("mobs:bunny", {
replace_with = "air", replace_with = "air",
-- right click to pick up rabbit -- right click to pick up rabbit
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
if item:get_name() == "farming_plus:carrot_item" or item:get_name() == "farming:carrot" then if item:get_name() == "farming_plus:carrot_item"
or item:get_name() == "farming:carrot" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
@ -62,7 +63,11 @@ mobs:register_mob("mobs:bunny", {
end end
return return
end end
if clicker:is_player() and clicker:get_inventory() and clicker:get_inventory():room_for_item("main", "mobs:bunny") then
if clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:bunny") then
clicker:get_inventory():add_item("main", "mobs:bunny") clicker:get_inventory():add_item("main", "mobs:bunny")
self.object:remove() self.object:remove()
end end

View File

@ -7,12 +7,13 @@ mobs:register_mob("mobs:chicken", {
-- is it aggressive -- is it aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 4, hp_max = 8, armor = 200, hp_min = 4,
hp_max = 8,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3}, collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3},
visual = "mesh", visual = "mesh",
mesh = "mobs_chicken.x", mesh = "mobs_chicken.x",
drawtype = "front",
textures = { textures = {
{"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", {"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png",
"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"}, "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
@ -52,7 +53,8 @@ mobs:register_mob("mobs:chicken", {
walk_end = 40, walk_end = 40,
}, },
-- follows wheat -- follows wheat
follow = "farming:seed_wheat", view_range = 8, follow = "farming:seed_wheat",
view_range = 8,
-- replace air with egg (lay) -- replace air with egg (lay)
replace_rate = 2000, replace_rate = 2000,
replace_what = {"air"}, replace_what = {"air"},
@ -60,43 +62,42 @@ mobs:register_mob("mobs:chicken", {
-- right click to pick up chicken -- right click to pick up chicken
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item() local tool = clicker:get_wielded_item()
if tool:get_name() == "farming:seed_wheat" then
if tool:get_name() == "farming:seed_wheat" then -- and self.gotten then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
tool:take_item(1) tool:take_item(1)
clicker:set_wielded_item(tool) clicker:set_wielded_item(tool)
end end
self.food = (self.food or 0) + 1
if self.child == true then if self.child == true then
self.hornytimer = self.hornytimer + 10 self.hornytimer = self.hornytimer + 10
return
end end
self.food = (self.food or 0) + 1
if self.food >= 8 then if self.food >= 8 then
self.food = 0 self.food = 0
if self.child == false then self.horny = true end if self.hornytimer == 0 then
self.gotten = false -- reset self.horny = true
end
self.tamed = true self.tamed = true
minetest.sound_play("mobs_chicken", {object = self.object,gain = 1.0,max_hear_distance = 16,loop = false,}) minetest.sound_play("mobs_chicken", {object = self.object,gain = 1.0,max_hear_distance = 16,loop = false,})
end end
return tool return
else
if clicker:is_player() and clicker:get_inventory() and clicker:get_inventory():room_for_item("main", "mobs:chicken") then
clicker:get_inventory():add_item("main", "mobs:chicken")
self.object:remove()
end
end end
if clicker:is_player() and clicker:get_inventory() and self.child == false
if clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:chicken") then and clicker:get_inventory():room_for_item("main", "mobs:chicken") then
clicker:get_inventory():add_item("main", "mobs:chicken") clicker:get_inventory():add_item("main", "mobs:chicken")
self.object:remove() self.object:remove()
end end
end, end,
}) })
-- spawn on default or bamboo grass between 8 and 20 light, 1 in 9000 change, 1 chicken in area up to 31000 in height -- spawn on default or bamboo grass between 8 and 20 light, 1 in 10000 change, 1 chicken in area up to 31000 in height
mobs:register_spawn("mobs:chicken", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31000) mobs:register_spawn("mobs:chicken", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31000)
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:chicken", "Chicken", "mobs_chicken_inv.png", 0) mobs:register_egg("mobs:chicken", "Chicken", "mobs_chicken_inv.png", 0)
-- Egg -- egg
minetest.register_node("mobs:egg", { minetest.register_node("mobs:egg", {
description = "Chicken Egg", description = "Chicken Egg",
tiles = {"mobs_chicken_egg.png"}, tiles = {"mobs_chicken_egg.png"},
@ -120,7 +121,7 @@ minetest.register_node("mobs:egg", {
end end
}) })
-- Fried egg -- fried egg
minetest.register_craftitem("mobs:chicken_egg_fried", { minetest.register_craftitem("mobs:chicken_egg_fried", {
description = "Fried Egg", description = "Fried Egg",
inventory_image = "mobs_chicken_egg_fried.png", inventory_image = "mobs_chicken_egg_fried.png",
@ -133,7 +134,7 @@ minetest.register_craft({
output = "mobs:chicken_egg_fried", output = "mobs:chicken_egg_fried",
}) })
-- Chicken (raw and cooked) -- chicken (raw and cooked)
minetest.register_craftitem("mobs:chicken_raw", { minetest.register_craftitem("mobs:chicken_raw", {
description = "Raw Chicken", description = "Raw Chicken",
inventory_image = "mobs_chicken_raw.png", inventory_image = "mobs_chicken_raw.png",

View File

@ -9,15 +9,16 @@ mobs:register_mob("mobs:cow", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 5, damage = 5,
-- health & armor -- health & armor
hp_min = 20, hp_max = 30, armor = 200, hp_min = 20,
hp_max = 30,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_cow.x", mesh = "mobs_cow.x",
drawtype = "front",
textures = { textures = {
{"mobs_cow.png"}, {"mobs_cow.png"},
{"mobs_cow_brown.png"}, -- dé-commenter quand "mobs_cow_brown.png" sera compatible --{"mobs_cow_brown.png"}, -- dé-commenter quand "mobs_cow_brown.png" sera compatible
}, },
blood_texture = "mobs_blood.png", blood_texture = "mobs_blood.png",
visual_size = {x=1,y=1}, visual_size = {x=1,y=1},
@ -58,8 +59,11 @@ mobs:register_mob("mobs:cow", {
-- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk -- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item() local tool = clicker:get_wielded_item()
if tool:get_name() == "bucket:bucket_empty" and self.child == false then if tool:get_name() == "bucket:bucket_empty" then
if self.gotten then return end if self.gotten == true
or self.child == true then
return
end
local inv = clicker:get_inventory() local inv = clicker:get_inventory()
inv:remove_item("main", "bucket:bucket_empty") inv:remove_item("main", "bucket:bucket_empty")
-- if room add bucket of milk to inventory, otherwise drop as item -- if room add bucket of milk to inventory, otherwise drop as item
@ -72,25 +76,39 @@ mobs:register_mob("mobs:cow", {
end end
self.gotten = true -- milked self.gotten = true -- milked
end end
if tool:get_name() == "farming:wheat" then -- and self.gotten then
if tool:get_name() == "farming:wheat" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
tool:take_item(1) tool:take_item(1)
clicker:set_wielded_item(tool) clicker:set_wielded_item(tool)
end end
self.food = (self.food or 0) + 1
if self.child == true then if self.child == true then
self.hornytimer = self.hornytimer + 10 self.hornytimer = self.hornytimer + 10
return
end end
self.food = (self.food or 0) + 1
if self.food >= 8 then if self.food >= 8 then
self.food = 0 self.food = 0
if self.child == false then self.horny = true end if self.hornytimer == 0 then
self.horny = true
end
self.gotten = false -- ready to be milked again self.gotten = false -- ready to be milked again
self.tamed = true self.tamed = true
minetest.sound_play("mobs_cow", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,}) minetest.sound_play("mobs_cow", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
end end
return tool return
end end
if tool:get_name() == "mobs:magic_lasso"
and clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:cow") then
clicker:get_inventory():add_item("main", "mobs:cow")
self.object:remove()
tool:add_wear(3000) -- 22 uses
clicker:set_wielded_item(tool)
end
end, end,
}) })
-- spawn on default;green;prairie grass between 0 and 20 light, 1 in 11000 chance, 1 cow in area up to 31000 in height -- spawn on default;green;prairie grass between 0 and 20 light, 1 in 11000 chance, 1 cow in area up to 31000 in height
@ -98,13 +116,13 @@ mobs:register_spawn("mobs:cow", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:cow", "Cow", "default_grass.png", 1) mobs:register_egg("mobs:cow", "Cow", "default_grass.png", 1)
-- Leather -- leather
minetest.register_craftitem("mobs:leather", { minetest.register_craftitem("mobs:leather", {
description = "Leather", description = "Leather",
inventory_image = "mobs_leather.png", inventory_image = "mobs_leather.png",
}) })
-- Bucket of Milk -- bucket of milk
minetest.register_craftitem("mobs:bucket_milk", { minetest.register_craftitem("mobs:bucket_milk", {
description = "Bucket of Milk", description = "Bucket of Milk",
inventory_image = "mobs_bucket_milk.png", inventory_image = "mobs_bucket_milk.png",
@ -112,7 +130,7 @@ minetest.register_craftitem("mobs:bucket_milk", {
on_use = minetest.item_eat(8, 'bucket:bucket_empty'), on_use = minetest.item_eat(8, 'bucket:bucket_empty'),
}) })
-- Cheese Wedge -- cheese wedge
minetest.register_craftitem("mobs:cheese", { minetest.register_craftitem("mobs:cheese", {
description = "Cheese", description = "Cheese",
inventory_image = "mobs_cheese.png", inventory_image = "mobs_cheese.png",
@ -127,7 +145,7 @@ minetest.register_craft({
replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}} replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
}) })
-- Cheese Block -- cheese block
minetest.register_node("mobs:cheeseblock", { minetest.register_node("mobs:cheeseblock", {
description = "Cheese Block", description = "Cheese Block",
tiles = {"mobs_cheeseblock.png"}, tiles = {"mobs_cheeseblock.png"},

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:dirt_monster", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 6, damage = 6,
-- health & armor -- health & armor
hp_min = 25, hp_max = 30, armor = 90, hp_min = 25,
hp_max = 30,
armor = 90,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_stone_monster.x", mesh = "mobs_stone_monster.x",
drawtype = "front",
textures = { textures = {
{"mobs_dirt_monster.png"}, {"mobs_dirt_monster.png"},
}, },
@ -33,13 +34,9 @@ mobs:register_mob("mobs:dirt_monster", {
-- drops dirt and coins when dead -- drops dirt and coins when dead
drops = { drops = {
{name = "default:dirt", {name = "default:dirt",
chance = 1, chance = 1, min = 3, max = 5,},
min = 3,
max = 5,},
{name = "maptools:copper_coin", {name = "maptools:copper_coin",
chance = 2, chance = 2, min = 2, max = 8,},
min = 2,
max = 8,},
}, },
-- damaged by -- damaged by
water_damage = 1, water_damage = 1,
@ -55,6 +52,6 @@ mobs:register_mob("mobs:dirt_monster", {
}, },
}) })
-- spawn on normal;grey dirt between 0 and 5 light, 1 in 7000 change, 1 dirt monster in area up to 31000 in height -- spawn on normal;grey dirt between 0 and 5 light, 1 in 7000 change, 1 dirt monster in area up to 31000 in height
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 9500, 1, 31000) mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 5, -1, 9500, 1, 31000)
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:dirt_monster", "Dirt Monster", "default_dirt.png", 1) mobs:register_egg("mobs:dirt_monster", "Dirt Monster", "default_dirt.png", 1)

View File

@ -1,133 +0,0 @@
-- Dungeon Master by PilzAdam
-- Node which cannot be destroyed by DungeonMasters' fireballs
local excluded = {"nether:netherrack","default:obsidian_glass","default:obsidian", "default:obsidian_cooled", "default:bedrock", "doors:door_steel_b_1", "doors:door_steel_t_1", "doors:door_steel_b_2", "doors:door_steel_t_2","default:chest_locked"}
mobs:register_mob("mobs:dungeon_master", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, shoots fireballs at player, deal 13 damages
passive = false,
damage = 13,
attack_type = "shoot",
shoot_interval = 2.5,
arrow = "mobs:fireball",
shoot_offset = 0,
-- health & armor
hp_min = 50, hp_max = 60, armor = 60,
-- textures and model
collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.6, 0.7},
visual = "mesh",
mesh = "mobs_dungeon_master.x",
drawtype = "front",
textures = {
{"mobs_dungeon_master.png"},
{"mobs_dungeon_master_cobblestone.png"},
{"mobs_dungeon_master_strangewhite.png"},
},
visual_size = {x=8, y=8},
blood_texture = "mobs_blood.png",
-- sounds
makes_footstep_sound = true,
sounds = {
random = "mobs_dungeonmaster",
attack = "mobs_fireball",
},
-- speed and jump
walk_velocity = 1,
run_velocity = 2,
jump = false,
view_range = 16,
-- drops mese or diamond when dead
drops = {
{name = "default:mese_crystal_fragment",
chance = 1, min = 1, max = 3,},
{name = "default:diamond",
chance = 5, min = 1, max = 3,},
{name = "default:mese_crystal",
chance = 2, min = 1, max = 3,},
{name = "default:diamond_block",
chance = 30, min = 1, max = 1,},
{name = "maptools:gold_coin",
chance = 15, min = 1, max = 2,},
{name = "maptools:silver_coin",
chance = 1, min = 2, max = 10,},
},
-- damaged by
water_damage = 1,
lava_damage = 1,
light_damage = 0,
-- 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,
},
})
-- spawn on stone between 20 and -1 light, 1 in 7000 chance, 1 dungeon master in area starting at -100 and below
mobs:register_spawn("mobs:dungeon_master", {"default:stone, nether:netherrack"}, 20, -1, 7000, 1, -100)
-- register spawn egg
mobs:register_egg("mobs:dungeon_master", "Dungeon Master", "fire_basic_flame.png", 1)
-- Fireball (dungeon masters weapon)
mobs:register_arrow("mobs:fireball", {
visual = "sprite",
visual_size = {x=1, y=1},
textures = {"mobs_fireball.png"},
velocity = 5,
-- direct hit, no fire... just plenty of pain
hit_player = function(self, player)
local s = self.object:getpos()
local p = player:getpos()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups = {fleshy=13},
}, 0)
end,
-- node hit, bursts into flame (cannot blast through obsidian or protection redo mod items)
hit_node = function(self, pos, node)
for dx=-1,1 do
for dy=-1,1 do
for dz=-1,1 do
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
local n = minetest.get_node(p).name
local excluding = minetest.get_item_group(n, "unbreakable") == 1
or n:split(":")[1] == "nether"
or next(areas:getAreasAtPos(p)) ~= nil
for _,i in ipairs(excluded) do
if i == n then excluding = true end
end
--if p.y < -19600 and including and n:split(":")[1] == "nether" then
if excluding then
return
end
if n == "default:chest" then
meta = minetest.get_meta(p)
inv = meta:get_inventory()
for i = 1,32 do
m_stack = inv:get_stack("main",i)
obj = minetest.add_item(pos,m_stack)
if obj then
obj:setvelocity({x=math.random(-2,1), y=7, z=math.random(-2,1)})
end
end
end
if minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30 then
minetest.set_node(p, {name="fire:basic_flame"})
else
minetest.set_node(p, {name="air"})
end
if n == "doors:door_wood_b_1" then
minetest.remove_node({x=p.x,y=p.y+1,z=p.z})
elseif n == "doors:door_wood_t_1" then
minetest.remove_node({x=p.x,y=p.y-1,z=p.z})
end
end
end
end
end
})

View File

@ -53,6 +53,22 @@ minetest.register_craft({
cooktime = 5, cooktime = 5,
}) })
-- Golden Lasso
minetest.register_tool("mobs:magic_lasso", {
description = "Magic Lasso (right-click animal to put in inventory)",
inventory_image = "mobs_magic_lasso.png",
})
minetest.register_craft({
output = "mobs:magic_lasso",
recipe = {
{"farming:string", "default:gold_lump", "farming:string"},
{"default:gold_lump", "default:diamondblock", "default:gold_lump"},
{"farming:string", "default:gold_lump", "farming:string"},
}
})
if minetest.setting_get("log_mods") then if minetest.setting_get("log_mods") then
minetest.log("action", "mobs loaded") minetest.log("action", "mobs loaded")
end end

View File

@ -7,7 +7,9 @@ mobs:register_mob("mobs:kitten", {
-- is it aggressive -- is it aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 4, hp_max = 8, armor = 200, hp_min = 4,
hp_max = 8,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3}, collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
visual = "mesh", visual = "mesh",
@ -50,7 +52,8 @@ mobs:register_mob("mobs:kitten", {
-- feed with raw fish to tame or right click to pick up -- feed with raw fish to tame or right click to pick up
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
if item:get_name() == "fishing:fish_raw" or item:get_name() == "ethereal:fish_raw" then if item:get_name() == "fishing:fish_raw"
or item:get_name() == "ethereal:fish_raw" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
@ -63,11 +66,15 @@ mobs:register_mob("mobs:kitten", {
end end
return return
end end
if clicker:is_player() and clicker:get_inventory() and clicker:get_inventory():room_for_item("main", "mobs:kitten") then
if clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:kitten") then
clicker:get_inventory():add_item("main", "mobs:kitten") clicker:get_inventory():add_item("main", "mobs:kitten")
self.object:remove() self.object:remove()
end end
end end,
}) })
mobs:register_spawn("mobs:kitten", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31000) mobs:register_spawn("mobs:kitten", {"default:dirt_with_grass"}, 20, 0, 10000, 1, 31000)

View File

@ -9,23 +9,23 @@ mobs:register_mob("mobs:lava_flan", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 5, damage = 5,
-- health and armor -- health and armor
hp_min = 20, hp_max = 35, armor = 80, hp_min = 20,
hp_max = 35,
armor = 80,
-- textures and model -- textures and model
collisionbox = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}, collisionbox = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
visual = "mesh", visual = "mesh",
mesh = "zmobs_lava_flan.x", mesh = "zmobs_lava_flan.x",
drawtype = "front",
textures = { textures = {
{"zmobs_lava_flan.png"}, {"zmobs_lava_flan.png"},
}, },
blood_texture = "fire_basic_flame.png", blood_texture = "fire_basic_flame.png",
visual_size = {x=1, y=1}, visual_size = {x=1, y=1},
-- sounds -- sounds
makes_footstep_sound = true, makes_footstep_sound = false,
sounds = { sounds = {
random = "mobs_lavaflan", random = "mobs_lavaflan",
war_cry = "mobs_lavaflan", war_cry = "mobs_lavaflan",
death = nil,
}, },
-- speed and jump, sinks in water -- speed and jump, sinks in water
walk_velocity = 0.5, walk_velocity = 0.5,
@ -51,15 +51,19 @@ mobs:register_mob("mobs:lava_flan", {
run_start = 20, run_end = 28, run_start = 20, run_end = 28,
punch_start = 20, punch_end = 28, punch_start = 20, punch_end = 28,
}, },
on_die = function(self, pos)
minetest.set_node(pos, {name="fire:basic_flame"})
end,
}) })
-- spawns in lava between -1 and 20 light, 1 in 2000 chance, 3 in area below 31000 in height -- spawns in lava between -1 and 20 light, 1 in 2000 chance, 3 in area below 31000 in height
mobs:register_spawn("mobs:lava_flan", {"default:lava_source"}, 20, -1, 2500, 3, 31000) mobs:register_spawn("mobs:lava_flan", {"default:lava_source"}, 20, -1, 2500, 3, 31000)
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:lava_flan", "Lava Flan", "default_lava.png", 1) mobs:register_egg("mobs:lava_flan", "Lava Flan", "default_lava.png", 1)
-- Lava Orb -- lava orb
minetest.register_craftitem("mobs:lava_orb", { minetest.register_craftitem("mobs:lava_orb", {
description = "Lava orb", description = "Lava orb",
inventory_image = "zmobs_lava_orb.png", inventory_image = "zmobs_lava_orb.png",
}) })
minetest.register_alias("zmobs:lava_orb", "mobs:lava_orb") minetest.register_alias("zmobs:lava_orb", "mobs:lava_orb")

View File

@ -12,7 +12,9 @@ mobs:register_mob("mobs:mese_monster", {
arrow = "mobs:mese_arrow", arrow = "mobs:mese_arrow",
shoot_offset = 2, shoot_offset = 2,
-- health & armor -- health & armor
hp_min = 30, hp_max = 40, armor = 80, hp_min = 30,
hp_max = 40,
armor = 80,
-- textures and model -- textures and model
collisionbox = {-0.5, -1.5, -0.5, 0.5, 0.5, 0.5}, collisionbox = {-0.5, -1.5, -0.5, 0.5, 0.5, 0.5},
visual = "mesh", visual = "mesh",
@ -21,10 +23,9 @@ mobs:register_mob("mobs:mese_monster", {
{"zmobs_mese_monster.png"}, {"zmobs_mese_monster.png"},
}, },
visual_size = {x=1, y=1}, visual_size = {x=1, y=1},
drawtype = "front",
blood_texture = "default_mese_crystal_fragment.png", blood_texture = "default_mese_crystal_fragment.png",
-- sounds -- sounds
makes_footstep_sound = true, makes_footstep_sound = false,
sounds = { sounds = {
random = "mobs_mesemonster", random = "mobs_mesemonster",
}, },
@ -33,6 +34,7 @@ mobs:register_mob("mobs:mese_monster", {
walk_velocity = 0.5, walk_velocity = 0.5,
run_velocity = 2, run_velocity = 2,
jump = true, jump = true,
jump_height = 8,
fall_damage = 0, fall_damage = 0,
fall_speed = -6, fall_speed = -6,
-- drops mese when dead -- drops mese when dead
@ -64,17 +66,21 @@ mobs:register_spawn("mobs:mese_monster", {"default:stone", }, 20, -1, 7000, 1, -
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:mese_monster", "Mese Monster", "default_mese_block.png", 1) mobs:register_egg("mobs:mese_monster", "Mese Monster", "default_mese_block.png", 1)
-- Mese Monster Crystal Shards (weapon) -- mese arrow (weapon)
mobs:register_arrow("mobs:mese_arrow", { mobs:register_arrow("mobs:mese_arrow", {
visual = "sprite", visual = "sprite",
visual_size = {x=.5, y=.5}, visual_size = {x=.5, y=.5},
textures = {"default_mese_crystal_fragment.png"}, textures = {"default_mese_crystal_fragment.png"},
velocity = 5, velocity = 6,
hit_player = function(self, player) hit_player = function(self, player)
local s = self.object:getpos() player:punch(self.object, 1.0, {
local p = player:getpos() full_punch_interval=1.0,
damage_groups = {fleshy=1},
}, 0)
end,
hit_mob = function(self, player)
player:punch(self.object, 1.0, { player:punch(self.object, 1.0, {
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups = {fleshy=9}, damage_groups = {fleshy=9},
@ -85,7 +91,7 @@ mobs:register_arrow("mobs:mese_arrow", {
end end
}) })
-- 9 mese crystal fragments = 1 mese crystal -- 9x mese crystal fragments = 1x mese crystal
minetest.register_craft({ minetest.register_craft({
output = "default:mese_crystal", output = "default:mese_crystal",
recipe = { recipe = {

View File

@ -17,12 +17,13 @@ mobs:register_mob("mobs:npc", {
attack_type = "dogfight", attack_type = "dogfight",
attacks_monsters = true, attacks_monsters = true,
-- health & armor -- health & armor
hp_min = mobs.npc_max_hp, hp_max = mobs.npc_max_hp, armor = 100, hp_min = 20,
hp_max = 20,
armor = 100,
-- textures and model -- textures and model
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35}, collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
visual = "mesh", visual = "mesh",
mesh = "character.b3d", mesh = "character.b3d",
drawtype = "front",
textures = { textures = {
{"mobs_npc.png"}, {"mobs_npc.png"},
}, },
@ -66,14 +67,17 @@ mobs:register_mob("mobs:npc", {
-- right clicking with "cooked meat" or "bread" will give npc more health -- right clicking with "cooked meat" or "bread" will give npc more health
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
if item:get_name() == "mobs:meat" or item:get_name() == "farming:bread" then if item:get_name() == "mobs:meat"
or item:get_name() == "farming:bread" then
local hp = self.object:get_hp() local hp = self.object:get_hp()
if hp + 4 > mobs.npc_max_hp then return end if hp + 4 > self.hp_max then
return
end
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
self.object:set_hp(hp+4) self.object:set_hp(hp + 4)
-- right clicking with gold lump drops random item from mobs.npc_drops -- right clicking with gold lump drops random item from mobs.npc_drops
elseif item:get_name() == "default:gold_lump" then elseif item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:oerkki", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 7, damage = 7,
-- health & armor -- health & armor
hp_min = 40, hp_max = 50, armor = 90, hp_min = 40,
hp_max = 50,
armor = 90,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_oerkki.x", mesh = "mobs_oerkki.x",
drawtype = "front",
textures = { textures = {
{"mobs_oerkki.png"}, {"mobs_oerkki.png"},
{"mobs_oerkki2.png"}, {"mobs_oerkki2.png"},
@ -40,8 +41,8 @@ mobs:register_mob("mobs:oerkki", {
chance = 2, min = 2, max = 3,}, chance = 2, min = 2, max = 3,},
}, },
-- damaged by -- damaged by
water_damage = 1, water_damage = 2,
lava_damage = 1, lava_damage = 2,
light_damage = 1, light_damage = 1,
-- model animation -- model animation
animation = { animation = {

View File

@ -7,12 +7,13 @@ mobs:register_mob("mobs:rat", {
-- not aggressive -- not aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 2, hp_max = 4, armor = 200, hp_min = 1,
hp_max = 4,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2}, collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2},
visual = "mesh", visual = "mesh",
mesh = "mobs_rat.x", mesh = "mobs_rat.x",
drawtype = "front",
textures = { textures = {
{"mobs_rat.png"}, {"mobs_rat.png"},
{"mobs_rat_brown.png"}, {"mobs_rat_brown.png"},
@ -30,11 +31,14 @@ mobs:register_mob("mobs:rat", {
drops = {}, drops = {},
-- damaged by -- damaged by
water_damage = 0, water_damage = 0,
lava_damage = 1, lava_damage = 4,
light_damage = 0, light_damage = 0,
-- right click to pick up rat -- right click to pick up rat
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if clicker:is_player() and clicker:get_inventory() and clicker:get_inventory():room_for_item("main", "mobs:rat") then if clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:rat") then
clicker:get_inventory():add_item("main", "mobs:rat") clicker:get_inventory():add_item("main", "mobs:rat")
self.object:remove() self.object:remove()
end end
@ -45,7 +49,7 @@ mobs:register_spawn("mobs:rat", {"default:stone"}, 20, 0, 10000, 1, 31000)
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:rat", "Rat", "mobs_rat_inventory.png", 0) mobs:register_egg("mobs:rat", "Rat", "mobs_rat_inventory.png", 0)
-- Cooked Rat, yummy! -- cooked rat, yummy!
minetest.register_craftitem("mobs:rat_cooked", { minetest.register_craftitem("mobs:rat_cooked", {
description = "Cooked Rat", description = "Cooked Rat",
inventory_image = "mobs_cooked_rat.png", inventory_image = "mobs_cooked_rat.png",

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:sand_monster", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 5, damage = 5,
-- health & armor -- health & armor
hp_min = 15, hp_max = 20, armor = 90, hp_min = 15,
hp_max = 20,
armor = 90,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_sand_monster.x", mesh = "mobs_sand_monster.x",
drawtype = "front",
textures = { textures = {
{"mobs_sand_monster.png"}, {"mobs_sand_monster.png"},
}, },
@ -40,7 +41,7 @@ mobs:register_mob("mobs:sand_monster", {
}, },
-- damaged by -- damaged by
water_damage = 3, water_damage = 3,
lava_damage = 1, lava_damage = 4,
light_damage = 0, light_damage = 0,
-- model animation -- model animation
animation = { animation = {

View File

@ -7,12 +7,13 @@ mobs:register_mob("mobs:sheep", {
-- not aggressive -- not aggressive
passive = true, passive = true,
-- health & armor -- health & armor
hp_min = 10, hp_max = 15, armor = 200, hp_min = 10,
hp_max = 15,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_sheep.x", mesh = "mobs_sheep.x",
drawtype = "front",
textures = { textures = {
{"mobs_sheep.png"}, {"mobs_sheep.png"},
}, },
@ -61,13 +62,16 @@ mobs:register_mob("mobs:sheep", {
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
self.food = (self.food or 0) + 1
if self.child == true then if self.child == true then
self.hornytimer = self.hornytimer + 10 self.hornytimer = self.hornytimer + 10
return
end end
self.food = (self.food or 0) + 1
if self.food >= 8 then if self.food >= 8 then
self.food = 0 self.food = 0
if self.child == false then self.horny = true end if self.hornytimer == 0 then
self.horny = true
end
self.gotten = false -- can be shaved again self.gotten = false -- can be shaved again
self.tamed = true self.tamed = true
self.object:set_properties({ self.object:set_properties({
@ -76,11 +80,12 @@ mobs:register_mob("mobs:sheep", {
}) })
minetest.sound_play("mobs_sheep", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,}) minetest.sound_play("mobs_sheep", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,})
end end
return return
end end
-- need shears to get wool from sheep
local inv = clicker:get_inventory() if item:get_name() == "mobs:shears"
if inv and item:get_name() == "mobs:shears" and not self.gotten and self.child == false then and self.gotten == false
and self.child == false then
self.gotten = true -- shaved self.gotten = true -- shaved
if minetest.registered_items["wool:white"] then if minetest.registered_items["wool:white"] then
local pos = self.object:getpos() local pos = self.object:getpos()
@ -89,7 +94,7 @@ mobs:register_mob("mobs:sheep", {
if obj then if obj then
obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)}) obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)})
end end
item:add_wear(65535/100) item:add_wear(650) -- 100 uses
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
self.object:set_properties({ self.object:set_properties({
@ -97,6 +102,18 @@ mobs:register_mob("mobs:sheep", {
mesh = "mobs_sheep_shaved.x", mesh = "mobs_sheep_shaved.x",
}) })
end end
if item:get_name() == "mobs:magic_lasso"
and clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:sheep") then
clicker:get_inventory():add_item("main", "mobs:sheep")
self.object:remove()
item:add_wear(3000) -- 22 uses
print ("wear", item:get_wear())
clicker:set_wielded_item(item)
end
end, end,
}) })
-- spawn on default;green grass between 20 and 8 light, 1 in 9000 chance, 1 sheep in area up to 31000 in height -- spawn on default;green grass between 20 and 8 light, 1 in 9000 chance, 1 sheep in area up to 31000 in height
@ -104,7 +121,7 @@ mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 10000, 1,
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:sheep", "Sheep", "wool_white.png", 1) mobs:register_egg("mobs:sheep", "Sheep", "wool_white.png", 1)
-- shears tool (right click sheep to shear) -- shears (right click sheep to shear wool)
minetest.register_tool("mobs:shears", { minetest.register_tool("mobs:shears", {
description = "Steel Shears (right-click sheep to shear)", description = "Steel Shears (right-click sheep to shear)",
inventory_image = "mobs_shears.png", inventory_image = "mobs_shears.png",

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:spider", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 6, damage = 6,
-- health & armor -- health & armor
hp_min = 30, hp_max = 40, armor = 100, hp_min = 30,
hp_max = 40,
armor = 100,
-- textures and model -- textures and model
collisionbox = {-0.9, -0.01, -0.7, 0.7, 0.6, 0.7}, collisionbox = {-0.9, -0.01, -0.7, 0.7, 0.6, 0.7},
visual = "mesh", visual = "mesh",
mesh = "mobs_spider.x", mesh = "mobs_spider.x",
drawtype = "front",
textures = { textures = {
{"mobs_spider.png"}, {"mobs_spider.png"},
}, },
@ -61,12 +62,12 @@ mobs:register_spawn("mobs:spider", {"default:jungleleaves", "default:jungletree"
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:spider", "Spider", "mobs_cobweb.png", 1) mobs:register_egg("mobs:spider", "Spider", "mobs_cobweb.png", 1)
-- Ethereal crystal spike compatibility -- ethereal crystal spike compatibility
if not minetest.get_modpath("ethereal") then if not minetest.get_modpath("ethereal") then
minetest.register_alias("ethereal:crystal_spike", "default:sandstone") minetest.register_alias("ethereal:crystal_spike", "default:sandstone")
end end
-- Spider Cobweb -- spider cobweb
minetest.register_node("mobs:spider_cobweb", { minetest.register_node("mobs:spider_cobweb", {
description = "Spider Cobweb", --Description changé pour éviter conflit avec homedecor_modpack description = "Spider Cobweb", --Description changé pour éviter conflit avec homedecor_modpack
drawtype = "plantlike", drawtype = "plantlike",
@ -87,7 +88,7 @@ minetest.register_node("mobs:spider_cobweb", {
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
-- Spider Cobweb craft (MFF : indentation modifié) -- spider cobweb craft (MFF : indentation modifié)
minetest.register_craft( { minetest.register_craft( {
output = "mobs:spider_cobweb", output = "mobs:spider_cobweb",
recipe = { recipe = {

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:stone_monster", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 8, damage = 8,
-- health & armor -- health & armor
hp_min = 30, hp_max = 35, armor = 60, hp_min = 30,
hp_max = 35,
armor = 60,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_stone_monster.x", mesh = "mobs_stone_monster.x",
drawtype = "front",
textures = { textures = {
{"mobs_stone_monster.png"}, {"mobs_stone_monster.png"},
}, },
@ -45,7 +46,7 @@ mobs:register_mob("mobs:stone_monster", {
}, },
-- damaged by -- damaged by
water_damage = 0, water_damage = 0,
lava_damage = 0, lava_damage = 0
light_damage = 0, light_damage = 0,
-- model animation -- model animation
animation = { animation = {

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:tree_monster", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 9, damage = 9,
-- health & armor -- health & armor
hp_min = 40, hp_max = 50, armor = 80, hp_min = 40,
hp_max = 50,
armor = 80,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_tree_monster.x", mesh = "mobs_tree_monster.x",
drawtype = "front",
textures = { textures = {
{"mobs_tree_monster.png"}, {"mobs_tree_monster.png"},
}, },
@ -60,7 +61,7 @@ mobs:register_spawn("mobs:tree_monster", {"default:leaves", "moretrees:beech_lea
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:tree_monster", "Tree Monster", "default_tree_top.png", 1) mobs:register_egg("mobs:tree_monster", "Tree Monster", "default_tree_top.png", 1)
-- Ethereal sapling compatibility -- ethereal sapling compatibility
if not minetest.get_modpath("ethereal") then if not minetest.get_modpath("ethereal") then
minetest.register_alias("ethereal:tree_sapling", "default:sapling") minetest.register_alias("ethereal:tree_sapling", "default:sapling")
minetest.register_alias("ethereal:jungle_tree_sapling", "default:junglesapling") minetest.register_alias("ethereal:jungle_tree_sapling", "default:junglesapling")

View File

@ -9,12 +9,13 @@ mobs:register_mob("mobs:pumba", {
attack_type = "dogfight", attack_type = "dogfight",
damage = 5, damage = 5,
-- health & armor -- health & armor
hp_min = 15, hp_max = 20, armor = 200, hp_min = 15,
hp_max = 20,
armor = 200,
-- textures and model -- textures and model
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_pumba.x", mesh = "mobs_pumba.x",
drawtype = "front",
textures = { textures = {
{"mobs_pumba.png"}, {"mobs_pumba.png"},
}, },
@ -57,15 +58,32 @@ mobs:register_mob("mobs:pumba", {
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
if self.child == true then
self.hornytimer = self.hornytimer + 10
return
end
self.food = (self.food or 0) + 1 self.food = (self.food or 0) + 1
if self.food >= 8 then if self.food >= 8 then
if self.child == false then self.horny = true end
self.food = 0 self.food = 0
if self.hornytimer == 0 then
self.horny = true
end
self.tamed = true self.tamed = true
minetest.sound_play("mobs_pig", {object = self.object,gain = 1.0,max_hear_distance = 32,loop = false,}) minetest.sound_play("mobs_pig", {object = self.object,gain = 1.0, max_hear_distance = 32,loop = false,})
end end
return return
end end
if item:get_name() == "mobs:magic_lasso"
and clicker:is_player()
and clicker:get_inventory()
and self.child == false
and clicker:get_inventory():room_for_item("main", "mobs:pumba") then
clicker:get_inventory():add_item("main", "mobs:pumba")
self.object:remove()
item:add_wear(3000) -- 22 uses
clicker:set_wielded_item(item)
end
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 -- spawns on normal or shroom dirt, between 8 and 20 light, 1 in 10000 chance, 1 in area up to 31000 in height
@ -73,7 +91,7 @@ mobs:register_spawn("mobs:pumba", {"default:dirt_with_grass", "default:dirt"}, 2
-- register spawn egg -- register spawn egg
mobs:register_egg("mobs:pumba", "Warthog", "wool_pink.png", 1) mobs:register_egg("mobs:pumba", "Warthog", "wool_pink.png", 1)
-- Porkchops (raw and cooked) -- porkchop (raw and cooked)
minetest.register_craftitem("mobs:pork_raw", { minetest.register_craftitem("mobs:pork_raw", {
description = "Raw Porkchop", description = "Raw Porkchop",
inventory_image = "mobs_pork_raw.png", inventory_image = "mobs_pork_raw.png",