Table of Contents for
Gaming Hacks

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Gaming Hacks by Simon Carless Published by O'Reilly Media, Inc., 2004
  1. Cover
  2. Gaming Hacks
  3. Credits
  4. Contributors
  5. Acknowledgments
  6. Foreword
  7. Preface
  8. How to Use This Book
  9. How This Book Is Organized
  10. Conventions Used in This Book
  11. Using Code Examples
  12. Comments and Questions
  13. Got a Hack?
  14. 1. Playing Classic Games
  15. Legal Emulation
  16. Play Commodore 64 Games Without the C-64
  17. Play Atari ROMs Without the Atari
  18. Use Atari Paddles with Your PC
  19. Run Homebrew Games on the Atari 2600
  20. Create Your Own Atari 2600 Homebrew Games
  21. Play Classic PC Graphic Adventures
  22. Play Old Games Through DOSBox
  23. Play Reissued All-in-One Joystick Games
  24. Play Arcade Games Without the Arcade
  25. Add and Manipulate a MAME Frontend
  26. Keep Your ROMs Tidy and Organized
  27. Learn Game-Specific MAME Controls
  28. Filter Inappropriate MAME ROMs
  29. Autoboot into MAME Heaven
  30. Play Emulated Arcade Games Online
  31. Play Classic Pinball Without the Table
  32. Emulate the SNES on the Dreamcast
  33. 2. Playing Portably
  34. Play Games on Your iPod
  35. Mod Your Game Boy
  36. Take and Print Photos with Your Game Boy
  37. Compose Music on Your Game Boy
  38. Explore the GP32 Handheld Gaming System
  39. Take Your Console with You
  40. Explore the Bandai WonderSwan
  41. Play Real Games on Your PDA
  42. Install a PlayStation 2 in Your Car
  43. 3. Playing Well with Others
  44. Practice Proper MMORPG Etiquette
  45. Understand MMORPG Lingo
  46. Grind Without Going Crazy
  47. Make a Profit in Vana’diel
  48. Write MMORPG Macros
  49. Build an Effective Group
  50. Catch Half-Life FPS Cheaters Redhanded
  51. 4. Playing with Hardware
  52. Build a Quiet, Killer Gaming Rig
  53. Find and Configure the Best FPS Peripherals
  54. Adapt Old Video Game Controllers to the PC
  55. Choose the Right Audio/Video Receiver
  56. Place Your Speakers Properly
  57. Connect Your Console to Your Home Theater
  58. Tune Console Video Output
  59. Tune Your TV for Console Video
  60. PC Audio Hacking
  61. Optimize PC Video Performance
  62. Build a Dedicated Multimedia PC
  63. Use a Multimedia Projector for Gaming
  64. 5. Playing with Console and Arcade Hardware
  65. Play LAN-Only Console Games Online
  66. Hack the Nuon DVD Player/Gaming System
  67. Play Import Games on American Consoles
  68. Find a Hackable Dreamcast
  69. Play Movies and Music on Your Dreamcast
  70. Hack the Dreamcast Visual Memory Unit
  71. Unblur Your Dreamcast Video
  72. Use Your Dreamcast Online
  73. Host Dreamcast Games Online
  74. Burn Dreamcast-Compatible Discs on Your PC
  75. Burn Dreamcast Homebrew Discs
  76. Buy Your Own Arcade Hardware
  77. Configure Your Arcade Controls, Connectors, and Cartridges
  78. Reorient and Align Your Arcade Monitor
  79. Buy Cart-Based JAMMA Boards
  80. Programming Music for the Nintendo Entertainment System
  81. 6. Playing Around the Game Engine
  82. Explore Machinima
  83. Choose a Machinima Engine
  84. Film Your First Machinima Movie
  85. Improve Your Camera Control
  86. Record Game Footage to Video
  87. Speedrun Your Way Through Metroid Prime
  88. Sequence-Break Quake
  89. Run Classic Game ROM Translations
  90. Change Games with ROM Hacks
  91. Apply ROM Hacks and Patches
  92. Create PS2 Cheat Codes
  93. Hack Xbox Game Saves
  94. Cheat on Other Consoles
  95. Modify PC Game Saves and Settings
  96. Buff Your Saved Characters
  97. Create Console Game Levels
  98. 7. Playing Your Own Games
  99. Adventure Game Studio Editing Tips
  100. Create and Play Pinball Tables
  101. Put Your Face in DOOM
  102. Create a Vehicle Model for Unreal Tournament 2004
  103. Add a Vehicle to Unreal Tournament 2004
  104. Modify the Behavior of a UT2004 Model
  105. Download, Compile, and Create an Inform Adventure
  106. Decorate Your IF Rooms
  107. Add Puzzles to Your IF Games
  108. Add Nonplayer Characters to IF Adventures
  109. Make Your IF NPCs Move
  110. Make Your IF NPCs Talk
  111. Create Your Own Animations
  112. Add Interactivity to Your Animations
  113. Write a Game in an Afternoon
  114. 8. Playing Everything Else
  115. Tweak Your Tactics for FPS Glory
  116. Beat Any Shoot-Em-Up
  117. Drive a Physics-Crazed Motorcycle
  118. Play Japanese Games Without Speaking Japanese
  119. Back Up, Modify, and Restore PlayStation Saved Games
  120. Access Your Console’s Memory Card Offline
  121. Overclock Your Console
  122. Index
  123. Colophon

