Bound and gagged! Immobilizing PC and NPCs

For the next release of adv3Lite I’m adding a preAction(lst) method which will be called on the actor just prior to the execution of any Doers. This will provide an easier way to veto any action before any verify stage messages are displayed. The example I’ve just tested (and which seems to work okay) looks like this:

+ me: Player 'you'   
    isFixed = true       
    person = 2  // change to 1 for a first-person game
    contType = Carrier    
    
    preAction(lst)
    {
        local action = lst[1];
        
        if(action == Think && isTiedUp)
        {
            "Thinking sets you free!<.p>";
            isTiedUp = nil;
        }
        
        if(action.ofKind(SystemAction) || !isTiedUp)
            return;
         
        "You can't do that while you're tied up. ";
        abort;      
    }
    
    isTiedUp = true         
;

You could obviously do something more elaborate here, such as testing for the location or the occurrence of a Scene or any other condition, as well as allowing/vetoing any action you like here. but of course you’d need the other couple of tweaks to the library to make this work.

One of these would just be:

modify Thing
   preAction(lst) { }
;

The other would be:

modify Command
    execIter(lst)
    {
       
        try
        {      
            /* 
             *   Give our actor's preAction method the chance to veto this action (or maybe do
             *   something else) before it's passed to a Doer.
             */
            gActor.preAction(lst);
            
            /* carry out the default action processing */            
            execDoer(lst);
        }
        catch (ExitSignal ex)
        {
        }
        
        finally
        {
            /* 
             *   If the action isn't one this Command has executed before while
             *   iterating over its list of objects, note that we've now
             *   executed it
             */
            if(actions.indexOf(action) == nil)
                actions += action;
            
            /*  Restore the original action */
            action = originalAction;
        }
    }

``
2 Likes