mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Resolve more review comments, fix crash
This commit is contained in:
parent
37d88038f1
commit
7d4b342d4d
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
|
||||
if self._stucktimer > ARROW_TIMEOUT then
|
||||
mcl_burning.extinguish(self.object)
|
||||
self._removed = true
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
if not pos then return end
|
||||
|
||||
-- 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.
|
||||
|
|
|
@ -57,23 +57,21 @@ function mcl_potions.register_arrow(name, desc, color, def)
|
|||
minetest.log("tipped arrow collision")
|
||||
|
||||
if def._effect_list then
|
||||
local ef_level
|
||||
local dur
|
||||
for name, details in pairs(def._effect_list) do
|
||||
local ef_level = details.level
|
||||
if details.uses_level then
|
||||
ef_level = details.level + details.level_scaling * (potency)
|
||||
else
|
||||
ef_level = details.level
|
||||
end
|
||||
|
||||
local dur = details.dur
|
||||
if details.dur_variable then
|
||||
dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus)
|
||||
if potency>0 and details.uses_level then
|
||||
dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency)
|
||||
end
|
||||
else
|
||||
dur = details.dur
|
||||
end
|
||||
dur = dur * mcl_potions.SPLASH_FACTOR
|
||||
|
||||
if details.effect_stacks then
|
||||
ef_level = ef_level + mcl_potions.get_effect_level(obj, name)
|
||||
end
|
||||
|
|
|
@ -51,15 +51,9 @@ minetest.register_entity("mcl_throwing:egg_entity",{
|
|||
-- BONUS ROUND: 1/32 chance to spawn 3 additional chicks
|
||||
if math.random(1,32) ~= 1 then return end
|
||||
|
||||
local offsets = {
|
||||
{ x=0.7, y=0, z=0 },
|
||||
{ x=-0.7, y=0, z=-0.7 },
|
||||
{ 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
|
||||
mcl_mobs.spawn_child(vector.offset(self._lastpos, 0.7, 0, 0), "mobs_mc:chicken")
|
||||
mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, -0.7), "mobs_mc:chicken")
|
||||
mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, 0.7), "mobs_mc:chicken")
|
||||
end,
|
||||
sounds = {
|
||||
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
|
||||
|
||||
-- First determine good teleport position
|
||||
local dir = {x=0, y=0, z=0}
|
||||
local dir = vector.zero()
|
||||
|
||||
local v = self.object:get_velocity()
|
||||
if node_def and node_def.walkable then
|
||||
|
|
|
@ -26,8 +26,8 @@ local function snowball_particles(pos, vel)
|
|||
time = 0.001,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.add({x=-2, y=3, z=-2}, vel),
|
||||
maxvel = vector.add({x=2, y=5, z=2}, vel),
|
||||
minvel = vector.offset(vel, -2, 3, -2),
|
||||
maxvel = vector.offset(vel, 2, 5, 2),
|
||||
minacc = {x=0, y=-9.81, z=0},
|
||||
maxacc = {x=0, y=-9.81, z=0},
|
||||
minexptime = 1,
|
||||
|
|
|
@ -50,12 +50,14 @@ local function random_hit_positions(positions, placement)
|
|||
return math.random(-4, 4)
|
||||
elseif positions == "y" then
|
||||
return math.random(0, 10)
|
||||
elseif positions == "z" then
|
||||
if placement == "front" then
|
||||
return 3
|
||||
elseif placement == "back" then
|
||||
return -3
|
||||
end
|
||||
end
|
||||
if placement == "front" and positions == "z" then
|
||||
return 3
|
||||
elseif placement == "back" and positions == "z" then
|
||||
return -3
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
local function check_hitpoint(hitpoint)
|
||||
|
@ -91,19 +93,11 @@ local function handle_player_sticking(self, entity_def, projectile_def, entity)
|
|||
end
|
||||
|
||||
-- Handle when the projectile hits the player
|
||||
local placement
|
||||
self._placement = math.random(1, 2)
|
||||
if self._placement == 1 then
|
||||
placement = "front"
|
||||
else
|
||||
placement = "back"
|
||||
end
|
||||
|
||||
local placement = self._placement == 1 and "front" or "back"
|
||||
self._rotation_station = self.placement == 1 and -90 or 90
|
||||
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._x_position = random_arrow_positions("x", placement)
|
||||
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.
|
||||
-- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-(
|
||||
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
|
||||
return
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue