Towns and Castles

Today I added some good old static content to the game. I wanted some more encounters specific to towns and castles. I had added some human enemy types, guards and thugs, for use as minions to some of the NPCs. I figured why not leverage these for some town encounters?
Required Features
I totally used AI to help me write some of these, and I’ve found that’s a really interesting way to flush out some feature needs. In this case, it wrote a couple encounters whereby the player could pay for services or bribe someone. I had hooks for decrementing the player’s gold, but what I didn’t have was a way to check their gold before offering that option. So if you had 0 gold and there’s an option to bribe the guards for 5 gold, well the gold decrement still left you at 0 and you still got to go down that branch of the encounter.
Well, that’s fixed now! Now we have the concept of filters on encounter responses. If you don’t have enough gold, the bribe option just doesn’t show up.
Bug Fixes
And of course I also discovered some bugs while testing these encounters. In one case it lead me down the road of cleaning up some AI code. One thing I’ve found is that AI has no problem repeating itself. It really wanted to write a huge custom branch for how to force a debug encounter vs. roll one on the tables. Um, maybe just refactor that code into a method and do a quick check to see if you should just force the result or call the new method that does the random table rolling AI?
This is one of those times where I caught myself and thought “would it be faster to yell at the AI to force it to fix it’s mistake, or to just fix it myself?” I opted for the latter. Yes, AI sometimes improves productivity. But also it sometimes is a wash or even slower. The trick is figuring out which is more likely before you go down a bad road.
Onwards
Anyway, please enjoy the new town and castle encounters! Next up I’ll be looking at figuring out how to add some more dynamic encounters to foreshadow the nearby presence of interesting NPCs.