forked from MineClone5/MineClone5
Introduce snowball_vulnerable armor group
This commit is contained in:
parent
be04de084b
commit
c234b273ad
|
@ -2876,7 +2876,14 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.path.stuck_timer = 0 -- if stuck for too long search for path
|
self.path.stuck_timer = 0 -- if stuck for too long search for path
|
||||||
|
|
||||||
-- mob defaults
|
-- mob defaults
|
||||||
self.object:set_armor_groups({immortal = 1, fleshy = self.armor})
|
local armor
|
||||||
|
if type(self.armor) == "table" then
|
||||||
|
armor = table.copy(self.armor)
|
||||||
|
armor.immortal = 1
|
||||||
|
else
|
||||||
|
armor = {immortal=1, fleshy = self.armor}
|
||||||
|
end
|
||||||
|
self.object:set_armor_groups(armor)
|
||||||
self.old_y = self.object:get_pos().y
|
self.old_y = self.object:get_pos().y
|
||||||
self.old_health = self.health
|
self.old_health = self.health
|
||||||
self.sounds.distance = self.sounds.distance or 10
|
self.sounds.distance = self.sounds.distance or 10
|
||||||
|
|
|
@ -35,8 +35,12 @@ functions needed for the mob to work properly which contains the following:
|
||||||
'breathes_in_water' If true, mob loses breath when not in water. Otherwise,
|
'breathes_in_water' If true, mob loses breath when not in water. Otherwise,
|
||||||
mob loses breath when inside a node with `drowning` attribute
|
mob loses breath when inside a node with `drowning` attribute
|
||||||
set (default: false).
|
set (default: false).
|
||||||
'armor' holds strength of mob, 100 is normal, lower is more powerful
|
'armor' entity armor groups (see lua_api.txt). If table, a list of
|
||||||
and needs more hits and better weapons to kill.
|
armor groups like for entities. If number, set value of
|
||||||
|
'fleshy' armor group only.
|
||||||
|
Note: The 'immortal=1' armor group will automatically be added
|
||||||
|
since this mod handles health and damage manually.
|
||||||
|
Default: 100 (mob will take full dmg from 'fleshy' hits)
|
||||||
'passive' when true allows animals to defend themselves when hit,
|
'passive' when true allows animals to defend themselves when hit,
|
||||||
otherwise they amble onwards.
|
otherwise they amble onwards.
|
||||||
'walk_velocity' is the speed that your mob can walk around.
|
'walk_velocity' is the speed that your mob can walk around.
|
||||||
|
|
|
@ -21,6 +21,7 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
textures = {
|
textures = {
|
||||||
{"mobs_mc_blaze.png"},
|
{"mobs_mc_blaze.png"},
|
||||||
},
|
},
|
||||||
|
armor = { fleshy = 100, snowball_vulnerable = 100 },
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
sounds = {
|
sounds = {
|
||||||
random = "mobs_mc_blaze_breath",
|
random = "mobs_mc_blaze_breath",
|
||||||
|
|
|
@ -145,7 +145,7 @@ local flying_bobber_ENTITY={
|
||||||
objtype="fishing",
|
objtype="fishing",
|
||||||
}
|
}
|
||||||
|
|
||||||
local check_object_hit = function(self, pos, mob_damage)
|
local check_object_hit = function(self, pos, dmg)
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do
|
for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do
|
||||||
|
|
||||||
local entity = object:get_luaentity()
|
local entity = object:get_luaentity()
|
||||||
|
@ -158,11 +158,6 @@ local check_object_hit = function(self, pos, mob_damage)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return true
|
return true
|
||||||
elseif entity._cmi_is_mob == true and (self._thrower ~= object) then
|
elseif entity._cmi_is_mob == true and (self._thrower ~= object) then
|
||||||
local dmg = {}
|
|
||||||
if mob_damage then
|
|
||||||
dmg = mob_damage(entity.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- FIXME: Knockback is broken
|
-- FIXME: Knockback is broken
|
||||||
object:punch(self.object, 1.0, {
|
object:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
|
@ -193,15 +188,7 @@ local snowball_on_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local mob_damage = function(mobname)
|
if check_object_hit(self, pos, {snowball_vulnerable = 3}) then
|
||||||
if mobname == "mobs_mc:blaze" then
|
|
||||||
return {fleshy = 3}
|
|
||||||
else
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if check_object_hit(self, pos, mob_damage) then
|
|
||||||
minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = self.object:get_pos(), max_hear_distance=16, gain=0.7 })
|
minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = self.object:get_pos(), max_hear_distance=16, gain=0.7 })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue