Feature - Implemented Cannot run Counter Script from automatic adventuring

Bale

Minion
All other elements of battle preparation can be scripted:

Code:
boolean adv_prep() {
	if(get_counters("", 0, 0) != "")  {
		print(get_counters("", 0, 0)+" counter is up.", "red");
		return false;
	}
	if(my_adventures() == 0) {
		print("You have run out of adventures.", "red");
		return false;
	}
	restore_hp(0);
	restore_mp(0);
	cli_execute("mood execute; burn extra");
	if(get_property("betweenBattleScript") != "")
		cli_execute("call "+ get_property("betweenBattleScript"));
	return true;
}

Unfortunately the best I can do when encountering an incipient counter is to print an error message. The counter script contains 2 parameters and that cannot be summoned from a cli_executed call. I cannot import it since the name of the counter script is unknown.

There's a cute little script I'd like to release to the community, but I consider this a flaw I'm hoping to repair before doing so.
 

jasonharper

Developer
This requires further explanation. Why would you want to duplicate all this functionality, rather than letting mafia do its job?
 

Bale

Minion
Because mafia will not differentiate between different non-combats encountered. If I rewrite my own version of adventure(), then I need to duplicate that functionality.
 
Last edited:

jasonharper

Developer
Is this related to that horribly broken run_adv() function you posted on the Wiki? Mafia contains about a thousand lines of code for deciding what to do at a choice adventure. The few lines in your function will handle some of the most common cases, but will screw up badly in others - goals that can override choices, "complete the outfit" choices, Louvre, Violet Fog, the class-specific handling of That Explains All The Eyepatches, and at least a dozen other special cases.

Now, what do you ACTUALLY NEED that isn't being handled by built-in adventuring? If you just want to know what the last encounter was, wouldn't a lastEncounter pref or function be a better solution?
 

Bale

Minion
Yes, a lastEncounter pref would be much better. I've long wanted such a function. The only reason that I haven't asked for that is because it has been asked for by many people for many years. After so much rejection I simply assumed that it was unconditionally off the table. Please add it.

That'd make it much easier to script for simple things in a zone with multiple choice adventures, like setting the Quartet song for instance.

Since you brought this solution up, does that mean you're willing to do so?
 

jasonharper

Developer
I wasn't aware of any previous rejection, and haven't had any luck searching for an example - could you provide a reference?
 

Bale

Minion
I just did a search and found some examples. They weren't exactly what I remembered. All the rejected requests were for selecting specific choice adventures as goals! Nothing about adding a function or preference to indicate the former adventure in a script. :)

If you're willing, how about int last_adventure() that returns 0 if the last adventure was a monster or returns the adventure number if it was a choice. We already have a last_monster() so that can be used for information about the previous adventure if last_adventure() returns 0.
 
Last edited:

jasonharper

Developer
What about non-combats other than choice adventures?

A string pref, holding whatever appeared on the most recent "Encounter:" line in the CLI and session log, looks like the simplest solution. I'm assuming that any user of this feature would be more interested in checking for specific adventures, than in the type of adventure.
 

Bale

Minion
Good point. Whatever appeared on the most recent Encounter line is the most important information.

Why do you think a preference is better than a function? Because it will persist through sessions?
 

jasonharper

Developer
Persistence through sessions is potentially useful, but the real reason is that it's simply a lot easier to add a pref than a function. Also, as a pref you can blank out its value before calling some code that may or may not actually do any adventuring, and be sure that you're not seeing an encounter from before the call.
 

lidden

Member
When I tried it it said "A Flat Miner". The last adventure spent was mining in disguise. Is that intentional?
 

Bale

Minion
What about the Daily Dungeon? Will that appear as an encounter since it does not call adventure.php?
 
Top