From 148b30694f2ee52ab454d72c6bff103a94c883e3 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 10 Nov 2022 22:59:42 +0100 Subject: [PATCH] Fix monster_attack and some other settings issues --- mods/ENTITIES/mcl_mobs/api.lua | 14 -------------- mods/ENTITIES/mcl_mobs/combat.lua | 4 ++++ mods/ENTITIES/mcl_mobs/effects.lua | 1 + mods/ENTITIES/mcl_mobs/init.lua | 18 ++++++++++++++++-- mods/ENTITIES/mcl_mobs/movement.lua | 11 +++++++++++ mods/ENTITIES/mcl_mobs/pathfinding.lua | 1 + 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 221c0a956..0c02c83f6 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3,13 +3,7 @@ local mob_class_meta = {__index = mcl_mobs.mob_class} local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs -- API for Mobs Redo: MineClone 2 Edition (MRM) local MAX_MOB_NAME_LENGTH = 30 -local HORNY_TIME = 30 -local HORNY_AGAIN_TIME = 300 -local CHILD_GROW_TIME = 60*20 -local DEATH_DELAY = 0.5 local DEFAULT_FALL_SPEED = -9.81*1.5 -local FLOP_HEIGHT = 6 -local FLOP_HOR_SPEED = 1.5 local PATHFINDING = "gowp" @@ -41,12 +35,9 @@ local function atan(x) end -- Load settings -local damage_enabled = minetest.settings:get_bool("enable_damage") -local disable_blood = minetest.settings:get_bool("mobs_disable_blood") local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false local remove_far = true -local show_health = false -- Shows helpful debug info above each mob local mobs_debug = minetest.settings:get_bool("mobs_debug", false) local spawn_logging = minetest.settings:get_bool("mcl_logging_mobs_spawn",true) @@ -69,7 +60,6 @@ end local node_ice = "mcl_core:ice" local node_snowblock = "mcl_core:snowblock" local node_snow = "mcl_core:snow" -mcl_mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" minetest.register_chatcommand("clearmobs",{ privs={maphack=true}, @@ -137,15 +127,11 @@ end -- get node but use fallback for nil or unknown local node_ok = function(pos, fallback) - fallback = fallback or mcl_mobs.fallback_node - local node = minetest.get_node_or_nil(pos) - if node and minetest.registered_nodes[node.name] then return node end - return minetest.registered_nodes[fallback] end diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 05f0f2ebc..91e7c7ec2 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -1,6 +1,10 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local mob_class = mcl_mobs.mob_class +local damage_enabled = minetest.settings:get_bool("enable_damage") +local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + +local show_health = false -- pathfinding settings local enable_pathfinding = true local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching diff --git a/mods/ENTITIES/mcl_mobs/effects.lua b/mods/ENTITIES/mcl_mobs/effects.lua index 3e62f2539..08a36780f 100644 --- a/mods/ENTITIES/mcl_mobs/effects.lua +++ b/mods/ENTITIES/mcl_mobs/effects.lua @@ -1,6 +1,7 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local mob_class = mcl_mobs.mob_class local active_particlespawners = {} +local disable_blood = minetest.settings:get_bool("mobs_disable_blood") local DEFAULT_FALL_SPEED = -9.81*1.5 local player_transfer_distance = tonumber(minetest.settings:get("player_transfer_distance")) or 128 diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 41fdbc3b0..106790a26 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -4,6 +4,7 @@ mcl_mobs.mob_class_meta = {__index = mcl_mobs.mob_class} local modname = minetest.get_current_modname() local path = minetest.get_modpath(modname) local S = minetest.get_translator(modname) +mcl_mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" --api and helpers -- effects: sounds and particles mostly dofile(path .. "/effects.lua") @@ -28,9 +29,22 @@ dofile(path .. "/mount.lua") dofile(path .. "/crafts.lua") dofile(path .. "/compat.lua") +local DEFAULT_FALL_SPEED = -9.81*1.5 +local MAX_MOB_NAME_LENGTH = 30 + local old_spawn_icons = minetest.settings:get_bool("mcl_old_spawn_icons",false) local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 +-- get node but use fallback for nil or unknown +local node_ok = function(pos, fallback) + fallback = fallback or mcl_mobs.fallback_node + local node = minetest.get_node_or_nil(pos) + if node and minetest.registered_nodes[node.name] then + return node + end + return minetest.registered_nodes[fallback] +end + --#### REGISTER FUNCS -- Code to execute before custom on_rightclick handling @@ -301,7 +315,7 @@ function mcl_mobs.register_arrow(name, def) if not name or not def then return end -- errorcheck - minetest.register_entity(name, setmetatable({ + minetest.register_entity(name, { physical = false, visual = def.visual, @@ -421,7 +435,7 @@ function mcl_mobs.register_arrow(name, def) self.lastpos = pos end - },mob_class)) + }) end -- Register spawn eggs diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 642f513d1..17df265a8 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -4,6 +4,17 @@ local DEFAULT_FALL_SPEED = -9.81*1.5 local FLOP_HEIGHT = 6 local FLOP_HOR_SPEED = 1.5 +local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + +local atann = math.atan +local function atan(x) + if not x or x ~= x then + return 0 + else + return atann(x) + end +end + -- get node but use fallback for nil or unknown local node_ok = function(pos, fallback) fallback = fallback or mcl_mobs.fallback_node diff --git a/mods/ENTITIES/mcl_mobs/pathfinding.lua b/mods/ENTITIES/mcl_mobs/pathfinding.lua index 2bab7524e..495d23cd4 100644 --- a/mods/ENTITIES/mcl_mobs/pathfinding.lua +++ b/mods/ENTITIES/mcl_mobs/pathfinding.lua @@ -2,6 +2,7 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local mob_class = mcl_mobs.mob_class local LOGGING_ON = minetest.settings:get_bool("mcl_logging_mobs_villager",false) +local PATHFINDING = "gowp" local LOG_MODULE = "[Mobs]" local function mcl_log (message)