Make dmg particles proportional to dmg
This commit is contained in:
parent
5bd19c03f6
commit
d9424ad82e
|
@ -375,20 +375,28 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- custom particle effects
|
-- custom particle effects
|
||||||
local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow)
|
local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down)
|
||||||
|
|
||||||
radius = radius or 2
|
radius = radius or 2
|
||||||
min_size = min_size or 0.5
|
min_size = min_size or 0.5
|
||||||
max_size = max_size or 1
|
max_size = max_size or 1
|
||||||
gravity = gravity or -10
|
gravity = gravity or -10
|
||||||
glow = glow or 0
|
glow = glow or 0
|
||||||
|
go_down = go_down or false
|
||||||
|
|
||||||
|
local ym
|
||||||
|
if go_down then
|
||||||
|
ym = 0
|
||||||
|
else
|
||||||
|
ym = -radius
|
||||||
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = amount,
|
amount = amount,
|
||||||
time = 0.25,
|
time = 0.25,
|
||||||
minpos = pos,
|
minpos = pos,
|
||||||
maxpos = pos,
|
maxpos = pos,
|
||||||
minvel = {x = -radius, y = -radius, z = -radius},
|
minvel = {x = -radius, y = ym, z = -radius},
|
||||||
maxvel = {x = radius, y = radius, z = radius},
|
maxvel = {x = radius, y = radius, z = radius},
|
||||||
minacc = {x = 0, y = gravity, z = 0},
|
minacc = {x = 0, y = gravity, z = 0},
|
||||||
maxacc = {x = 0, y = gravity, z = 0},
|
maxacc = {x = 0, y = gravity, z = 0},
|
||||||
|
@ -401,6 +409,35 @@ local effect = function(pos, amount, texture, min_size, max_size, radius, gravit
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local damage_effect = function(self, damage)
|
||||||
|
-- damage particles
|
||||||
|
if (not disable_blood) and damage > 0 then
|
||||||
|
|
||||||
|
local amount_large = math.floor(damage / 2)
|
||||||
|
local amount_small = damage % 2
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
|
pos.y = pos.y + (self.collisionbox[5] - self.collisionbox[2]) * .5
|
||||||
|
|
||||||
|
local texture
|
||||||
|
-- do we have a single blood texture or multiple?
|
||||||
|
if type(self.blood_texture) == "table" then
|
||||||
|
texture = self.blood_texture[random(1, #self.blood_texture)]
|
||||||
|
else
|
||||||
|
texture = self.blood_texture
|
||||||
|
end
|
||||||
|
-- full heart damage (one particle for each 2 HP damage)
|
||||||
|
if amount_large > 0 then
|
||||||
|
effect(pos, amount_large, texture, 2, 2, 1.75, 0, nil, true)
|
||||||
|
end
|
||||||
|
-- half heart damage (one additional particle if damage is an odd number)
|
||||||
|
if amount_small > 0 then
|
||||||
|
-- TODO: Use "half heart"
|
||||||
|
effect(pos, amount_small, texture, 1, 1, 1.75, 0, nil, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local update_tag = function(self)
|
local update_tag = function(self)
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
|
@ -781,13 +818,14 @@ local do_env_damage = function(self)
|
||||||
|
|
||||||
effect(pos, 2, "bubble.png", nil, nil, 1, nil)
|
effect(pos, 2, "bubble.png", nil, nil, 1, nil)
|
||||||
if self.breath <= 0 then
|
if self.breath <= 0 then
|
||||||
-- TODO: Damage particle
|
local dmg
|
||||||
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
|
|
||||||
if nodef.drowning > 0 then
|
if nodef.drowning > 0 then
|
||||||
self.health = self.health - nodef.drowning
|
dmg = nodef.drowning
|
||||||
else
|
else
|
||||||
self.health = self.health - 4
|
dmg = 4
|
||||||
end
|
end
|
||||||
|
damage_effect(self, dmg)
|
||||||
|
self.health = self.health - dmg
|
||||||
end
|
end
|
||||||
if check_for_death(self, "drowning", {type = "environment",
|
if check_for_death(self, "drowning", {type = "environment",
|
||||||
pos = pos, node = self.standing_in}) then return end
|
pos = pos, node = self.standing_in}) then return end
|
||||||
|
@ -2540,24 +2578,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- blood_particles
|
damage_effect(self, damage)
|
||||||
if self.blood_amount > 0
|
|
||||||
and not disable_blood then
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
pos.y = pos.y + (-self.collisionbox[2] + self.collisionbox[5]) * .5
|
|
||||||
|
|
||||||
-- do we have a single blood texture or multiple?
|
|
||||||
if type(self.blood_texture) == "table" then
|
|
||||||
|
|
||||||
local blood = self.blood_texture[random(1, #self.blood_texture)]
|
|
||||||
|
|
||||||
effect(pos, self.blood_amount, blood, nil, nil, 1, nil)
|
|
||||||
else
|
|
||||||
effect(pos, self.blood_amount, self.blood_texture, nil, nil, 1, nil)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- do damage
|
-- do damage
|
||||||
self.health = self.health - floor(damage)
|
self.health = self.health - floor(damage)
|
||||||
|
@ -3161,7 +3182,6 @@ minetest.register_entity(name, {
|
||||||
group_attack = def.group_attack or false,
|
group_attack = def.group_attack or false,
|
||||||
passive = def.passive or false,
|
passive = def.passive or false,
|
||||||
knock_back = def.knock_back ~= false,
|
knock_back = def.knock_back ~= false,
|
||||||
blood_amount = def.blood_amount or 5,
|
|
||||||
blood_texture = def.blood_texture or "mobs_blood.png",
|
blood_texture = def.blood_texture or "mobs_blood.png",
|
||||||
shoot_offset = def.shoot_offset or 0,
|
shoot_offset = def.shoot_offset or 0,
|
||||||
floats = def.floats or 1, -- floats in water by default
|
floats = def.floats or 1, -- floats in water by default
|
||||||
|
|
|
@ -123,8 +123,6 @@ functions needed for the mob to work properly which contains the following:
|
||||||
e.g. {"player", "mobs_animal:chicken"}.
|
e.g. {"player", "mobs_animal:chicken"}.
|
||||||
'runaway_from' contains a table with mob names to run away from, add
|
'runaway_from' contains a table with mob names to run away from, add
|
||||||
"player" to list to runaway from player also.
|
"player" to list to runaway from player also.
|
||||||
'blood_amount' contains the number of blood droplets to appear when
|
|
||||||
mob is hit.
|
|
||||||
'blood_texture' has the texture name to use for droplets e.g.
|
'blood_texture' has the texture name to use for droplets e.g.
|
||||||
"mobs_blood.png", or table {"blood1.png", "blood2.png"}
|
"mobs_blood.png", or table {"blood1.png", "blood2.png"}
|
||||||
'pathfinding' set to 1 for mobs to use pathfinder feature to locate
|
'pathfinding' set to 1 for mobs to use pathfinder feature to locate
|
||||||
|
|
|
@ -67,7 +67,6 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
fly = true,
|
fly = true,
|
||||||
jump_chance = 98,
|
jump_chance = 98,
|
||||||
fear_height = 0,
|
fear_height = 0,
|
||||||
blood_amount = 0,
|
|
||||||
glow = 14,
|
glow = 14,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,6 @@ mobs:register_mob("mobs_mc:creeper", {
|
||||||
floats = 1,
|
floats = 1,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
walk_start = 0, walk_end = 20,
|
walk_start = 0, walk_end = 20,
|
||||||
run_start = 0, run_end = 20,
|
run_start = 0, run_end = 20,
|
||||||
},
|
},
|
||||||
blood_amount = 0,
|
|
||||||
|
|
||||||
ignores_nametag = true,
|
ignores_nametag = true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -325,7 +325,6 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
view_range = 4,
|
view_range = 4,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ mobs:register_mob("mobs_mc:endermite", {
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
damage = 2,
|
damage = 2,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_egg("mobs_mc:endermite", S("Endermite"), "mobs_mc_spawn_icon_endermite.png", 0)
|
mobs:register_egg("mobs_mc:endermite", S("Endermite"), "mobs_mc_spawn_icon_endermite.png", 0)
|
||||||
|
|
|
@ -71,7 +71,6 @@ mobs:register_mob("mobs_mc:ghast", {
|
||||||
fly = true,
|
fly = true,
|
||||||
fly_in = {"air"},
|
fly_in = {"air"},
|
||||||
jump_chance = 98,
|
jump_chance = 98,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ mobs:register_mob("mobs_mc:guardian", {
|
||||||
stepheight = 0.1,
|
stepheight = 0.1,
|
||||||
jump = false,
|
jump = false,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:spawn_specific("mobs_mc:guardian", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 25000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water - 10)
|
mobs:spawn_specific("mobs_mc:guardian", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 25000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water - 10)
|
||||||
|
|
|
@ -82,7 +82,6 @@ mobs:register_mob("mobs_mc:guardian_elder", {
|
||||||
stepheight = 0.1,
|
stepheight = 0.1,
|
||||||
jump = false,
|
jump = false,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:spawn_specific("mobs_mc:guardian_elder", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 40000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-18)
|
mobs:spawn_specific("mobs_mc:guardian_elder", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 40000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-18)
|
||||||
|
|
|
@ -336,7 +336,6 @@ skeleton_horse.sounds = {
|
||||||
damage = "mobs_mc_skeleton_hurt",
|
damage = "mobs_mc_skeleton_hurt",
|
||||||
distance = 16,
|
distance = 16,
|
||||||
}
|
}
|
||||||
skeleton_horse.blood_amount = 0
|
|
||||||
mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse)
|
mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse)
|
||||||
|
|
||||||
-- Zombie horse
|
-- Zombie horse
|
||||||
|
|
|
@ -58,7 +58,6 @@ mobs:register_mob("mobs_mc:iron_golem", {
|
||||||
punch_start = 40, punch_end = 50,
|
punch_start = 40, punch_end = 50,
|
||||||
},
|
},
|
||||||
jump = true,
|
jump = true,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ mobs:register_mob("mobs_mc:shulker", {
|
||||||
run_start = 0, run_end = 45,
|
run_start = 0, run_end = 45,
|
||||||
punch_start = 80, punch_end = 100,
|
punch_start = 80, punch_end = 100,
|
||||||
},
|
},
|
||||||
blood_amount = 0,
|
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
})
|
})
|
||||||
|
|
|
@ -42,7 +42,6 @@ mobs:register_mob("mobs_mc:silverfish", {
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
damage = 1,
|
damage = 1,
|
||||||
reach = 1,
|
reach = 1,
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_silverfish.png", 0)
|
mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_silverfish.png", 0)
|
||||||
|
|
|
@ -83,7 +83,6 @@ local skeleton = {
|
||||||
shoot_offset = 1,
|
shoot_offset = 1,
|
||||||
dogshoot_switch = 1,
|
dogshoot_switch = 1,
|
||||||
dogshoot_count_max =1.8,
|
dogshoot_count_max =1.8,
|
||||||
blood_amount = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:skeleton", skeleton)
|
mobs:register_mob("mobs_mc:skeleton", skeleton)
|
||||||
|
|
|
@ -81,7 +81,6 @@ mobs:register_mob("mobs_mc:witherskeleton", {
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
dogshoot_switch = 1,
|
dogshoot_switch = 1,
|
||||||
dogshoot_count_max =0.5,
|
dogshoot_count_max =0.5,
|
||||||
blood_amount = 0,
|
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ mobs:register_mob("mobs_mc:snowman", {
|
||||||
die_speed = 25,
|
die_speed = 25,
|
||||||
die_loop = false,
|
die_loop = false,
|
||||||
},
|
},
|
||||||
blood_amount = 0,
|
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
if not mobs_griefing then
|
if not mobs_griefing then
|
||||||
return
|
return
|
||||||
|
|
|
@ -58,7 +58,6 @@ local spider = {
|
||||||
run_start = 0,
|
run_start = 0,
|
||||||
run_end = 20,
|
run_end = 20,
|
||||||
},
|
},
|
||||||
blood_amount = 0,
|
|
||||||
}
|
}
|
||||||
mobs:register_mob("mobs_mc:spider", spider)
|
mobs:register_mob("mobs_mc:spider", spider)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ mobs:register_mob("mobs_mc:wither", {
|
||||||
walk_start = 0, walk_end = 20,
|
walk_start = 0, walk_end = 20,
|
||||||
run_start = 0, run_end = 20,
|
run_start = 0, run_end = 20,
|
||||||
},
|
},
|
||||||
blood_amount = 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
||||||
|
|
Loading…
Reference in New Issue