forked from VoxeLibre/VoxeLibre
Merge pull request 'Make every mob besides spiders get slowed down by cobwebs like players' (#1643) from jordan4ibanez/MineClone2:mineclone5 into mineclone5
Reviewed-on: MineClone2/MineClone2#1643
This commit is contained in:
commit
24df0271d4
|
@ -359,6 +359,8 @@ function mobs:register_mob(name, def)
|
||||||
|
|
||||||
--fire timer
|
--fire timer
|
||||||
burn_timer = 0,
|
burn_timer = 0,
|
||||||
|
|
||||||
|
ignores_cobwebs = def.ignores_cobwebs,
|
||||||
--end j4i stuff
|
--end j4i stuff
|
||||||
|
|
||||||
-- MCL2 extensions
|
-- MCL2 extensions
|
||||||
|
|
|
@ -1035,6 +1035,30 @@ mobs.mob_step = function(self, dtime)
|
||||||
mobs.collision(self)
|
mobs.collision(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--overrides absolutely everything
|
||||||
|
--mobs get stuck in cobwebs like players
|
||||||
|
if not self.ignores_cobwebs then
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local node = minetest_get_node(pos).name
|
||||||
|
|
||||||
|
if node == "mcl_core:cobweb" then
|
||||||
|
|
||||||
|
--fight the rest of the api
|
||||||
|
if self.object:get_acceleration().y ~= 0 then
|
||||||
|
self.object:set_acceleration(vector_new(0,0,0))
|
||||||
|
end
|
||||||
|
|
||||||
|
mobs.stick_in_cobweb(self)
|
||||||
|
|
||||||
|
else
|
||||||
|
--return the mob back to normal
|
||||||
|
if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then
|
||||||
|
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.old_velocity = self.object:get_velocity()
|
self.old_velocity = self.object:get_velocity()
|
||||||
self.old_pos = self.object:get_pos()
|
self.old_pos = self.object:get_pos()
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ local vector_new = vector.new
|
||||||
local vector_length = vector.length
|
local vector_length = vector.length
|
||||||
local vector_multiply = vector.multiply
|
local vector_multiply = vector.multiply
|
||||||
local vector_distance = vector.distance
|
local vector_distance = vector.distance
|
||||||
|
local vector_normalize = vector.normalize
|
||||||
|
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
|
@ -19,6 +20,20 @@ local DEFAULT_FLOAT_SPEED = 4
|
||||||
local DEFAULT_CLIMB_SPEED = 3
|
local DEFAULT_CLIMB_SPEED = 3
|
||||||
|
|
||||||
|
|
||||||
|
mobs.stick_in_cobweb = function(self)
|
||||||
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
|
local goal_velocity = vector_multiply(vector_normalize(current_velocity), 0.4)
|
||||||
|
|
||||||
|
goal_velocity.y = -0.5
|
||||||
|
|
||||||
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
|
--smooths out mobs a bit
|
||||||
|
if vector_length(new_velocity_addition) >= 0.0001 then
|
||||||
|
self.object:add_velocity(new_velocity_addition)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--this is a generic float function
|
--this is a generic float function
|
||||||
mobs.float = function(self)
|
mobs.float = function(self)
|
||||||
|
|
|
@ -26,6 +26,7 @@ local spider = {
|
||||||
reach = 2,
|
reach = 2,
|
||||||
hp_min = 16,
|
hp_min = 16,
|
||||||
hp_max = 16,
|
hp_max = 16,
|
||||||
|
ignores_cobwebs = true,
|
||||||
xp_min = 5,
|
xp_min = 5,
|
||||||
xp_max = 5,
|
xp_max = 5,
|
||||||
eye_height = 0.475,
|
eye_height = 0.475,
|
||||||
|
|
|
@ -961,9 +961,11 @@ mobs:register_mob("mobs_mc:villager", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
visual_size = {x=2.75, y=2.75},
|
visual_size = {x=2.75, y=2.75},
|
||||||
|
rotate = 270,
|
||||||
|
skittish = true,
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1.2,
|
walk_velocity = 1.2,
|
||||||
run_velocity = 2.4,
|
run_velocity = 3,
|
||||||
drops = {},
|
drops = {},
|
||||||
can_despawn = false,
|
can_despawn = false,
|
||||||
-- TODO: sounds
|
-- TODO: sounds
|
||||||
|
|
Loading…
Reference in New Issue