From 06cee828c1be66bae071135a28f98d316ed802ca Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 21 Mar 2024 22:34:23 +0100 Subject: [PATCH] Move death particle to rp_textures --- mods/rp_mobs/api.lua | 49 ++++++++-------- mods/rp_mobs/mod.conf | 2 +- mods/rp_player/mod.conf | 2 +- mods/rp_player/player.lua | 54 +++++++++--------- .../rp_textures_death_smoke_anim_1.png} | Bin .../rp_textures_death_smoke_anim_2.png} | Bin 6 files changed, 55 insertions(+), 52 deletions(-) rename mods/{rp_mobs/textures/rp_mobs_death_smoke_anim_1.png => rp_textures/textures/rp_textures_death_smoke_anim_1.png} (100%) rename mods/{rp_mobs/textures/rp_mobs_death_smoke_anim_2.png => rp_textures/textures/rp_textures_death_smoke_anim_2.png} (100%) diff --git a/mods/rp_mobs/api.lua b/mods/rp_mobs/api.lua index e790e1c8..f96c091e 100644 --- a/mods/rp_mobs/api.lua +++ b/mods/rp_mobs/api.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator("rp_mobs") +local mod_textures = minetest.get_modpath("rp_textures") ~= nil + -- If true, will write the task queues of mobs as their nametag local TASK_DEBUG = false local STATE_DEBUG = false @@ -337,29 +339,30 @@ end rp_mobs.on_death_default = function(self, killer) local radius = get_mob_death_particle_radius(self) local pos = self.object:get_pos() - minetest.add_particlespawner({ - amount = 16, - time = 0.02, - pos = { - min = vector.subtract(pos, radius / 2), - max = vector.add(pos, radius / 2), - }, - vel = { - min = vector.new(-1, 0, -1), - max = vector.new(1, 2, 1), - }, - acc = vector.zero(), - exptime = { min = 0.4, max = 0.8 }, - size = { min = 8, max = 12 }, - drag = vector.new(1,1,1), - -- TODO: Move particle to particle mod - texture = { - name = "rp_mobs_death_smoke_anim_1.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_2.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_1.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_2.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - }, - }) + if mod_textures then + minetest.add_particlespawner({ + amount = 16, + time = 0.02, + pos = { + min = vector.subtract(pos, radius / 2), + max = vector.add(pos, radius / 2), + }, + vel = { + min = vector.new(-1, 0, -1), + max = vector.new(1, 2, 1), + }, + acc = vector.zero(), + exptime = { min = 0.4, max = 0.8 }, + size = { min = 8, max = 12 }, + drag = vector.new(1,1,1), + texture = { + name = "rp_textures_death_smoke_anim_1.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_2.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_1.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_2.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + }, + }) + end minetest.sound_play({name="rp_sounds_disappear", gain=0.4}, {pos=pos, max_hear_distance=12}, true) rp_mobs.drop_death_items(self) end diff --git a/mods/rp_mobs/mod.conf b/mods/rp_mobs/mod.conf index c2d51e2c..f4304e44 100644 --- a/mods/rp_mobs/mod.conf +++ b/mods/rp_mobs/mod.conf @@ -2,4 +2,4 @@ name = rp_mobs title = Repixture Mobs API description = Core logic for animals, monsters and other moving creatures depends = rp_default, rp_sounds, rp_achievements, rp_hud -optional_depends = rp_itemdef_defaults +optional_depends = rp_itemdef_defaults, rp_textures diff --git a/mods/rp_player/mod.conf b/mods/rp_player/mod.conf index f78d8257..528237f1 100644 --- a/mods/rp_player/mod.conf +++ b/mods/rp_player/mod.conf @@ -1,2 +1,2 @@ name = rp_player -optional_depends = rp_sounds, rp_achievements +optional_depends = rp_sounds, rp_achievements, rp_textures diff --git a/mods/rp_player/player.lua b/mods/rp_player/player.lua index b6654c09..acf2a987 100644 --- a/mods/rp_player/player.lua +++ b/mods/rp_player/player.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator("rp_player") +local mod_textures = minetest.get_modpath("rp_textures") ~= nil + local player_soundspec = {} local player_lastsound = {} local player_health = {} @@ -153,29 +155,30 @@ end local function on_respawnplayer(player) local pos = player:get_pos() - minetest.add_particlespawner({ - amount = 16, - time = 0.02, - pos = { - min = vector.add(pos, vector.new(-0.4, 0.0, -0.4)), - max = vector.add(pos, vector.new(0.4, 0.1, 0.4)), - }, - vel = { - min = vector.new(-1, 0.2, -1), - max = vector.new(1, 2, 1), - }, - acc = vector.zero(), - exptime = { min = 1.0, max = 1.5 }, - size = { min = 8, max = 12 }, - drag = vector.new(1,1,1), - -- TODO: Move particle to particle mod - texture = { - name = "rp_mobs_death_smoke_anim_1.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_2.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_1.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - name = "rp_mobs_death_smoke_anim_2.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, - }, - }) + if mod_textures then + minetest.add_particlespawner({ + amount = 16, + time = 0.02, + pos = { + min = vector.add(pos, vector.new(-0.4, 0.0, -0.4)), + max = vector.add(pos, vector.new(0.4, 0.1, 0.4)), + }, + vel = { + min = vector.new(-1, 0.2, -1), + max = vector.new(1, 2, 1), + }, + acc = vector.zero(), + exptime = { min = 1.0, max = 1.5 }, + size = { min = 8, max = 12 }, + drag = vector.new(1,1,1), + texture = { + name = "rp_textures_death_smoke_anim_1.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_2.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_1.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + name = "rp_textures_death_smoke_anim_2.png^[transformFX", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = -1 }, + }, + }) + end minetest.sound_play({name="rp_sounds_disappear", gain=0.4}, {pos=pos, max_hear_distance=12}, true) end @@ -213,9 +216,6 @@ end minetest.register_on_joinplayer(on_joinplayer) minetest.register_on_leaveplayer(on_leaveplayer) --- TODO: Remove mod requirement if particle moved to particle mod -if minetest.get_modpath("rp_mobs") then - minetest.register_on_respawnplayer(on_respawnplayer) -end +minetest.register_on_respawnplayer(on_respawnplayer) minetest.register_globalstep(step) diff --git a/mods/rp_mobs/textures/rp_mobs_death_smoke_anim_1.png b/mods/rp_textures/textures/rp_textures_death_smoke_anim_1.png similarity index 100% rename from mods/rp_mobs/textures/rp_mobs_death_smoke_anim_1.png rename to mods/rp_textures/textures/rp_textures_death_smoke_anim_1.png diff --git a/mods/rp_mobs/textures/rp_mobs_death_smoke_anim_2.png b/mods/rp_textures/textures/rp_textures_death_smoke_anim_2.png similarity index 100% rename from mods/rp_mobs/textures/rp_mobs_death_smoke_anim_2.png rename to mods/rp_textures/textures/rp_textures_death_smoke_anim_2.png