Minor updates and fixes

This commit is contained in:
MoNTE48 2021-05-26 19:47:23 +02:00
parent c80c5d0540
commit 2e67b14295
2 changed files with 58 additions and 47 deletions

View File

@ -147,7 +147,8 @@ armor.set_player_armor = function(self, player)
armor_groups.level = floor(armor_level / 20)
armor_groups.fleshy = 100 - armor_level
end
player:set_physics_override(physics)
-- temporary disable physics override
-- player:set_physics_override(physics)
self.textures[name].armor = texture
self.def[name].state = state
self.def[name].count = count

View File

@ -1,6 +1,6 @@
mobs = {
mod = "redo",
version = "20210323",
version = "20210405",
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -16,7 +16,7 @@ end
local S = mobs.S
-- localize functions
-- localize common functions
local abs = math.abs
local atan = function(x)
return x and math.atan(x) or 0
@ -30,7 +30,6 @@ local pi = math.pi
local rad = math.rad
local random = math.random
local sin = math.sin
local square = math.sqrt
local vadd = vector.add
local vdistance = vector.distance
local vdirection = vector.direction
@ -109,6 +108,7 @@ local mob_class = {
light_damage_max = 15,
water_damage = 0,
lava_damage = 5,
fire_damage = 4,
air_damage = 0,
suffocation = 2,
fall_damage = 1,
@ -161,6 +161,7 @@ local mob_class = {
local mob_class_meta = {__index = mob_class}
-- play sound
function mob_class:mob_sound(sound)
if not sound then
@ -903,7 +904,12 @@ local is_node_dangerous = function(self, nodename)
end
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
end
@ -981,44 +987,47 @@ function mob_class:do_env_damage()
local nodef = minetest.registered_nodes[self.standing_in]
-- water
if self.water_damage and nodef.groups.water then
if self.water_damage ~= 0 then
if self.water_damage ~= 0 and nodef.groups.water then
self.health = self.health - self.water_damage
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", pos = pos,
node = self.standing_in, hot = true}) then
return true
end
end
-- ignition source (fire or lava)
elseif self.lava_damage and nodef.groups.igniter then
if self.lava_damage ~= 0 then
-- lava damage
elseif self.lava_damage ~= 0 and nodef.groups.lava then
self.health = self.health - self.lava_damage
effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil)
if self:check_for_death({
type = "environment",
pos = pos,
node = self.standing_in,
hot = true}) then
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
-- fire damage
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
elseif nodef.damage_per_second ~= 0 then
-- 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
effect(pos, 5, "item_smoke.png")
if self:check_for_death({
type = "environment",
pos = pos,
node = self.standing_in}) then
effect(pos, 5, "tnt_smoke.png")
if self:check_for_death({type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end
@ -2521,18 +2530,19 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
return true
end
-- is mob protected
if self.tamed then
-- did player hit mob and if so is it in protected area
if hitter:is_player() then
local player_name = hitter:get_player_name()
-- is_protected_action check
if mobs.is_creative(hitter) and minetest.is_protected_action(self.object:get_pos(), player_name) then
if player_name ~= self.owner
and minetest.is_protected(self.object:get_pos(), player_name) then
minetest.chat_send_player(player_name,
S("Mob has been protected!"))
return true
end
-- is mob protected?
if self.tamed and minetest.is_protected(self.object:get_pos(), player_name) then
minetest.chat_send_player(player_name, S("Mob has been protected!"))
return true
end
end
@ -2834,8 +2844,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
def.textures = {def.textures}
end
self.base_texture = def.textures and
def.textures[random(#def.textures)]
self.base_texture = def.textures and def.textures[random(#def.textures)]
self.base_mesh = def.mesh
self.base_size = self.visual_size
self.base_colbox = self.collisionbox
@ -3200,6 +3209,7 @@ function mobs:register_mob(name, def)
light_damage_max = def.light_damage_max,
water_damage = def.water_damage,
lava_damage = def.lava_damage,
fire_damage = def.fire_damage,
air_damage = def.air_damage,
suffocation = def.suffocation,
fall_damage = def.fall_damage,