mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-23 17:20:22 +01:00
tweak damage and protectors
This commit is contained in:
parent
246b2769f7
commit
6750d176ee
89
api.lua
89
api.lua
@ -8,12 +8,12 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20210404",
|
version = "20210405",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- localize math functions
|
-- localize common functions
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local square = math.sqrt
|
local square = math.sqrt
|
||||||
local sin = math.sin
|
local sin = math.sin
|
||||||
@ -112,7 +112,8 @@ local mob_class = {
|
|||||||
light_damage_min = 14,
|
light_damage_min = 14,
|
||||||
light_damage_max = 15,
|
light_damage_max = 15,
|
||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 0,
|
lava_damage = 4,
|
||||||
|
fire_damage = 4,
|
||||||
air_damage = 0,
|
air_damage = 0,
|
||||||
suffocation = 2,
|
suffocation = 2,
|
||||||
fall_damage = 1,
|
fall_damage = 1,
|
||||||
@ -983,7 +984,12 @@ local is_node_dangerous = function(self, nodename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.lava_damage > 0
|
if self.lava_damage > 0
|
||||||
and minetest.get_item_group(nodename, "igniter") ~= 0 then
|
and minetest.get_item_group(nodename, "lava") ~= 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.fire_damage > 0
|
||||||
|
and minetest.get_item_group(nodename, "fire") ~= 0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1069,37 +1075,47 @@ function mob_class:do_env_damage()
|
|||||||
local nodef = minetest.registered_nodes[self.standing_in]
|
local nodef = minetest.registered_nodes[self.standing_in]
|
||||||
|
|
||||||
-- water
|
-- water
|
||||||
if self.water_damage and nodef.groups.water then
|
if self.water_damage ~= 0
|
||||||
|
and nodef.groups.water then
|
||||||
|
|
||||||
if self.water_damage ~= 0 then
|
self.health = self.health - self.water_damage
|
||||||
|
|
||||||
self.health = self.health - self.water_damage
|
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
|
||||||
|
|
||||||
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
|
if self:check_for_death({type = "environment",
|
||||||
|
pos = pos, node = self.standing_in}) then
|
||||||
if self:check_for_death({type = "environment",
|
return true
|
||||||
pos = pos, node = self.standing_in}) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ignition source (fire or lava)
|
-- lava damage
|
||||||
elseif self.lava_damage and nodef.groups.igniter then
|
elseif self.lava_damage ~= 0
|
||||||
|
and nodef.groups.lava then
|
||||||
|
|
||||||
if self.lava_damage ~= 0 then
|
self.health = self.health - self.lava_damage
|
||||||
|
|
||||||
self.health = self.health - self.lava_damage
|
effect(pos, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
|
||||||
|
|
||||||
effect(pos, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
|
if self:check_for_death({type = "environment", pos = pos,
|
||||||
|
node = self.standing_in, hot = true}) then
|
||||||
if self:check_for_death({type = "environment", pos = pos,
|
return true
|
||||||
node = self.standing_in, hot = true}) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- damage_per_second node check
|
-- fire damage
|
||||||
elseif nodef.damage_per_second ~= 0 then
|
elseif self.fire_damage ~= 0
|
||||||
|
and nodef.groups.fire then
|
||||||
|
|
||||||
|
self.health = self.health - self.fire_damage
|
||||||
|
|
||||||
|
effect(pos, 15, "fire_basic_flame.png", 1, 5, 1, 0.2, 15, true)
|
||||||
|
|
||||||
|
if self:check_for_death({type = "environment", pos = pos,
|
||||||
|
node = self.standing_in, hot = true}) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- damage_per_second node check (not fire and lava)
|
||||||
|
elseif nodef.damage_per_second ~= 0
|
||||||
|
and nodef.groups.lava == 0 and nodef.groups.fire == 0 then
|
||||||
|
|
||||||
self.health = self.health - nodef.damage_per_second
|
self.health = self.health - nodef.damage_per_second
|
||||||
|
|
||||||
@ -2777,13 +2793,18 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
if self.protected then
|
if self.protected then
|
||||||
|
|
||||||
-- did player hit mob and if so is it in protected area
|
-- did player hit mob and if so is it in protected area
|
||||||
if hitter:is_player() and
|
if hitter:is_player() then
|
||||||
minetest.is_protected(self.object:get_pos(), hitter:get_player_name() ) then
|
|
||||||
|
|
||||||
minetest.chat_send_player(hitter:get_player_name(),
|
local player_name = hitter:get_player_name()
|
||||||
S("Mob has been protected!"))
|
|
||||||
|
|
||||||
return true
|
if player_name ~= self.owner
|
||||||
|
and minetest.is_protected(self.object:get_pos(), player_name) then
|
||||||
|
|
||||||
|
minetest.chat_send_player(hitter:get_player_name(),
|
||||||
|
S("Mob has been protected!"))
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-- if protection is on level 2 then dont let arrows harm mobs
|
-- if protection is on level 2 then dont let arrows harm mobs
|
||||||
elseif self.protected == 2 then
|
elseif self.protected == 2 then
|
||||||
@ -2830,7 +2851,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
damage = damage + (tool_capabilities.damage_groups[group] or 0)
|
damage = damage + (tool_capabilities.damage_groups[group] or 0)
|
||||||
* tmp * ((armor[group] or 0) / 100.0)
|
* tmp * ((armor[group] or 0) / 100.0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3167,8 +3188,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
def.textures = {def.textures}
|
def.textures = {def.textures}
|
||||||
end
|
end
|
||||||
|
|
||||||
self.base_texture = def.textures and
|
self.base_texture = def.textures and def.textures[random(#def.textures)]
|
||||||
def.textures[random(#def.textures)]
|
|
||||||
self.base_mesh = def.mesh
|
self.base_mesh = def.mesh
|
||||||
self.base_size = self.visual_size
|
self.base_size = self.visual_size
|
||||||
self.base_colbox = self.collisionbox
|
self.base_colbox = self.collisionbox
|
||||||
@ -3575,6 +3595,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
light_damage_max = def.light_damage_max,
|
light_damage_max = def.light_damage_max,
|
||||||
water_damage = def.water_damage,
|
water_damage = def.water_damage,
|
||||||
lava_damage = def.lava_damage,
|
lava_damage = def.lava_damage,
|
||||||
|
fire_damage = def.fire_damage,
|
||||||
air_damage = def.air_damage,
|
air_damage = def.air_damage,
|
||||||
suffocation = def.suffocation,
|
suffocation = def.suffocation,
|
||||||
fall_damage = def.fall_damage,
|
fall_damage = def.fall_damage,
|
||||||
@ -4606,7 +4627,7 @@ function mobs:protect(self, clicker)
|
|||||||
if tool_name == "mobs:protector" then
|
if tool_name == "mobs:protector" then
|
||||||
self.protected = true
|
self.protected = true
|
||||||
else
|
else
|
||||||
self.protected = 2
|
self.protected = 2 ; self.fire_damage = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
5
api.txt
5
api.txt
@ -66,7 +66,10 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
water.
|
water.
|
||||||
'air_damage' holds damage per second inflicted to mob when standing in air.
|
'air_damage' holds damage per second inflicted to mob when standing in air.
|
||||||
'lava_damage' holds the damage per second inflicted to mobs when standing
|
'lava_damage' holds the damage per second inflicted to mobs when standing
|
||||||
in lava or fire or an ignition source.
|
in lava.
|
||||||
|
'fire_damage' holds the damage per second inflicted to mobs when standing
|
||||||
|
in fire.
|
||||||
|
|
||||||
'light_damage' holds the damage per second inflicted to mobs when light
|
'light_damage' holds the damage per second inflicted to mobs when light
|
||||||
level is between the min and max values below
|
level is between the min and max values below
|
||||||
'light_damage_min' minimum light value when mob is affected (default: 14)
|
'light_damage_min' minimum light value when mob is affected (default: 14)
|
||||||
|
Loading…
Reference in New Issue
Block a user