Resolve more review comments, fix crash

This commit is contained in:
teknomunk 2024-08-31 10:51:28 -05:00
parent 7d1046e1f4
commit 91e362329f
6 changed files with 23 additions and 35 deletions

@ -70,11 +70,13 @@ local function stuck_arrow_on_step(self, dtime)
self._stuckrechecktimer = self._stuckrechecktimer + dtime self._stuckrechecktimer = self._stuckrechecktimer + dtime
if self._stucktimer > ARROW_TIMEOUT then if self._stucktimer > ARROW_TIMEOUT then
mcl_burning.extinguish(self.object) mcl_burning.extinguish(self.object)
self._removed = true
self.object:remove() self.object:remove()
return return
end end
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end
-- Drop arrow as item when it is no longer stuck -- Drop arrow as item when it is no longer stuck
-- FIXME: Arrows are a bit slow to react and continue to float in mid air for a few seconds. -- FIXME: Arrows are a bit slow to react and continue to float in mid air for a few seconds.

@ -57,23 +57,21 @@ function mcl_potions.register_arrow(name, desc, color, def)
minetest.log("tipped arrow collision") minetest.log("tipped arrow collision")
if def._effect_list then if def._effect_list then
local ef_level
local dur
for name, details in pairs(def._effect_list) do for name, details in pairs(def._effect_list) do
local ef_level = details.level
if details.uses_level then if details.uses_level then
ef_level = details.level + details.level_scaling * (potency) ef_level = details.level + details.level_scaling * (potency)
else
ef_level = details.level
end end
local dur = details.dur
if details.dur_variable then if details.dur_variable then
dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus) dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus)
if potency>0 and details.uses_level then if potency>0 and details.uses_level then
dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency) dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency)
end end
else
dur = details.dur
end end
dur = dur * mcl_potions.SPLASH_FACTOR dur = dur * mcl_potions.SPLASH_FACTOR
if details.effect_stacks then if details.effect_stacks then
ef_level = ef_level + mcl_potions.get_effect_level(obj, name) ef_level = ef_level + mcl_potions.get_effect_level(obj, name)
end end

@ -51,15 +51,9 @@ minetest.register_entity("mcl_throwing:egg_entity",{
-- BONUS ROUND: 1/32 chance to spawn 3 additional chicks -- BONUS ROUND: 1/32 chance to spawn 3 additional chicks
if math.random(1,32) ~= 1 then return end if math.random(1,32) ~= 1 then return end
local offsets = { mcl_mobs.spawn_child(vector.offset(self._lastpos, 0.7, 0, 0), "mobs_mc:chicken")
{ x=0.7, y=0, z=0 }, mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, -0.7), "mobs_mc:chicken")
{ x=-0.7, y=0, z=-0.7 }, mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, 0.7), "mobs_mc:chicken")
{ x=-0.7, y=0, z=0.7 },
}
for o=1, 3 do
local pos = vector.add(self._lastpos, offsets[o])
mcl_mobs.spawn_child(pos, "mobs_mc:chicken")
end
end, end,
sounds = { sounds = {
on_collision = {"mcl_throwing_egg_impact", {max_hear_distance=10, gain=0.5}, true} on_collision = {"mcl_throwing_egg_impact", {max_hear_distance=10, gain=0.5}, true}

@ -63,7 +63,7 @@ minetest.register_entity("mcl_throwing:ender_pearl_entity",{
-- Teleport and hurt player -- Teleport and hurt player
-- First determine good teleport position -- First determine good teleport position
local dir = {x=0, y=0, z=0} local dir = vector.zero()
local v = self.object:get_velocity() local v = self.object:get_velocity()
if node_def and node_def.walkable then if node_def and node_def.walkable then

@ -26,8 +26,8 @@ local function snowball_particles(pos, vel)
time = 0.001, time = 0.001,
minpos = pos, minpos = pos,
maxpos = pos, maxpos = pos,
minvel = vector.add({x=-2, y=3, z=-2}, vel), minvel = vector.offset(vel, -2, 3, -2),
maxvel = vector.add({x=2, y=5, z=2}, vel), maxvel = vector.offset(vel, 2, 5, 2),
minacc = {x=0, y=-9.81, z=0}, minacc = {x=0, y=-9.81, z=0},
maxacc = {x=0, y=-9.81, z=0}, maxacc = {x=0, y=-9.81, z=0},
minexptime = 1, minexptime = 1,

@ -50,12 +50,14 @@ local function random_hit_positions(positions, placement)
return math.random(-4, 4) return math.random(-4, 4)
elseif positions == "y" then elseif positions == "y" then
return math.random(0, 10) return math.random(0, 10)
elseif positions == "z" then
if placement == "front" then
return 3
elseif placement == "back" then
return -3
end
end end
if placement == "front" and positions == "z" then
return 3
elseif placement == "back" and positions == "z" then
return -3
end
return 0 return 0
end end
local function check_hitpoint(hitpoint) local function check_hitpoint(hitpoint)
@ -91,19 +93,11 @@ local function handle_player_sticking(self, entity_def, projectile_def, entity)
end end
-- Handle when the projectile hits the player -- Handle when the projectile hits the player
local placement
self._placement = math.random(1, 2) self._placement = math.random(1, 2)
if self._placement == 1 then
placement = "front" local placement = self._placement == 1 and "front" or "back"
else self._rotation_station = self.placement == 1 and -90 or 90
placement = "back"
end
self._in_player = true self._in_player = true
if self._placement == 2 then
self._rotation_station = 90
else
self._rotation_station = -90
end
self._y_position = random_arrow_positions("y", placement) self._y_position = random_arrow_positions("y", placement)
self._x_position = random_arrow_positions("x", placement) self._x_position = random_arrow_positions("x", placement)
if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then
@ -147,7 +141,7 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
-- Projectile has stopped in one axis, so it probably hit something. -- Projectile has stopped in one axis, so it probably hit something.
-- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-( -- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-(
local vel = self.object:get_velocity() local vel = self.object:get_velocity()
if not( (math.abs(vel.x) < 0.0001) or (math.abs(vel.z) < 0.0001) or (math.abs(vel.y) < 0.00001) ) then if math.abs(vel.x) >= 0.0001 and math.abs(vel.z) >= 0.0001 and math.abs(vel.y) >= 0.0001 then
self._last_pos = pos self._last_pos = pos
return return
end end