Make Your IF NPCs Talk

Sass, growl, flirt, threaten, and cajole players.

A good writer can say a lot with a few words. One of the best tricks in interactive fiction is make players do exactly what you want them to do while maintaining the illusion that they have free will. Nowhere is this more evident than in NPC conversations.

Ideally, your NPCs should drop hints, help solve puzzles, and converse with, and ocasionally bedevil, players. How do you predict what players will say? How do you know how to respond? In general, you don’t, but there are a few tricks to make your NPCs seem like living, thinking beings.

Detailing NPC Conversation

Inform comes with a few built-in methods of talking to NPCs. The centerpiece of the default conversational model is the Ask verb. Let’s make this our means of chatting with the access controller. The game’s parser will take a command such as ask the access controller about the token, toss out the articles, figure out that the operative verb is ask, set the variable noun to controller, and then, as the key part, place the word token into the variable second. If you type ask the access controller about oatmeal, the word oatmeal goes into the variable second, even though there is no oatmeal object in the game. This makes conversation trivial to implement. Add this to the controller’s life block:

Ask:
    switch (second) {
        'id', 'identity', 'token', 'tokens':
            if (token has general)
                "~YES, TOKEN WAS ACCEPTABLE!~ the access controller
                barks. ~YOU MAY PROCEED!";
            "~DO YOU HAVE A TOKEN?~ the access controller shoots
            back. ~IF SO, GIVE TO ME AND YOU MAY PASS! QUICKLY!
            SO VERY HUNGRY...~";
        'access', 'controller', 'itself':
            "~I AM GATEKEEPER TO WORLD BEYOND!~ the access
            controller declares, preening.";
        'oatmeal':
            "~HUH? NOT KNOW WHAT IS!~ the access controller says.
            ~SOUNDS TASTY WITH BUTTER AND BROWN SUGAR, THOUGH!~";              
    }
    "That topic doesn't strike you as very promising.";

You can add as many topics as you like. As you saw earlier, using synonyms is a good idea. You’ve probably also noticed the safety-net line that catches topics that fall through the switch statement. It’s impossible to anticipate every single topic a player might try, so you’ll need some way to fend off topics for which you haven’t written a response; historically, games often made NPCs deaf, distracted, ignorant, uncooperative, or all four at once. Here we’ll just overrule the question instead.

Tip

This is by no means a complete discussion of the topic. NPC conversation is so engrossing a challenge that an entire genre of games has developed that do nothing but simulate a chat with an NPC; some of these games create a model of the NPC’s emotional state, monitor the topics discussed, check the conversation for coherence, and so forth.

The process of ordering characters around is somewhat more complicated than asking questions and telling[19] characters about various subjects. Inform supports directed commands such as cow, jump over the moon. Let’s try implementing the order controller, take the token (and, while we’re at it, controller, eat the token). Add this block to the controller object:

orders [;
    Eat, Take:
        if (noun =  = token) <<Give token self>>;
        "~ONLY WANT TOKEN!~ the access controller screams.";
    default: "~DO NOT ORDER ME AROUND!~ the access controller
        bellows.";
],

Note that the access controller takes the token only if the player has it to give; otherwise, the default response prints. This is exactly what we want, because controller, take the token while the token is in the other room suggests that the player wants the controller to fetch the token from the other room. That’s too easy. Let’s make the player work for it.

For the security daemon, let’s try something a bit different: implementing menu-based conversation like that employed in most graphical adventures. Some players dislike menu conversation because they feel restricted in their choice of topics, but it does keep conversations from becoming a string of default “I don’t know much about that” responses. It’s also a great way to include wisecracks. Inform doesn’t provide for menu-based conversation automatically, so you’ll have to use one of the modules available on the IF archive or hack together a system from scratch. The title of this book suggests the latter approach, but be warned: the degree of difficulty here is about to spike upward.

To make things interesting, let’s make the player figure out how to initiate a conversation with the daemon. Add the following routines to the pixie object:

