| /* | |
| * Electrick Shoc. (shoc.t) | |
| * | |
| * This is a piece of TADS code that implements | |
| * an electrically live item. The player will | |
| * get a shock if s/he touches it, but is | |
| * otherwise unaffected if s/he tries to use | |
| * a verb that doesn't involve physical contact | |
| * with the device. | |
| * | |
| * Requires TADS compiler 2.1 or higher. | |
| * | |
| * This code is copyright (c) 1993 Neil K. | |
| * Internet: n_k_guy@sfu.ca | |
| * | |
| * You may distribute, modify and copy this | |
| * file as much as you like, but it cannot | |
| * be bought or sold. Please include this | |
| * notice and a list of any changes you made | |
| * if you choose to distribute it. | |
| * | |
| * Version History: | |
| * | |
| * Written 4/26/93 Neil K. | |
| * | |
| */ | |
| /* | |
| * | |
| * This is our electrically dangerous object. | |
| * | |
| * The shock feature relies on the new "dobjGen" | |
| * method that was added to TADS in version | |
| * 2.0.13. Consult your TADSVER file for more | |
| * details on this useful feature. | |
| * | |
| * All this implementation does is catch every | |
| * single verb for which the transformer is the | |
| * direct object. If the verb in question is of | |
| * of the "contactVerb" type then the function | |
| * named "electricShock" is called. If the verb | |
| * isn't of this type then it's left alone. | |
| * | |
| * This method uses the "isclass" function to | |
| * check if the verb being passed (v) is of | |
| * the "contactVerb" class or not. | |
| * | |
| */ | |
| powerTransformer: fixeditem | |
| sdesc = "power transformer" | |
| ldesc = "This large grey power transformer is covered | |
| with an assortment of threatening decals that warn | |
| you of the dangers of touching uninsulated electrical | |
| devices. " | |
| noun = 'transformer' | |
| adjective = 'large' 'grey' 'gray' 'power' | |
| location = TransRoom | |
| // replace with your own location | |
| dobjGen( a, v, i, p ) = | |
| { | |
| if ( isclass( v, contactVerb ) | |
| { | |
| electricShock(); | |
| exit; | |
| } | |
| } | |
| ; | |
| /* | |
| * This function should be predeclared | |
| * in your "adv.t" file. | |
| * | |
| * Naturally, if you wanted to be more | |
| * gruesome you could add the die(); | |
| * function here, so the player would | |
| * be killed if s/he touches the device. | |
| * This is a *nice* example, though, so | |
| * this and nastier ideas are left up | |
| * to you. | |
| * | |
| * "electricShock" is implemented as | |
| * a function rather than being part of | |
| * of the transformer item so it's | |
| * easily re-used should you have | |
| * several electrically dangerous | |
| * objects. Of course, you could always | |
| * create a class of electrically nasty | |
| * items and incorporate the "electric | |
| * shock" code into that instead. | |
| * | |
| */ | |
| electricShock: function | |
| { | |
| "That really wasn't a very bright idea. | |
| A sudden surge of electricity courses | |
| through %your% body, leaving %you% shaken | |
| and drained. "; | |
| } | |
| /* | |
| * | |
| * This is a new class of verb. | |
| * | |
| * The idea behind it is to have | |
| * a way of identifying all verbs | |
| * that involve the player touching | |
| * the direct object. You would | |
| * modify your "adv.t" file so that | |
| * all "touchy" verbs - such as | |
| * "take", "push", "open", etc. - | |
| * are of the "contactVerb" class. | |
| * | |
| * For instance, you would directly | |
| * change the "touchVerb" verb from a | |
| * regular deepverb to a contactVerb, | |
| * by modifying your "adv.t" file like | |
| * this: | |
| * | |
| * touchVerb: contactVerb | |
| * | |
| * Note that TADS now has a "replace" | |
| * feature that lets you make this | |
| * sort of change to your adv.t file | |
| * by adding the change to your own | |
| * game code. Check the TADSVER file | |
| * for more info. Note that the "modify" | |
| * isn't much use here, as "modify" | |
| * doesn't let you change superclasses. | |
| * | |
| * This class will allow the game to | |
| * distinguish between player actions | |
| * that result in a nasty shock, and | |
| * those actions that don't, such as | |
| * simply looking at or asking about | |
| * the item. | |
| * | |
| * The verb inherits everything from | |
| * the "deepverb" definition. In fact, | |
| * it doesn't do anything new itself. | |
| * It's just a kind of flag so that | |
| * electrically nasty items can tell | |
| * whether a verb involves physical | |
| * contact or not. | |
| * | |
| */ | |
| class contactVerb: deepverb | |
| ; | |
Xet Storage Details
- Size:
- 4.16 kB
- Xet hash:
- 1a8bcd57c72e1245dabf3a12308f9ca48b12b8390b4b79b3e4cd2e1c3c273572
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.