Compare commits

...

6 Commits

5 changed files with 30 additions and 5 deletions

View File

@ -309,7 +309,10 @@ end
-- set and return valid yaw -- set and return valid yaw
local set_yaw = function(self, yaw, delay, dtime) local set_yaw = function(self, yaw, delay, dtime)
if true then
self.object:set_yaw(yaw)
return yaw
end
if not yaw or yaw ~= yaw then if not yaw or yaw ~= yaw then
yaw = 0 yaw = 0
end end
@ -1944,7 +1947,7 @@ local monster_attack = function(self)
-- find specific mob to attack, failing that attack player/npc/animal -- find specific mob to attack, failing that attack player/npc/animal
if specific_attack(self.specific_attack, name) if specific_attack(self.specific_attack, name)
and (type == "player" or type == "npc" and (type == "player" or ( type == "npc" and self.attack_npcs )
or (type == "animal" and self.attack_animals == true)) then or (type == "animal" and self.attack_animals == true)) then
p = player:get_pos() p = player:get_pos()
@ -4022,6 +4025,7 @@ minetest.register_entity(name, {
dogshoot_count_max = def.dogshoot_count_max or 5, dogshoot_count_max = def.dogshoot_count_max or 5,
dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5), dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5),
attack_animals = def.attack_animals or false, attack_animals = def.attack_animals or false,
attack_npcs = def.attack_npcs or false,
specific_attack = def.specific_attack, specific_attack = def.specific_attack,
runaway_from = def.runaway_from, runaway_from = def.runaway_from,
owner_loyal = def.owner_loyal, owner_loyal = def.owner_loyal,

View File

@ -444,8 +444,26 @@ minetest.register_chatcommand("mobstats",{
end end
}) })
if mobs_spawn then minetest.register_chatcommand("spawn_mob",{
privs = { debug = true },
func = function(n,param)
local pos = minetest.get_player_by_name(n):get_pos()
if mcl_mobs.spawn(pos,param) then
return true, param.." spawned at "..minetest.pos_to_string(pos)
end
return false, "Couldn't spawn "..param
end
})
function mcl_mobs.spawn(pos,id)
local def = minetest.registered_entities[id] or minetest.registered_entities["mobs_mc:"..id] or minetest.registered_entities["extra_mobs:"..id]
if not def or (def.can_spawn and not def.can_spawn(pos)) or not def.is_mob then
return false
end
return minetest.add_entity(pos, def.name)
end
if mobs_spawn then
local perlin_noise local perlin_noise
local function spawn_a_mob(pos, dimension, y_min, y_max) local function spawn_a_mob(pos, dimension, y_min, y_max)
@ -508,6 +526,7 @@ if mobs_spawn then
local mob_def = mob_library_worker_table[mob_index] local mob_def = mob_library_worker_table[mob_index]
local mob_type = minetest.registered_entities[mob_def.name].type local mob_type = minetest.registered_entities[mob_def.name].type
local spawn_in_group = minetest.registered_entities[mob_def.name].spawn_in_group or 4 local spawn_in_group = minetest.registered_entities[mob_def.name].spawn_in_group or 4
local spawn_in_group_min = minetest.registered_entities[mob_def.name].spawn_in_group_min or 1
local mob_count_wide = count_mobs(pos,aoc_range,mob_type) local mob_count_wide = count_mobs(pos,aoc_range,mob_type)
local mob_count = count_mobs(spawning_position,32,mob_type) local mob_count = count_mobs(spawning_position,32,mob_type)
if mob_def if mob_def
@ -540,10 +559,9 @@ if mobs_spawn then
local object local object
if spawn_in_group then if spawn_in_group then
object = spawn_group(spawning_position,mob_def,{gotten_node},spawn_in_group,spawn_in_group_min) object = spawn_group(spawning_position,mob_def,{gotten_node},spawn_in_group,spawn_in_group_min)
else object = minetest.add_entity(spawning_position, mob_def.name) else object = mcl_mobs.spawn(pos,mob_def.name)
end end
if object then if object then
return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position) return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position)
end end

View File

@ -38,6 +38,7 @@ mcl_mobs:register_mob("mobs_mc:vindicator", {
walk_velocity = 1.2, walk_velocity = 1.2,
run_velocity = 2.4, run_velocity = 2.4,
attack_type = "dogfight", attack_type = "dogfight",
attack_npcs = true,
drops = { drops = {
{name = "mcl_core:emerald", {name = "mcl_core:emerald",
chance = 1, chance = 1,

View File

@ -133,6 +133,7 @@ mcl_mobs:register_mob("mobs_mc:villager_zombie", {
view_range = 16, view_range = 16,
fear_height = 4, fear_height = 4,
harmed_by_heal = true, harmed_by_heal = true,
attack_npcs = true,
}) })
mcl_mobs:spawn_specific( mcl_mobs:spawn_specific(

View File

@ -95,6 +95,7 @@ local zombie = {
view_range = 16, view_range = 16,
attack_type = "dogfight", attack_type = "dogfight",
harmed_by_heal = true, harmed_by_heal = true,
attack_npcs = true,
} }
mcl_mobs:register_mob("mobs_mc:zombie", zombie) mcl_mobs:register_mob("mobs_mc:zombie", zombie)