The specific problem: I have a character who is asleep, and I want any verb involving touching him to be intercepted and handled with a “Leave him alone” message.
I did this with beforeAction, which works with verbs that I have created, but something is catching verbs that are already in the library and giving the default msg.
So here’s what I have done so far:
In my header file:
#define DefineTouchTAction(name) \
DefineTouchTActionSub(name, TouchTAction)
#define DefineTouchTActionSub(name, cls) \
DefineAction(name, cls) \
verDobjProp = &verifyDobj##name \
remapDobjProp = &remapDobj##name \
preCondDobjProp = &preCondDobj##name \
checkDobjProp = &checkDobj##name \
actionDobjProp = &actionDobj##name \
In my verbs file:
class TouchTAction: TAction
;
DefineTAction(Untape);
VerbRule(Untape)
('untape')
singleDobj
: TouchTAction, UntapeAction
verbPhrase = 'untape/untaping (what)'
askDobjResponseProd = singleNoun
;
modify Thing
dobjFor(Untape)
{
preCond = [touchObj]
action ()
{
"You don't see any tape on {the dobj/him}. ";
}
}
;
In my character file:
ch_jack...
beforeAction {
if(gAction.ofKind(TouchTAction))
{
if (ch_jack.curState == jackSleeping) {
"Aww, he looks so cute while he's asleep. Why don't you leave the poor guy alone. ";
exit;
}
}
}
So as I say, this works if Jack is asleep and I >untape Jack. But it doesn’t work if I, for example, >Push Jack (This gets “Jack probably wouldn’t like that.”)
Ideally, what I think I’d like to do is something like
dobjFor(gAction.ofKind(TouchTAction))
{
"You tried to use a touchverb on Jack. ";
}
But of course that won’t work because dobjFor is a macro that I only dimly understand.
In any case, and thinking more generally, there are lots of times when it is useful to catch all of a player’s touchverbs on a given object and handling them at once.
Any ideas?
Thanks in advance!
–Bob