1
0
Fork 0

Merge branch 'master' into biome_skycolor_otherworlds

This commit is contained in:
FossFanatic 2023-01-24 07:22:04 +00:00
commit f84bdbd777
14 changed files with 141 additions and 111 deletions

View File

@ -155,7 +155,6 @@ end, true)
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
if not damage_enabled then return 0 end
if player:get_hp() > 0 then
mt_reason.approved = true
if hp_change < 0 then
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason))
end
@ -163,9 +162,7 @@ minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
end, false)
minetest.register_on_dieplayer(function(player, mt_reason)
if mt_reason.approved then
mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason))
end
minetest.log("action","Player "..player:get_player_name().." died at "..minetest.pos_to_string(vector.round(player:get_pos())))
end)

View File

@ -335,24 +335,27 @@ function mob_class:on_step(dtime)
if self:check_despawn(pos, dtime) then return true end
self:slow_mob()
if self:check_death_and_slow_mob() then
--minetest.log("action", "Mob is dying: ".. tostring(self.name))
-- Do we abandon out of here now?
end
if self:falling(pos) then return end
self:check_suspend()
self:check_water_flow()
self:env_danger_movement_checks (dtime)
if not self.fire_resistant then
mcl_burning.tick(self.object, dtime, self)
-- mcl_burning.tick may remove object immediately
if not self.object:get_pos() then return end
end
if mobs_debug then self:update_tag() end
if self.state == "die" then return end
self:check_water_flow()
self:env_danger_movement_checks (dtime)
if mobs_debug then self:update_tag() end
self:follow_flop() -- Mob following code.
self:set_animation_speed() -- set animation speed relitive to velocity

View File

@ -746,7 +746,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
local name = hitter:get_player_name() or ""
-- attack puncher and call other mobs for help
-- attack puncher
if self.passive == false
and self.state ~= "flop"
and (self.child == false or self.type == "monster")
@ -758,6 +758,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
self:do_attack(hitter)
self._aggro= true
end
end
-- alert others to the attack
local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range)
@ -776,7 +777,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
obj:do_attack(hitter)
elseif type(obj.group_attack) == "table" then
for i=1, #obj.group_attack do
if obj.name == obj.group_attack[i] then
if obj.group_attack[i] == self.name then
obj._aggro = true
obj:do_attack(hitter)
break
@ -792,7 +793,6 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
end
end
end
end
function mob_class:check_aggro(dtime)
if not self._aggro or not self.attack then return end

View File

@ -279,6 +279,7 @@ function mob_class:env_danger_movement_checks(dtime)
yaw = self:set_yaw( yaw, 8)
end
else
-- This code should probably be moved to movement code
if self.move_in_group ~= false then
self:check_herd(dtime)
end

View File

