1
0
Fork 0

Make dmg particles proportional to dmg

objects
Wuzzy 2019-10-03 11:53:26 +02:00
parent 5bd19c03f6
commit d9424ad82e
19 changed files with 45 additions and 44 deletions

View File

@ -375,20 +375,28 @@ end
-- 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
min_size = min_size or 0.5
max_size = max_size or 1
gravity = gravity or -10
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({
amount = amount,
time = 0.25,
minpos = pos,
maxpos = pos,
minvel = {x = -radius, y = -radius, z = -radius},
minvel = {x = -radius, y = ym, z = -radius},
maxvel = {x = radius, y = radius, z = radius},
minacc = {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
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)
self.object:set_properties({
@ -781,13 +818,14 @@ local do_env_damage = function(self)
effect(pos, 2, "bubble.png", nil, nil, 1, nil)
if self.breath <= 0 then
-- TODO: Damage particle
effect(pos, 5, "bubble.png", nil, nil, 1, nil)
local dmg
if nodef.drowning > 0 then
self.health = self.health - nodef.drowning
dmg = nodef.drowning
else
self.health = self.health - 4
dmg = 4
end
damage_effect(self, dmg)
self.health = self.health - dmg
end
if check_for_death(self, "drowning", {type = "environment",
pos = pos, node = self.standing_in}) then return end
@ -2540,24 +2578,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
})
end
-- blood_particles
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
damage_effect(self, damage)
-- do damage
self.health = self.health - floor(damage)
@ -3161,7 +3182,6 @@ minetest.register_entity(name, {
group_attack = def.group_attack or false,
passive = def.passive or false,
knock_back = def.knock_back ~= false,
blood_amount = def.blood_amount or 5,
blood_texture = def.blood_texture or "mobs_blood.png",
shoot_offset = def.shoot_offset or 0,
floats = def.floats or 1, -- floats in water by default

View File

@ -123,8 +123,6 @@ functions needed for the mob to work properly which contains the following:
e.g. {"player", "mobs_animal:chicken"}.
'runaway_from' contains a table with mob names to run away from, add
"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.
"mobs_blood.png", or table {"blood1.png", "blood2.png"}
'pathfinding' set to 1 for mobs to use pathfinder feature to locate

View File

@ -67,7 +67,6 @@ mobs:register_mob("mobs_mc:blaze", {
fly = true,
jump_chance = 98,
fear_height = 0,
blood_amount = 0,
glow = 14,
})

View File

@ -115,7 +115,6 @@ mobs:register_mob("mobs_mc:creeper", {
floats = 1,
fear_height = 4,
view_range = 16,
blood_amount = 0,
})

View File

@ -60,7 +60,6 @@ mobs:register_mob("mobs_mc:enderdragon", {
walk_start = 0, walk_end = 20,
run_start = 0, run_end = 20,
},
blood_amount = 0,
ignores_nametag = true,
})

View File

@ -325,7 +325,6 @@ mobs:register_mob("mobs_mc:enderman", {
view_range = 4,
fear_height = 4,
attack_type = "dogfight",
blood_amount = 0,
})

View File

@ -31,7 +31,6 @@ mobs:register_mob("mobs_mc:endermite", {
view_range = 16,
damage = 2,
reach = 1,
blood_amount = 0,
})
mobs:register_egg("mobs_mc:endermite", S("Endermite"), "mobs_mc_spawn_icon_endermite.png", 0)

View File

@ -71,7 +71,6 @@ mobs:register_mob("mobs_mc:ghast", {
fly = true,
fly_in = {"air"},
jump_chance = 98,
blood_amount = 0,
})

View File

@ -77,7 +77,6 @@ mobs:register_mob("mobs_mc:guardian", {
stepheight = 0.1,
jump = false,
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)

View File

@ -82,7 +82,6 @@ mobs:register_mob("mobs_mc:guardian_elder", {
stepheight = 0.1,
jump = false,
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)

View File

@ -336,7 +336,6 @@ skeleton_horse.sounds = {
damage = "mobs_mc_skeleton_hurt",
distance = 16,
}
skeleton_horse.blood_amount = 0
mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse)
-- Zombie horse

View File

@ -58,7 +58,6 @@ mobs:register_mob("mobs_mc:iron_golem", {
punch_start = 40, punch_end = 50,
},
jump = true,
blood_amount = 0,
})

View File

@ -44,7 +44,6 @@ mobs:register_mob("mobs_mc:shulker", {
run_start = 0, run_end = 45,
punch_start = 80, punch_end = 100,
},
blood_amount = 0,
view_range = 16,
fear_height = 4,
})

View File

@ -42,7 +42,6 @@ mobs:register_mob("mobs_mc:silverfish", {
attack_type = "dogfight",
damage = 1,
reach = 1,
blood_amount = 0,
})
mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_silverfish.png", 0)

View File

@ -83,7 +83,6 @@ local skeleton = {
shoot_offset = 1,
dogshoot_switch = 1,
dogshoot_count_max =1.8,
blood_amount = 0,
}
mobs:register_mob("mobs_mc:skeleton", skeleton)

View File

@ -81,7 +81,6 @@ mobs:register_mob("mobs_mc:witherskeleton", {
attack_type = "dogfight",
dogshoot_switch = 1,
dogshoot_count_max =0.5,
blood_amount = 0,
fear_height = 4,
})

View File

@ -69,7 +69,6 @@ mobs:register_mob("mobs_mc:snowman", {
die_speed = 25,
die_loop = false,
},
blood_amount = 0,
do_custom = function(self, dtime)
if not mobs_griefing then
return

View File

@ -58,7 +58,6 @@ local spider = {
run_start = 0,
run_end = 20,
},
blood_amount = 0,
}
mobs:register_mob("mobs_mc:spider", spider)

View File

@ -63,7 +63,6 @@ mobs:register_mob("mobs_mc:wither", {
walk_start = 0, walk_end = 20,
run_start = 0, run_end = 20,
},
blood_amount = 0,
})
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false