I've been working on a pathfinding routine in JavaScript for a
tilebased game that I am writing in JavaScript. I am fairly proud of the pathfinding I came up with as I haven't done much with JavaScript for the past 13 years, and yet here I've made a few modifications to the standard
A* search.
The pathfinding code is available on my pastebin.Other than this code (which doesn't really belong on this forum), I wanted to share a thought I had while writing the code. I had this thought - which I'll describe in a minute if you can bare with me - because I am thinking a lot about tiles and grids. Between my current project, and the
improvements to Seamless Area Transitions which I released for NWN awhile back, you could say I've got squares on the mind. Since NWN is more or less a tile based game despite the 3D illusion, these square thoughts occassionally turn to elipses orbiting around NWN. Incidentally the thought I am about to share relates to an idea I had while I was still working on
Arnheim but never got around to implementing.
I like frameworks in NWN which create relations between areas. Seamless Area Transitions does this as the tag describes coordinates within a grid of other areas/nodes. Rolo has a regional mod project which takes a different approach but is yet another framework which positions areas at coordinates on a grid.
So the thought I had was pathfinding for creatures in NWN through a grid of areas. Using an A* routine and a function which could determine whether passage was possible between two adjacent tiles, you could provide a start and end destination point for a creature and have it wander through some areas. The actual implementation would take some finesse, as you'd have to treat the routine that simulates movement of the creature differently when a PC is in the same area as the creature - in that case you'd have to switch over to influencing the creature's AI until it perceives the PC and then determine whether or not to suspend the routine and later if the creature survives the encounter with the PC whether or when to resume the path finding routne driving its movements.
Anyway, its an idea. One of the germs of the idea came from a wolf pack I created which was designed to roam through a forest in Arnheim. My implementation was limited to movement thorugh one area but ti looked very cool when a PC witnessed it as the pack of wolves naturally roamed across the area with a modified patrol script. Another influence was the
old Atari game "Adventure". The movement of the creatures in the game from "room" to "room" and the way they could perceive the player in adjacent rooms and thus follow the PC was very cool. The roaming of the bat was also interesting, albeit random.
It would be very cool to create the same behavior for a flying dragon in NWN. The dragon would move around overhead. A text message would popup for players in the area when the dragon was spotted overhead. And then if the dragon spotted a PC in the area it might land.
Just an idea. Enjoy.
lastly - I've been looking at roguelike games a lot too and discovered this amazing
roguelike toolkit written in javascript. its a very nice implementation, and the pathfinding in rot.js was used as a base to write my own.
Modifié par henesua, 21 juin 2013 - 04:42 .