From 081ae7fbff9737a8baac7523d1a65bd2e864ba22 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 2 Jan 2021 12:43:50 +0100 Subject: [PATCH] Make undead mobs burn in sunlight instead of dealing damage directly --- mods/ENTITIES/mcl_mobs/api.lua | 8 ++++++-- mods/ENTITIES/mcl_mobs/api.txt | 1 + mods/ENTITIES/mobs_mc/skeleton+stray.lua | 2 +- mods/ENTITIES/mobs_mc/villager_zombie.lua | 3 ++- mods/ENTITIES/mobs_mc/zombie.lua | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 91157e12e9..e9e3caa813 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1053,8 +1053,11 @@ local do_env_damage = function(self) if mod_worlds then _, dim = mcl_worlds.y_to_layer(pos.y) end - if self.sunlight_damage ~= 0 and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then - if deal_light_damage(self, pos, self.sunlight_damage) then + if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then + if self.ignited_by_sunlight then + mcl_burning.set_on_fire(self.object, 10, self.sunlight_damage or 1) + else + deal_light_damage(self, pos, self.sunlight_damage) return true end end @@ -3813,6 +3816,7 @@ minetest.register_entity(name, { instant_death = def.instant_death or false, fire_resistant = def.fire_resistant or false, fire_damage_resistant = def.fire_damage_resistant or false, + ignited_by_sunlight = def.ignited_by_sunlight or false, -- 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 7c85ea5666..ee97489b55 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -251,6 +251,7 @@ functions needed for the mob to work properly which contains the following: 'xp_max' the maximum XP it drops on death (default: 0) 'fire_resistant' If true, the mob can't burn 'fire_damage_resistant' If true the mob will not take damage when burning + 'ignited_by_sunlight' If true the mod will burn at daytime. (Takes sunlight_damage per second) diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index f3ef3c4b1c..cb12e905d5 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -81,7 +81,7 @@ local skeleton = { die_speed = 15, die_loop = false, }, - sunlight_damage = 1, + ignited_by_sunlight = true, view_range = 16, fear_height = 4, attack_type = "dogshoot", diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index f6927aa41b..8bbd3c530f 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -82,7 +82,8 @@ mobs:register_mob("mobs_mc:villager_zombie", { run_start = 0, run_end = 20, }, - sunlight_damage = 1, + sunlight_damage = 2, + ignited_by_sunlight = true, view_range = 16, fear_height = 4, harmed_by_heal = true, diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 75c8273c67..df9727d34f 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -85,6 +85,7 @@ local zombie = { walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, + ignited_by_sunlight = true, sunlight_damage = 2, view_range = 16, attack_type = "dogfight", @@ -111,6 +112,7 @@ mobs:register_mob("mobs_mc:baby_zombie", baby_zombie) -- Desert variant of the zombie local husk = table.copy(zombie) husk.textures = {{"mobs_mc_husk.png"}} +husk.ignited_by_sunlight = false husk.sunlight_damage = 0 husk.drops = drops_common -- TODO: Husks avoid water