The “standard” way to create an action as a new turn for an NPC is to use newActorAction()
. Unfortunately, this is a macro, and it uses a somewhat idiosyncratic syntax. I.e., if bob
is an Actor
instance, something like:
newActorAction(bob, North, nil);
…to have bob
take a turn executing NorthAction
. But this, as an example, won’t compile:
actorAction() {
_doAction(North, nil);
}
_doAction(action, objs) {
newActorAction(self, action, objs);
}
Because North
isn’t defined, and the macro will try to construct an instance of actionAction
, which also isn’t defined.
This means that any NPC AI that relies on newActorAction()
ends up having to be a big messy switch()
statement or an even uglier mass of if-then spaghetti. Which is obviously undesirable.
So…is there some other way (in adv3) to do this sort of thing? You could obviously do something like build a bunch methods that shadow all the Action
types you want to be able to script (so things like _doNorth() { newActorAction(self, North, nil); }
and so on, and then you can have a LookupTable
that maps “north” to _doNorth()
.
Or am I fundamentally thinking about this the wrong way? The assumption in general seems to be…well, okay. The general assumption seems to be that NPCs are mostly static. But let’s ignore that. For NPCs with a bunch of scripting, the general assumption seems to be that you’ll just be miracle-ing your NPC into doing whatever they want to do. Like your scripting decides that the NPC wants to go to the stuff library, you just alice.moveInto(stuffyLibrary)
or whatever. That is: basically ignore any game logic the player is bound by in order to just let the NPC do whatever it needs to do.
I really don’t want to take that approach, I want all the NPCs to be playing by the same rules the player has. I’m aware of a couple things that kinda do this (like, in the travel example, scriptedTravelTo()
to move to a connected location), but as a general model it doesn’t appear to be well supported, and doesn’t seem to be an approach implemented in many games (or at least those adv3 games that have made their source available).
Am I just missing something obvious, or am I just asking for something silly here?