I spent yesterday afternoon working on the interface for shopkeepers – NPCs that you can buy and sell to. Then I decided that I didn’t like it, and stayed up until three watching bad SF movies and rebuilding it. Fred Brooks would not have been surprised.
When I was planning the instruction set for the conversation bytecode, I briefly entertained the idea of building stores out of primitive commands. Here’s an incomplete example from my notes:
say "welcome to foo's used weapons" START: say "buy or sell?" askc ifinputc "b" BUY ifinputc "s" SELL say "thanks anyway" end BUY: say "1 dagger 2" say "2 club 10" say "3 end" BUYLOOP: askc ifinputc "1" BUY1 ifinputc "2" BUY2 ifinputc "3" START beep goto BUYLOOP BUY1: ifgold 2 setgold -2 additem 1
Yeah… That was going to be pretty obnoxious, and take up a lot of disk space. Especially since there are likely to be a lot of shopkeepers in a CRPG like this. I got halfway through the example before deciding to do something else, and make CONVERSE_BUY and CONVERSE_SELL their own opcodes. Something like this:
SELL: sell "reg's weapon shop" weapon goto LOOP BUY: buy "reg's weapon shop" 3 1 5 3 6 4 0 goto LOOP
That’s much more compact. The CONVERSE_SELL opcode just lists the shop name and the category of items that you can sell to the shopkeeper. I wanted the buying interface to be more customizable, so it has a list of item ids and (encoded) prices. I’m still not 100% on this version – I’m starting to think combining both of these into a single CONVERSE_SHOP opcode might be the best way to go.
The display of the user interface also required several attempts, and that’s what kept me up last night. My first pass hewed pretty close to the Ultima IV model, where buying and selling was just handled in the same “console” area as the rest of the conversation interface. But that turned out very cramped, as you can see up at the top. Part of that is that my interface is a few characters narrower than Ultima’s. Also, I’m interested in having a greater diversity of items in this game.
The second attempt uses a full-screen interface, modeled after some of the screens I made for the map editor during the first phase of work. That gives me more room to display the player’s current gold, and also the costs and quantities of items. I’ve got things working now, though I’d still like to improve the support for buying large quantities of stackable items like food or torches.
I’m much happier with these newer menu screens, but they sure aren’t much to look at. At some point I’m going to have to go back and jazz things up a bit.