Is there a way to make it so usual npcs stop when they collide with another usual npc the way that they stop when they collide with a generalized npc? I'm trying to two npcs walk in a circle, but if one of the npcs is stopped the other one will just walk right through it.
QuoteI'm trying to two npcs walk in a circle, but if one of the npcs is stopped the other one will just walk right through it.
I think you want the set_traversable function? Sets whether this NPC can be traversed by other entities.
http://www.solarus-games.org/doc/latest/lua_api_npc.html#lua_api_npc_set_traversable
QuoteIs there a way to make it so usual npcs stop when they collide with another usual npc the way that they stop when they collide with a generalized npc?
If you want them to stop when encountering another NPC, then use the on_obstacle_reached function.
http://www.solarus-games.org/doc/latest/lua_api_entity.html#lua_api_entity_on_obstacle_reached
use entity:on_obstacle_reached(movement)
http://www.solarus-games.org/doc/latest/lua_api_entity.html#lua_api_entity_on_obstacle_reached
From there you have to configure the behaviour of what the entity do when it collide with something (and obviously, you can change it's movement)
Stopping an NPC ? No problem
function entity:on_obstacle_reached(movement)
-- Check if any movement exist
if movement ~= nil then
-- Stop the movement
movement:stop()
-- Do whatever you want here (restart a movement or else)
end
end
But you have to define this event for each NPC that does what you want
Careful though, this event is called each time the entity collide with something, so, if you want to make this entity to interact only with another entity, use
http://www.solarus-games.org/doc/latest/lua_api_entity.html#lua_api_entity_get_facing_entity
function entity:on_obstacle_reached(movement)
-- Check if any movement exist
if movement ~= nil then
-- Check the entity facing this entity
if self:get_facing_entity():get_name() == "name_of_your_npc" then
-- Stop the movement
movement:stop()
-- Do whatever you want here (restart a movement or else)
end
end
end