Fix crash with crossbow rockets (#4771)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4771
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <erich.schubert@gmail.com>
Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
kno10 2024-12-30 19:13:00 +01:00 committed by the-real-herowl
parent cf5fe25b7d
commit 0631319a00
2 changed files with 11 additions and 7 deletions

@ -2,5 +2,5 @@ name = mcl_bows
author = Arcelmi
description = This mod adds bows and arrows for MineClone 2.
depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util, mcl_shields, mcl_fovapi, mcl_luck, vl_projectile, mcl_explosions
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button, vl_fireworks

@ -8,7 +8,7 @@ local ROCKET_TIMEOUT = 1
local YAW_OFFSET = -math.pi/2
local particle_explosion = vl_fireworks.particle_explosion
local particle_explosion = vl_fireworks.generic_particle_explosion
local function damage_explosion(self, damagemulitplier, pos)
if self._harmless then return end
@ -52,8 +52,10 @@ core.register_craftitem("mcl_bows:rocket", {
damage_groups={fleshy=self._damage},
}, self.object:get_velocity())
local eploded_particle = particle_explosion(pos)
damage_explosion(self, eploded_particle * 17, pos)
if particle_explosion then
local eploded_particle = particle_explosion(pos)
damage_explosion(self, eploded_particle * 17, pos)
end
mcl_burning.extinguish(self.object)
mcl_util.remove_entity(self)
end
@ -79,8 +81,10 @@ rocket_entity.on_step = function(self, dtime)
self._stuck = true
end
if self._stuck and self._fuse > ROCKET_TIMEOUT then
local eploded_particle = particle_explosion(self)
damage_explosion(self, eploded_particle * 17)
if particle_explosion then
local eploded_particle = particle_explosion(self)
damage_explosion(self, eploded_particle * 17)
end
mcl_burning.extinguish(self.object)
mcl_util.remove_entity(self)
return
@ -92,7 +96,7 @@ end
vl_projectile.register("mcl_bows:rocket_entity", rocket_entity)
if core.get_modpath("mcl_core") and core.get_modpath("mcl_mobitems") then
if core.get_modpath("mcl_core") and core.get_modpath("mcl_mobitems") and core.get_modpath("vl_fireworks") then
core.register_craft({
output = "mcl_bows:rocket 1",
recipe = {