mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-12 20:53:16 +01:00
Make arrows damage players, update API documentation, fix several crashes that occurred when arrows hit a player
This commit is contained in:
parent
d9efac82c8
commit
2919f420d8
@ -15,20 +15,6 @@ local STUCK_RECHECK_TIME = 5
|
|||||||
|
|
||||||
local YAW_OFFSET = -math.pi/2
|
local YAW_OFFSET = -math.pi/2
|
||||||
|
|
||||||
local function random_arrow_positions(positions, placement)
|
|
||||||
if positions == "x" then
|
|
||||||
return math.random(-4, 4)
|
|
||||||
elseif positions == "y" then
|
|
||||||
return math.random(0, 10)
|
|
||||||
end
|
|
||||||
if placement == "front" and positions == "z" then
|
|
||||||
return 3
|
|
||||||
elseif placement == "back" and positions == "z" then
|
|
||||||
return -3
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
|
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
|
||||||
local mod_button = minetest.get_modpath("mesecons_button")
|
local mod_button = minetest.get_modpath("mesecons_button")
|
||||||
|
|
||||||
@ -143,6 +129,7 @@ local arrow_entity = {
|
|||||||
_vl_projectile = {
|
_vl_projectile = {
|
||||||
survive_collision = true,
|
survive_collision = true,
|
||||||
sticks_in_players = true,
|
sticks_in_players = true,
|
||||||
|
damages_players = true,
|
||||||
damage_groups = function(self)
|
damage_groups = function(self)
|
||||||
return { fleshy = self._damage }
|
return { fleshy = self._damage }
|
||||||
end,
|
end,
|
||||||
|
@ -14,6 +14,7 @@ Arguments:
|
|||||||
* `liquid_drag`: if true, apply drag from liquid nodes to the projectile
|
* `liquid_drag`: if true, apply drag from liquid nodes to the projectile
|
||||||
* `survive_collision`: if this field is `false` or `nil`, the projectile will be removed after a collision.
|
* `survive_collision`: if this field is `false` or `nil`, the projectile will be removed after a collision.
|
||||||
* `sticks_in_players`: if true, the projectile will stick into players after colliding with them.
|
* `sticks_in_players`: if true, the projectile will stick into players after colliding with them.
|
||||||
|
* `damages_players`: if true, the projectile will deal damage to players.
|
||||||
* `damage_groups`: damage group information to use for `punch()`. May be a function of type `function(projectile, entity_def, projectile_def, obj)`
|
* `damage_groups`: damage group information to use for `punch()`. May be a function of type `function(projectile, entity_def, projectile_def, obj)`
|
||||||
that returns dynamic damange group information.
|
that returns dynamic damange group information.
|
||||||
* `allow_punching`: will the projectile punch entities it collides with. May be a function of type `function(projectile, entity_def, projectile_def, obj)`.
|
* `allow_punching`: will the projectile punch entities it collides with. May be a function of type `function(projectile, entity_def, projectile_def, obj)`.
|
||||||
|
@ -102,6 +102,20 @@ local function damage_particles(pos, is_critical)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function random_arrow_positions(positions, placement)
|
||||||
|
if positions == "x" then
|
||||||
|
return math.random(-4, 4)
|
||||||
|
elseif positions == "y" then
|
||||||
|
return math.random(0, 10)
|
||||||
|
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 random_hit_positions(positions, placement)
|
local function random_hit_positions(positions, placement)
|
||||||
if positions == "x" then
|
if positions == "x" then
|
||||||
return math.random(-4, 4)
|
return math.random(-4, 4)
|
||||||
@ -144,7 +158,7 @@ local function handle_player_sticking(self, entity_def, projectile_def, entity)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- Handle blocking projectiles
|
-- Handle blocking projectiles
|
||||||
if mcl_shields.is_blocking(obj) then
|
if mcl_shields.is_blocking(entity) then
|
||||||
self._blocked = true
|
self._blocked = true
|
||||||
self.object:set_velocity(vector.multiply(self.object:get_velocity(), -0.25))
|
self.object:set_velocity(vector.multiply(self.object:get_velocity(), -0.25))
|
||||||
return
|
return
|
||||||
@ -175,7 +189,7 @@ local function handle_player_sticking(self, entity_def, projectile_def, entity)
|
|||||||
self._z_rotation = math.random(-30, 30)
|
self._z_rotation = math.random(-30, 30)
|
||||||
self._y_rotation = math.random( -30, 30)
|
self._y_rotation = math.random( -30, 30)
|
||||||
self.object:set_attach(
|
self.object:set_attach(
|
||||||
obj, self._attach_parent,
|
entity, self._attach_parent,
|
||||||
vector.new(self._x_position, self._y_position, random_arrow_positions("z", placement)),
|
vector.new(self._x_position, self._y_position, random_arrow_positions("z", placement)),
|
||||||
vector.new(0, self._rotation_station + self._y_rotation, self._z_rotation)
|
vector.new(0, self._rotation_station + self._y_rotation, self._z_rotation)
|
||||||
)
|
)
|
||||||
@ -262,7 +276,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
|||||||
-- Apply damage
|
-- Apply damage
|
||||||
-- Note: Damage blocking for shields is handled in mcl_shields with an mcl_damage modifier
|
-- Note: Damage blocking for shields is handled in mcl_shields with an mcl_damage modifier
|
||||||
local do_damage = false
|
local do_damage = false
|
||||||
if object:is_player() and projectile_def.hits_players and self_vl_projectile.owner ~= hit:get_player_name() then
|
if object:is_player() and projectile_def.damanges_players and self_vl_projectile.owner ~= object:get_player_name() then
|
||||||
do_damage = true
|
do_damage = true
|
||||||
|
|
||||||
handle_player_sticking(self, entity_def, projectile_def, object)
|
handle_player_sticking(self, entity_def, projectile_def, object)
|
||||||
|
Loading…
Reference in New Issue
Block a user