import <Zlib.ash>
import <NCF Bountyhunting.ash> 
boolean USE_PUTTY = to_boolean(vars["neocowfarm_puttybounty"]);
BountyInfo currentBounty = find_BHH_object( get_property( "currentBountyItem" ).to_item() ); 
void main( int round, string opponent, string text ) 
	{    
    buffer mac;  // macro in progress   
    string macro(string mac) // ASH function for submitting a macro   
    	{  
		// Uncomment these when bug testing
#		print( mac ); 
#		print( "" ); 
#		print( url_encode(mac) );
         
        return visit_url("fight.php?action=macro¯otext="+url_encode(mac), true, true);   
    	}
	// We want to pickpocket regardless of what we're fighting
	mac.append( 'pickpocket; ');
	
	// Use spooky putty if advisable
	if(USE_PUTTY)
		{
		if(get_property("spookyPuttyCopiesMade") != "5") // Check for available putties
			{ 
			if(item_amount($item[spooky putty monster]) == 1)
				abort("You have a spooky putty monster, use it!");
			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(opponent.to_monster()) contains get_property("currentBountyItem").to_item() && currentBounty.bountyTarget - item_amount(currentBounty.bountyItem) > 1 ) 
 ) // 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");
		}
		else
		print("You have opted not to use putty to speed up bounty hunting", "blue");
	
	// Olfact the monster if you can, and if it drops your bounty item
	if(item_drops(opponent.to_monster()) 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); 
	}