#include #include ///////////////////////////////////////////////////// /* * This section includes the macros that make the action * response system work. */ /* n/k without action phase */ #define nKWOA(z) \ //within verify \ if(!propDefined(&k##z)) { \ if(propDefined(&n##z)) illogical(n##z); \ else illogical('That\'s not happening. '); } \ else if(!overrides(self,Thing,&k##z) && propDefined(&n##z)) \ illogical(n##z) /* the standard full mechanism */ #define nK(z) \ nKWOA(z); } //end verify \ action() { say(k##z); } } /* optional form for making dobjFor or iobjFor more illogical * than the standard illogical. Normally, if you enter something * like 'drill rock with doughnut' you will end up with something * like 'You don't need to drill the rock right now. ', because the illogical * msg for the direct object will be preferred if both are illogical. * If you'd rather see 'Why are you trying to drill things with a * doughnut? ', you can set the iobj to an illogical rank of 20: * iobjFor(DrillWith) pHnK20(DrillWith) */ #define nK20(z) \ if(!propDefined(&k##z)) { \ if(propDefined(&n##z)) illogical(rank:20,n##z); \ else illogical(rank:20,'That\'s not happening. '); } \ else if(!overrides(self,Thing,&k##z) && propDefined(&n##z)) \ illogical(rank:20,n##z); } //end verify \ action() { say(k##z); } } /* this is defined to mimic the adv3 library's standard of giving * most objects a logicalRank of 50 for such verbs as push and turn */ #define nK50(z) \ nKWOA(z); \ else LR(50,''); } //end verify \ action { say(k##z); } } /* These are the macros/codes that you will use for your custom- * defined verbs */ #define pTnK(z) { preCond = [touchObj] verify() { nK(z) #define pTnK50(z) { preCond = [touchObj] verify() { nK50(z) #define pTnK20(z) { preCond = [touchObj] verify() { nK20(z) #define pHnK(z) { preCond = [objHeld] verify() { nK(z) #define pHnK20(z) { preCond = [objHeld] verify() { nK20(z) #define pVnK(z) { preCond = [objVisible] verify() { nK(z) #define pVnK20(z) { preCond = [objVisible] verify() { nK20(z) #define pnK(z) { preCond = [] verify() { nK(z) #define pnK20(z) { preCond = [] verify() { nK20(z) /* These are just abbreviations for converting library verbs * to the system. */ #define libpTnK(z) dobjFor(z) { preCond = [touchObj] verify() { nK(z) #define libpTnK50(z) dobjFor(z) { preCond = [touchObj] verify() { nK50(z) #define libpHnK(z) dobjFor(z) { preCond = [objHeld] verify() { nK(z) #define libpVnK(z) dobjFor(z) { preCond = [objVisible] verify() { nK(z) #define libpnK(z) dobjFor(z) { preCond = [] verify() { nK(z) ///////////////////////////////////////////////////// /* * These 'n' and 'k' names are not part of the macro system: trying to * change the 'n' or 'k' prefix of these in your code will not perform * the automatic verification distinction. These are just typing shortcuts * for library messages (unless you add the corresponding verb to the * macro system), for consistency. */ #define nAttach cannotAttachMsg #define nAttachTo cannotAttachToMsg #define nBoard cannotBoardMsg #define nBurnWith cannotBurnWithMsg #define nClose cannotCloseMsg #define nDetach cannotDetachMsg #define nDetachFrom cannotDetachFromMsg #define nDoff notDoffableMsg #define nEnter cannotEnterMsg #define nGetOffOf cannotGetOffOfMsg #define nGetOutOf cannotUnboardMsg #define nGo cannotGoThatWayMsg #define nGoThrough cannotGoThroughMsg #define nAttackWith notAWeaponMsg #define nKissActor cannotKissActorMsg #define nLieOn cannotLieOnMsg #define nMoveComponent cannotMoveComponentMsg #define nMoveWith cannotMoveWithMsg #define nOpen cannotOpenMsg #define nOpenLocked cannotOpenLockedMsg #define nPour cannotPourMsg #define nPushTravel cannotPushTravelMsg #define nPut cannotPutMsg #define nPutIn notAContainerMsg #define nPutOn notASurfaceMsg #define nPutInOn(str) nPutIn = iobjMsg(str) \ nPutOn = iobjMsg(str) // for convenience #define nPutUnder cannotPutUnderMsg #define nPutBehind cannotPutBehindMsg #define nPutComponent cannotPutComponentMsg #define nSitOn cannotSitOnMsg #define nStandOn cannotStandOnMsg #define nTake cannotTakeMsg #define nTakeComponent cannotTakeComponentMsg #define nUnlockWith cannotUnlockWithMsg #define nWear notWearableMsg #define kBurn okayBurnMsg #define kClose okayCloseMsg #define kDrop okayDropMsg #define kLI nothingInsideMsg // def. LookIn response #define kLU nothingUnderMsg // " " LookUnder #define kLB nothingBehindMsg // " " LookBehind #define kLT nothingThroughMsg // " " LookThrough #define kLTP nothingThroughPassageMsg //okayLookThroughPassage #define kOpen okayOpenMsg #define kPutIn okayPutInMsg #define kPutOn okayPutOnMsg #define kTake okayTakeMsg /* other shortcuts */ #define kOff okayNotStandingOnMsg #define nIntang notWithIntangibleMsg #define nHere notHereMsg #define nImp notImportantMsg #define tooFull tooFullMsg #define tooLarge tooLargeForContainerMsg /* For RestrictedHolders: * If you use these, bear in mind that the parameter "obj" is included * in the macro. so that your code might look like this: * nPutInR { if(obj==something) return 'blah <> blah'; * else if(obj==otherThing) return 'other string'; * else return inherited(obj); } */ #define nPutInR cannotPutInMsg(obj) #define nPutOnR cannotPutOnMsg(obj) #define nPutUnderR cannotPutUnderMsg(obj) #define nPutBehindR cannotPutBehindMsg(obj) ///////////////////////////////////////////////////// /* Macros unrelated to the action response system, which * you may find handy if you get used to them */ #define acI DefineIAction #define acLit DefineLiteralAction #define acLitT DefineLiteralTAction #define acT DefineTAction #define acTI DefineTIAction #define acTop DefineTopicAction #define acTopT DefineTopicTAction #define vP verbPhrase #define vR VerbRule #define IL illogical #define ILA illogicalAlready #define ILN illogicalNow #define ILS illogicalSelf #define LR logicalRank #define fC failCheck #define rA replaceAction #define mI moveInto #define rT remapTo #define dF dobjFor #define iF iobjFor #define adF asDobjFor #define aiF asIobjFor #define aE asExit #define oK ofKind /* To direct multiple verbs to the same response: obj: Fixture 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: Fixture 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) : : //remap several verbs to another object (the first param) #define maprT(obj,df...) df#foreach: dF(df) rT(df,obj) : : #define mapProp(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(Feel,LookUnder,Move) //etc. */ #define mapINH(vb...) vb#foreach: dF(vb) INH : : // version for iobjs #define mapINHI(vb...) vb#foreach: iF(vb) INH : : #define INH { preCond = (inherited) remap { inherited; } verify() { inherited(); } \ check() { inherited(); } action() { inherited(); } } //define all four put messages with one string #define mapPuts(str) nPutIn = iobjMsg(str) \ mapN(PutIn,PutOn,PutUnder,PutBehind) //cover 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 aE(to) : : /* a lot of times we just want an object (usu. iobj) * to clear verify and check so other object can * handle action on it. Versions for the most common * preconditions; code looks like: * iobjFor(DigWith) pHvc */ #define pvc { preCond = [] verify(){} check(){} } #define pTvc { preCond = [touchObj] verify(){} check(){} } #define pHvc { preCond = [objHeld] verify(){} check(){} } #define pSvc { preCond = [actorStanding] verify(){} check(){} } /* when you want to clear everything and just get to the action phase. * You'll need to close with two braces: * dobjFor(GoNear) pvca replaceAction(East); } } */ #define pvca { preCond = [] verify(){} check(){} action(){ #define pTvca { preCond = [touchObj] verify(){} check(){} action(){