Light/shadow projectile destroy each other on hit

This commit is contained in:
Wuzzy 2024-01-10 13:31:12 +01:00
parent dc12f4366c
commit 2a01146ff8
2 changed files with 13 additions and 6 deletions

View File

@ -1,8 +1,8 @@
local S = minetest.get_translator("sf_mobs")
--[[ Armor groups used by the mobs:
shadow_physical: Shadow mob that has "materialized" somewhat, vulnerable to physical attacks
shadow_special: Shadow mob that is vulnerable to special attack
shadow_physical: Normal shadow mob
shadow_special: Shadow projectile
]]
local EDITOR = minetest.settings:get_bool("sf_editor", false) or minetest.settings:get_bool("creative_mode", false)
@ -41,7 +41,7 @@ local SHADOW_ORB_DEATH_CHECK_RANGE = 40
local SHADOW_PROJECTILE_TOOL_PROPERTIES = {
full_punch_interval = 0.0,
damage_groups = { fleshy = 1, },
damage_groups = { fleshy = 1, light = 1 },
}
local SHADOW_FRAGMENTS_DROP_MIN = 1

View File

@ -142,7 +142,7 @@ local function register_simple_projectile(id, initial_properties, def)
self._shooter = ddata.shooter
self._life_timer = ddata.life_timer
end
self.object:set_armor_groups({immortal=1})
self.object:set_armor_groups(def.armor)
end,
on_step = function(self, dtime, moveresult)
local opos = self.object:get_pos()
@ -169,9 +169,10 @@ local function register_simple_projectile(id, initial_properties, def)
end
if self._shooter then
local armor = collision.object:get_armor_groups()
if not armor or not armor.immortal or armor.immortal == 0 then
-- Play notify sound to shooter when hitting a shadow mob
if armor and armor.shadow_physical ~= nil and armor.shadow_physical ~= 0 then
local shooter = minetest.get_player_by_name(self._shooter)
-- Play notify sound to shooter unless it's a self-hit
-- No sound for self-hit
if shooter and not (collision.object:is_player() and collision.object:get_player_name() == self._shooter) then
minetest.sound_play({name="sf_projectiles_hit_ranged", gain=0.8}, {to_player=self._shooter}, true)
end
@ -202,6 +203,7 @@ end
register_simple_projectile("shadow",
{
hp_max = 1,
textures = {"sf_projectiles_shadow.png"},
pointable = true,
is_visible = true,
@ -220,10 +222,14 @@ register_simple_projectile("shadow",
impact_particles_func=shadow_impact_particles,
move_particles_func=shadow_move_particles,
impact_sound={name="sf_projectiles_shadow_impact", gain=0.1},
-- Special armor group to differenciate the shadow projectile
-- from shadow mobs (which use shadow_physical)
armor={shadow_special=100},
}
)
register_simple_projectile("light",
{
hp_max = 1,
pointable = false,
visual = "sprite",
is_visible = true,
@ -240,5 +246,6 @@ register_simple_projectile("light",
impact_particles_func=light_impact_particles,
move_particles_func=light_move_particles,
impact_sound={name="sf_projectiles_light_impact", gain=0.2},
armor={light=100},
}
)