From 460d6e837ab3f4e5fc65baec2ec5b8c436c53f13 Mon Sep 17 00:00:00 2001 From: MysticTempest Date: Mon, 3 Aug 2020 08:37:58 -0500 Subject: [PATCH] Fix farm mobs following players slowly, adjust animations to follow suit, increase pig view range slightly, and change the runaway animation from walk to run. --- mods/ENTITIES/mcl_mobs/api.lua | 11 ++++++----- mods/ENTITIES/mcl_mobs/api.txt | 1 + mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 9 +++++---- mods/ENTITIES/mobs_mc/horse.lua | 2 +- mods/ENTITIES/mobs_mc/llama.lua | 4 ++++ mods/ENTITIES/mobs_mc/ocelot.lua | 4 +++- mods/ENTITIES/mobs_mc/pig.lua | 5 +++-- mods/ENTITIES/mobs_mc/rabbit.lua | 1 + mods/ENTITIES/mobs_mc/sheep.lua | 4 ++-- mods/ENTITIES/mobs_mc/wolf.lua | 1 + mods/ENTITIES/mobs_mc_gameconfig/init.lua | 3 ++- 11 files changed, 29 insertions(+), 16 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 2d45bb257..622b87461 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1931,16 +1931,16 @@ local follow_flop = function(self) if p.x > s.x then yaw = yaw + pi end - set_yaw(self, yaw, 6) + set_yaw(self, yaw, 2.35) -- anyone but standing npc's can move along - if dist > self.reach + if dist > 3 and self.order ~= "stand" then - set_velocity(self, self.walk_velocity) + set_velocity(self, self.follow_velocity) if self.walk_chance ~= 0 then - set_animation(self, "walk") + set_animation(self, "run") end else set_velocity(self, 0) @@ -2179,7 +2179,7 @@ local do_states = function(self, dtime) set_animation(self, "stand") else set_velocity(self, self.run_velocity) - set_animation(self, "walk") + set_animation(self, "run") end -- attack routines (explode, dogfight, shoot, dogshoot) @@ -3472,6 +3472,7 @@ minetest.register_entity(name, { sounds_child = def.sounds_child, explosion_strength = def.explosion_strength, suffocation_timer = 0, + follow_velocity = def.follow_velocity or 2.4, -- End of MCL2 extensions on_spawn = def.on_spawn, diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index 17a6a8b04..8b7f71192 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -241,6 +241,7 @@ functions needed for the mob to work properly which contains the following: dir is mob's aiming direction 'sounds_child' same as sounds, but for childs. If not defined, childs will use same sound as adults but with higher pitch + 'follow_velocity' The speed at which a mob moves toward the player when they're holding the appropriate follow item. Node Replacement diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index cb5bb029a..dc231627c 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -35,10 +35,11 @@ local cow_def = { distance = 16, }, animation = { - stand_speed = 25, walk_speed = 25, run_speed = 50, - stand_start = 0, stand_end = 0, - walk_start = 0, walk_end = 40, - run_start = 0, run_end = 40, + stand_speed = 25, walk_speed = 40, + run_speed = 60, stand_start = 0, + stand_end = 0, walk_start = 0, + walk_end = 40, run_start = 0, + run_end = 40, }, follow = mobs_mc.follow.cow, on_rightclick = function(self, clicker) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 32ebbc1a9..bb4a93e2c 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -96,7 +96,7 @@ local horse = { walk_speed = 25, walk_start = 0, walk_end = 40, - run_speed = 50, + run_speed = 60, run_start = 0, run_end = 40, }, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 8215dcfd1..6391e867c 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -46,6 +46,7 @@ mobs:register_mob("mobs_mc:llama", { runaway = true, walk_velocity = 1, run_velocity = 4.4, + follow_velocity = 4.4, floats = 1, drops = { {name = mobs_mc.items.leather, @@ -61,6 +62,9 @@ mobs:register_mob("mobs_mc:llama", { }, animation = { speed_normal = 24, + run_speed = 60, + run_start = 0, + run_end = 40, stand_start = 0, stand_end = 0, walk_start = 0, diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index 5d7fe3bc2..89a41fe44 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -41,6 +41,7 @@ local ocelot = { walk_chance = default_walk_chance, walk_velocity = 1, run_velocity = 3, + follow_velocity = 1, floats = 1, runaway = true, fall_damage = 0, @@ -52,7 +53,7 @@ local ocelot = { }, animation = { speed_normal = 25, - speed_run = 50, + run_speed = 50, stand_start = 0, stand_end = 0, walk_start = 0, @@ -105,6 +106,7 @@ cat.order = "roam" -- "sit" or "roam" cat.owner_loyal = true cat.tamed = true cat.runaway = false +cat.follow_velocity = 2.4 -- Automatically teleport cat to owner cat.do_custom = mobs_mc.make_owner_teleport_function(12) cat.sounds = { diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index ebb3f7aa4..259f45d95 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -20,6 +20,7 @@ mobs:register_mob("mobs_mc:pig", { makes_footstep_sound = true, walk_velocity = 1, run_velocity = 3, + follow_velocity = 3.4, drops = { {name = mobs_mc.items.porkchop_raw, chance = 1, @@ -36,7 +37,7 @@ mobs:register_mob("mobs_mc:pig", { animation = { stand_speed = 40, walk_speed = 40, - run_speed = 50, + run_speed = 90, stand_start = 0, stand_end = 0, walk_start = 0, @@ -45,7 +46,7 @@ mobs:register_mob("mobs_mc:pig", { run_end = 40, }, follow = mobs_mc.follow.pig, - view_range = 5, + view_range = 8, do_custom = function(self, dtime) -- set needed values if not already present diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 8c0885636..783a24ff4 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -27,6 +27,7 @@ local rabbit = { makes_footstep_sound = false, walk_velocity = 1, run_velocity = 3.7, + follow_velocity = 1.1, floats = 1, runaway = true, jump = true, diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index a0c0a8a08..374ea4b59 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -76,8 +76,8 @@ mobs:register_mob("mobs_mc:sheep", { distance = 16, }, animation = { - speed_normal = 25, speed_run = 50, - stand_start = 40, stand_end = 80, + speed_normal = 25, run_speed = 65, + stand_start = 40, stand_end = 80, walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index e99853655..058c57153 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -125,6 +125,7 @@ dog.owner = "" -- TODO: Start sitting by default dog.order = "roam" dog.owner_loyal = true +dog.follow_velocity = 3.2 -- Automatically teleport dog to owner dog.do_custom = mobs_mc.make_owner_teleport_function(12) dog.follow = mobs_mc.follow.dog diff --git a/mods/ENTITIES/mobs_mc_gameconfig/init.lua b/mods/ENTITIES/mobs_mc_gameconfig/init.lua index bcac2256a..5f4e37c43 100644 --- a/mods/ENTITIES/mobs_mc_gameconfig/init.lua +++ b/mods/ENTITIES/mobs_mc_gameconfig/init.lua @@ -129,9 +129,10 @@ mobs_mc.override.items = { }, } +--Horses, Llamas, and Wolves shouldn't follow, but leaving this alone until leads are implemented. mobs_mc.override.follow = { chicken = { "mcl_farming:wheat_seeds", "mcl_farming:melon_seeds", "mcl_farming:pumpkin_seeds", "mcl_farming:beetroot_seeds", }, - parrot = { "mcl_farming:seed_wheat", "mcl_farming:seed_beetroot", "mcl_farming:seed_pumpkin", "mcl_farming:seed_melon" }, -- seeds in general + parrot = { "mcl_farming:wheat_seeds", "mcl_farming:melon_seeds", "mcl_farming:pumpkin_seeds", "mcl_farming:beetroot_seeds", }, pig = { mobs_mc.override.items.potato, mobs_mc.override.items.carrot, "mcl_farming:beetroot_item", mobs_mc.override.items.carrot_on_a_stick}, ocelot = { mobs_mc.override.items.fish_raw, mobs_mc.override.items.salmon_raw, mobs_mc.override.items.clownfish_raw, mobs_mc.override.items.pufferfish_raw, }, sheep = { mobs_mc.override.items.wheat },