summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-08-11 10:46:03 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-08-11 10:46:03 +0100
commit4d80e58a2cd9841e66f2ff72c9a30ab1c7554227 (patch)
treec5ec325fffaa7d48e06bee5be77e9da8913e15fa
parentba167a345160a6066795777dd90fdb52ef8f8ba4 (diff)
added fence check to stop mobs walking forwards
-rw-r--r--api.lua35
1 files changed, 22 insertions, 13 deletions
diff --git a/api.lua b/api.lua
index 884dacb..b956327 100644
--- a/api.lua
+++ b/api.lua
@@ -1,9 +1,9 @@
--- Mobs Api (7th August 2017)
+-- Mobs Api (11th August 2017)
mobs = {}
mobs.mod = "redo"
-mobs.version = "20170807"
+mobs.version = "20170811"
-- Intllib
@@ -670,6 +670,8 @@ local do_jump = function(self)
return false
end
+self.facing_fence = false
+
-- something stopping us while moving?
if self.state ~= "stand"
and get_velocity(self) > 0.5
@@ -709,20 +711,24 @@ local do_jump = function(self)
--print ("in front:", nod.name, pos.y + 0.5)
- if (minetest.registered_items[nod.name].walkable
- and not nod.name:find("fence")
- and not nod.name:find("gate"))
- or self.walk_chance == 0 then
+ if self.walk_chance == 0
+ or minetest.registered_items[nod.name].walkable then
+
+ if not nod.name:find("fence")
+ and not nod.name:find("gate") then
- local v = self.object:getvelocity()
+ local v = self.object:getvelocity()
- v.y = self.jump_height
+ v.y = self.jump_height
- set_animation(self, "jump") -- only when defined
+ set_animation(self, "jump") -- only when defined
- self.object:setvelocity(v)
+ self.object:setvelocity(v)
- mob_sound(self, self.sounds.jump)
+ mob_sound(self, self.sounds.jump)
+ else
+ self.facing_fence = true
+ end
return true
end
@@ -753,7 +759,7 @@ local entity_physics = function(pos, radius)
objs[n]:punch(objs[n], 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = damage},
- }, pos) -- was nil
+ }, pos)
end
end
@@ -1491,6 +1497,7 @@ local do_states = function(self, dtime)
or self.order ~= "stand" then
if self.walk_chance ~= 0
+ and self.facing_fence ~= true
and random(1, 100) <= self.walk_chance
and is_at_cliff(self) == false then
@@ -1590,7 +1597,8 @@ local do_states = function(self, dtime)
-- stand for great fall in front
local temp_is_cliff = is_at_cliff(self)
- if temp_is_cliff
+ if self.facing_fence == true
+ or temp_is_cliff
or random(1, 100) <= 30 then
set_velocity(self, 0)
@@ -2676,6 +2684,7 @@ minetest.register_entity(name, {
attack_animals = def.attack_animals or false,
specific_attack = def.specific_attack,
owner_loyal = def.owner_loyal,
+ facing_fence = false,
_cmi_is_mob = true,
on_blast = def.on_blast or do_tnt,