@ -47,7 +47,8 @@ end
function mob_class:player_in_active_range()
for _,p in pairs(minetest.get_connected_players()) do
if vector.distance(self.object:get_pos(),p:get_pos()) <= mob_active_range then return true end
local pos = self.object:get_pos()
if pos and vector.distance(pos, p:get_pos()) <= mob_active_range then return true end
-- slightly larger than the mc 32 since mobs spawn on that circle and easily stand still immediately right after spawning.
end
end
@ -182,15 +183,17 @@ function mob_class:collision()
return({x,z})
end
function mob_class:slow_mob()
function mob_class:check_death_and_slow_mob()
local d = 0.85
if self:check_dying() then d = 0.92 end
local dying = self:check_dying()
if dying then d = 0.92 end
local v = self.object:get_velocity()
if v then
--diffuse object velocity
self.object:set_velocity({x = v.x*d, y = v.y, z = v.z*d})
end
return dying
end
-- move mob in facing direction
@ -519,17 +522,16 @@ function mob_class:check_for_death(cause, cmi_cause)
self:set_velocity(0)
local acc = self.object:get_acceleration()
if acc then
acc.x, acc.y, acc.z = 0, DEFAULT_FALL_SPEED, 0
self.object:set_acceleration(acc)
end
local length
-- default death function and die animation (if defined)
if self.instant_death then
length = 0
elseif self.animation
and self.animation.die_start
and self.animation.die_end then
elseif self.animation and self.animation.die_start and self.animation.die_end then
local frames = self.animation.die_end - self.animation.die_start
local speed = self.animation.die_speed or 15
length = math.max(frames / speed, 0) + DEATH_DELAY
@ -545,7 +547,6 @@ function mob_class:check_for_death(cause, cmi_cause)
if not self.object:get_luaentity() then
return
end
death_handle(self)
local dpos = self.object:get_pos()
local cbox = self.collisionbox
@ -554,6 +555,7 @@ function mob_class:check_for_death(cause, cmi_cause)
self.object:remove()
mcl_mobs.death_effect(dpos, yaw, cbox, not self.instant_death)
end
if length <= 0 then
kill(self)
else
@ -870,9 +872,8 @@ function mob_class:falling(pos)
-- floating in water (or falling)
local v = self.object:get_velocity()
if v then
if v.y > 0 then
-- apply gravity when moving up
self.object:set_acceleration({
x = 0,
@ -881,7 +882,6 @@ function mob_class:falling(pos)
})
elseif v.y <= 0 and v.y > self.fall_speed then
-- fall downwards at set speed
self.object:set_acceleration({
x = 0,
@ -892,11 +892,12 @@ function mob_class:falling(pos)
-- stop accelerating once max fall speed hit
self.object:set_acceleration({x = 0, y = 0, z = 0})
end
end
local acc = self.object:get_acceleration()
if minetest.registered_nodes[node_ok(pos).name].groups.lava then
if self.floats_on_lava == 1 then
if acc and self.floats_on_lava == 1 then
self.object:set_acceleration({
x = 0,
y = -self.fall_speed / (math.max(1, v.y) ^ 2),
@ -907,9 +908,7 @@ function mob_class:falling(pos)
-- in water then float up
if minetest.registered_nodes[node_ok(pos).name].groups.water then
if self.floats == 1 then
if acc and self.floats == 1 then
self.object:set_acceleration({
x = 0,
y = -self.fall_speed / (math.max(1, v.y) ^ 2),
@ -917,10 +916,8 @@ function mob_class:falling(pos)
})
end
else
-- fall damage onto solid ground
if self.fall_damage == 1
and self.object:get_velocity().y == 0 then
if self.fall_damage == 1 and self.object:get_velocity().y == 0 then
local n = node_ok(vector.offset(pos,0,-1,0)).name
local d = (self.old_y or 0) - self.object:get_pos().y
@ -981,18 +978,24 @@ end
function mob_class:check_dying()
if ((self.state and self.state=="die") or self:check_for_death()) and not self.animation.die_end then
local rot = self.object:get_rotation()
if rot then
rot.z = ((math.pi/2-rot.z)*.2)+rot.z
self.object:set_rotation(rot)
end
return true
end
end
function mob_class:check_suspend()
if not self:player_in_active_range() then
local pos = self.object:get_pos()
if pos and not self:player_in_active_range() then
local node_under = node_ok(vector.offset(pos,0,-1,0)).name
local acc = self.object:get_acceleration()
self:set_animation( "stand", true)
local acc = self.object:get_acceleration()
if acc then
if acc.y > 0 or node_under ~= "air" then
self.object:set_acceleration(vector.new(0,0,0))
self.object:set_velocity(vector.new(0,0,0))
@ -1000,6 +1003,7 @@ function mob_class:check_suspend()
if acc.y == 0 and node_under == "air" then
self:falling(pos)
end
end
return true
end
end

View File

@ -15,7 +15,7 @@ mcl_mobs.register_mob("mobs_mc:iron_golem", {
description = S("Iron Golem"),
type = "npc",
spawn_class = "passive",
passive = true,
passive = false,
hp_min = 100,
hp_max = 100,
breath_max = -1,
@ -42,7 +42,7 @@ mcl_mobs.register_mob("mobs_mc:iron_golem", {
damage = 14,
knock_back = false,
reach = 3,
group_attack = true,
group_attack = { "mobs_mc:villager" },
attacks_monsters = true,
attack_type = "dogfight",
_got_poppy = false,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 969 B

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname())
local ASSIST_TIMEOUT_SEC = 5
mcl_death_messages = {
assist = {},
messages = {
@ -181,8 +183,10 @@ local function get_killer_message(obj, messages, reason)
end
local function get_assist_message(obj, messages, reason)
if messages.assist and mcl_death_messages.assist[obj] then
return messages._translator(messages.assist, mcl_util.get_object_name(obj), mcl_death_messages.assist[obj].name)
-- Avoid a timing issue if the assist passes its timeout.
local assist_details = mcl_death_messages.assist[obj]
if messages.assist and assist_details then
return messages._translator(messages.assist, mcl_util.get_object_name(obj), assist_details.name)
end
end
@ -232,20 +236,17 @@ mcl_damage.register_on_death(function(obj, reason)
end)
mcl_damage.register_on_damage(function(obj, damage, reason)
if obj:get_hp() - damage > 0 then
if reason.source then
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), timeout = 5}
else
mcl_death_messages.assist[obj] = nil
if (obj:get_hp() - damage > 0) and reason.source and
(reason.source:is_player() or obj:get_luaentity()) then
-- To avoid timing issues we cancel the previous job before adding a new one.
if mcl_death_messages.assist[obj] then
mcl_death_messages.assist[obj].job:cancel()
end
end
end)
minetest.register_globalstep(function(dtime)
for obj, tbl in pairs(mcl_death_messages.assist) do
tbl.timeout = tbl.timeout - dtime
if not obj:is_player() and not obj:get_luaentity() or tbl.timeout > 0 then
-- Add a new assist object with a timeout job.
local new_job = minetest.after(ASSIST_TIMEOUT_SEC, function()
mcl_death_messages.assist[obj] = nil
end
end)
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job}
end
end)

View File

@ -809,7 +809,7 @@ function mcl_core.get_grass_palette_index(pos)
local biome_name = minetest.get_biome_name(biome)
local reg_biome = minetest.registered_biomes[biome_name]
if reg_biome then
index = reg_biome._mcl_palette_index
index = reg_biome._mcl_grass_palette_index
end
end
return index
@ -939,7 +939,7 @@ minetest.register_lbm({
else
node.name = "mcl_core:dirt_with_grass"
end
node.param2 = reg_biome._mcl_palette_index
node.param2 = reg_biome._mcl_grass_palette_index
-- Fall back to savanna palette index
if not node.param2 then
node.param2 = SAVANNA_INDEX

View File

@ -373,7 +373,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
overlay_tiles = {"mcl_core_grass_block_top.png", "", {name="mcl_core_grass_block_side_overlay.png", tileable_vertical=false}},
palette = "mcl_core_palette_grass.png",
palette_index = 0,
color = "#8EB971",
color = "#7CBD6B",
is_ground_content = true,
stack_max = 64,
groups = {

View File

@ -35,7 +35,14 @@ function mcl_core.update_leaves(pos, oldnode)
-- manually placed leaf nodes have param2
-- set and will never decay automatically
if lnode.param2 == 0 then
minetest.swap_node(lpos, {name = lnode.name .. "_orphan"})
local orphan_name = lnode.name .. "_orphan"
local def = minetest.registered_nodes[orphan_name]
if def then
--minetest.log("Registered: ".. orphan_name)
minetest.swap_node(lpos, {name = orphan_name})
else
--minetest.log("Not registered: ".. orphan_name)
end
end
end
end

View File

@ -107,7 +107,7 @@ local function berry_damage_check(obj)
if not p then return end
if not minetest.find_node_near(p,0.4,{"group:sweet_berry_thorny"},true) then return end
local v = obj:get_velocity()
if v.x < 0.1 and v.y < 0.1 and v.z < 0.1 then return end
if math.abs(v.x) < 0.1 and math.abs(v.y) < 0.1 and math.abs(v.z) < 0.1 then return end
mcl_util.deal_damage(obj, 0.5, {type = "sweet_berry"})
end

View File

@ -19,7 +19,7 @@ local get_palette_color_from_pos = function(pos)
local biome_name = minetest.get_biome_name(biome)
local reg_biome = minetest.registered_biomes[biome_name]
if reg_biome then
index = reg_biome._mcl_palette_index
index = reg_biome._mcl_grass_palette_index
end
end
return index

View File

@ -280,8 +280,8 @@ local function set_palette(minp,maxp,data2,area,biomemap,nodes)
local bn = minetest.get_biome_name(biomemap[b_pos])
if bn then
local biome = minetest.registered_biomes[bn]
if biome and biome._mcl_biome_type then
data2[p_pos] = biome._mcl_palette_index
if biome and biome._mcl_biome_type and biome._mcl_grass_palette_index then
data2[p_pos] = biome._mcl_grass_palette_index
lvm_used = true
end
end
@ -349,8 +349,8 @@ local function block_fixes(vm, data, data2, emin, emax, area, minp, maxp, blocks
local lvm_used = false
local pr = PseudoRandom(blockseed)
if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then
-- Set param2 (=color) of sugar cane and grass
lvm_used = set_palette(minp,maxp,data2,area,biomemap,{"mcl_core:reeds","mcl_core:dirt_with_grass"})
-- Set param2 (=color) of nodes which use the grass colour palette.
lvm_used = set_palette(minp,maxp,data2,area,biomemap,{"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"})
end
return lvm_used
end
@ -417,3 +417,20 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks
end
return false, false, false
end, 100, true)
minetest.register_lbm({
label = "Fix grass palette indexes",
name = "mcl_mapgen_core:fix_grass_palette_indexes",
nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"},
run_at_every_load = true,
action = function(pos, node)
local biome_data = minetest.get_biome_data(pos)
local biome = biome_data.biome
local biome_name = minetest.get_biome_name(biome)
local reg_biome = minetest.registered_biomes[biome_name]
if node.param2 ~= reg_biome._mcl_grass_palette_index then
node.param2 = reg_biome._mcl_grass_palette_index
minetest.set_node(pos, node)
end
end,
})