Here's a version that will remap >KISS X to >ASK X FOR KISS, when X is an Actor. Commands in the form >X, KISS Y will be likewise transformed into >X, ASK Y FOR KISS.
Code:
kissToGiveKissTo: GlobalRemapping
getRemapping(issuingActor, targetActor, action)
{
if (action.ofKind(KissAction))
{
local dobjActor = nil;
local obj = firstObj();
while (obj != nil)
{
if (obj.ofKind(Actor) && action.canDobjResolveTo(obj))
dobjActor = true;
obj = nextObj(obj);
}
local newAction, dobj, iobj;
if (!dobjActor)
{
newAction = GiveToAction.createActionInstance();
dobj = new PreResolvedProd(kiss);
iobj = action.dobjMatch;
}
else
{
newAction = AskForAction.createActionInstance();
dobj = action.dobjMatch;
iobj = new ResolveInfo(kiss, 0);
}
newAction.setOriginalAction(action);
newAction.setRemapped();
newAction.setObjectMatches(dobj,iobj);
return [targetActor, newAction];
}
return nil;
}
;
modify giveMeToAskFor
getRemapping(issuingActor, targetActor, action)
{
if (!(action.isRemapped()))
return inherited(issuingActor, targetActor, action);
else
return nil;
}
;
modify TAction
isRemapped() { return remapped_ != nil; }
setRemapped() { remapped_ = true; }
remapped_ = nil
;
It's a bit clunky in performance terms because it has to iterate through every object in the game, check whether that object is an actor, and then check whether that actor could resolve as the direct object.
Transcript with results.
Quote:
> kiss me
Talking to yourself won’t accomplish anything.
> slime, kiss me
You do not respond.
> slime, ask me for a kiss
You do not respond.
> kiss slime
The RED SLIME does not respond.
> slime, give me a kiss
The RED SLIME does not respond.
> ask slime for a kiss
The RED SLIME does not respond.
> kiss widget
You cannot give anything to a WIDGET.
> slime, kiss widget
The RED SLIME cannot give anything to a WIDGET.