Closed BrunoMine closed 6 years ago
But you can also create different types of search.
You are right, the node_query
search radius work on same y-coordinate than the NPC. Since we have a good pathfinder that supports stairs, maybe I should make change the radius from 2D to 3D, and therefore a larger search radius might help on this case.
node_query
(and its predecessor, schedule check) were envisioned for a place where the NPC had to repeat actions in a close radius with similar nodes (this is the case of a field/plot/plantation). Your use case is valid as well, so I may expand upon it.
Yes, coincidentally, the NPC eventually found a box on the ground, but his own box was upstairs and he went up the stairs and through a door walking on the carpet of the house, that spatial recognition surprised me. But as this was a coincidence, he stays upstairs interacting with the same box until bedtime.
I want to take this opportunity to inform you of a small inconvenience. Sometimes he closes the door and crosses it, it seems to me that he does not understand which direction the door has been placed.
The pathfinder code is very good at moving through stairs, and I added the door support (at least for MTG default doors and cottages
mod doors) and it works quite ok.
The problem with closing the door and then moving through it is a small bug in which the NPC thinks it has moved across the door and is completely at the other side, and then rotates back to look at the door to close it. Here is the problem, it has not moved completely across the door, and then it rotates and actually stays inside. I have noticed this and is in my to-do list.
However, the movement is anything but smooth, and NPCs look like they are teleporting when walking (which actually they do, they teleport as well). I have to find a better way to smooth out the movement.
Yes, but the game is already very interesting with these beings living in a house. Maybe we can make ghosts to take advantage of this problem. :D
Yeah, that is a good idea! :D will look at expanding the radius.
I actually checked the code and the radius already is 3D (it is not flat). So you can find other objects by expanding your radius. If your floor height is 3 blocks, you would have to make your radius 5: [] <- actual node in second floor ------ <- second floor nodes |
---|
If I expand the radius this does not solve because the height limit is 3 blocks.
code in node query code in find_nodes function
-- This function searches on a squared are of the given radius
-- for nodes of the given type. The type should be npc.locations.nodes
function npc.locations.find_node_nearby(pos, type, radius)
-- Determine area points
local start_pos = {x=pos.x - radius, y=pos.y - 1, z=pos.z - radius}
local end_pos = {x=pos.x + radius, y=pos.y + 1, z=pos.z + radius}
-- Get nodes
local nodes = minetest.find_nodes_in_area(start_pos, end_pos, type)
return nodes
end
You are completely right about this, missed that part. Pushed a fix for this: d16b5419a94ec993e93b7265868b73ba2ceff944
Regarding
Sometimes he closes the door and crosses it, it seems to me that he does not understand which direction the door has been placed.
Should be addressed and fixed by #51
Fixed.
They remain locked on the same floor in node_query check (This needs to be made clear in the documentation). This is pretty bad, but you can work around this problem by using programs that are conditioned to NPC locations. How is this possible?