Friday, September 26, 2014

phones and stuff

The other month, I was taking a look at Cardinal Teulbach's phone code in the Hugo game source directory at the IF Archive, partly because the phone in Cryptozookeeper frustrated me and partly just because I was wondering if I could improve upon it, knowing that people still use whatever they find in that directory for their games today.

I think it might have been easier to just write a new phone class from scratch, so while I made some improvements, I'm not entirely sure how happy I am with the whole thing.  Really, there are just so many options on how to design a phone in a game that it seems kind of like wasted effort to perfectly hone this one approach.

Still, while I don't like the results enough to upload my code to the IF Archive, I figure I should share it somewhere so I'll share it here.

EDIT: misterman83 over at the joltcountry Hugo forum suggested moving answer/dial responses to the phone number object properties, and I agree that it's a good idea.  The code has been updated accordingly.

First off, your game would need the following grammar:

verb "dial", "call"
*                                               DoVague
* object                                        DoDial
* object "on" xobject                           DoDial

verb "answer"
*                                               DoVague
* object                                        DoAnswer

verb "hang"
* "up"                                          DoHangup
* "up" object                                   DoHangup

And then here is the rest of the code:

Like the original code, there's some example code mixed in there which you'd basically just want to ignore for your own game.  I don't remember everything I did with this and I don't care enough to look, but I think I took some steps to make it more efficient about object and attribute usage and stuff.

Since guns have come up fairly regularly in Robb Sherwin's games, I've been thinking of writing a gun class.  I made a little progress on that but it's complicated enough that I just decided to shelve it for a while.  Besides doing things like making the grammar support "FIRE GUN" and "SHOOT BAD GUY," there's just a bunch of things to implement for a gun class done right (like, checking ammo type and quantity in a multiple-gun-type game and having >RELOAD work appropriately) and making sure SHOOT BAD GUY'S GUN doesn't give you a "You're not holding that." type message.

Anyhow, it's a lot of work considering any game of mine probably wouldn't even have an ammo system, which means I'd also have to code options to turn this or that feature off, and that's even more work (all surmountable, of course, but just annoying enough that I put it off).