life [;
    Ask, Tell: "The security daemon replies with a crescendo of
        wordless music.";
],
orders [;
    "The security daemon replies with a crescendo of wordless music.";
],

This serves as an initial hint that the player should try to sing to the daemon. If your playtesters seem unable to guess this, you can add more explicit hinting later on. Let’s begin by specifying a class of objects to serve as songs. Put the following right after the Include "VerbLib" line:

Class Song
  with
    number 0,
  has scenery;

Inform already has a Sing verb, but it is intransitive (which means it doesn’t take a direct object), so you’ll have to replace it. Add the following lines after the Include "Grammar" line:

Extend 'sing' replace
    * 'to' noun -> SingTo;

[ SingToSub x count choice;                       
    if (noun =  = player)
        "Singing to yourself is a sign of impending mental collapse.";
    if (noun =  = controller)
        "~NO SINGING IN THE ROUTER!~ the controller barks.";
    if (noun hasnt animate)
        "You can only do that to something animate.";
    print "Please select one:^^";
    objectloop (x ofclass Song) {
       x.number = 0;
       if (x in noun) {
           count++;
           x.number = count;
           print "(", x.number, ") ", (name) x, "^";
       }
    }

    do {
        print "^Select an option or 0 to say nothing >> ";
        read buffer parse DrawStatusLine;
        choice = TryNumber(1);
    } until ((choice >= 0) && (choice <= count));

    if (choice =  = 0) "^You decide not to sing after all.";
      objectloop (x ofclass Song) {
       if (x.number =  = choice) <<ChooseSong x>>;
    }
    "Singing routine failed! [BUG]";
];

[ ChooseSongSub; rtrue; ];

Holy crow. That is a lot of new stuff. Let’s walk through it.

First, you’re accounting for what happens if the player tries to sing to a creature other than the security daemon. This really should go in the objects themselves, but since there are only two of them for now, you can deal with it here. Also make sure the thing you’re singing to is animate.

Next, look at every Song in the entire game. Clear its number field, and then if it’s in the object we want (currently always pixie), give it a number and stick it on a list. Next, have the player type the number of the song he wants to sing. Finally, send a ChooseSong call to that song. ChooseSong is a dummy verb, a fake action that the player cannot trigger directly.

Let’s write some songs:

Song deathmetal "(death metal) ~STOP OR I WILL KILL YOU!~" pixie
  with
    before [;
        ChooseSong:
            deadflag = 1;
            "^The security daemon lets out an alarmed trill and, deciding
            quarantine is insufficient, deletes you.";
    ];

Song folk "(earnest folk) ~Surely we can be friends...~" pixie
  with
    before [;
        ChooseSong:
            remove self; remove deathmetal; remove aria;
            move seductive to pixie; move lullaby to pixie;
            "^The security daemon murmurs some skeptical notes at you.";
    ];

Song aria "(operatic aria) ~Looook! There is some SPAAAAM behind you!
    You'd better go CHAAAASE it!~" pixie
  with
    before [;
        ChooseSong:
            remove self;
            "^The security daemon isn't buying it. Apparently she wasn't
            compiled yesterday.";
    ];

Song seductive "(seductive R&B) ~Oh, yeah, baby, I got what you need.~"
  with
    before [;
        ChooseSong:
            deadflag = 1;
            "^The security daemon lets out an alarmed trill and, deciding
            quarantine is insufficient, deletes you.";
    ];

Song lullaby "(lullaby) ~It's all right... don't be scared... I've been
    granted legal access...~"
  with
    before [;
        ChooseSong:
            StopDaemon(pixie); remove pixie;
            "^The security daemon circles around you uncertainly and
            flies off to check with the access controller. At last, a
            moment's peace.";
    ];

Now you have a slapdash conversational menu. The player types sing to daemon (or even just sing, when she’s in sight), and the SingToSub routine creates a list of available songs and prompts the player to choose one. The ChooseSong part of the selected song’s before block then runs whatever code the player likes: rearranging the list of available songs, killing the player, switching off the security daemon’s daemon code, or whatever you like.

Now the player is free to continue exploring the game world, but the shape the rest of that world will take is up to you.

See Also

  • The Inform manual (http://www.inform-fiction.org/manual/), which links to downloadable versions of both Graham Nelson’s Inform Designer’s Manual and Roger Firth and Sonja Kesserich’s Inform Beginner’s Guide .

  • The Interactive Fiction Archive (http://ifarchive.org/) is the chief repository for all modern interactive fiction, from games to compilers to players to hint files and more.



[19] Yes, there is a Tell verb as well, which works exactly the same as Ask.