mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-26 02:30:38 +01:00
Update mobs mod
- Add Golden lasso texture - Improve code for mobs jump next to fences
This commit is contained in:
parent
94c8d0521a
commit
c8353dd2fb
@ -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,14 +272,24 @@ 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
|
||||||
|
|
||||||
|
if self.direction then
|
||||||
|
local nod = minetest.get_node_or_nil({x=pos.x + self.direction.x,y=pos.y+1,z=pos.z + self.direction.z})
|
||||||
|
if nod and nod.name and (nod.name ~= "air" or self.walk_chance == 0) then
|
||||||
|
local def = minetest.registered_items[nod.name]
|
||||||
|
if (def and def.walkable and not nod.name:find("fence")) or self.walk_chance == 0 then
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:getvelocity()
|
||||||
v.y = self.jump_height
|
v.y = self.jump_height + 1
|
||||||
if self.following then v.y = v.y + 1 end
|
v.x = v.x * 2.2
|
||||||
|
v.z = v.z * 2.2
|
||||||
self.object:setvelocity(v)
|
self.object:setvelocity(v)
|
||||||
if self.sounds.jump then
|
if self.sounds.jump then
|
||||||
minetest.sound_play(self.sounds.jump, {object = self.object})
|
minetest.sound_play(self.sounds.jump, {object = self.object})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- environmental damage timer
|
-- environmental damage timer
|
||||||
self.env_damage_timer = self.env_damage_timer + dtime
|
self.env_damage_timer = self.env_damage_timer + dtime
|
||||||
@ -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,9 +941,7 @@ lifetimer = def.lifetimer or 600,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -946,7 +955,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||||||
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]
|
||||||
|
Loading…
Reference in New Issue
Block a user