mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00:37 +01:00
Update mobs mod and news.txt
mobs mod tweaks : - tweaked environmental damage check - mobs retain health, code tidy - Updated weapon wear & sounds - code tidy
This commit is contained in:
parent
1f426f2e94
commit
9eea1d7f42
@ -1,4 +1,4 @@
|
|||||||
-- Mobs Api (24th May 2015)
|
-- Mobs Api (27th May 2015)
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
|
|
||||||
@ -12,10 +12,6 @@ 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, {
|
||||||
--weight = 5,
|
|
||||||
--is_visible = true,
|
|
||||||
--automatic_rotate = false,
|
|
||||||
--automatic_face_movement_dir = 0.0, -- set yaw direction in degrees, false to disable
|
|
||||||
stepheight = def.stepheight or 0.6,
|
stepheight = def.stepheight or 0.6,
|
||||||
name = name,
|
name = name,
|
||||||
fly = def.fly,
|
fly = def.fly,
|
||||||
@ -34,7 +30,7 @@ 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 or true,
|
makes_footstep_sound = def.makes_footstep_sound or false,
|
||||||
view_range = def.view_range or 5,
|
view_range = def.view_range or 5,
|
||||||
walk_velocity = def.walk_velocity or 1,
|
walk_velocity = def.walk_velocity or 1,
|
||||||
run_velocity = def.run_velocity or 2,
|
run_velocity = def.run_velocity or 2,
|
||||||
@ -61,12 +57,15 @@ function mobs:register_mob(name, def)
|
|||||||
--fov = def.fov or 120,
|
--fov = def.fov or 120,
|
||||||
passive = def.passive or false,
|
passive = def.passive or false,
|
||||||
recovery_time = def.recovery_time or 0.5,
|
recovery_time = def.recovery_time or 0.5,
|
||||||
knock_back = def.knock_back or 1, --Modif MFF, default value is "or 3",
|
knock_back = def.knock_back or 3,
|
||||||
blood_amount = def.blood_amount or 5,
|
blood_amount = def.blood_amount or 5,
|
||||||
blood_texture = def.blood_texture or "mobs_blood.png",
|
blood_texture = def.blood_texture or "mobs_blood.png",
|
||||||
shoot_offset = def.shoot_offset or 0,
|
shoot_offset = def.shoot_offset or 0,
|
||||||
floats = def.floats or 1, -- floats in water by default
|
floats = def.floats or 1, -- floats in water by default
|
||||||
replacements = def.replacements or {},
|
replace_rate = def.replace_rate,
|
||||||
|
replace_what = def.replace_what,
|
||||||
|
replace_with = def.replace_with,
|
||||||
|
replace_offset = def.replace_offset or 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},
|
||||||
@ -78,6 +77,7 @@ function mobs:register_mob(name, def)
|
|||||||
child = false,
|
child = false,
|
||||||
gotten = false,
|
gotten = false,
|
||||||
owner = "",
|
owner = "",
|
||||||
|
health = 0,
|
||||||
|
|
||||||
do_attack = function(self, player, dist)
|
do_attack = function(self, player, dist)
|
||||||
if self.state ~= "attack" then
|
if self.state ~= "attack" then
|
||||||
@ -161,57 +161,42 @@ function mobs:register_mob(name, def)
|
|||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
|
||||||
local yaw = 0
|
|
||||||
|
|
||||||
if self.type == "monster" and peaceful_only then
|
if self.type == "monster" and peaceful_only then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if lifetimer run out and not npc, tamed or attacking then remove mob
|
-- if lifetimer run out and not npc; tamed or attacking then remove mob
|
||||||
if self.type ~= "npc" and not self.tamed then
|
if self.type ~= "npc" and not self.tamed then
|
||||||
self.lifetimer = self.lifetimer - dtime
|
self.lifetimer = self.lifetimer - dtime
|
||||||
if self.lifetimer <= 0 and self.state ~= "attack" then
|
if self.lifetimer <= 0 and self.state ~= "attack" then
|
||||||
for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
|
minetest.log("action","lifetimer expired, removed "..self.name)
|
||||||
if obj:is_player() then
|
effect(self.object:getpos(), 15, "tnt_smoke.png")
|
||||||
minetest.log("action","lifetimer expired, removed mob "..self.name)
|
self.object:remove()
|
||||||
self.object:remove()
|
return
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
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
|
||||||
old fields :
|
and self.child == false
|
||||||
replace_rate = def.replace_rate,
|
and math.random(1,self.replace_rate) == 1 then
|
||||||
replace_what = def.replace_what,
|
local pos = self.object:getpos()
|
||||||
replace_with = def.replace_with,
|
pos.y = pos.y + self.replace_offset
|
||||||
replace_offset = def.replace_offset or 0,
|
if self.replace_what
|
||||||
]]--
|
and self.object:getvelocity().y == 0
|
||||||
for _, fields in pairs(self.replacements) do
|
and #minetest.find_nodes_in_area(pos, pos, self.replace_what) > 0 then
|
||||||
|
--and self.state == "stand" then
|
||||||
if fields.replace_rate
|
minetest.set_node(pos, {name = self.replace_with})
|
||||||
and math.random(1,fields.replace_rate) == 1
|
|
||||||
and self.child == false then
|
|
||||||
|
|
||||||
fields.replace_offset = fields.replace_offset or 0
|
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
pos.y = pos.y + fields.replace_offset
|
|
||||||
if #minetest.find_nodes_in_area(pos,pos,fields.replace_what) > 0
|
|
||||||
and self.object:getvelocity().y == 0
|
|
||||||
and fields.replace_what then
|
|
||||||
minetest.set_node(pos, {name = fields.replace_with})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local yaw = 0
|
||||||
|
|
||||||
-- jump direction (adapted from Carbone mobs), gravity, falling or floating in water
|
-- jump direction (adapted from Carbone mobs), gravity, falling or floating in water
|
||||||
if not self.fly then
|
if not self.fly then
|
||||||
if self.object:getvelocity().y > 0.1 then
|
if self.object:getvelocity().y > 0.1 then
|
||||||
local yaw = self.object:getyaw() + self.rotate
|
yaw = self.object:getyaw() + self.rotate
|
||||||
local x = math.sin(yaw) * -2
|
local x = math.sin(yaw) * -2
|
||||||
local z = math.cos(yaw) * 2
|
local z = math.cos(yaw) * 2
|
||||||
|
|
||||||
@ -233,6 +218,7 @@ function mobs:register_mob(name, def)
|
|||||||
local d = self.old_y - self.object:getpos().y
|
local d = self.old_y - self.object:getpos().y
|
||||||
if d > 5 then
|
if d > 5 then
|
||||||
self.object:set_hp(self.object:get_hp() - math.floor(d - 5))
|
self.object:set_hp(self.object:get_hp() - math.floor(d - 5))
|
||||||
|
effect(self.object:getpos(), 5, "tnt_smoke.png")
|
||||||
check_for_death(self)
|
check_for_death(self)
|
||||||
end
|
end
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
@ -268,28 +254,29 @@ function mobs:register_mob(name, def)
|
|||||||
local tod = minetest.get_timeofday()
|
local tod = minetest.get_timeofday()
|
||||||
pos.y = (pos.y + self.collisionbox[2]) -- foot level
|
pos.y = (pos.y + self.collisionbox[2]) -- foot level
|
||||||
--print ("standing on:", minetest.get_node(pos).name)
|
--print ("standing on:", minetest.get_node(pos).name)
|
||||||
|
|
||||||
if self.light_damage and self.light_damage ~= 0
|
if self.light_damage and self.light_damage ~= 0
|
||||||
and pos.y > 0
|
and pos.y > 0
|
||||||
and tod > 0.2 and tod < 0.8
|
and tod > 0.2 and tod < 0.8
|
||||||
and (minetest.get_node_light(pos) or 0) > 10 then
|
and (minetest.get_node_light(pos) or 0) > 10 then
|
||||||
self.object:set_hp(self.object:get_hp()-self.light_damage)
|
self.object:set_hp(self.object:get_hp()-self.light_damage)
|
||||||
effect(pos, 5, "tnt_smoke.png")
|
effect(pos, 5, "tnt_smoke.png")
|
||||||
|
check_for_death(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.water_damage and self.water_damage ~= 0
|
if self.water_damage and self.water_damage ~= 0
|
||||||
and minetest.get_item_group(n.name, "water") ~= 0 then
|
and minetest.get_item_group(n.name, "water") ~= 0 then
|
||||||
self.object:set_hp(self.object:get_hp()-self.water_damage)
|
self.object:set_hp(self.object:get_hp()-self.water_damage)
|
||||||
effect(pos, 5, "bubble.png")
|
effect(pos, 5, "bubble.png")
|
||||||
|
check_for_death(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.lava_damage and self.lava_damage ~= 0
|
if self.lava_damage and self.lava_damage ~= 0
|
||||||
and minetest.get_item_group(n.name, "lava") ~= 0 then
|
and minetest.get_item_group(n.name, "lava") ~= 0 then
|
||||||
self.object:set_hp(self.object:get_hp()-self.lava_damage)
|
self.object:set_hp(self.object:get_hp()-self.lava_damage)
|
||||||
effect(pos, 5, "fire_basic_flame.png")
|
effect(pos, 5, "fire_basic_flame.png")
|
||||||
|
check_for_death(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
check_for_death(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local do_jump = function(self)
|
local do_jump = function(self)
|
||||||
@ -432,8 +419,8 @@ 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() ; pos.y = pos.y + 1
|
local pos = self.object:getpos()
|
||||||
effect(pos, 4, "heart.png") ; pos.y = pos.y - 1
|
effect({x=pos.x, y=pos.y+1, z=pos.z}, 4, "heart.png")
|
||||||
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
|
||||||
@ -509,7 +496,7 @@ function mobs:register_mob(name, def)
|
|||||||
self.following = nil
|
self.following = nil
|
||||||
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) + self.rotate
|
yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate -- local
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
@ -518,7 +505,7 @@ 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 (self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0)
|
if (self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0)
|
||||||
or (self.object:getvelocity().y == 0 and self.jump_chance > 0) then -- CHANGED from self.jump
|
or (self.object:getvelocity().y == 0 and self.jump_chance > 0) then
|
||||||
self.direction = {x = math.sin(yaw)*-1, y = -20, z = math.cos(yaw)}
|
self.direction = {x = math.sin(yaw)*-1, y = -20, z = math.cos(yaw)}
|
||||||
do_jump(self)
|
do_jump(self)
|
||||||
end
|
end
|
||||||
@ -591,10 +578,9 @@ function mobs:register_mob(name, def)
|
|||||||
|
|
||||||
elseif self.state == "walk" then
|
elseif self.state == "walk" then
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
-- if there is water nearby, try to avoid it
|
local lp = minetest.find_node_near(s, 1, {"group:water"})
|
||||||
local lp = minetest.find_node_near(s, 2, {"group:water"})
|
-- if water nearby then turn away
|
||||||
|
if lp 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) + 3*math.pi / 2 + self.rotate
|
yaw = math.atan(vec.z/vec.x) + 3*math.pi / 2 + self.rotate
|
||||||
if lp.x > s.x then
|
if lp.x > s.x then
|
||||||
@ -602,7 +588,7 @@ function mobs:register_mob(name, def)
|
|||||||
end
|
end
|
||||||
self.object:setyaw(yaw)
|
self.object:setyaw(yaw)
|
||||||
|
|
||||||
-- no water near, so randomly turn
|
-- otherwise randomly turn
|
||||||
elseif math.random(1, 100) <= 30 then
|
elseif math.random(1, 100) <= 30 then
|
||||||
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
|
||||||
@ -646,7 +632,7 @@ 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 + self.rotate
|
yaw = math.atan(vec.z/vec.x)+math.pi/2 + self.rotate -- local
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
@ -711,30 +697,31 @@ function mobs:register_mob(name, def)
|
|||||||
local p = self.attack.player:getpos()
|
local p = self.attack.player:getpos()
|
||||||
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
|
||||||
|
|
||||||
-- fly bit modified from BlockMens creatures mod
|
-- fly bit modified from BlockMens creatures mod
|
||||||
if self.fly and dist > 2 then
|
if self.fly and dist > 2 then
|
||||||
|
|
||||||
local nod = minetest.get_node_or_nil(s)
|
local nod = minetest.get_node_or_nil(s)
|
||||||
local p1 = s
|
local p1 = s
|
||||||
local me_y = math.floor(p1.y)
|
local me_y = math.floor(p1.y)
|
||||||
local p2 = p
|
local p2 = p
|
||||||
local p_y = math.floor(p2.y+1)
|
local p_y = math.floor(p2.y+1)
|
||||||
if nod and nod.name == self.fly_in then
|
local v = self.object:getvelocity()
|
||||||
if me_y < p_y then
|
if nod and nod.name == self.fly_in then
|
||||||
self.object:setvelocity({x=self.object:getvelocity().x,y=1*self.walk_velocity,z=self.object:getvelocity().z})
|
if me_y < p_y then
|
||||||
elseif me_y > p_y then
|
self.object:setvelocity({x=v.x,y=1*self.walk_velocity,z=v.z})
|
||||||
self.object:setvelocity({x=self.object:getvelocity().x,y=-1*self.walk_velocity,z=self.object:getvelocity().z})
|
elseif me_y > p_y then
|
||||||
end
|
self.object:setvelocity({x=v.x,y=-1*self.walk_velocity,z=v.z})
|
||||||
else
|
end
|
||||||
if me_y < p_y then
|
else
|
||||||
self.object:setvelocity({x=self.object:getvelocity().x,y=0.01,z=self.object:getvelocity().z})
|
if me_y < p_y then
|
||||||
elseif me_y > p_y then
|
self.object:setvelocity({x=v.x,y=0.01,z=v.z})
|
||||||
self.object:setvelocity({x=self.object:getvelocity().x,y=-0.01,z=self.object:getvelocity().z})
|
elseif me_y > p_y then
|
||||||
end
|
self.object:setvelocity({x=v.x,y=-0.01,z=v.z})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
-- end fly bit
|
-- end fly bit
|
||||||
|
|
||||||
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"
|
||||||
@ -747,7 +734,7 @@ end
|
|||||||
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) + self.rotate
|
yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate -- local
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
@ -812,7 +799,7 @@ end
|
|||||||
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) + self.rotate
|
yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate -- local
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
@ -843,18 +830,19 @@ end
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
local pos = self.object:getpos()
|
if self.type == "monster" and peaceful_only then
|
||||||
self.object:set_hp( math.random(self.hp_min, self.hp_max) ) -- set HP
|
self.object:remove()
|
||||||
self.oldhp = self.object:get_hp(self) -- used for hurt sound
|
end
|
||||||
|
|
||||||
|
self.health = math.random (self.hp_min, self.hp_max) -- set initial HP
|
||||||
|
self.object:set_hp( self.health )
|
||||||
|
self.health = self.object:get_hp()
|
||||||
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"
|
||||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||||
if self.type == "monster" and peaceful_only then
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
if staticdata then
|
if staticdata then
|
||||||
local tmp = minetest.deserialize(staticdata)
|
local tmp = minetest.deserialize(staticdata)
|
||||||
@ -892,12 +880,12 @@ end
|
|||||||
if tmp.owner then
|
if tmp.owner then
|
||||||
self.owner = tmp.owner
|
self.owner = tmp.owner
|
||||||
end
|
end
|
||||||
|
if tmp.health then
|
||||||
|
self.health = tmp.health
|
||||||
|
self.object:set_hp( self.health )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- quick fix for dog so it doesn't revert back to wolf
|
|
||||||
if self.type == "monster" and self.tamed == true then
|
|
||||||
self.type = "npc"
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
@ -942,17 +930,36 @@ end
|
|||||||
base_texture = self.base_texture,
|
base_texture = self.base_texture,
|
||||||
collisionbox = colbox,
|
collisionbox = colbox,
|
||||||
owner = self.owner,
|
owner = self.owner,
|
||||||
|
health = self.health,
|
||||||
}
|
}
|
||||||
self.object:set_properties(tmp)
|
self.object:set_properties(tmp)
|
||||||
return minetest.serialize(tmp)
|
return minetest.serialize(tmp)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
|
-- weapon wear
|
||||||
|
local weapon = hitter:get_wielded_item()
|
||||||
|
if weapon:get_definition().tool_capabilities ~= nil then
|
||||||
|
local wear = ( weapon:get_definition().tool_capabilities.full_punch_interval / 75 ) * 9000
|
||||||
|
weapon:add_wear(wear)
|
||||||
|
hitter:set_wielded_item(weapon)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- weapon sounds
|
||||||
|
if weapon:get_definition().sounds ~= nil then
|
||||||
|
local s = math.random(0,#weapon:get_definition().sounds)
|
||||||
|
minetest.sound_play(weapon:get_definition().sounds[s], {
|
||||||
|
object=hitter,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
minetest.sound_play("default_punch", {
|
||||||
|
object = hitter,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
process_weapon(hitter,tflp,tool_capabilities)
|
|
||||||
check_for_death(self)
|
check_for_death(self)
|
||||||
|
|
||||||
--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 and enable_blood == true then
|
if self.blood_amount > 0 and pos and enable_blood == true then
|
||||||
@ -960,17 +967,14 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- knock back effect, adapted from blockmen's pyramids mod
|
-- knock back effect, adapted from blockmen's pyramids mod
|
||||||
-- 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 = 0 -- was 2
|
|
||||||
local v = self.object:getvelocity()
|
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
|
self.object:setvelocity({x=dir.x*kb,y=0,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
|
||||||
|
|
||||||
-- attack puncher and call other mobs for help
|
-- attack puncher and call other mobs for help
|
||||||
@ -1083,24 +1087,6 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
|
|||||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
local p = {}
|
local p = {}
|
||||||
local undestroyed = { --Modif MFF DEBUT
|
|
||||||
minetest.get_content_id("air"),
|
|
||||||
minetest.get_content_id("ignore"),
|
|
||||||
minetest.get_content_id("default:obsidian"),
|
|
||||||
minetest.get_content_id("default:obsidianbrick"),
|
|
||||||
minetest.get_content_id("default:chest_locked"),
|
|
||||||
minetest.get_content_id("doors:door_steel_b_1"),
|
|
||||||
minetest.get_content_id("doors:door_steel_t_1"),
|
|
||||||
minetest.get_content_id("doors:door_steel_b_2"),
|
|
||||||
minetest.get_content_id("doors:door_steel_t_2"),
|
|
||||||
minetest.get_content_id("default:bedrock"),
|
|
||||||
minetest.get_content_id("default:obsidian_cooled"),
|
|
||||||
minetest.get_content_id("more_chests:cobble"),
|
|
||||||
minetest.get_content_id("more_chests:shared"),
|
|
||||||
minetest.get_content_id("more_chests:secret"),
|
|
||||||
minetest.get_content_id("more_chests:dropbox"),
|
|
||||||
minetest.get_content_id("more_chests:shared_chest")
|
|
||||||
} --Modif MFF DEBUT
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_ignore = minetest.get_content_id("ignore")
|
local c_ignore = minetest.get_content_id("ignore")
|
||||||
local c_obsidian = minetest.get_content_id("default:obsidian")
|
local c_obsidian = minetest.get_content_id("default:obsidian")
|
||||||
@ -1134,19 +1120,14 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
if fire > 0 and (minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30) then
|
||||||
if n.name == "doors:door_wood_b_1" then
|
minetest.set_node(p, {name="fire:basic_flame"})
|
||||||
minetest.remove_node({x=np.x,y=np.y+1,z=np.z})
|
else
|
||||||
elseif n.name == "doors:door_wood_t_1" then
|
minetest.remove_node(p)
|
||||||
minetest.remove_node({x=np.x,y=np.y-1,z=np.z})
|
end
|
||||||
end
|
if smoke > 0 then
|
||||||
if fire > 0 and (minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30) then
|
effect(p, 2, "tnt_smoke.png", 5)
|
||||||
minetest.set_node(p, {name="fire:basic_flame"})
|
end
|
||||||
else
|
|
||||||
minetest.remove_node(p)
|
|
||||||
end
|
|
||||||
if smoke > 0 then
|
|
||||||
effect(p, 2, "tnt_smoke.png", 5)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vi = vi + 1
|
vi = vi + 1
|
||||||
@ -1159,9 +1140,9 @@ end
|
|||||||
function check_for_death(self)
|
function check_for_death(self)
|
||||||
local hp = self.object:get_hp()
|
local hp = self.object:get_hp()
|
||||||
if hp > 0 then
|
if hp > 0 then
|
||||||
if self.sounds.damage ~= nil and hp < self.oldhp then
|
if self.sounds.damage ~= nil then
|
||||||
minetest.sound_play(self.sounds.damage,{object = self.object})
|
minetest.sound_play(self.sounds.damage,{object = self.object})
|
||||||
self.oldhp = hp
|
self.health = hp
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1269,15 +1250,6 @@ function mobs:register_arrow(name, def)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_weapon(player, time_from_last_punch, tool_capabilities)
|
|
||||||
local weapon = player:get_wielded_item()
|
|
||||||
if tool_capabilities ~= nil then
|
|
||||||
local wear = ( tool_capabilities.full_punch_interval / 75 ) * 65535
|
|
||||||
weapon:add_wear(wear)
|
|
||||||
player:set_wielded_item(weapon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Spawn Egg
|
-- Spawn Egg
|
||||||
function mobs:register_egg(mob, desc, background, addegg)
|
function mobs:register_egg(mob, desc, background, addegg)
|
||||||
local invimg = background
|
local invimg = background
|
||||||
@ -1294,8 +1266,7 @@ function mobs:register_egg(mob, desc, background, addegg)
|
|||||||
local mob = minetest.add_entity(pos, mob)
|
local mob = minetest.add_entity(pos, mob)
|
||||||
local ent = mob:get_luaentity()
|
local ent = mob:get_luaentity()
|
||||||
if ent.type ~= "monster" then
|
if ent.type ~= "monster" then
|
||||||
ent.owner = placer:get_player_name()
|
-- set owner
|
||||||
ent.tamed = true
|
|
||||||
ent.owner = placer:get_player_name()
|
ent.owner = placer:get_player_name()
|
||||||
ent.tamed = true
|
ent.tamed = true
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,10 @@ News de FR - MinetestForFun (Survival - PVP - Hardcore)
|
|||||||
/!\ Le serveur étant devenu extrêmement stable, les MAJ vont se rarifier pour un temps /!\
|
/!\ Le serveur étant devenu extrêmement stable, les MAJ vont se rarifier pour un temps /!\
|
||||||
/!\ En effet, nous profitons de cette stabilité pour préparer une grosse MAJ qui boulversera à jamais le gameplay de Minetest /!\
|
/!\ En effet, nous profitons de cette stabilité pour préparer une grosse MAJ qui boulversera à jamais le gameplay de Minetest /!\
|
||||||
|
|
||||||
|
---xx/05/2015--- (Remerciements : x)
|
||||||
|
MAJ de "mobs" (possibilité d'ajouter des armes aux monstres, les monstres endommagés ne voient plus leur vie restauré s'ils sont déchargés puis rechergés, et amélioration du code)
|
||||||
|
MAJ de "hud/hunger.lua" (ajout des valeurs de nutritions des haricots/beans)
|
||||||
|
|
||||||
---27/05/2015--- (Remerciements : Mg, Obani, Ataron)
|
---27/05/2015--- (Remerciements : Mg, Obani, Ataron)
|
||||||
MAJ de "/_misc/whoison" ("/timeonline" à maintenant un alias "/played", libre à vous de l'utiliser)
|
MAJ de "/_misc/whoison" ("/timeonline" à maintenant un alias "/played", libre à vous de l'utiliser)
|
||||||
MAJ de "bobblocks" (grosse amélioration du code par HybridDog)
|
MAJ de "bobblocks" (grosse amélioration du code par HybridDog)
|
||||||
|
Loading…
Reference in New Issue
Block a user