From 8293781f549dd4ccca5cb1e90479a0f2f345bbe6 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Sun, 12 Apr 2020 01:18:15 -0400 Subject: [PATCH] Make criticals even better --- mods/mob/pig/interaction_code.lua | 62 ++++++++++++++++++---------- mods/mob/pig/piginit.lua | 4 ++ mods/mob/slime/interaction_code.lua | 53 ++++++++++++++++-------- mods/mob/slime/slimeinit.lua | 4 ++ mods/mob/textures/critical.png | Bin 575 -> 575 bytes 5 files changed, 84 insertions(+), 39 deletions(-) diff --git a/mods/mob/pig/interaction_code.lua b/mods/mob/pig/interaction_code.lua index 5afe09f..8d64586 100644 --- a/mods/mob/pig/interaction_code.lua +++ b/mods/mob/pig/interaction_code.lua @@ -1,5 +1,6 @@ --this is the file which houses the functions that control how mobs interact with the world + --the sword wear mechanic pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabilities, dir) if puncher:is_player() then @@ -15,40 +16,49 @@ pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabili end end +--critical effect particles +pig.do_critical_particles = function(pos) + minetest.add_particlespawner({ + amount = 40, + time = 0.001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-5,-5,-5), + maxvel = vector.new(5,5,5), + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1.1, + maxexptime = 1.5, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "critical.png", + }) +end + --this controls what happens when the mob gets punched pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir) local hp = self.hp local vel = self.object:get_velocity() local hurt = tool_capabilities.damage_groups.damage + if not hurt then hurt = 1 end + local critical = false + --criticals local pos = self.object:get_pos() if puncher:is_player() then local puncher_vel = puncher:get_player_velocity().y if puncher_vel < 0 then hurt = hurt * 1.5 - minetest.add_particlespawner({ - amount = 40, - time = 0.001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-5,-5,-5), - maxvel = vector.new(5,5,5), - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, - minexptime = 1.1, - maxexptime = 1.5, - minsize = 1, - maxsize = 2, - collisiondetection = false, - vertical = false, - texture = "critical.png", - }) + critical = true end end + local hp = hp-hurt if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then @@ -69,17 +79,27 @@ pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, else dir.y = 0 end + + --critical effect + if critical == true then + self.do_critical_particles(pos) + end + self.object:add_velocity(dir) - - self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir) elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then + --critical effect + if critical == true then + self.do_critical_particles(pos) + end self.death_animation_timer = 1 self.dead = true minetest.sound_play("pig_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100}) - --self.object:set_texture_mod("^[colorize:red:90") - --self.child:set_texture_mod("^[colorize:red:90") + self.object:set_texture_mod("^[colorize:red:130") + if self.child then + self.child:set_texture_mod("^[colorize:red:130") + end self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir) end end diff --git a/mods/mob/pig/piginit.lua b/mods/mob/pig/piginit.lua index 8721a3a..7f3a096 100644 --- a/mods/mob/pig/piginit.lua +++ b/mods/mob/pig/piginit.lua @@ -110,6 +110,10 @@ pig.on_step = function(self, dtime) self.manage_punch_timer(self,dtime) --self.debug_nametag(self,dtime) end + --fix zombie state again + if self.dead == true and self.death_animation_timer <= 0 then + self.on_death(self) + end end minetest.register_entity("mob:pig", pig) diff --git a/mods/mob/slime/interaction_code.lua b/mods/mob/slime/interaction_code.lua index 2b803de..6ab992f 100644 --- a/mods/mob/slime/interaction_code.lua +++ b/mods/mob/slime/interaction_code.lua @@ -16,6 +16,27 @@ slime.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabi end end +--critical effect particles +slime.do_critical_particles = function(pos) + minetest.add_particlespawner({ + amount = 40, + time = 0.001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-5,-5,-5), + maxvel = vector.new(5,5,5), + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1.1, + maxexptime = 1.5, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "critical.png", + }) +end + --this controls what happens when the mob gets punched slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir) local hp = self.hp @@ -26,29 +47,15 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities hurt = 1 end + local critical = false + --criticals local pos = self.object:get_pos() if puncher:is_player() then local puncher_vel = puncher:get_player_velocity().y if puncher_vel < 0 then hurt = hurt * 1.5 - minetest.add_particlespawner({ - amount = 40, - time = 0.001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-5,-5,-5), - maxvel = vector.new(5,5,5), - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, - minexptime = 1.1, - maxexptime = 1.5, - minsize = 1, - maxsize = 2, - collisiondetection = false, - vertical = false, - texture = "critical.png", - }) + critical = true end end @@ -72,13 +79,23 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities else dir.y = 0 end + + --critical effect + if critical == true then + self.do_critical_particles(pos) + end + self.object:add_velocity(dir) self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir) elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then + --critical effect + if critical == true then + self.do_critical_particles(pos) + end self.death_animation_timer = 1 self.dead = true minetest.sound_play("slime_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100}) - --self.object:set_texture_mod("^[colorize:red:90") + self.object:set_texture_mod("^[colorize:red:130") --self.child:set_texture_mod("^[colorize:red:90") self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir) end diff --git a/mods/mob/slime/slimeinit.lua b/mods/mob/slime/slimeinit.lua index 7f36cef..5f6eeeb 100644 --- a/mods/mob/slime/slimeinit.lua +++ b/mods/mob/slime/slimeinit.lua @@ -99,6 +99,10 @@ slime.on_step = function(self, dtime) self.manage_punch_timer(self,dtime) --self.debug_nametag(self,dtime) end + --fix zombie state again + if self.dead == true and self.death_animation_timer <= 0 then + self.on_death(self) + end end minetest.register_entity("mob:slime", slime) diff --git a/mods/mob/textures/critical.png b/mods/mob/textures/critical.png index fda41f55677c8978a868d247b8454bf79d2af6ec..56c28236fa7453d6ed6aba469ff03d2e09e07568 100644 GIT binary patch delta 51 zcmdnbvY%zcQ$}`HUXz@*Me&p0Fq+7Bq|f+0pK)fRA_K$J