Add in mob criticals when falling

This commit is contained in:
jordan4ibanez 2021-04-22 22:08:54 -04:00
parent afdcada1fd
commit 0a8fff6524
4 changed files with 71 additions and 33 deletions

View File

@ -160,6 +160,7 @@ dofile(api_path .. "set_up.lua")
dofile(api_path .. "attack_type_instructions.lua") dofile(api_path .. "attack_type_instructions.lua")
dofile(api_path .. "sound_handling.lua") dofile(api_path .. "sound_handling.lua")
dofile(api_path .. "death_logic.lua") dofile(api_path .. "death_logic.lua")
dofile(api_path .. "mob_effects.lua")
mobs.spawning_mobs = {} mobs.spawning_mobs = {}

View File

@ -1,5 +1,4 @@
local minetest_add_item = minetest.add_item local minetest_add_item = minetest.add_item
local minetest_add_particlespawner = minetest.add_particlespawner
local minetest_sound_play = minetest.sound_play local minetest_sound_play = minetest.sound_play
local math_pi = math.pi local math_pi = math.pi
@ -10,37 +9,6 @@ local HALF_PI = math_pi / 2
local vector_new = vector.new local vector_new = vector.new
local death_effect = function(self)
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local collisionbox = self.object:get_properties().collisionbox
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
end
minetest_add_particlespawner({
amount = 50,
time = 0.001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector.new(-0.5,0.5,-0.5),
maxvel = vector.new(0.5,1,0.5),
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "mcl_particles_mob_death.png", -- this particle looks strange
})
end
-- drop items -- drop items
local item_drop = function(self, cooked, looting_level) local item_drop = function(self, cooked, looting_level)
@ -127,7 +95,7 @@ mobs.death_logic = function(self, dtime)
item_drop(self,false,1) item_drop(self,false,1)
death_effect(self) mobs.death_effect(self)
self.object:remove() self.object:remove()

View File

@ -170,6 +170,14 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
end end
end end
--if player is falling multiply damage by 1.5
--critical hit
if hitter:get_velocity().y < 0 then
damage = damage * 1.5
mobs.critical_effect(self)
end
local die = false local die = false
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.

View File

@ -0,0 +1,61 @@
local minetest_add_particlespawner = minetest.add_particlespawner
mobs.death_effect = function(self)
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local collisionbox = self.object:get_properties().collisionbox
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
end
minetest_add_particlespawner({
amount = 50,
time = 0.0001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector.new(-0.5,0.5,-0.5),
maxvel = vector.new(0.5,1,0.5),
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "mcl_particles_mob_death.png", -- this particle looks strange
})
end
mobs.critical_effect = function(self)
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local collisionbox = self.object:get_properties().collisionbox
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
end
minetest_add_particlespawner({
amount = 10,
time = 0.0001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector.new(-1,1,-1),
maxvel = vector.new(1,3,1),
minexptime = 0.7,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "heart.png^[colorize:black:255",
})
end