From f9e46b914dd530df021661b6985a8340b0fddf2a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 2 Oct 2019 18:43:48 +0200 Subject: [PATCH] Mobs: Separate fire damage from lava damage --- mods/ENTITIES/mcl_mobs/api.lua | 24 ++++++++++++++++------ mods/ENTITIES/mcl_mobs/api.txt | 4 +++- mods/ENTITIES/mobs_mc/blaze.lua | 1 + mods/ENTITIES/mobs_mc/creeper.lua | 2 -- mods/ENTITIES/mobs_mc/ender_dragon.lua | 1 + mods/ENTITIES/mobs_mc/skeleton_wither.lua | 1 + mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 1 + mods/ENTITIES/mobs_mc/snowman.lua | 4 +--- mods/ENTITIES/mobs_mc/wither.lua | 1 + mods/ENTITIES/mobs_mc/zombie.lua | 1 - mods/ENTITIES/mobs_mc/zombiepig.lua | 1 + 11 files changed, 28 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 4c34e3a545..9dd6cb6e58 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -712,7 +712,7 @@ local do_env_damage = function(self) pos.y = pos.y + 1 -- for particle effect position - -- water + -- water damage if self.water_damage and nodef.groups.water then @@ -720,14 +720,13 @@ local do_env_damage = function(self) self.health = self.health - self.water_damage - -- TODO: Damage particle - effect(pos, 5, "bubble.png", nil, nil, 1, nil) + effect(pos, 5, "tnt_smoke.png", nil, nil, 1, nil) if check_for_death(self, "water", {type = "environment", pos = pos, node = self.standing_in}) then return end end - -- lava + -- lava damage elseif self.lava_damage and (nodef.groups.lava) then @@ -735,19 +734,31 @@ local do_env_damage = function(self) self.health = self.health - self.lava_damage - -- TODO: Damage particle effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) if check_for_death(self, "lava", {type = "environment", pos = pos, node = self.standing_in}) then return end end + -- fire damage + elseif self.fire_damage + and (nodef.groups.fire) then + + if self.fire_damage ~= 0 then + + self.health = self.health - self.fire_damage + + effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) + + if check_for_death(self, "fire", {type = "environment", + pos = pos, node = self.standing_in}) then return end + end + -- damage_per_second node check elseif nodef.damage_per_second ~= 0 then self.health = self.health - nodef.damage_per_second - -- TODO: Damage particle effect(pos, 5, "tnt_smoke.png") if check_for_death(self, "dps", {type = "environment", @@ -3132,6 +3143,7 @@ minetest.register_entity(name, { sunlight_damage = def.sunlight_damage or 0, water_damage = def.water_damage or 0, lava_damage = def.lava_damage or 8, + fire_damage = def.fire_damage or 1, suffocation = def.suffocation or true, fall_damage = def.fall_damage or 1, fall_speed = def.fall_speed or -10, -- must be lower than -2 (default: -10) diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index 283bc6a239..70ce89ffcf 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -61,9 +61,11 @@ functions needed for the mob to work properly which contains the following: 'fall_speed' has the maximum speed the mob can fall at, default is -10. 'fall_damage' when true causes falling to inflict damage. 'water_damage' holds the damage per second infliced to mobs when standing in - water. + water (default: 0). 'lava_damage' holds the damage per second inflicted to mobs when standing in lava (default: 8). + 'fire_damage' holds the damage per second inflicted to mobs when standing + in fire (default: 1). 'light_damage' holds the damage per second inflicted to mobs when it's too bright (above 13 light). 'suffocation' when true causes mobs to suffocate inside solid blocks (2 damage per second). diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 421a90d4b5..0af6691394 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -53,6 +53,7 @@ mobs:register_mob("mobs_mc:blaze", { -- MC Wiki: takes 1 damage every half second while in water water_damage = 2, lava_damage = 0, + fire_damage = 0, fall_damage = 0, fall_speed = -2.25, light_damage = 0, diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 77737997c8..184d9cbe19 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -114,8 +114,6 @@ mobs:register_mob("mobs_mc:creeper", { }, floats = 1, fear_height = 4, - lava_damage = 4, - light_damage = 0, view_range = 16, blood_amount = 0, }) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index fd5543aea7..0653c6d0a6 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -48,6 +48,7 @@ mobs:register_mob("mobs_mc:enderdragon", { max = 1}, }, lava_damage = 0, + fire_damage = 0, on_rightclick = nil, attack_type = "dogshoot", arrow = "mobs_mc:fireball2", diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index 8d8ebb3ba2..1816b177c8 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -75,6 +75,7 @@ mobs:register_mob("mobs_mc:witherskeleton", { }, water_damage = 0, lava_damage = 0, + fire_damage = 0, light_damage = 0, view_range = 16, attack_type = "dogfight", diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 8cb9dc8cca..f3f6ba4a8c 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -201,6 +201,7 @@ local magma_cube_big = { }, water_damage = 0, lava_damage = 0, + fire_damage = 0, light_damage = 0, fall_damage = 0, view_range = 16, diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index f0f8fc4fb2..c238925e39 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -28,7 +28,7 @@ mobs:register_mob("mobs_mc:snowman", { view_range = 10, fall_damage = 0, water_damage = 4, - lava_damage = 20, + rain_damage = 4, attacks_monsters = true, collisionbox = {-0.35, -0.01, -0.35, 0.35, 1.89, 0.35}, visual = "mesh", @@ -119,8 +119,6 @@ mobs:register_mob("mobs_mc:snowman", { end end end, - - rain_damage = 4, }) -- This is to be called when a pumpkin or jack'o lantern has been placed. Recommended: In the on_construct function diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index a6e6c70a59..547abd75c6 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -49,6 +49,7 @@ mobs:register_mob("mobs_mc:wither", { max = 1}, }, lava_damage = 0, + fire_damage = 0, attack_type = "dogshoot", explosion_radius = 3, explosion_fire = false, diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 48e7fedf2c..d754898888 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -75,7 +75,6 @@ local zombie = { walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, - lava_damage = 4, sunlight_damage = 2, view_range = 16, attack_type = "dogfight", diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index 660346015e..77bd0e1967 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -75,6 +75,7 @@ local pigman = { punch_end = 130, }, lava_damage = 0, + fire_damage = 0, fear_height = 4, view_range = 16, }