CCS/Macro in consult script

holatuwol

Developer
Yeah, the end result is the same (embedding ASH in combat macros), so it's just a matter of whether you view it as a problem of pre-existing CCS that you want to augment with ASH (employ scripts) or as a pre-existing macro that you want to augment with ASH (inlining ASH in a CCS macro).
 

Banana Lord

Member
Personally I find the macro+ash=brighter future direction more appealing than the CCS+ash one. From the point of view of a novice-coder, a macro will do everything and more that a CCS will, macros are built into KoL so I'm not so limited if I can't use mafia for some reason (not to mention the fact that I would be able to more easily adapt my existing macro(s) to the former system than the latter), AND they come with a handy syntax checker, courtesy of mafia, which while not perfect is still very handy.
 

slyz

Developer
In both cases, a KoL macro will be used. The options Hola is presenting are two ways of using ASH to customize the macro that will be generated from your CCS: either you call an ASH "employ script" or you add ASH commands directly in you CCS.
 

Banana Lord

Member
I realise that. I was just saying (poorly, on re-reading) that I prefer Hola's way to Jason's. Not that it matters all that much since, as has been said, the result is the same.
 

zarqon

Well-known member
I don't think the existing CCS system should be complexified at the moment, since it probably should be reworked with regard to round numbers.
 

holatuwol

Developer
Yeah, that was my goal at the start of the combat refactoring. Hopefully I'll be able to merge macrofication and the notion of a 'combat strategy' so that that combat parser just iterates over macrofied actions (and unmacrofiable actions if there's any encountered) without caring about the whole numbering system that CCS used to have since that's almost entirely gone now.
 

Banana Lord

Member
I was trying to use the information I got out of this thread to improve the neocow farming script over in another thread, but calling the consult script below from a CCS (which handles the beginning and end of the fight) fails to use the spooky putty sheet. I get "Banana Lord executes a macro" in the gCLI, and error checking confirms that the if statements are working as they should. So I assume there's something up with the visit_url() line.
PHP:
if(get_property("spookyPuttyCopiesMade") != 5)
	{ 
	if(item_amount($item[spooky putty sheet]) == 0)
		abort("No putty!"); // don't even hit the server for your abort situation
	visit_url("fight.php?action=macro&macrotext="+url_encode("use item spooky putty sheet") ,true,true); 
	}
	else
	print("You're out of putties for today so spooku putty was not used", "blue");
 

jasonharper

Developer
"use item spooky putty sheet" is not a valid macro; the word 'item' doesn't belong in there.

There is absolutely no point in submitting a single action as a macro, anyway - there's no benefit over the existing consult script functions.
 

Banana Lord

Member
Oh d'oh. Thanks. Yes, I realise that, but when I first wrote it I was submitting several actions and subsequently decided to simplify it and never around to changing that.
 

zarqon

Well-known member
There is sometimes a small scripting benefit -- you can index combat actions by macro-ready string and then use a single command to perform any action, rather than needing logic to decide which ASH function to use.

Don't know how that "item" crept in there -- I think that was my fault.
 

heeheehee

Developer
Staff member
There is sometimes a small scripting benefit -- you can index combat actions by macro-ready string and then use a single command to perform any action, rather than needing logic to decide which ASH function to use.

Don't know how that "item" crept in there -- I think that was my fault.

Can't you generally use call, since ASH combat functions all (I think) return a buffer?

Edit: Actually, wait, no, I guess that doesn't work if you're doing something like use_skill(), where you have args, as opposed to attack(), which takes no args.
 
Last edited:

zarqon

Well-known member
Plus, there is no ASH "jiggle" or "summon" (or whatever the macro command for summoning pasta guardians is).
 

Veracity

Developer
Staff member
There should be. What were those developers thinking when they added new CCS actions without adding new ash combat functions? Slackers.
 

Banana Lord

Member
Probably another simple oversight, but the script is using the sheet even when I've maxed out my putties (get_property("spookyPuttyCopiesMade") returns 5).

PHP:
if(get_property("spookyPuttyCopiesMade") != 5)
	{ 
	if(item_amount($item[spooky putty sheet]) == 0)
		abort("No putty!"); // don't even hit the server for your abort situation
	throw_item($item[spooky putty sheet]);	
	}
	else
	print("You're out of putties for today so spooku putty was not used", "blue");
 

Banana Lord

Member
When I tested it in another function it didn't make a difference which type I used. Even so, changing the first line to if(get_property("spookyPuttyCopiesMade") != "5") still fails to not use the putty (I'm sure there's a better way of phrasing that but I'm too tired to think of it!). That WAS the right way to do what you were suggesting wasn't it?
 

zarqon

Well-known member
What you might want to do is build your macro in a buffer as the script goes on (adding pieces bit by bit), and then submit it all at the end. It would not only run faster, it would be closer to your original macro. You could use ASH to determine which bits to include.

PHP:
buffer mac;  // macro in progress

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

// sub lobsterfrogman -- doesn't need to be called because it's inserted already in the correct place
if (last_monster() == $monster[lobsterfrogman] && get_property("spookyPuttyCopiesMade").to_int() < 5 && item_amount($item[spooky putty sheet]) > 0)
   mac.append("use spooky putty sheet; ");

// your shieldbutt-everything code
mac.append("while !pastround 25 && !hpbelow 30; skill shieldbutt; endwhile; abort \"Too many rounds!\"");

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

Banana Lord

Member
Ah, thanks, but for the moment I've abandoned my idea of enhancing my (big) macro with ash until I see what Hola and Jason come up with. Right now I'm trying to improve a much simpler CCS with a consult script (as posted further up).
 

Banana Lord

Member
That code you posted proved useful Zarqon, but I've run into a problem. After adapting it to my current goal of fixing up NeoCowFarm it returns "invalid macro command" and repeatedly attacks when the following is called from a CCS.
PHP:
buffer mac;  // macro in progress 

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

// Stasis with scepter if using hobo monkey -- doesn't need to be called because it's inserted already in the correct place 
if(my_familiar() == $familiar[hobo monkey])
   mac.append(" while !match \"climbs up and sits\" && !pastround 24; item spectre scepter; endwhile; "); 

// Use summon hobo if you can
if(have_equipped($item[hodgman's porkpie hat]) && have_equipped($item[hodgman's lobsterskin pants]) && have_equipped($item[hodgman's bow tie]))
	mac.append(" if hasskill summon hobo underling; skill summon hobo underling; endif; if hasskill ask the hobo for a drink; skill ask the hobo for a drink; endif; if hasskill ask the hobo to tell you a joke; skill ask the hobo to tell you a joke; endif; while !pastround 25; attack with weapon; endwhile; "); 

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

slyz

Developer
You can use Mafia's macro syntax checker by creating a new macro in your account menu and pasting your macro.

For what you posted above, I see the error:
Code:
Line 1: "item" is not a known command; did you mean "use"?
The first part then becomes:
PHP:
" while !match \"climbs up and sits\" && !pastround 24; use spectre scepter; endwhile; "
For the hobo underling summon:
Code:
Line 1: "attack" should not be followed by anything.  Especially not "with weapon"!
Your macro becomes:
PHP:
" if hasskill summon hobo underling; skill summon hobo underling; endif; if hasskill ask the hobo for a drink; skill ask the hobo for a drink; endif; if hasskill ask the hobo to tell you a joke; skill ask the hobo to tell you a joke; endif; while !pastround 25; attack with weapon; endwhile; "
 
Last edited:
Top