Actions: Fully working 2D pathfinding code, including doors.

Added NPC actions so that it now closes doors after opening them.
Fixed rotations for opening/closing doors and for reaching the goal point.
Added full support to cottages mod gates and half doors.
WIP: Support for cottages beds and sleeping mats.
This commit is contained in:
zorman2000
2017-01-09 11:34:38 -05:00
parent 49cdae423f
commit 641bdd8874
6 changed files with 162 additions and 53 deletions

14
npc.lua
View File

@ -11,10 +11,14 @@ npc.MALE = "male"
npc.INVENTORY_ITEM_MAX_STACK = 99
npc.ANIMATION_STAND_START = 0
npc.ANIMATION_STAND_END = 79
npc.ANIMATION_SIT_START = 81
npc.ANIMATION_SIT_END = 160
npc.ANIMATION_LAY_START = 162
npc.ANIMATION_LAY_END = 166
npc.ANIMATION_WALK_START = 168
npc.ANIMATION_WALK_END = 187
npc.direction = {
north = 0,
@ -346,7 +350,7 @@ local function npc_spawn(self, pos)
ent.places_map = {}
-- Temporary initialization of actions for testing
local nodes = npc.places.find_new_nearby(ent, {"cottages:tub"}, 30)
local nodes = npc.places.find_node_nearby(ent, {"beds:bed_bottom"}, 30)
minetest.log("Found nodes: "..dump(nodes))
--local path = pathfinder.find_path(ent.object:getpos(), nodes[1], 20)
@ -354,13 +358,13 @@ local function npc_spawn(self, pos)
--npc.add_action(ent, npc.actions.use_door, {self = ent, pos = nodes[1], action = npc.actions.door_action.OPEN})
--npc.add_action(ent, npc.actions.stand, {self = ent})
--npc.add_action(ent, npc.actions.stand, {self = ent})
npc.actions.walk_to_pos(ent, nodes[1])
--npc.actions.use_bed(ent, nodes[1], npc.actions.const.beds.LAY)
--npc.add_action(ent, npc.actions.lay, {self = ent})
npc.actions.walk_to_pos(ent, nodes[1], {"cottages:bench"})
npc.actions.use_bed(ent, nodes[1], npc.actions.const.beds.LAY)
npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
--npc.actions.use_bed(ent, nodes[1], npc.actions.const.beds.GET_UP)
npc.actions.use_bed(ent, nodes[1], npc.actions.const.beds.GET_UP)
-- npc.add_action(ent, npc.action.stand, {self = ent})