#charset "us-ascii" // THIS CODE NEEDS TO BE INCLUDED BY EVERY SOURCE FILE! // Either #include this file at the top of every other source // file, or paste this code into some other header that all of // your source files include. /* * This section includes the macros that make the action * response system work. */ #define pD propDefined #define PDD PropDefDirectly #define IL illogical #define inh inherited #define dF dobjFor #define iF iobjFor #define nSmell nSmellSomething #define chSmell chSmellSomething #define kSmell kSmellSomething /* The macro structure works as follows. In general, if con- flicting properties are defined on an object, the ones that dis- allow the action will prevail; and any usage of the macro system will be preferred over the default library handling. Specifically, if a game object has an nVerb directly defined on it, this will trump everything else: the action fails in verify. If the object has chVerb defined on it, this will rank next, and the action will fail in check(). If the object has kVerb defined directly on it, this will trump any nVerb or chVerb that is inherited from a superclass, and the action will proceed (after preconds) to the action phase where kVerb will be executed. If none of n-,ch-,or k- Verbs are defined directly on an object, the same priority order will be followed in looking for inherited n-, ch-, or k- Verbs. If none are found, then the default library handling of the verb (including all of the isXXXable properties and cannotXXXMsgs) will be used. */ #define nKVer(z) \ if(pD(&n##z,PDD)) IL(n##z); \ else if(pD(&k##z,PDD) || pD(&ch##z,PDD)) logical; \ else if(pD(&n##z)) IL(n##z); \ else if(pD(&k##z) || pD(&ch##z)) logical; \ else inh; #define nKCheck(z) \ if(pD(&ch##z,PDD)) display(&ch##z); \ else if(pD(&k##z,PDD)) return; \ else if(pD(&ch##z)) display(&ch##z); \ else if(pD(&k##z)) return; \ else inh; #define nKAction(z) \ if(pD(&k##z)) display(&k##z); \ else inh; #define nK(z) \ verify { nKVer(z) } \ check { nKCheck(z) } \ action { nKAction(z) } } #define nk(z) \ verify { nKVer(z) } \ check { nKCheck(z) } \ action { nKAction(z) } // macros for users defining new verbs #define nkTouch(z) { preCond = [touchObj] nK(z) #define nkHeld(z) { preCond = [objHeld] nK(z) #define nkVisible(z) { preCond = [objVisible] nK(z) #define nkNoPrec(z) { preCond = [] nK(z) // Terse macros used for converting library verbs in nkLite.t #define pTnK_(z) dobjFor(z) { preCond = [touchObj] nK(z) #define pHnK_(z) dobjFor(z) { preCond = [objHeld] nK(z) #define pVnK_(z) dobjFor(z) { preCond = [objVisible] nK(z) #define pnK_(z) dobjFor(z) { preCond = [] nK(z) #define pTnK_dj(z) dobjFor(z) { preCond = [touchObj] nK(z##Dj) #define pHnK_dj(z) dobjFor(z) { preCond = [objHeld] nK(z##Dj) #define pVnK_dj(z) dobjFor(z) { preCond = [objVisible] nK(z##Dj) #define pnK_dj(z) dobjFor(z) { preCond = [] nK(z##Dj) #define pTnK_ij(z) iobjFor(z) { preCond = [touchObj] nK(z##Ij) #define pHnK_ij(z) iobjFor(z) { preCond = [objHeld] nK(z##Ij) #define pVnK_ij(z) iobjFor(z) { preCond = [objVisible] nK(z##Ij) #define pnK_ij(z) iobjFor(z) { preCond = [] nK(z##Ij) //////// OPTIONAL MATERIAL: Helper Macros /* To direct multiple verbs to the same response: ``` obj: Thing isFixed = true nBoard = 'Don\'t get on that. ' mapN(Board,StandOn,SitOn,LieOn,Climb) //nStandOn,nClimb,etc. will all redirect to nBoard, the first argument of mapN macro or: obj: Thing isFixed = true dobjFor(Enter) { verify { ...check stuff } action { ...do more than print a message } } mapdF(Enter,Board,Climb,StandOn) //all of the subsequent arguments will be treated as asDobjFor(Enter) ``` */ #define mapN(to,from...) from#foreach: n##from = n##to : : #define mapK(to,from...) from#foreach: k##from = k##to : : #define mapdF(to,from...) from#foreach: dF(from) adF(to) : : #define mapiF(to,from...) from#foreach: iF(from) aiF(to) : : #define mapProps(obj,prop...) prop#foreach: prop = obj.prop : : /* when you want to use dobjFor(Default), but you * want to leave some standard behavior, you can do: * mapINH(Examine,Feel,LookUnder,Move) //etc. */ #define INH { preCond = (inherited) verify { inherited; } \ check { inherited; } action { inherited; } } #define mapINH(vb...) vb#foreach: dF(vb) INH : : // version for iobjs #define mapINHI(vb...) vb#foreach: iF(vb) INH : : //dismiss all attempts to "get on" something with one string #define mapMounts(str) nBoard = str \ mapN(Board,StandOn,SitOn,LieOn,Enter,Climb) //like asExit but taking multiple arguments #define mapExits(to,from...) from#foreach: from asExit(to) : : // dF(Enter) VI('You can\'t go in that. ') #define VI(msg) {verify{illogical(msg);}}