skittish = def.skittish,
skittish_timer = 0,
-- skittish when player spotted
elseif self.state == "skittish" then
self.skittish_timer = self.skittish_timer + 1
-- stop after 5 seconds or when at cliff
if self.skittish_timer > 5
or is_at_cliff(self) then
self.skittish_timer = 0
set_velocity(self, 0)
self.state = "stand"
set_animation(self, "stand")
else
set_velocity(self, self.run_velocity)
set_animation(self, "walk")
end
--mob, find closest player to run away from
local mob_scared = function(self)
local s = self.object:getpos()
local min_dist = self.view_range + 1
local obj, min_player = nil, nil
local objs = minetest.get_objects_inside_radius(s, self.view_range)
for n = 1, #objs do
obj = objs[n]:get_luaentity()
if obj and obj.type == "player" then
p = obj.object:getpos()
dist = get_distance(p, s)
if dist < min_dist then
min_dist = dist
min_player = obj.object
end
end
end
if min_player then
do_scaredrun(self, min_player)
end
end
mob_scared(self)
do_scaredrun = function(self, player)
if self.state == "skittish" then
return
end
self.state = "skittish"
if random(0, 100) < 90 then
mob_sound(self, self.sounds.war_cry)
end
end
TenPlus1 wrote:ExeterDad - I've fixed that problem now, lava flan should swim around happily inside lava for now.
FreeLikeGNU wrote:
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
TenPlus1 wrote:Andrey01: most of those mobs already come as an addon-mod for mobs redo, no point making this mod any larger than it has to be :)
TenPlus1 wrote:Sandworm and Bacteriophage should both me in the nssm mod.
if spawned_npc_count < npc_count then
-- Spawn a NPC
local npc = minetest.add_entity(pos, "advanced_npc:npc")
if npc and npc:get_luaentity() then
spawn(npc, pos)
-- Check some stuff ...
return true
else
npc:remove()
return false
end
if game_time <= 6000 or game_time >= 18000 and self.home ~= nil then
if self.home_object == nil then
self.home_object = minetest.add_entity(self.home, "mobs_npc:dummy")
end
self.following = self.home_object
end
TenPlus1 wrote:Mobs themselves only save variables beginning with self. and that's it, anything else you add has to be saved either in a file or setting.
TenPlus1 wrote:Sadly mobs aren't that smart but in the api we have a mob variable called self.path.way which contains the pathfinding data for a mob to find and get to the player when attacking, and this could possibly be modified to a HOME position instead if mob has pathfinding enabled :)
do_custom = function(self, dtime)
self.home_timer = (self.home_timer or 0) + dtime
if self.home_timer < 1 then return end -- every 1 second
self.home_timer = 0
if self.time_of_day > 0.2 and self.time_of_day < 0.8 then
return -- return if not night time
end
local h = {x = 1, y = 8, z = 2} -- destination coords
local p = self.object:getpos() -- mob position
local x, y, z = p.x - h.x, p.y - h.y, p.z - h.z
local dist = math.floor(math.sqrt(x * x + y * y + z * z))
if dist <= 1 then
print ("--- home!")
self.homepath = nil
self.state = "stand"
return
end
if self.homepath == nil then
self.homepath = minetest.find_path(h, h, 16, 3, 6, "Dijkstra")
print ("--- finding route", self.homepath, dist)
end
if self.homepath then
print ("--- following path", dist, #self.homepath)
local np = self.homepath[1] ; if not np then return end
if math.abs(np.x - p.x) + math.abs(np.z - p.z) < 0.6 then
table.remove(self.homepath, 1) ; print ("-- removed entry")
end
np = {x = np.x, y = np.y, z = np.z}
local vec = {x = np.x - p.x, z = np.z - p.z}
local yaw = (math.atan(vec.z / vec.x) + math.pi / 2) - self.rotate
if np.x > p.x then yaw = yaw + math.pi end
self.object:setyaw(yaw)
set_velocity(self, self.walk_velocity)
end
end,
TenPlus1 wrote:They do ? which mod, what's it standing on at the time ?
Users browsing this forum: No registered users and 31 guests