Random adventuring, string manipulation, and stat monitoring questions

gxc

New member
I apologize for my lack of knowledge. This is an accumulation of questions.

I'd like to create a script that allows random adventuring in certain places until certain conditions are met, but I have no idea how to loop it. The loop would need to run at least once, and check the conditions (in this case a certain level) after each adventure.

Code:
cli_execute("conditions clear");
cli_execute("conditions level x");

int ranNum;
string loc;

## Place loop here. 
	ranNum = random();
	if(ranNum<=(1/3)){
		loc = "place 1";
	} else if (ranNum<=(2/3)){
		loc = "place 2";
	} else if(ranNum<=1){
		loc = "place 3";
	}
	adventure(1, $location[loc]);
## loop ends here

Also, several questions about strings. My questions, numbered:
1. How do I create a loop that would check conditions generated through CLI (as in not add_item_condition(), more like level or meat)? And would the loop similarly the same if I used add_item_condition()? I was thinking something along the lines of "conditions list" or something, but I have no clue.
--Answered, normal programming loops appear to be easier to use than CLI conditions.

2. Are strings dynamic? That is, can I change a string after it has been defined (as I do in the script above)? In Java there's some extra work that goes into changing a string that has already been defined.
--Answered - I think, just use the individual datatype constants, which appear to be dynamic.

3. How easy is string concatenation? Would it be this easy?
Code:
int intLevel = 5;
string condition = "conditions level " + intLevel;
cli_execute(conditions)
--Answered - lol yes

4. Suppose that the user is running this to gain quite a few items or levels or meat or whatever, something that will take at least two days, but the user wants to run this in conjunction with several other cooking, cocktailing, whatever scripts. Can a script like this be reused without redoing initial conditions?
Code:
cli_execute("conditions clear");
cli_execute("conditions level x");
cli_execute("conditions add x meat");
add_item_condition(x, $item[some item]);
After the first run, the user has the meat and and some of the items. If the user runs again later with more adventures without losing the meat or the items, are those conditions already filled?

5. In this random loop, if I'd like to check HP/MP/Effect and included it at the end of every loop, would that ping the server each time I requested those values or does it check it with a value already stored from the end of combat? The next question might nullify this one, if there are autorecover functions that don't require constant monitoring.

6. (Not a random adventure question) If I'm adventuring using "adventure(my_adventures(), $location[loc])", how do I monitor HP/MP/Effects? Is that programmed into KoL Mafia? Would I set some autorecover values earlier that would be monitored while autoadventuring?

More questions at bottom.
 

hippymon

Member
Re: Random adventuring with conditions (and some string manipulation questions)

