Skip to content

Commit

Permalink
switch to non-physical projectils
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxionary committed Jan 28, 2024
1 parent 34d42a5 commit c679f09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
23 changes: 10 additions & 13 deletions entities.lua
Expand Up @@ -58,17 +58,16 @@ local base_def = {
end
end,

on_hit_node = function(self, node_pos, node, axis, old_velocity, new_velocity)
ballistics.on_hit_node_freeze(self, node_pos, node, axis, old_velocity, new_velocity)
ballistics.on_hit_node_active_sound_stop(self, node_pos, node, axis, old_velocity, new_velocity)
ballistics.on_hit_node_hit_sound_play(self, node_pos, node, axis, old_velocity, new_velocity)
ballistics.on_hit_node_become_non_physical(self, node_pos, node, axis, old_velocity, new_velocity)
on_hit_node = function(self, node_pos, node, ...)
ballistics.on_hit_node_freeze(self, node_pos, node, ...)
ballistics.on_hit_node_active_sound_stop(self, node_pos, node, ...)
ballistics.on_hit_node_hit_sound_play(self, node_pos, node, ...)

if self._parameters.replace then
ballistics.on_hit_node_replace(self, node_pos, node, axis, old_velocity, new_velocity)
ballistics.on_hit_node_replace(self, node_pos, node, ...)
end

if y_bows.util.bullseye_was_hit(self, node_pos, node, axis, old_velocity, new_velocity) then
if y_bows.util.bullseye_was_hit(self, node_pos, node, ...) then
y_bows.on_bullseye_hit(node_pos, self._source_obj)
end

Expand All @@ -79,7 +78,7 @@ local base_def = {
return true
end,

on_hit_object = function(self, object, axis, old_velocity, new_velocity)
on_hit_object = function(self, object, ...)
local hit_a_projectile = false
local entity = object:get_luaentity()
if entity and registered_projectiles[entity.name] then
Expand All @@ -88,24 +87,22 @@ local base_def = {

ballistics.on_hit_object_active_sound_stop(self)
if not hit_a_projectile then
ballistics.on_hit_object_hit_sound_play(self, object, axis, old_velocity, new_velocity)
ballistics.on_hit_object_hit_sound_play(self, object, ...)
end

if self._parameters.replace then
ballistics.on_hit_object_replace(self, object, axis, old_velocity, new_velocity)
ballistics.on_hit_object_replace(self, object, ...)
end

if self._parameters.punch then
ballistics.on_hit_object_punch(self, object, axis, old_velocity, new_velocity)
ballistics.on_hit_object_punch(self, object, ...)
end

local source = self._source_obj
if minetest.is_player(source) and not hit_a_projectile then
minetest.sound_play({ name = "y_bows_arrow_successful_hit" }, { to_player = source:get_player_name() })
end

ballistics.on_hit_object_become_non_physical(self, object, axis, old_velocity, new_velocity)

if self._parameters.remove_object then
self.object:remove()
elseif hit_a_projectile then
Expand Down
2 changes: 1 addition & 1 deletion track_drawing.lua
Expand Up @@ -52,7 +52,7 @@ minetest.register_globalstep(function(dtime)
if prev_elapsed < wielded_def._y_bows_draw_time and elapsed == wielded_def._y_bows_draw_time then
minetest.sound_play({ name = "y_bows_bow_loaded" }, { to_player = player:get_player_name() })
end
elseif wielding_bow_weapon then
elseif wielding_bow_weapon and projectile then
meta:set_float("y_bows:drawing_elapsed", 0)
meta:set_string("y_bows:drawing_name", wielded_item:get_name())

Expand Down
2 changes: 1 addition & 1 deletion util.lua
Expand Up @@ -65,7 +65,7 @@ function y_bows.util.bullseye_was_hit(
box_id
)
if node.name == "y_bows:target" and minetest.is_player(entity._source_obj) then
local hit_position = vector.copy(intersection_point)
local hit_position = node_pos - intersection_point
local axis
if intersection_normal.x ~= 0 then
axis = "x"
Expand Down

0 comments on commit c679f09

Please sign in to comment.