Eating script

D

Daeth Eater

Guest
Hi everyone. I'm pretty new to this scripting world, I've only read one tutorial (http://kolmafia.sourceforge.net/advanced.html), and I have caught the gist of it, but I still lack a lot of skills.

The thing is, I'm trying to assemble a "optimum diet" script, that makes a character eat the biggest amount of food he can, without getting drunk, and taking into consideration which "steel organ" the character has. The idea is to use regular chow meins (bat wing, knob sausage and rat appendix ones), cocktailcrafting drinks (although I guess that if the character has SHC I could make him prepare SHC drinks), with the help of ode to booze and milk of magnesium (maybe munchies pill too, I'm not sure).

In order not to have to write the whole name of the food again every time you use it, I wanted to try and see if I canget a string to say "batwng" if the character's class is P or S, "knob sausage" if he is SC or TT, "rat appendix" if he is DB or AT, and then use it to consume [X, 'string' chow mein]. The thing is, I have NO idea how a string works in ASH, between other things.

The only experience with a programming language I have is a year of Pascal learning in 2004, so I?m not really well prepared to do this "diet script" alone.

Suming up, any tutorials, help, or script bits you can give me are welcome. Anybody?
 

exdeath

Member
[quote author=Daeth Eater link=topic=481.msg2337#msg2337 date=1159818281]
Hi everyone. I'm pretty new to this scripting world, I've only read one tutorial (http://kolmafia.sourceforge.net/advanced.html), and I have caught the gist of it, but I still lack a lot of skills.

The thing is, I'm trying to assemble a "optimum diet" script, that makes a character eat the biggest amount of food he can, without getting drunk, and taking into consideration which "steel organ" the character has. The idea is to use regular chow meins (bat wing, knob sausage and rat appendix ones), cocktailcrafting drinks (although I guess that if the character has SHC I could make him prepare SHC drinks), with the help of ode to booze and milk of magnesium (maybe munchies pill too, I'm not sure).
[/quote]
int fullness=15;
if(have_skill($skill[stomach of steel])) fullness=20;


[quote author=Daeth Eater link=topic=481.msg2337#msg2337 date=1159818281]
In order not to have to write the whole name of the food again every time you use it, I wanted to try and see if I canget a string to say "batwng" if the character's class is P or S, "knob sausage" if he is SC or TT, "rat appendix" if he is DB or AT, and then use it to consume [X, 'string' chow mein]. The thing is, I have NO idea how a string works in ASH, between other things.
[/quote]

item batwing = $item[bat wing chow mein];

Those can all be done outside of any functions so they're global if you want. For eating you could just do something like

eat(fullness/5, batwing);

Hope those help a bit. :)
 

Daeth Eater

New member
Ok, those ere pretty useful, but what I'd really like is an ASH tutorial so that I can learn hoe to script properly.
Meanwhile, here's what I have ( I'm not on how to define the item variables):

void organs ()
{
int drunklimit;
drunklimit = 14;
if( have_skill( $skill[liver of steel]))
{
drunklimit = 19;
}
int foodlimit;
foodlimit = 15;
if( have_skill( $skill[stomach of steel]))
{
foodlimit = 20;
}
}

void diet ()
{
item food;
item main_drink;
item liver_drink;
item unliver_drink;
if ( my_class() == $class[turtle tamer] || my_class() == $class[seal clubber] )
{
food = $item[Knob sausage chow mein];
main_drink = $item[slip 'n' slide];
liver_drink = $item[tequila with training wheels];
umliver_drink = $item[shot of orange schnapps];
}
if ( my_class() == $class[pastamancer] || my_class() == $class[sauceror] )
{
food = $item[Bat wing chow mein];
main_drink = $item[roll in the hay];
liver_drink = $item[sangria];
umliver_drink = $item[shot of grapefruit schnapps];
}
if ( my_class() == $class[disco bandit] || my_class() == $class[accordion thief] )
{
food = $item[Rat appendix chow mein];
main_drink = $item[rockin' wagon];
liver_drink = $item[dry martini];
umliver_drink = $item[fine wine];
}

void lunch ()
{
eat(foodlimit/5, food);
drink(drunklimit/4, main_drink);
if (drunklimit = 19)
{
drink(1, liver_drink);
}
if (drunklimit = 14)
{
drink(2, unliver_drink);
}
}

void dinner ()
{
drink(1, main_drink);
}

void main ()
{
organs ();
diet ();
lunch ();
// Here goes the adventuring part
dinner ();
}

Any flagrant mistakes?
 

Daeth Eater

New member
I know, I realised later. Now I've got this

int drunklimit;
int foodlimit;
item food;
item main_drink;
item liver_drink;
item unliver_drink;

void organs ()
{

drunklimit = 14;
if( have_skill( $skill[liver of steel]))
{
drunklimit = 19;
}

foodlimit = 15;
if( have_skill( $skill[stomach of steel]))
{
foodlimit = 20;
}
}

void diet ()
{
if ( my_class() == $class[turtle tamer] || my_class() ==

$class[seal clubber] )
{
food = $item[Knob sausage chow mein];
main_drink = $item[slip 'n' slide];
liver_drink = $item[tequila with training wheels];
unliver_drink = $item[shot of orange schnapps];
}
if ( my_class() == $class[pastamancer] || my_class() ==

$class[sauceror] )
{
food = $item[Bat wing chow mein];
main_drink = $item[roll in the hay];
liver_drink = $item[sangria];
unliver_drink = $item[shot of grapefruit schnapps];
}
if ( my_class() == $class[disco bandit] || my_class() ==

$class[accordion thief] )
{
food = $item[Rat appendix chow mein];
main_drink = $item[rockin' wagon];
liver_drink = $item[dry martini];
unliver_drink = $item[fine wine];
}
}

void lunch ()
{
eat(foodlimit/5, food);
drink(drunklimit/4, main_drink);
if (drunklimit == 19)
{
drink(1, liver_drink);
}
if (drunklimit == 14)
{
drink(2, unliver_drink);
}
}

void dinner ()
{
drink(1, main_drink);
}

void main ()
{
organs ();
diet ();
lunch ();
}

Which works great, really. Hope somebody finds it useful. The only thing else I could do is to adapt it to inlude SHC if you have the skill.

Oh, completely unrelated to this, how do do to make a character adventure at X place?
 

Nightmist

Member
[quote author=Daeth Eater link=topic=481.msg2389#msg2389 date=1160007443]
Oh, completely unrelated to this, how do do to make a character adventure at X place?
[/quote]
The Scripting Wiki said:
boolean adventure( int visits, location place )
Visits the desired place the number of times that you wish.
 
Top