mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-03 16:23:47 +01:00
Correct damage for mob projectiles
This commit is contained in:
parent
42c4d91967
commit
be876c3988
@ -409,7 +409,7 @@ function mcl_mobs.register_arrow(name, def)
|
||||
switch = 0,
|
||||
_lifetime = def._lifetime or 7,
|
||||
owner_id = def.owner_id,
|
||||
_vl_projectile = {
|
||||
_vl_projectile = table.update(def._vl_projectile or {},{
|
||||
behaviors = behaviors,
|
||||
ignore_gravity = true,
|
||||
damages_players = true,
|
||||
@ -458,7 +458,7 @@ function mcl_mobs.register_arrow(name, def)
|
||||
return
|
||||
end
|
||||
end
|
||||
},
|
||||
}),
|
||||
on_punch = def.on_punch or function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
local vel = self.object:get_velocity():length()
|
||||
self.object:set_velocity(dir * vel)
|
||||
|
@ -163,22 +163,17 @@ mcl_mobs.register_arrow("mobs_mc:blaze_fireball", {
|
||||
textures = {"mcl_fire_fire_charge.png"},
|
||||
velocity = 15,
|
||||
_is_fireball = true,
|
||||
_vl_projectile = {
|
||||
damage_groups = {fleshy = 5}
|
||||
},
|
||||
|
||||
-- Direct hit, no fire... just plenty of pain
|
||||
hit_player = function(self, player)
|
||||
mcl_burning.set_on_fire(player, 5)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 5},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_mob = function(self, mob)
|
||||
mcl_burning.set_on_fire(mob, 5)
|
||||
mob:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 5},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_object = function(self, object)
|
||||
|
@ -155,21 +155,15 @@ mcl_mobs.register_arrow("mobs_mc:dragon_fireball", {
|
||||
visual_size = {x = 1.25, y = 1.25},
|
||||
textures = {"mobs_mc_dragon_fireball.png"},
|
||||
velocity = 6,
|
||||
_vl_projectile = {
|
||||
damage_groups = {fleshy = 12}
|
||||
},
|
||||
|
||||
-- direct hit, no fire... just plenty of pain
|
||||
hit_player = function(self, player)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 0.5,
|
||||
damage_groups = {fleshy = 12},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_mob = function(self, mob)
|
||||
minetest.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5, max_hear_distance = 2*64}, true)
|
||||
mob:punch(self.object, 1.0, {
|
||||
full_punch_interval = 0.5,
|
||||
damage_groups = {fleshy = 12},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
-- node hit, explode
|
||||
|
@ -111,12 +111,11 @@ mcl_mobs.register_arrow("mobs_mc:fireball", {
|
||||
collisionbox = {-.5, -.5, -.5, .5, .5, .5},
|
||||
_lifetime = 10,
|
||||
_is_fireball = true,
|
||||
_vl_projectile = {
|
||||
damage_groups = {fleshy = 6}
|
||||
},
|
||||
|
||||
hit_player = function(self, player)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 6},
|
||||
}, nil)
|
||||
local p = self.object:get_pos()
|
||||
if p then
|
||||
mcl_mobs.mob_class.boom(self,p, 1, true)
|
||||
@ -127,10 +126,6 @@ mcl_mobs.register_arrow("mobs_mc:fireball", {
|
||||
|
||||
hit_mob = function(self, mob)
|
||||
local name = mob:get_luaentity().name
|
||||
mob:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 6},
|
||||
}, nil)
|
||||
mcl_mobs.mob_class.boom(self,self.object:get_pos(), 1, true)
|
||||
local ent = mob:get_luaentity()
|
||||
if (not ent or ent.health <= 0) and self._owner and minetest.get_player_by_name(self._owner) and name == "mobs_mc:ghast" then
|
||||
|
@ -258,11 +258,10 @@ mcl_mobs.register_arrow("mobs_mc:llamaspit", {
|
||||
visual_size = {x = 0.10, y = 0.10},
|
||||
textures = {"mobs_mc_llama_spit.png"},
|
||||
velocity = 5,
|
||||
_vl_projectile = {
|
||||
damage_groups = {fleshy = 1}
|
||||
},
|
||||
hit_player = function(self, player)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 1},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_mob = function(self, mob)
|
||||
|
@ -464,6 +464,9 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||
},
|
||||
velocity = 7,
|
||||
_lifetime = 15,
|
||||
_vl_projectile = {
|
||||
damage_groups = {fleshy = 8},
|
||||
},
|
||||
on_punch = function(self) end,
|
||||
allow_punching = function(self, _, _, object)
|
||||
local le = object and object:get_luaentity()
|
||||
@ -474,10 +477,6 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||
hit_player = function(self, player)
|
||||
local pos = vector.new(self.object:get_pos())
|
||||
mcl_potions.give_effect("withering", player, 2, 10)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 0.5,
|
||||
damage_groups = {fleshy = 8},
|
||||
}, nil)
|
||||
mcl_mobs.mob_class.boom(self, pos, 1)
|
||||
if player:get_hp() <= 0 then
|
||||
local shooter = self._shooter:get_luaentity()
|
||||
@ -489,10 +488,6 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||
hit_mob = function(self, mob)
|
||||
local pos = vector.new(self.object:get_pos())
|
||||
mcl_potions.give_effect("withering", mob, 2, 10)
|
||||
mob:punch(self.object, 1.0, {
|
||||
full_punch_interval = 0.5,
|
||||
damage_groups = {fleshy = 8},
|
||||
}, nil)
|
||||
mcl_mobs.mob_class.boom(self, pos, 1)
|
||||
local l = mob:get_luaentity()
|
||||
if l and l.health - 8 <= 0 then
|
||||
|
@ -464,16 +464,12 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||
allow_punching = allow_punching,
|
||||
entity_def = entity_def,
|
||||
object = object,
|
||||
object_id = mcl_util.get_entity_id(object),
|
||||
luaentity = object:get_luaentity(),
|
||||
})..")")
|
||||
end
|
||||
|
||||
if not allow_punching then return end
|
||||
-- Get damage
|
||||
local dmg = projectile_def.damage_groups or 0
|
||||
if type(dmg) == "function" then
|
||||
dmg = dmg(self, entity_def, projectile_def, object)
|
||||
end
|
||||
|
||||
local object_lua = object:get_luaentity()
|
||||
|
||||
@ -489,6 +485,12 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||
end
|
||||
|
||||
if do_damage then
|
||||
-- Get damage
|
||||
local dmg = projectile_def.damage_groups or 0
|
||||
if type(dmg) == "function" then
|
||||
dmg = dmg(self, entity_def, projectile_def, object)
|
||||
end
|
||||
|
||||
object:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir )
|
||||
|
||||
-- Guard against crashes when projectiles get destroyed in response to what it punched
|
||||
|
Loading…
Reference in New Issue
Block a user