Compare commits
3 Commits
a6363f779f
...
bc3e2ebd72
Author | SHA1 | Date |
---|---|---|
teknomunk | bc3e2ebd72 | |
teknomunk | 4731ae64f0 | |
teknomunk | 7867168c41 |
|
@ -731,3 +731,13 @@ function mcl_util.get_entity_id(entity)
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function mcl_util.get_entity_from_id(id)
|
||||||
|
local player = minetest.get_player_by_name(id)
|
||||||
|
if player then return player end
|
||||||
|
|
||||||
|
for i,le in pairs(minetest.luaentities) do
|
||||||
|
if le._uuid == id then return le.object end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
|
@ -412,7 +412,7 @@ function mcl_mobs.register_arrow(name, def)
|
||||||
switch = 0,
|
switch = 0,
|
||||||
_lifetime = def._lifetime or 7,
|
_lifetime = def._lifetime or 7,
|
||||||
owner_id = def.owner_id,
|
owner_id = def.owner_id,
|
||||||
_vl_projectile = {
|
_vl_projectile = table.update(def._vl_projectile or {},{
|
||||||
behaviors = behaviors,
|
behaviors = behaviors,
|
||||||
ignore_gravity = true,
|
ignore_gravity = true,
|
||||||
damages_players = true,
|
damages_players = true,
|
||||||
|
@ -424,7 +424,7 @@ function mcl_mobs.register_arrow(name, def)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
on_collide_with_solid = function(self, pos, node, nodedef)
|
on_collide_with_solid = function(self, pos, node, nodedef)
|
||||||
if nodedef or not nodedef.walkable then return end
|
if not nodedef or not nodedef.walkable then return end
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
self.hit_node(self, pos, node)
|
||||||
if self.drop == true then
|
if self.drop == true then
|
||||||
|
@ -461,7 +461,7 @@ function mcl_mobs.register_arrow(name, def)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
},
|
}),
|
||||||
on_punch = def.on_punch or function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
on_punch = def.on_punch or function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
local vel = self.object:get_velocity():length()
|
local vel = self.object:get_velocity():length()
|
||||||
self.object:set_velocity(dir * vel)
|
self.object:set_velocity(dir * vel)
|
||||||
|
|
|
@ -163,22 +163,17 @@ mcl_mobs.register_arrow("mobs_mc:blaze_fireball", {
|
||||||
textures = {"mcl_fire_fire_charge.png"},
|
textures = {"mcl_fire_fire_charge.png"},
|
||||||
velocity = 15,
|
velocity = 15,
|
||||||
_is_fireball = true,
|
_is_fireball = true,
|
||||||
|
_vl_projectile = {
|
||||||
|
damage_groups = {fleshy = 5}
|
||||||
|
},
|
||||||
|
|
||||||
-- Direct hit, no fire... just plenty of pain
|
-- Direct hit, no fire... just plenty of pain
|
||||||
hit_player = function(self, player)
|
hit_player = function(self, player)
|
||||||
mcl_burning.set_on_fire(player, 5)
|
mcl_burning.set_on_fire(player, 5)
|
||||||
player:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = 5},
|
|
||||||
}, nil)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
hit_mob = function(self, mob)
|
||||||
mcl_burning.set_on_fire(mob, 5)
|
mcl_burning.set_on_fire(mob, 5)
|
||||||
mob:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = 5},
|
|
||||||
}, nil)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_object = function(self, object)
|
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},
|
visual_size = {x = 1.25, y = 1.25},
|
||||||
textures = {"mobs_mc_dragon_fireball.png"},
|
textures = {"mobs_mc_dragon_fireball.png"},
|
||||||
velocity = 6,
|
velocity = 6,
|
||||||
|
_vl_projectile = {
|
||||||
|
damage_groups = {fleshy = 12}
|
||||||
|
},
|
||||||
|
|
||||||
-- direct hit, no fire... just plenty of pain
|
|
||||||
hit_player = function(self, player)
|
hit_player = function(self, player)
|
||||||
player:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 0.5,
|
|
||||||
damage_groups = {fleshy = 12},
|
|
||||||
}, nil)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
hit_mob = function(self, mob)
|
||||||
minetest.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5, max_hear_distance = 2*64}, true)
|
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,
|
end,
|
||||||
|
|
||||||
-- node hit, explode
|
-- node hit, explode
|
||||||
|
|
|
@ -111,12 +111,11 @@ mcl_mobs.register_arrow("mobs_mc:fireball", {
|
||||||
collisionbox = {-.5, -.5, -.5, .5, .5, .5},
|
collisionbox = {-.5, -.5, -.5, .5, .5, .5},
|
||||||
_lifetime = 10,
|
_lifetime = 10,
|
||||||
_is_fireball = true,
|
_is_fireball = true,
|
||||||
|
_vl_projectile = {
|
||||||
|
damage_groups = {fleshy = 6}
|
||||||
|
},
|
||||||
|
|
||||||
hit_player = function(self, player)
|
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()
|
local p = self.object:get_pos()
|
||||||
if p then
|
if p then
|
||||||
mcl_mobs.mob_class.boom(self,p, 1, true)
|
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)
|
hit_mob = function(self, mob)
|
||||||
local name = mob:get_luaentity().name
|
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)
|
mcl_mobs.mob_class.boom(self,self.object:get_pos(), 1, true)
|
||||||
local ent = mob:get_luaentity()
|
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
|
if (not ent or ent.health <= 0) and self._owner and minetest.get_player_by_name(self._owner) and name == "mobs_mc:ghast" then
|
||||||
|
|
|
@ -259,11 +259,10 @@ mcl_mobs.register_arrow("mobs_mc:llamaspit", {
|
||||||
visual_size = {x = 0.10, y = 0.10},
|
visual_size = {x = 0.10, y = 0.10},
|
||||||
textures = {"mobs_mc_llama_spit.png"},
|
textures = {"mobs_mc_llama_spit.png"},
|
||||||
velocity = 5,
|
velocity = 5,
|
||||||
|
_vl_projectile = {
|
||||||
|
damage_groups = {fleshy = 1}
|
||||||
|
},
|
||||||
hit_player = function(self, player)
|
hit_player = function(self, player)
|
||||||
player:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = 1},
|
|
||||||
}, nil)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
hit_mob = function(self, mob)
|
||||||
|
|
|
@ -464,6 +464,9 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||||
},
|
},
|
||||||
velocity = 7,
|
velocity = 7,
|
||||||
_lifetime = 15,
|
_lifetime = 15,
|
||||||
|
_vl_projectile = {
|
||||||
|
damage_groups = {fleshy = 8},
|
||||||
|
},
|
||||||
on_punch = function(self) end,
|
on_punch = function(self) end,
|
||||||
allow_punching = function(self, _, _, object)
|
allow_punching = function(self, _, _, object)
|
||||||
local le = object and object:get_luaentity()
|
local le = object and object:get_luaentity()
|
||||||
|
@ -474,10 +477,6 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||||
hit_player = function(self, player)
|
hit_player = function(self, player)
|
||||||
local pos = vector.new(self.object:get_pos())
|
local pos = vector.new(self.object:get_pos())
|
||||||
mcl_potions.give_effect("withering", player, 2, 10)
|
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)
|
mcl_mobs.mob_class.boom(self, pos, 1)
|
||||||
if player:get_hp() <= 0 then
|
if player:get_hp() <= 0 then
|
||||||
local shooter = self._shooter:get_luaentity()
|
local shooter = self._shooter:get_luaentity()
|
||||||
|
@ -489,10 +488,6 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", {
|
||||||
hit_mob = function(self, mob)
|
hit_mob = function(self, mob)
|
||||||
local pos = vector.new(self.object:get_pos())
|
local pos = vector.new(self.object:get_pos())
|
||||||
mcl_potions.give_effect("withering", mob, 2, 10)
|
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)
|
mcl_mobs.mob_class.boom(self, pos, 1)
|
||||||
local l = mob:get_luaentity()
|
local l = mob:get_luaentity()
|
||||||
if l and l.health - 8 <= 0 then
|
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,
|
allow_punching = allow_punching,
|
||||||
entity_def = entity_def,
|
entity_def = entity_def,
|
||||||
object = object,
|
object = object,
|
||||||
|
object_id = mcl_util.get_entity_id(object),
|
||||||
luaentity = object:get_luaentity(),
|
luaentity = object:get_luaentity(),
|
||||||
})..")")
|
})..")")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not allow_punching then return 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()
|
local object_lua = object:get_luaentity()
|
||||||
|
|
||||||
|
@ -489,7 +485,13 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
|
|
||||||
if do_damage then
|
if do_damage then
|
||||||
object:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir )
|
-- Get damage
|
||||||
|
local dmg = projectile_def.damage_groups or 0
|
||||||
|
if type(dmg) == "function" then
|
||||||
|
dmg = dmg(self, entity_def, projectile_def, object)
|
||||||
|
end
|
||||||
|
|
||||||
|
mcl_util.deal_damage(object, dmg.fleshy, {type = projectile_def.damage_type or "arrow", source = mcl_util.get_entity_from_id(self._owner), direct = self.object})
|
||||||
|
|
||||||
-- Guard against crashes when projectiles get destroyed in response to what it punched
|
-- Guard against crashes when projectiles get destroyed in response to what it punched
|
||||||
if not self.object:get_pos() then return true end
|
if not self.object:get_pos() then return true end
|
||||||
|
|
Loading…
Reference in New Issue