Today I started on something I've been avoidng: Npcs. They are probably one of the biggest parts of the game and require the most code (in my opinion). So far I having been working on what actions they can do: moving, stabbing, shooting. I also have started to work on the pathfinding system. So far my Npc is running back and forth in a straight line.
You cannot see it but he is running back and forth non-stopI have also added the code that can change clothes! Why? Because green is fashionable!Green FTW!Also I'm going to be making different armours for the defence stat.
I posted an example on randomly moving NPCs back in '07. If anything, you should check it out. My logic style has changed a great deal from then, but it may prove useful to you.
This is the kind of thing I use for wandering
With that code, your NPCs could potentially just walk in one direction forever… never to be seen again.
I actually won't be using random wandering in this game. Most of the NPCs will have a predetermined path.
Just be sure to have them check if their pathing location is not blocked. Can't tell you how many times a static npc has broken my movement logic with its automatic static pathing.