mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-18 00:08:25 +01:00
update mobs
This commit is contained in:
parent
a24926d266
commit
bfc572f898
@ -1,4 +1,4 @@
|
|||||||
-- Mobs Api (27th September 2015)
|
-- Mobs Api (5th October 2015)
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
|
|
||||||
@ -265,7 +265,9 @@ minetest.register_entity(name, {
|
|||||||
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")
|
effect(self.object:getpos(), 5, "tnt_smoke.png")
|
||||||
check_for_death(self)
|
if check_for_death(self) then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
end
|
end
|
||||||
@ -318,8 +320,8 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.water_damage ~= 0 or self.lava_damage ~= 0 then
|
if self.water_damage ~= 0 or self.lava_damage ~= 0 then
|
||||||
pos.y = pos.y + self.collisionbox[2] -- foot level
|
pos.y = (pos.y + self.collisionbox[2]) + 0.1 -- foot level
|
||||||
local nod = node_ok(pos, "air") -- print ("standing in "..nod.name)
|
local nod = node_ok(pos, "air") ; -- print ("standing in "..nod.name)
|
||||||
local nodef = minetest.registered_nodes[nod.name]
|
local nodef = minetest.registered_nodes[nod.name]
|
||||||
if not nodef then return end
|
if not nodef then return end
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
@ -841,7 +843,6 @@ end
|
|||||||
entity_physics(pos, 3, self) -- hurt player/mobs caught in blast area --/MFF (Crabman|06/23/2015)add self to use punch function
|
entity_physics(pos, 3, self) -- hurt player/mobs caught in blast area --/MFF (Crabman|06/23/2015)add self to use punch function
|
||||||
if minetest.find_node_near(pos, 1, {"group:water"})
|
if minetest.find_node_near(pos, 1, {"group:water"})
|
||||||
or minetest.is_protected(pos, "") then
|
or minetest.is_protected(pos, "") then
|
||||||
self.object:remove()
|
|
||||||
if self.sounds.explode ~= "" then
|
if self.sounds.explode ~= "" then
|
||||||
minetest.sound_play(self.sounds.explode, {
|
minetest.sound_play(self.sounds.explode, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
@ -849,12 +850,13 @@ end
|
|||||||
max_hear_distance = 16
|
max_hear_distance = 16
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
self.object:remove()
|
||||||
effect(pos, 15, "tnt_smoke.png", 5)
|
effect(pos, 15, "tnt_smoke.png", 5)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.object:remove()
|
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
mobs:explosion(pos, 2, 0, 1, self.sounds.explode)
|
mobs:explosion(pos, 2, 0, 1, self.sounds.explode)
|
||||||
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1009,6 +1011,7 @@ end
|
|||||||
if self.type == "monster"
|
if self.type == "monster"
|
||||||
and peaceful_only then
|
and peaceful_only then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- load entity variables
|
-- load entity variables
|
||||||
@ -1019,6 +1022,8 @@ end
|
|||||||
self[_] = stat
|
self[_] = stat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- select random texture, set model and size
|
-- select random texture, set model and size
|
||||||
@ -1089,6 +1094,7 @@ end
|
|||||||
if mobs.remove and self.remove_ok and not self.tamed then
|
if mobs.remove and self.remove_ok and not self.tamed then
|
||||||
print ("REMOVED", self.remove_ok, self.name)
|
print ("REMOVED", self.remove_ok, self.name)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
self.remove_ok = true
|
self.remove_ok = true
|
||||||
self.attack = nil
|
self.attack = nil
|
||||||
@ -1363,7 +1369,6 @@ function check_for_death(self)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
self.object:remove()
|
|
||||||
local obj = nil
|
local obj = nil
|
||||||
for _,drop in ipairs(self.drops) do
|
for _,drop in ipairs(self.drops) do
|
||||||
if math.random(1, drop.chance) == 1 then
|
if math.random(1, drop.chance) == 1 then
|
||||||
@ -1372,7 +1377,7 @@ function check_for_death(self)
|
|||||||
if obj then
|
if obj then
|
||||||
obj:setvelocity({
|
obj:setvelocity({
|
||||||
x = math.random(-1, 1),
|
x = math.random(-1, 1),
|
||||||
y = 5,
|
y = 6,
|
||||||
z = math.random(-1, 1)
|
z = math.random(-1, 1)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -1387,6 +1392,7 @@ function check_for_death(self)
|
|||||||
if self.on_die then
|
if self.on_die then
|
||||||
self.on_die(self, pos)
|
self.on_die(self, pos)
|
||||||
end
|
end
|
||||||
|
self.object:remove()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -160,12 +160,25 @@ minetest.register_entity("mobs:sheep", {
|
|||||||
collisionbox = {-0.4, -1, -0.4, 0.4, 0.3, 0.4},
|
collisionbox = {-0.4, -1, -0.4, 0.4, 0.3, 0.4},
|
||||||
is_visible = true,
|
is_visible = true,
|
||||||
speed = 0,
|
speed = 0,
|
||||||
|
timer = 0,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
clicker:get_inventory():add_item("main", "mobs:sheep_white")
|
clicker:get_inventory():add_item("main", "mobs:sheep_white")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer >= 1 then
|
||||||
|
self.timer = 0
|
||||||
|
self.object:setacceleration({
|
||||||
|
x = 0,
|
||||||
|
y = -10,
|
||||||
|
z = 0
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- -- shears (right click sheep to shear wool)
|
-- -- shears (right click sheep to shear wool)
|
||||||
|
@ -61,7 +61,7 @@ mobs:register_mob("mobs:pumba", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
-- spawns on dirt or junglegrass, between 8 and 20 light, 1 in 10000 chance, 1 in area up to 31000 in height
|
-- spawns on dirt or junglegrass, between 8 and 20 light, 1 in 10000 chance, 1 in area up to 31000 in height
|
||||||
mobs:spawn_specific("mobs:pumba", {"default:dirt", "default:junglegrass"}, {"air"}, 8, 20, 30, 10000, 1, -31000, 31000, true)
|
mobs:spawn_specific("mobs:pumba", {"default:dirt", "default:junglegrass", "default:dirt_with_dry_grass"}, {"air"}, 8, 20, 30, 10000, 1, -31000, 31000, true)
|
||||||
-- register spawn egg
|
-- register spawn egg
|
||||||
mobs:register_egg("mobs:pumba", "Warthog", "mobs_warthog_inv.png", 1)
|
mobs:register_egg("mobs:pumba", "Warthog", "mobs_warthog_inv.png", 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user