auto-Pet-buffing spray

mrmooge88

New member
I'm a noob to scripting. I've made a few basic scripts, but nothing using in ash. I've looked at Xylpher's very helpful guide and I have tried to write a script based off his healing script. I made my changes here and there (I kinda knew what I was doing) and produced this script.

Code:
void use_pet-buff( int amount )
	{
	    if ( item_amount( $item[Knob Goblin pet-buffing spray] ) < amount )
	    {
	        buy( amount - item_amount( $item[Knob Goblin pet-buffing spray] ), $item[Knob Goblin pet-buffing spray] );
	    }
	    use( amount, $item[Knob Goblin pet-buffing spray] );
	}

	void main()
	{
	    while( my_maxhp() > my_hp() )
	    {
	        int tospray = $effect[Heavy Petting] - my_adventures();
	        int amount = tospray / 10;
	        if ( amount == 0 )
	        {
	            amount = 1;
	        }
	        use_pet-buff( amount );
	    }
	}

I tried to use it but it didn't work. I know what ever I mistake(s) I made was/were a noobish one(s).

I want it to take the amount of adventures I have and divide it by 10 and use that many, but first use the one's in my inventory before going out to buy any.

Please give me corrections and tell me why the changes need to be done. I am sure there are a bunch.
 

Nightmist

Member
[quote author=mrmooge88 link=topic=718.msg3384#msg3384 date=1169419216]
Please give me corrections and tell me why the changes need to be done. I am sure there are a bunch.
[/quote]
Wow you learn something everyday, on my V10.1 (Jan 7th re-release), it seems you can't have functions that use "-" in its name. (So you will need to change that to a "_" or such) Thats not really a error on your part though.
Once you change the name of the function theres only one other error, $effect[Heavy Petting] is just a effect, not howmuch of that effect you have. (The function to use to find how many turns of a effect is remaining in on this page: http://www.wiki.kolmafia.us/index.php/(ASHRM)_Skills_and_Effects , its the 2nd function incase you get stuck... Yes shameless advertising of the new wiki >>)

Oh and just noticed that you will want to change this part "while( my_maxhp() > my_hp() )", it loops aslong as your not at max hp... (And since your script doesn't heal, it will just infinitely loop since you will never reach max HP, change it to something that checks if the number of turns of heavy petting you have left is less than your total adventures)

Those are the basic errors, if your looking to improve the script even more then you can start adding price checks and checks to make sure you have access to the buffing spray.
 

mrmooge88

New member
Changes
---------
omitted the "-" one lines 1 and 20 (I think that is what you were talking about)
got the newest version of the Mafia (10.2 I was on 10.0)
changed line 12 to: while( my_adventures() > int have_effect[Heavy Petting] )

I got this error
"Expected ;, found - (PetBuffing.ash, line 1)"

Thank you Nightmist for taking the time to help me correct my script.


[quote author=Nightmist link=topic=718.msg3386#msg3386 date=1169432573]
Those are the basic errors, if your looking to improve the script even more then you can start adding price checks and checks to make sure you have access to the buffing spray.
[/quote]

price checks? wouldn't that be considered mallbotting (or what ever people call it when a bot scans the mall to buy cheep stuff to sell at higher prices)
 

Nightmist

Member
[quote author=mrmooge88 link=topic=718.msg3396#msg3396 date=1169505906]
...Snip
[/quote]
Hmmm mind attaching the updated file? It's really kind of hard debugging something when you probably have a different version of the script as the person thats trying to use it >>.

Hmm use
Code:
have_effect( $effect[Heavy Petting])
instead of
Code:
int have_effect[Heavy Petting]
(The int at the start is just to tell us what type of value it returns so we don't need it in actual code, and have_effect expects a "effect" value as input and to it Heavy Petting is just 2 variables, Heavy and Petting, you have to tell mafia its a effect by putting it inside $effect[EffectName])

Yes I did mean the "-" on lines 1 and 20. Hmm curious, your sure you removed and saved the file before running it? Because the error seems to be saying it found a "-" on line 1.


By price checks I meant like when you don't have mall access your going to be using the lab store and the total cost of sprays when your buying from a NPC store is easily predicted. (Then you might also want checks to see if you can even get access to the lab store)
 

Metraxis

Member
To be kind to the server, of course, you'd want to minimize the number of requests you make, so something like this might be a place to start:
Code:
{Verifying the presence of the Elite Guard Uniform and Lab Key are left as an exercise for the reader.  Consider: In what situations will have_outfit("Knob Goblin Elite Guard Uniform") give the wrong result?}

int min(int a, int b) {
    if(a > b) { return b; }
    return a;
}

void main() {
    use(min((my_adventures()+9-have_effect($effect[Heavy Petting]))/10,my_meat()/300), $item[Knob goblin pet-buffing spray]);
}
 
Top