From 4f0d920988f5abd7f16c3f72ca66c82bac89dc85 Mon Sep 17 00:00:00 2001 From: IamPyu Date: Fri, 6 Dec 2024 20:45:41 -0600 Subject: [PATCH] Add firework damage --- CHANGELOG.md | 3 +++ mods/CORE/pyutest/damage.lua | 10 ++++++++++ mods/ENTITIES/pyutest_fireworks/init.lua | 7 ++++++- mods/PLAYER/pyutest_hud/init.lua | 17 +++++++++++++++++ mods/PLAYER/pyutest_spawnpoints/init.lua | 13 +++++++------ textures/pyutest-bar-breath.png | Bin 0 -> 86 bytes textures/pyutest-bar-empty.png | Bin 0 -> 86 bytes textures/pyutest-bar-health.png | Bin 0 -> 86 bytes textures/pyutest-star.png | Bin 0 -> 149 bytes 9 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 mods/PLAYER/pyutest_hud/init.lua create mode 100644 textures/pyutest-bar-breath.png create mode 100644 textures/pyutest-bar-empty.png create mode 100644 textures/pyutest-bar-health.png create mode 100644 textures/pyutest-star.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d4150..97cb8f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Notable Game Changes: - Improved Stairs - Added Reinforced Glass - Add back the Rubies that were removed a while ago! +- Replaced Spawnpoints with a item Other Game Changes: @@ -31,6 +32,8 @@ Other Game Changes: - Fire is now marked as floodable - You can now walk through leaves - Make crop hitbox smaller +- Fireworks now damage entities when they're too close to the explosion +- Added new damage type `fireworks` Code Changes: diff --git a/mods/CORE/pyutest/damage.lua b/mods/CORE/pyutest/damage.lua index 55f1cd5..f7e962b 100644 --- a/mods/CORE/pyutest/damage.lua +++ b/mods/CORE/pyutest/damage.lua @@ -16,6 +16,14 @@ PyuTest.DAMAGE_TYPES = { } } end, + fireworks = function () + return { + type = "set_hp", + _pyutest = { + type = "fireworks", + } + } + end, burning = function () return { type = "set_hp", @@ -55,6 +63,8 @@ core.register_on_dieplayer(function(player, reason) if newreason.type == "explosion" then message = string.format("%s blew up", playername) + elseif newreason.type == "fireworks" then + message = string.format("%s went off with a bang", playername) elseif newreason.type == "burning" then message = string.format("%s burned to death", playername) end diff --git a/mods/ENTITIES/pyutest_fireworks/init.lua b/mods/ENTITIES/pyutest_fireworks/init.lua index 5c2034d..39600cc 100644 --- a/mods/ENTITIES/pyutest_fireworks/init.lua +++ b/mods/ENTITIES/pyutest_fireworks/init.lua @@ -25,7 +25,6 @@ core.register_entity("pyutest_fireworks:firework", { trail = function(self) local pos = self.object:get_pos() - vector.new(0, 1, 0) - local velocity = vector.new(math.random(-1, 1), 0, math.random(-1, 1)) if math.random(1, 2) == 1 then @@ -65,6 +64,12 @@ core.register_entity("pyutest_fireworks:firework", { local pos = self.object:get_pos() + for _, v in pairs(core.get_objects_inside_radius(pos, 3)) do + if v ~= self.object then + PyuTest.deal_damage(v, 9, PyuTest.DAMAGE_TYPES.fireworks()) + end + end + core.add_particlespawner({ amount = math.random(20, 40), time = 0.8, diff --git a/mods/PLAYER/pyutest_hud/init.lua b/mods/PLAYER/pyutest_hud/init.lua new file mode 100644 index 0000000..25af244 --- /dev/null +++ b/mods/PLAYER/pyutest_hud/init.lua @@ -0,0 +1,17 @@ +-- core.hud_replace_builtin("health", {}) + +-- PyuTest.HUDBARS = { + +-- } + +-- core.hud_replace_builtin("health", { +-- hud_elem_type = "statbar", +-- text = "pyutest-bar-health.png", +-- text2 = "pyutest-bar-empty.png", +-- number = core.PLAYER_MAX_HP_DEFAULT, +-- item = core.PLAYER_MAX_HP_DEFAULT, +-- position = {x = 0.5, y = 1}, +-- direction = 0, +-- size = {x = 24, y = 24}, +-- offset = {x = (-10 * 24) - 25, y = -(48 + 24 + 16)}, +-- }) diff --git a/mods/PLAYER/pyutest_spawnpoints/init.lua b/mods/PLAYER/pyutest_spawnpoints/init.lua index 5e9a050..dacc040 100644 --- a/mods/PLAYER/pyutest_spawnpoints/init.lua +++ b/mods/PLAYER/pyutest_spawnpoints/init.lua @@ -23,16 +23,17 @@ end core.register_on_shutdown(save_data) PyuTest.register_interval(save_data, 10) -PyuTest.make_node("pyutest_spawnpoints:spawnpoint", "Spawnpoint", { - choppy = PyuTest.BLOCK_FAST, - block = 1 -}, { "pyutest-spawnpoint.png" }, { - on_rightclick = function(pos, node, clicker) +PyuTest.make_item("pyutest_spawnpoints:spawnpoint", "Spawnpoint Setter", {}, "pyutest-star.png", { + color = PyuTest.COLORS.khaki[2], + on_use = function(itemstack, clicker) if clicker == nil then return end if not clicker:is_player() then return end local name = clicker:get_player_name() - spawnpoints[name] = pos + spawnpoints[name] = clicker:get_pos() + + itemstack:take_item() + return itemstack end }) diff --git a/textures/pyutest-bar-breath.png b/textures/pyutest-bar-breath.png new file mode 100644 index 0000000000000000000000000000000000000000..699ad69849ae03606304ca9bb847820f366222cd GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vYsxEAr`&KJ?E-_%x`2m;L`al iklBq_!Zg7^l7WFIpXub0%^A8tg$$mqelF{r5}E)$rxqvx literal 0 HcmV?d00001 diff --git a/textures/pyutest-bar-empty.png b/textures/pyutest-bar-empty.png new file mode 100644 index 0000000000000000000000000000000000000000..7a3fefe7d6af78b721663ad60951ae13025ff795 GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vYsxEAr`&KXU?4Zb>4w7VUf${ j6^x77dZY|y@Gvk0Jz$Dyx^*HKsF1s literal 0 HcmV?d00001 diff --git a/textures/pyutest-bar-health.png b/textures/pyutest-bar-health.png new file mode 100644 index 0000000000000000000000000000000000000000..2ea48ae740abeed660b3e6afc8f55aa048850879 GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vYsxEAr`&KG07=k<~K4OaOr#& i$n3@|VVYnd$-pq@8k4^1ulQ`BLIzJ)KbLh*2~7Ye{1v8cNqh&p4