1
0
Fork 0

Compare commits

...

5 Commits

Author SHA1 Message Date
the-real-herowl 72435933e4 Add defensive check (#4437)
This fixes #4436 and possible other unnoticed crashes by adding a defensive check.

Reviewed-on: VoxeLibre/VoxeLibre#4437
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
2024-06-15 03:51:03 +02:00
the-real-herowl 35e14dd415 Potion conversion fix (#4426)
Reviewed-on: VoxeLibre/VoxeLibre#4426
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
2024-06-13 13:22:14 +02:00
the-real-herowl 173f8a0bca Effect loading fixes (#4425)
Reviewed-on: VoxeLibre/VoxeLibre#4425
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
2024-06-13 13:21:36 +02:00
teknomunk 1f32b47208 Fix crash while fighting whither (#4392)
Reviewed-on: VoxeLibre/VoxeLibre#4392
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
2024-06-12 14:18:03 +02:00
SmokeyDope bf67fd52e1 Zombie texture improvements (#4260)
Reviewed-on: VoxeLibre/VoxeLibre#4260
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: SmokeyDope <smokey@tilde.team>
Co-committed-by: SmokeyDope <smokey@tilde.team>
2024-06-11 19:38:41 +02:00
5 changed files with 62 additions and 40 deletions

View File

@ -802,34 +802,37 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
end
-- alert others to the attack
local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range)
local obj = nil
local alert_pos = hitter:get_pos()
if alert_pos then
local objs = minetest.get_objects_inside_radius(alert_pos, self.view_range)
local obj = nil
for n = 1, #objs do
for n = 1, #objs do
obj = objs[n]:get_luaentity()
obj = objs[n]:get_luaentity()
if obj then
-- only alert members of same mob or friends
if obj.group_attack
and obj.state ~= "attack"
and obj.owner ~= name then
if obj.name == self.name then
obj:do_attack(hitter)
elseif type(obj.group_attack) == "table" then
for i=1, #obj.group_attack do
if obj.group_attack[i] == self.name then
obj._aggro = true
obj:do_attack(hitter)
break
if obj then
-- only alert members of same mob or friends
if obj.group_attack
and obj.state ~= "attack"
and obj.owner ~= name then
if obj.name == self.name then
obj:do_attack(hitter)
elseif type(obj.group_attack) == "table" then
for i=1, #obj.group_attack do
if obj.group_attack[i] == self.name then
obj._aggro = true
obj:do_attack(hitter)
break
end
end
end
end
end
-- have owned mobs attack player threat
if obj.owner == name and obj.owner_loyal then
obj:do_attack(self.object)
-- have owned mobs attack player threat
if obj.owner == name and obj.owner_loyal then
obj:do_attack(self.object)
end
end
end
end

View File

@ -456,6 +456,10 @@ mcl_potions.register_effect({
object:get_meta():set_int("night_vision", 1)
mcl_weather.skycolor.update_sky_color({object})
end,
on_load = function(object, factor)
object:get_meta():set_int("night_vision", 1)
mcl_weather.skycolor.update_sky_color({object})
end,
on_step = function(dtime, object, factor, duration)
mcl_weather.skycolor.update_sky_color({object})
end,
@ -1352,7 +1356,7 @@ minetest.register_globalstep(function(dtime)
potions_set_hud(object)
else
local ent = object:get_luaentity()
if ent then
if ent and ent._mcl_potions then
ent._mcl_potions["_EF_"..name] = nil
end
end
@ -1367,7 +1371,7 @@ minetest.register_globalstep(function(dtime)
end
else
local ent = object:get_luaentity()
if ent then
if ent and ent._mcl_potions then
ent._mcl_potions["_EF_"..name] = EF[name][object]
end
end
@ -1525,6 +1529,11 @@ function mcl_potions._load_player_effects(player)
local loaded = minetest.deserialize(meta:get_string("mcl_potions:_EF_"..name))
if loaded then
EF[name][player] = loaded
end
if EF[name][player] then -- this is needed because of legacy effects loaded separately
if effect.uses_factor and type(EF[name][player].factor) ~= "number" then
EF[name][player].factor = effect.level_to_factor(1)
end
if effect.on_load then
effect.on_load(player, EF[name][player].factor)
end
@ -1542,6 +1551,9 @@ function mcl_potions._load_entity_effects(entity)
local loaded = entity._mcl_potions["_EF_"..name]
if loaded then
EF[name][object] = loaded
if effect.uses_factor and not loaded.factor then
EF[name][object].factor = effect.level_to_factor(1)
end
if effect.on_load then
effect.on_load(object, EF[name][object].factor)
end
@ -1780,9 +1792,14 @@ end
local function target_valid(object, name)
if not object or object:get_hp() <= 0 then return false end
-- Don't apply effects to anything other than players and entities that have mcl_potions support
-- but are not bosses
local entity = object:get_luaentity()
if entity and entity.is_boss then return false end
if not object:is_player() and (not entity or entity.is_boss or not entity._mcl_potions) then
return false
end
-- Check resistances
for i=1, #registered_res_predicates do
if registered_res_predicates[i](object, name) then return false end
end

View File

@ -841,20 +841,22 @@ local function replace_legacy_potion(itemstack)
end
local compat = "mcl_potions:compat_potion"
local compat_arrow = "mcl_potions:compat_arrow"
minetest.register_craftitem(compat, {
description = S("Unknown Potion"),
_tt_help = S("Right-click to identify"),
local compat_def = {
description = S("Unknown Potion") .. "\n" .. minetest.colorize("#ff0", S("Right-click to identify")),
image = "mcl_potions_potion_overlay.png^[colorize:#00F:127^mcl_potions_potion_bottle.png^vl_unknown.png",
groups = {not_in_creative_inventory = 1},
on_secondary_use = replace_legacy_potion,
on_place = replace_legacy_potion,
})
minetest.register_craftitem(compat_arrow, {
description = S("Unknown Tipped Arrow"),
_tt_help = S("Right-click to identify"),
}
local compat_arrow_def = {
description = S("Unknown Tipped Arrow") .. "\n" .. minetest.colorize("#ff0", S("Right-click to identify")),
image = "mcl_bows_arrow_inv.png^(mcl_potions_arrow_inv.png^[colorize:#FFF:100)^vl_unknown.png",
groups = {not_in_creative_inventory = 1},
on_secondary_use = replace_legacy_potion,
on_place = replace_legacy_potion,
})
}
minetest.register_craftitem(compat, compat_def)
minetest.register_craftitem(compat_arrow, compat_arrow_def)
local old_potions_plus = {
"fire_resistance", "water_breathing", "invisibility", "regeneration", "poison",
@ -866,14 +868,14 @@ local old_potions_2 = {
}
for _, name in pairs(old_potions_2) do
minetest.register_alias("mcl_potions:" .. name .. "_2", compat)
minetest.register_alias("mcl_potions:" .. name .. "_2_splash", compat)
minetest.register_alias("mcl_potions:" .. name .. "_2_lingering", compat)
minetest.register_alias("mcl_potions:" .. name .. "_2_arrow", compat_arrow)
minetest.register_craftitem("mcl_potions:" .. name .. "_2", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_2_splash", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_2_lingering", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_2_arrow", compat_arrow_def)
end
for _, name in pairs(old_potions_plus) do
minetest.register_alias("mcl_potions:" .. name .. "_plus", compat)
minetest.register_alias("mcl_potions:" .. name .. "_plus_splash", compat)
minetest.register_alias("mcl_potions:" .. name .. "_plus_lingering", compat)
minetest.register_alias("mcl_potions:" .. name .. "_plus_arrow", compat_arrow)
minetest.register_craftitem("mcl_potions:" .. name .. "_plus", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_plus_splash", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_plus_lingering", compat_def)
minetest.register_craftitem("mcl_potions:" .. name .. "_plus_arrow", compat_arrow_def)
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB