diff --git a/CHANGELOG.md b/CHANGELOG.md index b7fe01a..a6067a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ Game Changes: - Added guns - Added Electrified Mithril - Improved Windballs +- Added Sea Master potion effect +- Added silver color + +Code Changes: + +- Revamped status effect system Bugfixes: diff --git a/mods/CORE/pyutest/init.lua b/mods/CORE/pyutest/init.lua index 1c0babb..c398228 100644 --- a/mods/CORE/pyutest/init.lua +++ b/mods/CORE/pyutest/init.lua @@ -70,6 +70,7 @@ PyuTest.COLORS = { peach = { "Peach", "#FFE5B4"}, bloodred = { "Blood Red", "#660000"}, grey = { "Grey", "#606060" }, + silver = { "Silver", "#C0C0C0" }, } PyuTest.WORLD_GRAVITY = core.settings:get("movement_gravity") diff --git a/mods/ENTITIES/pyutest_projectiles/api.lua b/mods/ENTITIES/pyutest_projectiles/api.lua index 37edffb..3a16101 100644 --- a/mods/ENTITIES/pyutest_projectiles/api.lua +++ b/mods/ENTITIES/pyutest_projectiles/api.lua @@ -4,27 +4,28 @@ local class = { } function class:on_step(dtime, moveresult) - local slowdown_speed = self._slowdown_speed or 0.98 - local slowdown = self._slowdown - local godown = self._godown + local slow_down_speed = self._slow_down_speed or 0.98 - if slowdown == nil then - slowdown = true + local slow_down = self._slow_down + local go_down = self._go_down + + if slow_down == nil then + slow_down = false end - if godown == nil then - godown = false + if go_down == nil then + go_down = true end - if slowdown then + if slow_down and not go_down then local vel = self.object:get_velocity() - vel = vector.multiply(vel, slowdown_speed) + vel = vector.multiply(vel, slow_down_speed) self.object:set_velocity(vel) end - if godown and not slowdown then + if go_down and not slow_down then local vel = self.object:get_velocity() - vel.y = vel.y - (5 * dtime) + vel.y = vel.y - (15 * dtime) self.object:set_velocity(vel) end diff --git a/mods/ENTITIES/pyutest_projectiles/init.lua b/mods/ENTITIES/pyutest_projectiles/init.lua index dec6fb9..83cf594 100644 --- a/mods/ENTITIES/pyutest_projectiles/init.lua +++ b/mods/ENTITIES/pyutest_projectiles/init.lua @@ -10,7 +10,7 @@ PyuTest.make_projectile("pyutest_projectiles:fireball", { "pyutest-fireball.png", } }, { - _slowdown = false + _go_down = false }, { on_hit_node = function (self, pos, node) PyuTest.create_explosion(pos, 3, false, 12) @@ -28,7 +28,6 @@ PyuTest.make_projectile("pyutest_projectiles:arrow", { "pyutest-arrow.png", } }, { - _slowdown = false }, { on_hit_node = function (self, pos, node) end, diff --git a/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua b/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua index 836085c..819a66b 100644 --- a/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua +++ b/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua @@ -24,7 +24,6 @@ PyuTest.make_projectile("pyutest_projectiles:snowball", { "pyutest-snowball.png", } }, { - _slowdown = false, }, { on_hit_node = function (self, pos, node) do_particles(pos + vector.new(0, 1, 0)) diff --git a/mods/ITEMS/pyutest_guns/api.lua b/mods/ITEMS/pyutest_guns/api.lua index b4dc115..e040c64 100644 --- a/mods/ITEMS/pyutest_guns/api.lua +++ b/mods/ITEMS/pyutest_guns/api.lua @@ -33,8 +33,6 @@ PyuTest.make_gun = function(name, desc, texture, cooldown, damage, extra) "pyutest-bullet.png", } }, { - _slowdown = false, - _godown = true, }, { on_hit_node = function(self, pos, node) end, on_hit_object = function(self, object) diff --git a/mods/ITEMS/pyutest_magic/wands.lua b/mods/ITEMS/pyutest_magic/wands.lua index 3a594c7..8f9d36a 100644 --- a/mods/ITEMS/pyutest_magic/wands.lua +++ b/mods/ITEMS/pyutest_magic/wands.lua @@ -2,7 +2,6 @@ PyuTest.make_wand = function (id, desc, texture, mana, properties, fns) local e_id = id .. "_projectile" PyuTest.make_projectile(e_id, properties, { - _slowdown = false }, { on_hit_node = fns.on_hit_node, on_hit_object = fns.on_hit_object diff --git a/mods/ITEMS/pyutest_potions/api.lua b/mods/ITEMS/pyutest_potions/api.lua index 461a678..55aa0cc 100644 --- a/mods/ITEMS/pyutest_potions/api.lua +++ b/mods/ITEMS/pyutest_potions/api.lua @@ -75,7 +75,6 @@ PyuTest.make_potion = function (name, desc, options) visual = "sprite", textures = {texture}, }, { - _slowdown = false, }, { on_hit_node = function (self, pos, node) splash(pos + vector.new(0, 1, 0)) diff --git a/mods/ITEMS/pyutest_potions/potions.lua b/mods/ITEMS/pyutest_potions/potions.lua index b1671da..ca0ad65 100644 --- a/mods/ITEMS/pyutest_potions/potions.lua +++ b/mods/ITEMS/pyutest_potions/potions.lua @@ -1,8 +1,10 @@ +PyuTest.POTION_LENGTH = 90 + PyuTest.make_potion("pyutest_potions:speed", "Speed Potion", { - color = PyuTest.COLORS.turquoise[2], + color = PyuTest.COLORS.teal[2], effect = "speed", multiplier = 2.5, - length = 60, + length = PyuTest.POTION_LENGTH, craft = "pyutest_tools:sugar" }) @@ -10,26 +12,34 @@ PyuTest.make_potion("pyutest_potions:slowness", "Slowness Potion", { color = PyuTest.COLORS.grey[2], effect = "speed", multiplier = 0.45, - length = 60, + length = PyuTest.POTION_LENGTH, craft = "pyutest_tools:ash" }) -PyuTest.make_potion("pyutest_potions:jump_boost", "Jump Boost Potion", { - color = PyuTest.COLORS.pink[2], +PyuTest.make_potion("pyutest_potions:jump_boost", "Leaping Potion", { + color = PyuTest.COLORS.khaki[2], effect = "jump_boost", multiplier = 2.5, - length = 60, + length = PyuTest.POTION_LENGTH, craft = "pyutest_tools:paper" }) PyuTest.make_potion("pyutest_potions:low_gravity", "Low Gravity Potion", { - color = PyuTest.COLORS.chartreuse[2], - effect = "low_gravity", + color = PyuTest.COLORS.silver[2], + effect = "gravity", multiplier = 0.25, - length = 30, + length = PyuTest.POTION_LENGTH, craft = "pyutest_magic:windball" }) +PyuTest.make_potion("pyutest_potions:sea_master", "Sea Master Potion", { + color = PyuTest.COLORS.indigo[2], + effect = "sea_master", + multiplier = 0.25, + length = PyuTest.POTION_LENGTH, + craft = "pyutest_buckets:water_bucket" +}) + PyuTest.make_potion("pyutest_potions:instant_damage", "Instant Damage Potion", { color = PyuTest.COLORS.bloodred[2], action = function (itemstack, user, pointed_thing) diff --git a/mods/PLAYER/pyutest_effects/api.lua b/mods/PLAYER/pyutest_effects/api.lua new file mode 100644 index 0000000..77b23ad --- /dev/null +++ b/mods/PLAYER/pyutest_effects/api.lua @@ -0,0 +1,63 @@ +local effects = {} + +PyuTest.STATUS_EFFECTS = {} + +PyuTest.register_status_effect = function(id, func, oih) + PyuTest.STATUS_EFFECTS[id] = func or function(ObjectRef)end +end + +PyuTest.status_effect_add = function(player, name, multiplier, length) + effects[player][name] = multiplier + + if length ~= nil then + core.after(length, function() + PyuTest.status_effect_remove(player, name) + end) + end +end + +PyuTest.status_effect_remove = function(player, name) + effects[player][name] = false +end + +PyuTest.status_effect_get = function(player, name) + if effects[player][name] ~= false and effects[player][name] ~= nil then + return effects[player][name] + end + return 1 +end + +PyuTest.status_effect_has = function(player, name) + return effects[player][name] ~= false +end + +core.register_on_joinplayer(function (player) + local name = player:get_player_name() + if effects[name] == nil then + effects[name] = {} + end + + for _, v in pairs(PyuTest.STATUS_EFFECTS) do + if effects[name][v] == nil then + effects[name][v] = false + end + end +end) + +core.register_on_respawnplayer(function (player) + local name = player:get_player_name() + + for k, _ in pairs(PyuTest.STATUS_EFFECTS) do + effects[name][k] = false + end +end) + +core.register_globalstep(function () + for _, v in pairs(core.get_connected_players()) do + local name = v:get_player_name() + + for k, f in pairs(PyuTest.STATUS_EFFECTS) do + f(v, name) + end + end +end) diff --git a/mods/PLAYER/pyutest_effects/command.lua b/mods/PLAYER/pyutest_effects/command.lua new file mode 100644 index 0000000..7eeedd4 --- /dev/null +++ b/mods/PLAYER/pyutest_effects/command.lua @@ -0,0 +1,35 @@ +core.register_chatcommand("effect", { + params = "add|remove