1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 18:20:36 +01:00

Update mobs mod

- Add Golden lasso texture
- Improve code for mobs jump next to fences
This commit is contained in:
Ombridride 2015-04-12 22:45:04 +02:00
parent 94c8d0521a
commit c8353dd2fb

View File

@ -90,7 +90,7 @@ lifetimer = def.lifetimer or 600,
end, end,
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
if def.drawtype and def.drawtype == "side" then self.rotate = 1.5 end if def.drawtype and def.drawtype == "side" then self.rotate = 1.5 end
local yaw = self.object:getyaw() + self.rotate local yaw = self.object:getyaw() + self.rotate
local x = math.sin(yaw) * -v local x = math.sin(yaw) * -v
@ -272,12 +272,22 @@ lifetimer = def.lifetimer or 600,
local nod = minetest.get_node(pos) local nod = minetest.get_node(pos)
if not nod or not minetest.registered_nodes[nod.name] if not nod or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == false then return end or minetest.registered_nodes[nod.name].walkable == false then return end
local v = self.object:getvelocity()
v.y = self.jump_height if self.direction then
if self.following then v.y = v.y + 1 end local nod = minetest.get_node_or_nil({x=pos.x + self.direction.x,y=pos.y+1,z=pos.z + self.direction.z})
self.object:setvelocity(v) if nod and nod.name and (nod.name ~= "air" or self.walk_chance == 0) then
if self.sounds.jump then local def = minetest.registered_items[nod.name]
minetest.sound_play(self.sounds.jump, {object = self.object}) if (def and def.walkable and not nod.name:find("fence")) or self.walk_chance == 0 then
local v = self.object:getvelocity()
v.y = self.jump_height + 1
v.x = v.x * 2.2
v.z = v.z * 2.2
self.object:setvelocity(v)
if self.sounds.jump then
minetest.sound_play(self.sounds.jump, {object = self.object})
end
end
end
end end
end end
@ -458,6 +468,7 @@ lifetimer = def.lifetimer or 600,
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 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)}
do_jump(self) do_jump(self)
end end
self.set_velocity(self, self.walk_velocity) self.set_velocity(self, self.walk_velocity)
@ -521,6 +532,7 @@ lifetimer = def.lifetimer or 600,
-- jumping mobs only -- jumping mobs only
if self.jump_chance ~= 0 and math.random(1, 100) <= self.jump_chance then if self.jump_chance ~= 0 and math.random(1, 100) <= self.jump_chance then
self.direction = {x=0, y=0, z=0}
do_jump(self) do_jump(self)
self.set_velocity(self, self.walk_velocity) self.set_velocity(self, self.walk_velocity)
end end
@ -532,6 +544,7 @@ lifetimer = def.lifetimer or 600,
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
self.direction = {x = math.sin(yaw)*-1, y = -20, z = math.cos(yaw)}
do_jump(self) do_jump(self)
end end
@ -542,7 +555,8 @@ lifetimer = def.lifetimer or 600,
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 --Modif MFF, attack type Creeper -- Modif MFF "attack type kamicaze" des creepers /DEBUT
elseif self.state == "attack" and self.attack_type == "kamicaze" then
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")
@ -668,6 +682,7 @@ lifetimer = def.lifetimer or 600,
end end
end end
end end
-- Modif MFF "attack type kamicaze" des creepers /FIN
elseif self.state == "attack" and self.attack_type == "dogfight" then elseif self.state == "attack" and self.attack_type == "dogfight" then
if not self.attack.player or not self.attack.player:getpos() then if not self.attack.player or not self.attack.player:getpos() then
@ -699,6 +714,7 @@ lifetimer = def.lifetimer or 600,
-- jump attack -- jump attack
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 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)}
do_jump(self) do_jump(self)
end end
self.set_velocity(self, self.run_velocity) self.set_velocity(self, self.run_velocity)
@ -795,14 +811,12 @@ lifetimer = def.lifetimer or 600,
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
-- self.lifetimer = self.lifetimer - dtime_s
-- 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
end end
if tmp.tamed then if tmp.tamed then
self.tamed = tmp.tamed self.tamed = tmp.tamed
@ -837,9 +851,6 @@ lifetimer = def.lifetimer or 600,
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
-- self.object:remove()
-- end
end, end,
get_staticdata = function(self) get_staticdata = function(self)
@ -930,23 +941,20 @@ lifetimer = def.lifetimer or 600,
end end
end end
end end
end, end,
}) })
end end
mobs.spawning_mobs = {} mobs.spawning_mobs = {}
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, 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 = neighbors, neighbors = neighbors,
interval = interval, interval = interval,
chance = chance, chance = chance,
action = function(pos, node, _, active_object_count_wider) action = function(pos, node, _, active_object_count_wider)
-- do not spawn if too many active in area -- do not spawn if too many active in area
if active_object_count_wider > active_object_count if active_object_count_wider > active_object_count
or not mobs.spawning_mobs[name] or not mobs.spawning_mobs[name]