Attempting to adventure up to a condition

Heya,

this is supposed to be simple but I'm having trouble with it.. if anyone feels like helping... that'd be swell :)


I like bat wing chow meins. I want to make code that roughly says:

* start adventure counter
* adventure in "batrat and ratbat cave" until 3 bat wings are obtained
* adventure in "knob goblin kitchens" until 3 knob mushrooms && 3 spices && 3 dry noodles are obtained (I don't want the game to count any existing ingredients I have.. just new ones.)
* stop adventure counter. report how many turns it's taken to generate the ingredients.
* create 3 bwcm's, and eat them.

Why just new ingredients? I want to know how many turns it makes, from nothing, to get the raw ingredients to make bwcms.

Thanks!
RtD
 

Grotfang

Developer
Untested, typed straight into the forums:

Code:
void main()
{
    int my_start_adv = my_adventures();
    add_item_condition( 3 , $item[bat wing] );
    adventure( my_adventures() , $location[batrat and ratbat cave] );
    add_item_condition( 3 , $item[knob mushroom] );
    add_item_condition( 3 , $item[dry noodles] );
    add_item_condition( 3 , $item[spices] );
    adventure( my_adventures() , $location[knob goblin kitchens] );
    int counter = my_adventures() - my_start_adv;
    print( "Took " + counter + " turns." );
    create( 3 , $item[bat wing chow mein] );
    eat( 3 , $item[bat wing chow mein] );
}

That should do EXACTLY what you asked for. No sanity checks (eg. for fullness, adventure numbers, etc). See this as example code for what I think you will be struggling with, which is adding the conditions. If you do decide to add a check, remember that adventure() returns false every time it fails to use the specified number of turns in an area. Therefore, it will return false when you fulfill all your conditions, but will return true ONLY if you run out of adventures (almost... cheers zarqon!).
 
Last edited:

zarqon

Well-known member
Just one hair to split. In a few cases, adventure(my_adventures(), place) may return true with adventures remaining if you gained adventures while adventuring. This could happen from adventuring with a Vivala mask, a counter script eating fortune cookies, or even clan training.
 

StDoodle

Minion
For the wiki's sake as well as the OP, does add_item_condition() default to + mode (as in, get X more, not X total)?
 
Top