forked from VoxeLibre/VoxeLibre
Remove _cmi_is_mob
This commit is contained in:
parent
4054f05a4c
commit
e0f70b54ec
|
@ -78,7 +78,7 @@ function mcl_damage.from_punch(mcl_reason, object)
|
|||
mcl_reason.type = "arrow"
|
||||
elseif luaentity._is_fireball then
|
||||
mcl_reason.type = "fireball"
|
||||
elseif luaentity._cmi_is_mob then
|
||||
elseif luaentity.is_mob then
|
||||
mcl_reason.type = "mob"
|
||||
end
|
||||
mcl_reason.source = mcl_reason.source or luaentity._source_object
|
||||
|
|
|
@ -524,7 +524,7 @@ function mcl_util.deal_damage(target, damage, mcl_reason)
|
|||
if luaentity.deal_damage then
|
||||
luaentity:deal_damage(damage, mcl_reason or {type = "generic"})
|
||||
return
|
||||
elseif luaentity._cmi_is_mob then
|
||||
elseif luaentity.is_mob then
|
||||
-- local puncher = mcl_reason and mcl_reason.direct or target
|
||||
-- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage)
|
||||
if luaentity.health > 0 then
|
||||
|
@ -544,7 +544,7 @@ end
|
|||
function mcl_util.get_hp(obj)
|
||||
local luaentity = obj:get_luaentity()
|
||||
|
||||
if luaentity and luaentity._cmi_is_mob then
|
||||
if luaentity and luaentity.is_mob then
|
||||
return luaentity.health
|
||||
else
|
||||
return obj:get_hp()
|
||||
|
|
|
@ -314,7 +314,7 @@ function boat.on_step(self, dtime, moveresult)
|
|||
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity._cmi_is_mob then
|
||||
if entity and entity.is_mob then
|
||||
attach_object(self, obj)
|
||||
break
|
||||
end
|
||||
|
|
|
@ -78,10 +78,6 @@ local node_snowblock = "mcl_core:snowblock"
|
|||
local node_snow = "mcl_core:snow"
|
||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
||||
|
||||
--Helper function to clear all mobs because /clearobjects removes too much
|
||||
local function is_mob(o)
|
||||
return o.type == "ambient" or o.type == "animal" or o.type == "monster" or o.type == "npc"
|
||||
end
|
||||
minetest.register_chatcommand("clearmobs",{
|
||||
privs={maphack=true},
|
||||
params = "<all>|<nametagged>|<range>",
|
||||
|
@ -90,7 +86,7 @@ minetest.register_chatcommand("clearmobs",{
|
|||
local p = minetest.get_player_by_name(n)
|
||||
local num=tonumber(param)
|
||||
for _,o in pairs(minetest.luaentities) do
|
||||
if is_mob(o) then
|
||||
if o.is_mob then
|
||||
if param == "all" or
|
||||
( param == "nametagged" and o.nametag ) or
|
||||
( param == "" and not o.nametag and not o.tamed ) or
|
||||
|
@ -223,7 +219,7 @@ local collision = function(self)
|
|||
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
|
||||
|
||||
local ent = object:get_luaentity()
|
||||
if object:is_player() or (ent and ent._cmi_is_mob and object ~= self.object) then
|
||||
if object:is_player() or (ent and ent.is_mob and object ~= self.object) then
|
||||
|
||||
local pos2 = object:get_pos()
|
||||
local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z}
|
||||
|
@ -3951,7 +3947,7 @@ minetest.register_entity(name, {
|
|||
runaway_from = def.runaway_from,
|
||||
owner_loyal = def.owner_loyal,
|
||||
facing_fence = false,
|
||||
_cmi_is_mob = true,
|
||||
is_mob = true,
|
||||
pushable = def.pushable or true,
|
||||
|
||||
|
||||
|
@ -3999,6 +3995,7 @@ minetest.register_entity(name, {
|
|||
--this is a temporary hack so mobs stop
|
||||
--glitching and acting really weird with the
|
||||
--default built in engine collision detection
|
||||
self.is_mob = true
|
||||
self.object:set_properties({
|
||||
collide_with_objects = false,
|
||||
})
|
||||
|
@ -4123,7 +4120,7 @@ function mobs:register_arrow(name, def)
|
|||
|
||||
if entity
|
||||
and self.hit_mob
|
||||
and entity._cmi_is_mob == true
|
||||
and entity.is_mob == true
|
||||
and tostring(player) ~= self.owner_id
|
||||
and entity.name ~= self.object:get_luaentity().name then
|
||||
self.hit_mob(self, player)
|
||||
|
@ -4133,7 +4130,7 @@ function mobs:register_arrow(name, def)
|
|||
|
||||
if entity
|
||||
and self.hit_object
|
||||
and (not entity._cmi_is_mob)
|
||||
and (not entity.is_mob)
|
||||
and tostring(player) ~= self.owner_id
|
||||
and entity.name ~= self.object:get_luaentity().name then
|
||||
self.hit_object(self, player)
|
||||
|
@ -4452,7 +4449,7 @@ minetest.register_globalstep(function(dtime)
|
|||
local pos = player:get_pos()
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do
|
||||
local lua = obj:get_luaentity()
|
||||
if lua and lua._cmi_is_mob then
|
||||
if lua and lua.is_mob then
|
||||
lua.lifetimer = math.max(20, lua.lifetimer)
|
||||
lua.despawn_immediately = false
|
||||
end
|
||||
|
|
|
@ -195,7 +195,7 @@ local list_of_all_biomes = {
|
|||
local function count_mobs(pos)
|
||||
local num = 0
|
||||
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
|
||||
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
|
||||
if object and object:get_luaentity() and object:get_luaentity().is_mob then
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ end
|
|||
|
||||
function mcl_bossbars.update_boss(object, name, color)
|
||||
local props = object:get_luaentity()
|
||||
if not props or not props._cmi_is_mob then
|
||||
if not props or not props.is_mob then
|
||||
props = object:get_properties()
|
||||
props.health = object:get_hp()
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ local function pp_on_timer(pos, elapsed)
|
|||
local obj_does_activate = function(obj, activated_by)
|
||||
if activated_by.any then
|
||||
return true
|
||||
elseif activated_by.mob and obj:get_luaentity() and obj:get_luaentity()._cmi_is_mob == true then
|
||||
elseif activated_by.mob and obj:get_luaentity() and obj:get_luaentity().is_mob == true then
|
||||
return true
|
||||
elseif activated_by.player and obj:is_player() then
|
||||
return true
|
||||
|
|
|
@ -106,7 +106,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||
local mobname = ent.name
|
||||
local def = minetest.registered_entities[mobname]
|
||||
-- Approximation of monster detection range
|
||||
if def._cmi_is_mob and ((mobname ~= "mobs_mc:pigman" and def.type == "monster" and not monster_exceptions[mobname]) or (mobname == "mobs_mc:pigman" and ent.state == "attack")) then
|
||||
if def.is_mob and ((mobname ~= "mobs_mc:pigman" and def.type == "monster" and not monster_exceptions[mobname]) or (mobname == "mobs_mc:pigman" and ent.state == "attack")) then
|
||||
if math.abs(bed_pos.y - obj:get_pos().y) <= 5 then
|
||||
return false, S("You can't sleep now, monsters are nearby!")
|
||||
end
|
||||
|
|
|
@ -203,7 +203,7 @@ function ARROW_ENTITY.on_step(self, dtime)
|
|||
if obj:is_player() then
|
||||
ok = true
|
||||
elseif obj:get_luaentity() then
|
||||
if (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then
|
||||
if (obj:get_luaentity().is_mob or obj:get_luaentity()._hittable_by_projectile) then
|
||||
ok = true
|
||||
end
|
||||
end
|
||||
|
@ -226,7 +226,7 @@ function ARROW_ENTITY.on_step(self, dtime)
|
|||
local obj = closest_object
|
||||
local is_player = obj:is_player()
|
||||
local lua = obj:get_luaentity()
|
||||
if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua._cmi_is_mob or lua._hittable_by_projectile))) then
|
||||
if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua.is_mob or lua._hittable_by_projectile))) then
|
||||
if obj:get_hp() > 0 then
|
||||
-- Check if there is no solid node between arrow and object
|
||||
local ray = minetest.raycast(self.object:get_pos(), obj:get_pos(), true)
|
||||
|
|
|
@ -24,7 +24,7 @@ local function damage_explosion(self, damagemulitplier)
|
|||
for _,obj in pairs(objects) do
|
||||
if obj:is_player() then
|
||||
mcl_util.deal_damage(obj, damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos()), {type = "explosion"})
|
||||
elseif obj:get_luaentity()._cmi_is_mob then
|
||||
elseif obj:get_luaentity().is_mob then
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos())},
|
||||
|
@ -415,7 +415,7 @@ function ARROW_ENTITY.on_step(self, dtime)
|
|||
if obj:is_player() then
|
||||
ok = true
|
||||
elseif obj:get_luaentity() then
|
||||
if (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then
|
||||
if (obj:get_luaentity().is_mob or obj:get_luaentity()._hittable_by_projectile) then
|
||||
ok = true
|
||||
end
|
||||
end
|
||||
|
@ -438,7 +438,7 @@ function ARROW_ENTITY.on_step(self, dtime)
|
|||
local obj = closest_object
|
||||
local is_player = obj:is_player()
|
||||
local lua = obj:get_luaentity()
|
||||
if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua._cmi_is_mob or lua._hittable_by_projectile))) then
|
||||
if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua.is_mob or lua._hittable_by_projectile))) then
|
||||
if obj:get_hp() > 0 then
|
||||
-- Check if there is no solid node between arrow and object
|
||||
local ray = minetest.raycast(self.object:get_pos(), obj:get_pos(), true)
|
||||
|
|
|
@ -167,7 +167,7 @@ minetest.register_globalstep(function(dtime)
|
|||
if is_player then
|
||||
player:set_hp(math.min(player:get_properties().hp_max or 20, player:get_hp() + 1), { type = "set_hp", other = "regeneration" })
|
||||
EF.regenerating[player].heal_timer = 0
|
||||
elseif entity and entity._cmi_is_mob then
|
||||
elseif entity and entity.is_mob then
|
||||
entity.health = math.min(entity.hp_max, entity.health + 1)
|
||||
EF.regenerating[player].heal_timer = 0
|
||||
else -- stop regenerating if not a player or mob
|
||||
|
@ -545,7 +545,7 @@ function mcl_potions.is_obj_hit(self, pos)
|
|||
|
||||
if entity and entity.name ~= self.object:get_luaentity().name then
|
||||
|
||||
if entity._cmi_is_mob then
|
||||
if entity.is_mob then
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -686,7 +686,7 @@ function mcl_potions.healing_func(player, hp)
|
|||
hp = 1
|
||||
end
|
||||
|
||||
if obj and obj._cmi_is_mob then
|
||||
if obj and obj.is_mob then
|
||||
obj.health = math.max(obj.health + hp, obj.hp_max)
|
||||
elseif player:is_player() then
|
||||
player:set_hp(math.min(player:get_hp() + hp, player:get_properties().hp_max), { type = "set_hp", other = "healing" })
|
||||
|
|
|
@ -281,7 +281,7 @@ local function water_splash(obj, damage)
|
|||
end
|
||||
-- Damage mobs that are vulnerable to water
|
||||
local lua = obj:get_luaentity()
|
||||
if lua and lua._cmi_is_mob then
|
||||
if lua and lua.is_mob then
|
||||
obj:punch(obj, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {water_vulnerable=damage},
|
||||
|
|
|
@ -66,7 +66,7 @@ minetest.register_globalstep(function(dtime)
|
|||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, d)) do
|
||||
|
||||
local entity = obj:get_luaentity()
|
||||
if obj:is_player() or entity._cmi_is_mob then
|
||||
if obj:is_player() or entity.is_mob then
|
||||
|
||||
vals.def.potion_fun(obj)
|
||||
-- TODO: Apply timer penalty only if the potion effect was acutally applied
|
||||
|
|
|
@ -110,7 +110,7 @@ function mcl_potions.register_splash(name, descr, color, def)
|
|||
for _,obj in pairs(minetest.get_objects_inside_radius(pos, 4)) do
|
||||
|
||||
local entity = obj:get_luaentity()
|
||||
if obj:is_player() or entity._cmi_is_mob then
|
||||
if obj:is_player() or entity.is_mob then
|
||||
|
||||
local pos2 = obj:get_pos()
|
||||
local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2))
|
||||
|
|
|
@ -216,7 +216,7 @@ function mcl_potions.register_arrow(name, desc, color, def)
|
|||
if obj ~= self._shooter and obj:is_player() then
|
||||
ok = true
|
||||
elseif obj:get_luaentity() then
|
||||
if obj ~= self._shooter and obj:get_luaentity()._cmi_is_mob then
|
||||
if obj ~= self._shooter and obj:get_luaentity().is_mob then
|
||||
ok = true
|
||||
end
|
||||
end
|
||||
|
@ -238,7 +238,7 @@ function mcl_potions.register_arrow(name, desc, color, def)
|
|||
local obj = closest_object
|
||||
local is_player = obj:is_player()
|
||||
local lua = obj:get_luaentity()
|
||||
if obj ~= self._shooter and (is_player or (lua and lua._cmi_is_mob)) then
|
||||
if obj ~= self._shooter and (is_player or (lua and lua.is_mob)) then
|
||||
|
||||
if obj:get_hp() > 0 then
|
||||
-- Check if there is no solid node between arrow and object
|
||||
|
|
|
@ -64,7 +64,7 @@ local function check_object_hit(self, pos, dmg)
|
|||
-- TODO: Deal knockback
|
||||
self.object:remove()
|
||||
return true
|
||||
elseif (entity._cmi_is_mob == true or entity._hittable_by_projectile) and (self._thrower ~= object) then
|
||||
elseif (entity.is_mob == true or entity._hittable_by_projectile) and (self._thrower ~= object) then
|
||||
-- FIXME: Knockback is broken
|
||||
object:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
|
|
|
@ -4,7 +4,7 @@ local orig_func = minetest.registered_chatcommands["spawnentity"].func
|
|||
local cmd = table.copy(minetest.registered_chatcommands["spawnentity"])
|
||||
cmd.func = function(name, param)
|
||||
local ent = minetest.registered_entities[param]
|
||||
if minetest.settings:get_bool("only_peaceful_mobs", false) and ent and ent._cmi_is_mob and ent.type == "monster" then
|
||||
if minetest.settings:get_bool("only_peaceful_mobs", false) and ent and ent.is_mob and ent.type == "monster" then
|
||||
return false, S("Only peaceful mobs allowed!")
|
||||
else
|
||||
local bool, msg = orig_func(name, param)
|
||||
|
|
|
@ -36,7 +36,7 @@ local function player_collision(player)
|
|||
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
|
||||
|
||||
local ent = object:get_luaentity()
|
||||
if (object:is_player() or (ent and ent._cmi_is_mob and object ~= player)) then
|
||||
if (object:is_player() or (ent and ent.is_mob and object ~= player)) then
|
||||
|
||||
local pos2 = object:get_pos()
|
||||
local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z}
|
||||
|
|
Loading…
Reference in New Issue