forked from VoxeLibre/VoxeLibre
Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
cora | 9e4faf1b62 | |
cora | 90419424ae | |
cora | 831a5c949c | |
cora | ad4eb2c0d6 | |
cora | 64f672c15f | |
cora | bd6e6b48d9 |
|
@ -311,7 +311,10 @@ end
|
|||
|
||||
-- set and return valid yaw
|
||||
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
|
||||
yaw = 0
|
||||
end
|
||||
|
@ -1946,7 +1949,7 @@ local monster_attack = function(self)
|
|||
|
||||
-- find specific mob to attack, failing that attack player/npc/animal
|
||||
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
|
||||
|
||||
p = player:get_pos()
|
||||
|
@ -3403,21 +3406,20 @@ end
|
|||
-- get entity staticdata
|
||||
local mob_staticdata = function(self)
|
||||
|
||||
--[[
|
||||
|
||||
-- remove mob when out of range unless tamed
|
||||
if remove_far
|
||||
and self.can_despawn
|
||||
and self.remove_ok
|
||||
and ((not self.nametag) or (self.nametag == ""))
|
||||
and self.lifetimer <= 20 then
|
||||
|
||||
minetest.log("action", "Mob "..name.." despawns in mob_staticdata at "..minetest.pos_to_string(self.object.get_pos(), 1))
|
||||
minetest.log("action", "Mob "..tostring(self.name).." despawns in mob_staticdata at "..minetest.pos_to_string(self.object:get_pos()))
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
|
||||
return ""-- nil
|
||||
return "remove"-- nil
|
||||
end
|
||||
--]]
|
||||
|
||||
self.remove_ok = true
|
||||
self.attack = nil
|
||||
self.following = nil
|
||||
|
@ -3453,6 +3455,11 @@ local mob_activate = function(self, staticdata, def, dtime)
|
|||
return
|
||||
end
|
||||
|
||||
if staticdata == "remove" then
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
-- load entity variables
|
||||
local tmp = minetest.deserialize(staticdata)
|
||||
|
||||
|
@ -3620,6 +3627,7 @@ end
|
|||
|
||||
-- main mob function
|
||||
local mob_step = function(self, dtime)
|
||||
self.lifetimer = self.lifetimer - dtime
|
||||
check_item_pickup(self)
|
||||
check_aggro(self,dtime)
|
||||
if not self.fire_resistant then
|
||||
|
@ -3833,12 +3841,11 @@ local mob_step = function(self, dtime)
|
|||
and ((not self.nametag) or (self.nametag == ""))
|
||||
and self.state ~= "attack"
|
||||
and self.following == nil then
|
||||
|
||||
self.lifetimer = self.lifetimer - dtime
|
||||
if self.despawn_immediately or self.lifetimer <= 0 then
|
||||
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos, 1))
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
return
|
||||
elseif self.lifetimer <= 10 then
|
||||
if math.random(10) < 4 then
|
||||
self.despawn_immediately = true
|
||||
|
@ -4030,6 +4037,7 @@ minetest.register_entity(name, {
|
|||
dogshoot_count_max = 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_npcs = def.attack_npcs or false,
|
||||
specific_attack = def.specific_attack,
|
||||
runaway_from = def.runaway_from,
|
||||
owner_loyal = def.owner_loyal,
|
||||
|
|
|
@ -466,6 +466,15 @@ local function spawn_check(pos,spawn_def)
|
|||
return false
|
||||
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
|
||||
|
||||
|
||||
local function spawn_group(p,mob,spawn_on,group_max,group_min)
|
||||
if not group_min then group_min = 1 end
|
||||
local nn= minetest.find_nodes_in_area_under_air(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on)
|
||||
|
@ -481,13 +490,26 @@ local function spawn_group(p,mob,spawn_on,group_max,group_min)
|
|||
if mob.type_of_spawning == "water" then
|
||||
sp = get_water_spawn(sp)
|
||||
end
|
||||
o = minetest.add_entity(sp,mob.name)
|
||||
o = mcl_mobs.spawn(sp,mob.name)
|
||||
if o then dbg_spawn_succ = dbg_spawn_succ + 1 end
|
||||
end
|
||||
end
|
||||
return o
|
||||
end
|
||||
|
||||
mcl_mobs.spawn_group = spawn_group
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
if mobs_spawn then
|
||||
|
||||
local perlin_noise
|
||||
|
@ -541,7 +563,7 @@ if mobs_spawn then
|
|||
object = spawn_group(spawning_position,mob_def,{minetest.get_node(vector.offset(spawning_position,0,-1,0)).name},spawn_in_group,spawn_in_group_min)
|
||||
minetest.log("action", "A group of mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1))
|
||||
else
|
||||
object = minetest.add_entity(spawning_position, mob_def.name)
|
||||
object = mcl_mobs.spawn(spawning_position, mob_def.name)
|
||||
minetest.log("action", "Mob " .. mob_def.name .. " spawns at " .. minetest.pos_to_string(spawning_position, 1))
|
||||
end
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ mcl_mobs:register_mob("mobs_mc:vindicator", {
|
|||
walk_velocity = 1.2,
|
||||
run_velocity = 2.4,
|
||||
attack_type = "dogfight",
|
||||
attack_npcs = true,
|
||||
drops = {
|
||||
{name = "mcl_core:emerald",
|
||||
chance = 1,
|
||||
|
|
|
@ -133,6 +133,7 @@ mcl_mobs:register_mob("mobs_mc:villager_zombie", {
|
|||
view_range = 16,
|
||||
fear_height = 4,
|
||||
harmed_by_heal = true,
|
||||
attack_npcs = true,
|
||||
})
|
||||
|
||||
mcl_mobs:spawn_specific(
|
||||
|
|
|
@ -101,6 +101,7 @@ local zombie = {
|
|||
self.object:set_properties({visual_size = self.visual_size})
|
||||
self.base_size = self.visual_size
|
||||
end,
|
||||
attack_npcs = true,
|
||||
}
|
||||
|
||||
mcl_mobs:register_mob("mobs_mc:zombie", zombie)
|
||||
|
|
Loading…
Reference in New Issue