Ok, here's what I've come up with as a workable implementation of in-script combat customization. It ended up as neither CCS nor consult, but an unholy chimera of the two. Fortunately, unstable DNA is readily available at the moment!
There would be a version of adventure() that takes a third string argument, naming a function.
That function should have a signature like this:
string my_consult_function(int round, monster opponent, string pageText)
'round' starts at zero, and is incremented by one on each successive call to your function. It's not exactly the same as the combat round number, since there are actions that take no rounds (such as "steal" when that's unavailable or inappropriate), and actions that take more than one round (skill use with insufficient MP, thus requiring a restorative to be used first).
The normal consult-related functions could probably be used, but there's a better way - just return a string in the form of a CCS command. (Actually, I'm surprised that this isn't the way consult scripts worked from the beginning - seems like it would have been a lot easier to implement.) It will be executed, and then, assuming that the combat hasn't been finished or aborted, your function will be called again to produce the next action. Note that, unlike existing consult scripts, your script isn't being reloaded each time, so you've got continuity of global variables between each call.
To allow your function to modify the user's combat strategy rather than completely replacing it, there would be one new built-in function:
string get_ccs_action(int round)
It will return the specified line from the CCS section appropriate for the monster currently being fought (which therefore makes this function only usable from within a consult function). Numbers past the end of the CCS will return copies of the last line. It will transparently handle switching to a different CCS section after a "default" command or use of CLEESH - complications that would make it difficult to provide a version of the function that allowed you to explicitly specify a section. Also, if the user has specified a simple battle action instead of a CCS, this function will make it look as if they had a CCS that read:
1: steal
2: <their battle action>
So, a minimal do-nothing consult function would look like this:
Code:
string null_consult(int round, string opp, string text) {
return get_ccs_action(round);
}
adventure(1, $location[whatever], "null_consult");
And one that inserts an action into the user's strategy might look like this:
Code:
int insertRound = 2;
string insertAction = "item meat vortex";
string insert_consult(int round, string opp, string text) {
if (round == insertRound) return insertAction;
else if (round > insertRound) round = round - 1;
return get_ccs_action(round);
}
To make that really useful, you'd need to scan the CCS to determine the right place to insert the action - perhaps after any "steal" or "skill entangling noodles" command, but before anything that can kill the monster.
Now the big question: does this meet everyone's needs?