From a9b59816c4a0165f6cd4967a9dfc5a8a8df0f54f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 5 Dec 2020 14:14:16 +0100 Subject: [PATCH] Implement very basic flopping --- mods/ENTITIES/mcl_mobs/api.lua | 16 ++++++++++++++-- mods/ENTITIES/mobs_mc/squid.lua | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 37a10a5efe..d03092998e 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -11,6 +11,8 @@ local HORNY_AGAIN_TIME = 300 local CHILD_GROW_TIME = 60*20 local DEATH_DELAY = 0.5 local DEFAULT_FALL_SPEED = -10 +local FLOP_HEIGHT = 5.0 +local FLOP_HOR_SPEED = 1.5 local MOB_CAP = {} MOB_CAP.hostile = 70 @@ -2147,13 +2149,23 @@ local follow_flop = function(self) if not flight_check(self, s) then self.state = "flop" - self.object:set_velocity({x = 0, y = -5, z = 0}) + self.object:set_acceleration({x = 0, y = DEFAULT_FALL_SPEED, z = 0}) - set_animation(self, "stand") + local sdef = minetest.registered_nodes[self.standing_on] + if sdef and sdef.walkable then + self.object:set_velocity({ + x = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), + y = FLOP_HEIGHT, + z = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), + }) + end + + set_animation(self, "stand", true) return elseif self.state == "flop" then self.state = "stand" + self.object:set_acceleration({x = 0, y = 0, z = 0}) end end end diff --git a/mods/ENTITIES/mobs_mc/squid.lua b/mods/ENTITIES/mobs_mc/squid.lua index a43bade397..12e4a8f592 100644 --- a/mods/ENTITIES/mobs_mc/squid.lua +++ b/mods/ENTITIES/mobs_mc/squid.lua @@ -47,7 +47,6 @@ mobs:register_mob("mobs_mc:squid", { fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, breathes_in_water = true, jump = false, - fall_speed = 0.5, view_range = 16, runaway = true, fear_height = 4,