summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-03-17 11:30:16 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2017-03-17 11:30:16 +0000
commit1205ec36a68cb498a8eb489e03de7030e9e92a61 (patch)
treebc9e629c140a35598c6701b156f173936ff6a2d6
parentaa591925b11e19db50ca1d7e5a3e64c8ff2b7dc2 (diff)
flying mobs go up and down, code tidy.
-rw-r--r--api.lua21
1 files changed, 18 insertions, 3 deletions
diff --git a/api.lua b/api.lua
index 5c6bbbc..adad4b9 100644
--- a/api.lua
+++ b/api.lua
@@ -1,5 +1,5 @@
--- Mobs Api (10th March 2017)
+-- Mobs Api (17th March 2017)
mobs = {}
mobs.mod = "redo"
@@ -40,7 +40,7 @@ local difficulty = tonumber(minetest.setting_get("mob_difficulty")) or 1.0
local show_health = minetest.setting_getbool("mob_show_health") ~= false
local max_per_block = tonumber(minetest.setting_get("max_objects_per_block") or 99)
--- calculate aoc range for mob counts
+-- calculate aoc range for mob count
local aosrb = tonumber(minetest.setting_get("active_object_send_range_blocks"))
local abr = tonumber(minetest.setting_get("active_block_range"))
local aoc_range = math.max(aosrb, abr) * 16
@@ -1334,6 +1334,16 @@ local do_states = function(self, dtime)
set_velocity(self, self.walk_velocity)
self.state = "walk"
set_animation(self, "walk")
+
+-- fly up/down randombly for flying mobs
+if self.fly and random(1, 100) <= self.walk_chance then
+
+ local v = self.object:getvelocity()
+ local ud = random(-1, 2) / 9
+
+ self.object:setvelocity({x = v.x, y = ud, z = v.z})
+end
+
end
end
@@ -1379,6 +1389,11 @@ local do_states = function(self, dtime)
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
if lp.x > s.x then yaw = yaw + pi end
+
+-- look towards land and jump/move in that direction
+self.object:setyaw(yaw)
+do_jump(self)
+set_velocity(self, self.walk_velocity)
else
yaw = (random(0, 360) - 180) / 180 * pi
end
@@ -1558,7 +1573,7 @@ local do_states = function(self, dtime)
if self.fly
and dist > self.reach then
- local nod = node_ok(s)
+-- local nod = node_ok(s)
local p1 = s
local me_y = floor(p1.y)
local p2 = p