Closed Kln95130 closed 3 years ago
Proposition: I would like to experiment the player moving in an old school grid pattern, meaning only north, east, south, and west. For now, I can handle it through a BORDER and some math, but that could be something more easily customizable. It could be something simple, like an attribute that takes an array of strings, and whose default value would be ["n", "ne", "e", "se", "s", "sw", "w", "nw"]. Then, a check "if dirList.contains(dir)" to check if the direction is available.
I can also see a potential for NPCs "patrolling" the area. Maybe even rudimentary AI that reacts to the player being in range. It might need some effort to make it work without any custom code, however.
I take the liberty to answer on my own message, as I found a solution for the customization of the exit list.
Add a falcutative list of blocked directions to ZONE, then check the direction.
const ZONE = function(defaultToBlocked, blockedDirs=[]) {
const res = {
// ...
blockedDirs: blockedDirs
};
Then
res.hasExit = function(dir, options) {
// ...
// Non-compass directions not allowed
if (this.blockedDirs.includes(dir) || this.defaultToBlocked || this[dir].data.type !== 'compass') {
return false
}
Which gives us, for a zone that forbids diagonal moves:
ZONE(false, ["northeast", "northwest", "southeast", "southwest"])
One way to do this would be in Zone.js, at line 84, instead of iterating over all exits, just iterate over the ones you want. Or even, forget iterating - there is only four, set each one yourself.
I think this has been resolved (and indeed was back in July), so I am closing. Re-open if it is still an issue.
I really struggled on how to represent the player moving down "long" rooms like hallways or streets, and your newest feature will definitely bring a lot of quality-of-life in that area. Same with the map builder feature.
I keep watching your updates now and then, and I appreciate your continuous work for this framework. I hope you will be able to see it through.