forked from mtcontrib/mobs_redo
added light damage _min and _max values, also igniter check for lava damage
This commit is contained in:
parent
9737bde6fb
commit
f1476077bd
55
api.lua
55
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
||||
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20180905",
|
||||
version = "20180907",
|
||||
intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
}
|
||||
@ -431,7 +431,7 @@ end
|
||||
|
||||
|
||||
-- check if mob is dead or only hurt
|
||||
local check_for_death = function(self, cause, cmi_cause)
|
||||
local check_for_death = function(self, cmi_cause)
|
||||
|
||||
-- has health actually changed?
|
||||
if self.health == self.old_health and self.health > 0 then
|
||||
@ -598,32 +598,22 @@ local do_env_damage = function(self)
|
||||
return
|
||||
end
|
||||
|
||||
-- is mob light sensative :)
|
||||
if self.light_damage ~= 0
|
||||
-- and pos.y > 0
|
||||
-- and self.time_of_day > 0.2
|
||||
-- and self.time_of_day < 0.8
|
||||
and (minetest.get_node_light(pos) or 0) > 12 then
|
||||
-- is mob light sensative, or scared of the dark :P
|
||||
if self.light_damage ~= 0 then
|
||||
|
||||
local light = minetest.get_node_light(pos) or 0
|
||||
|
||||
if light >= self.light_damage_min
|
||||
and light <= self.light_damage_max then
|
||||
|
||||
self.health = self.health - self.light_damage
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png")
|
||||
|
||||
if check_for_death(self, "light", {type = "light"}) then return end
|
||||
if check_for_death(self, {type = "light"}) then return end
|
||||
end
|
||||
--[[
|
||||
local y_level = self.collisionbox[2]
|
||||
|
||||
if self.child then
|
||||
y_level = self.collisionbox[2] * 0.5
|
||||
end
|
||||
|
||||
-- what is mob standing in?
|
||||
pos.y = pos.y + y_level + 0.25 -- foot level
|
||||
self.standing_in = node_ok(pos, "air").name
|
||||
-- print ("standing in " .. self.standing_in)
|
||||
]]
|
||||
|
||||
local nodef = minetest.registered_nodes[self.standing_in]
|
||||
|
||||
pos.y = pos.y + 1 -- for particle effect position
|
||||
@ -638,15 +628,16 @@ local do_env_damage = function(self)
|
||||
|
||||
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
|
||||
|
||||
if check_for_death(self, "water", {type = "environment",
|
||||
if check_for_death(self, {type = "environment",
|
||||
pos = pos, node = self.standing_in}) then return end
|
||||
end
|
||||
|
||||
-- lava or fire
|
||||
-- lava or fire or ignition source
|
||||
elseif self.lava_damage
|
||||
and (nodef.groups.lava
|
||||
or self.standing_in == node_fire
|
||||
or self.standing_in == node_permanent_flame) then
|
||||
and nodef.groups.igniter then
|
||||
-- and (nodef.groups.lava
|
||||
-- or self.standing_in == node_fire
|
||||
-- or self.standing_in == node_permanent_flame) then
|
||||
|
||||
if self.lava_damage ~= 0 then
|
||||
|
||||
@ -654,7 +645,7 @@ local do_env_damage = function(self)
|
||||
|
||||
effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil)
|
||||
|
||||
if check_for_death(self, "lava", {type = "environment",
|
||||
if check_for_death(self, {type = "environment",
|
||||
pos = pos, node = self.standing_in, hot = true}) then return end
|
||||
end
|
||||
|
||||
@ -665,7 +656,7 @@ local do_env_damage = function(self)
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png")
|
||||
|
||||
if check_for_death(self, "dps", {type = "environment",
|
||||
if check_for_death(self, {type = "environment",
|
||||
pos = pos, node = self.standing_in}) then return end
|
||||
end
|
||||
--[[
|
||||
@ -677,11 +668,11 @@ local do_env_damage = function(self)
|
||||
|
||||
self.health = self.health - self.suffocation
|
||||
|
||||
if check_for_death(self, "suffocation", {type = "environment",
|
||||
if check_for_death(self, {type = "environment",
|
||||
pos = pos, node = self.standing_in}) then return end
|
||||
end
|
||||
]]
|
||||
check_for_death(self, "", {type = "unknown"})
|
||||
check_for_death(self, {type = "unknown"})
|
||||
end
|
||||
|
||||
|
||||
@ -2275,7 +2266,7 @@ local falling = function(self, pos)
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png", 1, 2, 2, nil)
|
||||
|
||||
if check_for_death(self, "fall", {type = "fall"}) then
|
||||
if check_for_death(self, {type = "fall"}) then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -2445,7 +2436,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||
local hot = tool_capabilities and tool_capabilities.damage_groups
|
||||
and tool_capabilities.damage_groups.fire
|
||||
|
||||
if check_for_death(self, "hit", {type = "punch",
|
||||
if check_for_death(self, {type = "punch",
|
||||
puncher = hitter, hot = hot}) then
|
||||
return
|
||||
end
|
||||
@ -2982,6 +2973,8 @@ minetest.register_entity(name, {
|
||||
run_velocity = def.run_velocity or 2,
|
||||
damage = max(0, (def.damage or 0) * difficulty),
|
||||
light_damage = def.light_damage or 0,
|
||||
light_damage_min = def.light_damage_min or 14,
|
||||
light_damage_max = def.light_damage_max or 15,
|
||||
water_damage = def.water_damage or 0,
|
||||
lava_damage = def.lava_damage or 0,
|
||||
suffocation = def.suffocation or 2,
|
||||
|
8
api.txt
8
api.txt
@ -57,9 +57,11 @@ functions needed for the mob to work properly which contains the following:
|
||||
'water_damage' holds the damage per second infliced to mobs when standing in
|
||||
water.
|
||||
'lava_damage' holds the damage per second inflicted to mobs when standing
|
||||
in lava or fire.
|
||||
'light_damage' holds the damage per second inflicted to mobs when it's too
|
||||
bright (above 13 light).
|
||||
in lava or fire or an ignition source.
|
||||
'light_damage' holds the damage per second inflicted to mobs when light
|
||||
level is between the min and max values below
|
||||
'light_damage_min' minimum light value when mob is affected (default: 14)
|
||||
'light_damage_max' maximum light value when mob is affected (default: 15)
|
||||
'suffocation' when true causes mobs to suffocate inside solid blocks.
|
||||
'floats' when set to 1 mob will float in water, 0 has them sink.
|
||||
'follow' mobs follow player when holding any of the items which appear
|
||||
|
@ -23,6 +23,7 @@ Lucky Blocks: 9
|
||||
|
||||
|
||||
Changelog:
|
||||
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
|
||||
- 1.46- Mobs only drop rare items when killed by player (drops.min = 0 makes them rare), code tweak, pathfinding no longer sees through walkable nodes
|
||||
- 1.45- Added Fence Top to add on top of any fence to stop mobs escaping, new line_of_sight tweaked by Astrobe
|
||||
- 1.44- Added ToolRanks support for swords when attacking mobs
|
||||
|
Loading…
Reference in New Issue
Block a user