The Neo-Cow Farming Script

Banana Lord

Member
Never mind. We got there in the end! (D'oh). I've updated puttybountyfarm.ash to handle the entire combat, and to deal with any monster while bounty hunting. Now the we don't need anywhere near as much junk in our bounty-related CCSs. This is much better for all sorts of reasons.

As I want to eventually reduce NCF's combat handling to a single consult script and a single CCS, is there a way I can change the void main() { } bit to something like void bounty_combat() { } so that it can be called as a function at an appropriate time by an overarching combat script? Does that make sense?

PHP:
void main( int round, string opponent, string text ) 
	{ 
    buffer mac;  // macro in progress   

    string macro(string mac) // ASH function for submitting a macro   
    	{  
        print( mac ); 
        print( "" ); 
        print( url_encode(mac) ); 
         
        return visit_url("fight.php?action=macro&macrotext="+url_encode(mac), true, true);   
    	}   

	// We want to pickpocket regardless of what we're fighting
	mac.append( 'pickpocket; ');
	
	// Use spooky putty if possible and advisable
	if(get_property("spookyPuttyCopiesMade") != "5") // Check for available putties
		{ 
		if(item_amount($item[spooky putty sheet]) == 0) // Make sure you have a putty sheet
			abort("No putty!"); // don't even hit the server for your abort situation
		if ( item_drops(to_monster(opponent)) contains get_property("currentBountyItem").to_item() ) // Only use putty if the monster drops your current bounty item
			mac.append( 'use spooky putty sheet; ' );
			else
			print("That monster doesn't drop your bounty item so putty was not used", "blue");
		}
		else
		print("You're out of putties for today so spooky putty was not used", "blue");
	
	// Olfact the monster if you can, and if it drops your bounty item
	if( item_drops(to_monster(opponent)) contains get_property("currentBountyItem").to_item() ) // Only olfact if the monster drops your current bounty item
		{
		if(have_skill($skill[transcendent olfaction]))
			mac.append( 'skill transcendent olfaction; ' );
		}
		else
		print("That monster doesn't drop your bounty item so it was not olfacted", "blue");

	// Finish the fight
	mac.append(" while !pastround 25; attack; endwhile; ");

    // finally, submit the macro   
    macro(mac); 
	}
 

Banana Lord

Member
Hah! Figured out what my versioning problem was! Bale, could you remove the bold face from the script title in the third post?

Also, shameless triple post.
 

slyz

Developer
As I want to eventually reduce NCF's combat handling to a single consult script and a single CCS, is there a way I can change the void main() { } bit to something like void bounty_combat() { } so that it can be called as a function at an appropriate time by an overarching combat script? Does that make sense?
You could do a main like this:
PHP:
void main( int round, string opponent, string text ) 
{
    if ( condition ) bounty_combat( int round, string opponent, string text );
    else other_combat( int round, string opponent, string text );
}
You just need to find a way for the script to figure out what condition the current combat has to satisfy. Maybe something like:
PHP:
if ( item_drops( opponent.to_monster() ) contains get_property( "currentBountyItem" ).to_item()  )


Banana Lord said:
Hah! Figured out what my versioning problem was! Bale, could you remove the bold face from the script title in the third post?
I remove the bold from post #3.
 

slyz

Developer
Oh, I hadn't read all your code, sorry :)

I'll change the wording a little to see if it helps.

EDIT: I didn't change the wording. You should do "set _version_NeoCowFarm = " in the gCLI and try again.
 
Last edited:

Banana Lord

Member
Ah! Thanks!

I'm well on track to releasing a stable version. I'll do a quick test run after rollover and, all going well, roll v1.5.0

EDIT: Anyone know what's causing me to get an "I wasnt able to match up a BHH object!" error? I tried it with the original version of the bountyhunting script (with changes to script/CCS names to allow it to run) and got the same error.
 

Banana Lord

Member
Version 1.5.0 released. Fingers crossed all my bounty hunting changes work (I couldn't test the new stuff because something old wouldn't work).

Could someone please test NCF Bountyhunting.ash today (in case it's something to do with today's bounties? I reverted to version 1.3.4 (version pre-dating any recent updates) and got the same error as above, so either it's an existing bug (which is, at present at least, beyond my ability to squish), or something weird at my end. A test run by someone else will give me a better idea of which it is.
 
Last edited:

morwen

New member
Okay, when I tried to run the new stable version, it asked for a value for "int rnd" "string opp" and "string text"

Earlier versions never did this and I have no idea where, if, it says what those values should be.
 

slyz

Developer
Today has bundles of receipts as bounty, and apparently you noticed that the old bounty.txt data file still had "Knob Goble Treasury" as a location, instead of the new "Cobb's Knob Treasury".

I had a peek at NCF Bountyhunting.ash, and you could simplyfy bounty_options() a little bit by creating a straghtforward matcher instead of juggling with group_string() on lines 198-209:
PHP:
item wanted;
matcher bounty_matcher = create_matcher( "<b>[0-9]+ (.+?)</b>", data );
while( bounty_matcher.find() )
{
	wanted = bounty_matcher.group( 1 ).normalize_item();
	todays_options[i] = find_BHH_object(wanted);
	print("LOCATION #" + i + " : " + to_string(todays_options[i].bountyLocation)); 
}

EDIT: now with a simpler regex.
 
Last edited:

morwen

New member
I couldn't run through 1.5.0 (see below about the value requests), but when I tried to revert back to 1.3.4, I got the same BHH error both with the old bounty hunting .ash and then new one.
 

Banana Lord

Member
Okay, when I tried to run the new stable version, it asked for a value for "int rnd" "string opp" and "string text"

Earlier versions never did this and I have no idea where, if, it says what those values should be.

That's being returned by "NCF Combat - Meatfarm.ash". Did you try to run that directly? You should have run "NeoCowFarm.ash". Also it wouldn't be a bad idea to run "NCF Initialize.ash" before you try and use the new version.

@Slyz: I did notice that (because I was looking for it :)), but it didn't fix the problem. Swapping those lines for the code you posted gives: "Unknown variable 'i' (NCF Bountyhunting.ash, line 203)".

EDIT:
I couldn't run through 1.5.0 (see below about the value requests), but when I tried to revert back to 1.3.4, I got the same BHH error both with the old bounty hunting .ash and then new one.
Thanks for that!
 
Last edited:

Winterbay

Active member
Try this perhaps?
PHP:
item wanted;
int i = 1;
matcher bounty_matcher = create_matcher( "<b>[0-9]+ (.+?)</b>", data );
while( bounty_matcher.find() )
{
    wanted = bounty_matcher.group( 1 ).normalize_item();
    todays_options[i] = find_BHH_object(wanted);
    print("LOCATION #" + i + " : " + to_string(todays_options[i].bountyLocation)); 
    i = i + 1;
}

I thin "i" may be a bad name for that variable though if you're using that in a loop somewhere else. Perhaps rename it "number" or "order" or soemthing.
 

slyz

Developer
Right, sorry:
PHP:
item wanted;
int i;
matcher bounty_matcher = create_matcher( "<b>[0-9]+ (.+?)</b>", data );
while( bounty_matcher.find() )
{
	wanted = bounty_matcher.group( 1 ).normalize_item();
	todays_options[i] = find_BHH_object(wanted);
	print("LOCATION #" + i + " : " + to_string(todays_options[i].bountyLocation));
	i += 1;
}

Regarding the "I wasnt able to match up a BHH object!" problem, I guess something is wrong in the data file, but it's not one of today's bounty items. Which bounties were available when you had the problem?

EDIT: so many server hits in NCF Bountyhunting.ash! Why not visit bhh.php ONCE, and use that in all the script?

EDIT2: I'm not getting the error, even after having accepted one of the bounties.
 
Last edited:

Banana Lord

Member
Mine is much closer than that... I'm going to google that word now xD

Morwen, how is your issue going?

Thanks Slyz! That was my guess too, but I couldn't see anything obvious. The problem occurred today (after rollover), with the current bounties (Treasury, Fernswarthy, McLarge).
 

slyz

Developer
Try adding
PHP:
print( "grabbing info for " + wanted );
at the beginning of find_BHH_object() so you can see which item it is having problems with.
 

slyz

Developer
I'm stumped, I can't reproduce this.

Try to re-download bounty.txt? I'm using the one provided in v1.5, the only thing I changed is "Knob Goblin Treasury" to "Cobb's Knob Treasury".

Or try changing
PHP:
if(bountymap[i].bountyItem == wanted)
to
PHP:
if(bountymap[i].bountyItem == wanted.to_item())
 
Top