mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Fix typo in api.md, add TODO, change entity -> object
This commit is contained in:
parent
8c55d13a29
commit
e167bc7f09
3 changed files with 18 additions and 17 deletions
|
@ -149,8 +149,8 @@ local arrow_entity = {
|
||||||
vl_projectile.collides_with_solids,
|
vl_projectile.collides_with_solids,
|
||||||
vl_projectile.raycast_collides_with_entities,
|
vl_projectile.raycast_collides_with_entities,
|
||||||
},
|
},
|
||||||
allow_punching = function(self, entity_def, projectile_def, entity)
|
allow_punching = function(self, entity_def, projectile_def, object)
|
||||||
local lua = entity:get_luaentity()
|
local lua = object:get_luaentity()
|
||||||
if lua and lua.name == "mobs_mc:rover" then return false end
|
if lua and lua.name == "mobs_mc:rover" then return false end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -49,7 +49,7 @@ Arguments:
|
||||||
* `options`: A table with optional parameters. Supported fields are:
|
* `options`: A table with optional parameters. Supported fields are:
|
||||||
* `dir`: direction the projectile is moving in
|
* `dir`: direction the projectile is moving in
|
||||||
* `velocity`: scalar velocity amount
|
* `velocity`: scalar velocity amount
|
||||||
* `drag`: scalar resistence to velocity
|
* `drag`: scalar resistance to velocity
|
||||||
* `owner`: passed thru unmodified
|
* `owner`: passed thru unmodified
|
||||||
* `extra`: passed thru unmodified
|
* `extra`: passed thru unmodified
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ local function check_hitpoint(hitpoint)
|
||||||
if hitpoint.type ~= "object" then return false end
|
if hitpoint.type ~= "object" then return false end
|
||||||
|
|
||||||
-- find the closest object that is in the way of the arrow
|
-- find the closest object that is in the way of the arrow
|
||||||
|
-- TODO: change this check when adding mob projectiles
|
||||||
if hitpoint.ref:is_player() and enable_pvp then
|
if hitpoint.ref:is_player() and enable_pvp then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -237,7 +238,7 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_entity_collision(self, entity_def, projectile_def, entity)
|
local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local dir = vector.normalize(self.object:get_velocity())
|
local dir = vector.normalize(self.object:get_velocity())
|
||||||
local self_vl_projectile = self._vl_projectile
|
local self_vl_projectile = self._vl_projectile
|
||||||
|
@ -245,31 +246,31 @@ local function handle_entity_collision(self, entity_def, projectile_def, entity)
|
||||||
-- Allow punching
|
-- Allow punching
|
||||||
local allow_punching = projectile_def.allow_punching or true
|
local allow_punching = projectile_def.allow_punching or true
|
||||||
if type(allow_punching) == "function" then
|
if type(allow_punching) == "function" then
|
||||||
allow_punching = allow_punching(self, entity_def, projectile_def, entity)
|
allow_punching = allow_punching(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
|
|
||||||
if allow_punching then
|
if allow_punching then
|
||||||
-- Get damage
|
-- Get damage
|
||||||
local dmg = projectile_def.damage_groups or 0
|
local dmg = projectile_def.damage_groups or 0
|
||||||
if type(dmg) == "function" then
|
if type(dmg) == "function" then
|
||||||
dmg = dmg(self, entity_def, projectile_def, entity)
|
dmg = dmg(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity_lua = entity:get_luaentity()
|
local object_lua = object:get_luaentity()
|
||||||
|
|
||||||
-- 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 entity:is_player() and projectile_def.hits_players and self_vl_projectile.owner ~= hit:get_player_name() then
|
if object:is_player() and projectile_def.hits_players and self_vl_projectile.owner ~= hit:get_player_name() then
|
||||||
do_damage = true
|
do_damage = true
|
||||||
|
|
||||||
handle_player_sticking(self, entity_def, projectile_def, entity)
|
handle_player_sticking(self, entity_def, projectile_def, object)
|
||||||
elseif entity_lua and (entity_lua.is_mob == true or entity_lua._hittable_by_projectile) and (self_vl_projectile.owner ~= entity) then
|
elseif object_lua and (object_lua.is_mob == true or object_lua._hittable_by_projectile) and (self_vl_projectile.owner ~= object) then
|
||||||
do_damage = true
|
do_damage = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if do_damage then
|
if do_damage then
|
||||||
entity:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir )
|
object:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir )
|
||||||
|
|
||||||
-- Indicate damage
|
-- Indicate damage
|
||||||
damage_particles(vector.add(pos, vector.multiply(self.object:get_velocity(), 0.1)), self._is_critical)
|
damage_particles(vector.add(pos, vector.multiply(self.object:get_velocity(), 0.1)), self._is_critical)
|
||||||
|
@ -282,18 +283,18 @@ local function handle_entity_collision(self, entity_def, projectile_def, entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Call entity collision hook
|
-- Call entity collision hook
|
||||||
(projectile_def.on_collide_with_entity or no_op)(self, pos, entity)
|
(projectile_def.on_collide_with_entity or no_op)(self, pos, object)
|
||||||
|
|
||||||
-- Call reverse entity collision hook
|
-- Call reverse entity collision hook
|
||||||
local other_entity_def = minetest.registered_entities[entity.name] or {}
|
local other_object_def = minetest.registered_entities[object.name] or {}
|
||||||
local other_entity_vl_projectile = other_entity_def._vl_projectile or {}
|
local other_object_vl_projectile = other_object_def._vl_projectile or {}
|
||||||
local hook = (other_entity_vl_projectile or {}).on_collide or no_op
|
local hook = (other_object_vl_projectile or {}).on_collide or no_op
|
||||||
hook(entity, self)
|
hook(object, self)
|
||||||
|
|
||||||
-- Play sounds
|
-- Play sounds
|
||||||
local sounds = (projectile_def.sounds or {})
|
local sounds = (projectile_def.sounds or {})
|
||||||
local sound = sounds.on_entity_collion or sounds.on_collision
|
local sound = sounds.on_entity_collion or sounds.on_collision
|
||||||
if type(sound) == "function" then sound = sound(self, entity_def, projectile_def, "entity", entity) end
|
if type(sound) == "function" then sound = sound(self, entity_def, projectile_def, "entity", object) end
|
||||||
if sound then
|
if sound then
|
||||||
local arg2 = table.copy(sound[2])
|
local arg2 = table.copy(sound[2])
|
||||||
arg2.pos = pos
|
arg2.pos = pos
|
||||||
|
|
Loading…
Reference in a new issue