For the first part I get what you want to do, but I need more info.... Is it completely random level && location? Or just random locations?
I have made a few changes to your scriptlet and turned it into more of an example....
Code:
int ranNum = random(1-3);
location AdvLoc;
int NextLevel = my_level() +1;
void main(){
	while(my_level() == NextLevel -1){
		cli_execute("conditions clear");
		cli_execute("conditions add level " + NextLevel);
		if (ranNum == 1){
			AdvLoc = $location[1];
		}
		else if (ranNum == 2){
			AdvLoc = $location[2];
		} 
		else if (ranNum == 3){
			AdvLoc= $location[3];
		}
		adventure(my_adventures(), AdvLoc);
	}
 

gxc

New member
Just random locations. So, for example, getting to level two and the Council quest, the user can adventure in the Back Alley, Outside Cobb's Knob, and Haunted Pantry. Until the user reaches level 2, I'd like to be able to loop it so the user adventures once in a location, then the location is changed, possibly to the same place. I don't want to spend all of the adventures in the same place.

So, I think, using your code, this would work.
Code:
location AdvLoc;
int NextLevel = my_level() +1;
void main(){

	while(my_level() == NextLevel -1){
## or maybe (my_level()<NextLevel)
                int ranNum = random(1-3);

		if (ranNum == 1){
			AdvLoc = $location[1];
		}
		else if (ranNum == 2){
			AdvLoc = $location[2];
		} 
		else if (ranNum == 3){
			AdvLoc= $location[3];
		}
		adventure(1, AdvLoc);
	}
}

I removed the conditions lines because it seemed redundant if the while loop has the same conditions.
 

hippymon

Member
Oh, oh, oh, ok I see. In that case, simply change this line:
adventure(my_adventures(), AdvLoc);
into:
adventure(1, AdvLoc);
And I believe that should work.

[quote author=gxc link=topic=1295.msg5993#msg5993 date=1193592010]
4. In this random loop, if I'd like to check HP/MP/Effect and included it at the end of every loop, would that ping the server each time I requested those values or does it check it with a value already stored from the end of combat? The next question might nullify this one, if there are autorecover functions that don't require constant monitoring.

5. (Not a random adventure question) If I'm adventuring using "adventure(my_adventures(), $location[loc])", how do I monitor HP/MP/Effects? Is that programmed into KoL Mafia? Would I set some autorecover values earlier that would be monitored while autoadventuring?
[/quote]
Yes, there are autorecovery functions and effects fuctions.
For your Hp and Mp;
Code:
 cli_execute{
## Change the 0.0 to a number between 0.0 (0%) and 1.0 (100%). 
## Depending on your Hp max it will be set to auto-recover when your Hp falls to or below the number chosen turned into a % (examples: 0.5 = %50, 0.7 = %70)
set hpAutoRecovery = 0.0;

## This is the full list of items available to use when auto-recovering, choose which items out of the list you wish to have KoLmafia use.
set hpAutoRecoveryItems = sleep on your clan sofa,rest at your campground,galaktik's curative nostrum,medicinal herb's medicinal herbs,scroll of drastic healing,scented, massage oil,cannelloni cocoon,red pixel potion,really thick bandage,filthy poultice,gauze garter,bottle of vangoghbitussin,ancient magi-wipes,phonics down,disco power nap,tongue of the walrus,honey-dipped locust,red paisley oyster egg,red polka-dot oyster egg,red striped oyster egg,tiny house,disco nap,lasagna bandages,green pixel potion,doc galaktik's homeopathic elixir,cast,tongue of the otter,doc galaktik's restorative balm,doc galaktik's ailment ointment,forest tears,doc galaktik's pungent unguent;

## This is the % it will try to recover to..
set hpAutoRecoveryTarget = 0.0;

## All this is \/ \/ is the same us Hp functions but with MP.
set mpAutoRecovery = 0.0;

set mpAutoRecoveryItems = sleep on your clan sofa,relax in your beanbag,rest at your campground,galaktik's fizzy invigorating tonic,natural fennel soda,bottle of vangoghbitussin,monstar energy beverage,carbonated soy milk,carbonated water lily,bottle of monsieur bubble,ancient magi-wipes,unrefined mountain stream syrup,phonics down,tonic water,honey-dipped locust,marquis de poivre soda,blue paisley oyster egg,blue polka-dot oyster egg,blue striped oyster egg,blue pixel potion,knob goblin superseltzer,blatantly canadian,tiny house,green pixel potion,dyspepsi-cola,cloaca-cola,mountain stream soda,magical mystery juice,black cherry soda,knob goblin seltzer,cherry cloaca cola,soda water;
set mpAutoRecoveryTarget = 0.0
}

And for the effects part you would use moods...

This will explain them better than I can:
http://kolmafia.sourceforge.net/scripting.html#moods
When using the mood scripts be sure to do "cli_execute()"...

4. Suppose that the user is running this to gain quite a few items or levels or meat or whatever, something that will take at least two days, but the user wants to run this in conjunction with several other cooking, cocktailing, whatever scripts. Can a script like this be reused without redoing initial conditions?
Code:

cli_execute("conditions clear");
cli_execute("conditions level x");
cli_execute("conditions add x meat");
add_item_condition(x, $item[some item]);


After the first run, the user has the meat and and some of the items. If the user runs again later with more adventures without losing the meat or the items, are those conditions already filled?

Yea, this part simply do:
cil_execute{
conditions clear
conditions add level X
conditions add X meat
conditions add X item(s)
}



[quote author=gxc link=topic=1295.msg5995#msg5995 date=1193594096]
Just random locations. So, for example, getting to level two and the Council quest, the user can adventure in the Back Alley, Outside Cobb's Knob, and Haunted Pantry. Until the user reaches level 2, I'd like to be able to loop it so the user adventures once in a location, then the location is changed, possibly to the same place. I don't want to spend all of the adventures in the same place.

So, I think, using your code, this would work.
Code:
location AdvLoc;
int NextLevel = my_level() +1;
void main(){

	while(my_level() == NextLevel -1){
## or maybe (my_level()<NextLevel)
                int ranNum = random(1-3);

		if (ranNum == 1){
			AdvLoc = $location[1];
		}
		else if (ranNum == 2){
			AdvLoc = $location[2];
		} 
		else if (ranNum == 3){
			AdvLoc= $location[3];
		}
		adventure(1, AdvLoc);
	}
}

I removed the conditions lines because it seemed redundant if the while loop has the same conditions.
[/quote]
Heh, I guess so... But, yea, this should work..
 

gxc

New member
Okay, sorry it's taking me so long to get this, but the autorecover functions and moods will take care of HP/MP/Effects if I'm running adventure(my_adventures(), location)? There's no coding (other than setting it) on my part? I seem to remember Mafia doing that while I was manually doing all this stuff.

And another question, this time involving matrices. Does ASH use matrices/how do I set them up. I think I saw one or two on the wiki, but that thing is pretty bad.

So, secondary question, is it cool to add articles to the wiki?
 

hippymon

Member
[quote author=gxc link=topic=1295.msg6000#msg6000 date=1193596205]
Okay, sorry it's taking me so long to get this, but the autorecover functions and moods will take care of HP/MP/Effects if I'm running adventure(my_adventures(), location)? There's no coding (other than setting it) on my part? I seem to remember Mafia doing that while I was manually doing all this stuff.

And another question, this time involving matrices. Does ASH use matrices/how do I set them up. I think I saw one or two on the wiki, but that thing is pretty bad.

So, secondary question, is it cool to add articles to the wiki?
[/quote]
1: Yea, moods and auto recovery should take care of Hp/Mp/Effects.
2: I have no clue what the matrices stuff is.. :\
3: It is alright to add pages... As long as the pages are for a constructive purpose and have to do with scripting....
 

gxc

New member
Just a normal array. I forget the Java syntax, but it'd be something like
Code:
int[] someValues = new int[5];
int[0] = 1;
int[1] = 2;
int[2] = 3;
int[3] = 4;
int[4] = 5;
would be an array [1,2,3,4,5].

Can ASH do this, and if so, any idea on the syntax?
 

holatuwol

Developer
Arrays are reallly a specific instance of a map, which are available.

That said, I'm thinking of implementing a new "list" data type some time in the near future since I've finally come up an interesting use for "prompting" scripts (I think this was a feature request somewhere, but I didn't like any of the proposed uses) and a list object makes the most sense as an input for something like that.
 

gxc

New member
Sweet. I missed that.

New question. Is there anyway to print some values to a text file to monitor where a user is in a large script? For example, I make a script that combines all the small subquests (maps, stuff like that). In the first run, the user gets the first two maps, but doesn't complete the rest. Do I just have to manually turn those conditions off the next run or can I add something that would check against an outside file? (you can't exactly add an "item_amount" in case the user has sold it)
 

gxc

New member
Can I then create script-defined preferences with that, or am I limited to the current KoL Mafia properties?
 

MagiNinjA

New member
[quote author=gxc link=topic=1295.msg6010#msg6010 date=1193602251]
Can I then create script-defined preferences with that, or am I limited to the current KoL Mafia properties?
[/quote]

Indeed you can do set_property("ZOMGMYVALUE", "Yep."); or something.
 

gxc

New member
Where does that write to? The user preferences?

Also, is it possible to incorporate multiple ASH files into one? IE main turn-burning has you adventure randomly in some area, and the script is coded to run ASH files that complete subquests in those areas.
 

Veracity

Developer
Staff member
[quote author=gxc link=topic=1295.msg6012#msg6012 date=1193603933]
Where does that write to? The user preferences?[/quote]
Yes.

(And before you say "so, how do I write to the global preferences" and argue with me when I say "you can't", come up with a real use for saving a property that is shared among all users.. :))
 

gxc

New member
More questions

1. Can you create a condition based off the name of an encounter/script the answer (like the haiku dungeon quest or hammer time or happy birthday, claude)? Would that just be knowing exactly what all the choiceAdventure properties stand for? And if so, does anyone have a complete list online (the wiki only covers so much and doesn't give values)?

2. What are the actual resistance check functions? I tried using stench_resistance() and got "unknown reference". Or do I just have to use "element_resistance($element[elem])" (that works, I did try it)?

3. How do I check current equipment? The wiki says use "current_equipment($slot[slot])", but that returns "unknown reference". Is it "equipped_item(slot sl)"? That seems to work, but means wiki needs updated.
 

holatuwol

Developer
I personally don't use the kolmafia wiki, or even have an account there, so basically what's there is whatever the current script writers felt should be there. If it hasn't been updated, it's probably because I deprecate a lot of things without warning or notice and it only becomes a problem if you actually use those functions.

1) No.
2) You have to use element_resistance(element).
3) You have to use equipped_item(slot).
 
Top