master
runs 2019-11-16 23:18:20 +01:00
parent f412850fd8
commit 99222a6b61
4 changed files with 61 additions and 13 deletions

View File

@ -2,7 +2,11 @@ local modpath, S = ...
petz.ownthing = function(self)
self.status = mobkit.remember(self, "status", "")
mobkit.hq_roam(self, 0)
if not(self.can_fly) then
mobkit.hq_roam(self, 0)
else
mobkit.hq_wanderfly(self, 0)
end
mobkit.clear_queue_high(self)
end

View File

@ -27,12 +27,16 @@ function petz.bh_runaway_from_predator(self, pos)
end
function petz.bh_start_follow(self, pos, player, prty)
if player then
if player then
local wielded_item_name = player:get_wielded_item():get_name()
local player_pos = player:get_pos()
if wielded_item_name == self.follow and vector.distance(pos, player_pos) <= self.view_range then
if wielded_item_name == self.follow and vector.distance(pos, player_pos) <= self.view_range then
self.status = mobkit.remember(self, "status", "follow")
mobkit.hq_follow(self, prty, player)
if not(self.can_fly) then
mobkit.hq_follow(self, prty, player)
else
mobkit.hq_followfly(self, prty, player)
end
return true
else
return false
@ -53,9 +57,14 @@ end
function petz.bh_stop_follow(self, player)
if player then
local wielded_item_name = player:get_wielded_item():get_name()
if wielded_item_name ~= self.follow then
if wielded_item_name ~= self.follow then
self.status = mobkit.remember(self, "status", "")
mobkit.hq_roam(self, 0)
if not(self.can_fly) then
mobkit.hq_roam(self, 0)
else
mobkit.hq_wanderfly(self, 0)
end
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
return true
else
@ -172,11 +181,9 @@ function petz.herbivore_brain(self)
--Follow Behaviour
if prty < 16 then
if not(self.can_fly) then
if petz.bh_start_follow(self, pos, player, 16) == true then
return
end
end
if petz.bh_start_follow(self, pos, player, 16) == true then
return
end
end
if prty == 16 then

View File

@ -104,6 +104,44 @@ function mobkit.node_name_in(self, where)
end
end
--
-- Follow Fly Behaviour (2 functions)
--
function mobkit.hq_followfly(self, prty, player)
local func=function(self)
local pos = self.object:get_pos()
local tpos = player:get_pos()
if pos and tpos then
local distance = vector.distance(pos, tpos)
if distance > 2 then
if mobkit.is_queue_empty_low(self) then
mobkit.lq_followfly(self, pos, tpos)
end
else
return true
end
end
end
mobkit.queue_high(self, func, prty)
end
function mobkit.lq_followfly(self, pos, tpos)
local func = function(self)
local dir = vector.direction(pos, tpos)
local velocity = {
x= self.max_speed* dir.x,
y= self.max_speed* dir.y,
z= self.max_speed* dir.z,
}
local new_yaw = minetest.dir_to_yaw(dir)
self.object:set_yaw(new_yaw)
self.object:set_velocity(velocity)
return true
end
mobkit.queue_low(self,func)
end
--
-- Wander Fly Behaviour (3 functions)
--

View File

@ -95,12 +95,11 @@ hamster_spawn = true
dolphin_spawn = true
toucan_spawn = true
queen_bee_spawn = true
#Warning: Mr Pumpkin is still on progress!!!
mr_pumpkin_spawn = true
#Normal bees should not spam!!!
bee_spawn = false
foxy_spawn = true
penguin_spawn = false
penguin_spawn = true
##Enviromental Damage
air_damage = 1