Miscellaneous Functions: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>ZammyWarrior
No edit summary
imported>ZammyWarrior
No edit summary
Line 1: Line 1:
== Part 6 - Miscellaneous ==
== Part 6 - In-combat functions for consulting scripting ==
<p><em>Mostly internal stuff. Some good for everyone, some only for ASH wizards.</em></p>
These functions are for use when handling a battle in a script using your custom combat settings. There is very little documentation of how to do this, and for most people these functions are useless.


<p><strong>void print( string helloworld )</strong><br />
<p><strong>string attack()</strong><br />
Prints the given string to the graphical CLI window and to the status line of the main Adventuring window</p>
<strong>string runaway()</strong><br />
<strong>string use_skill(  skill touse )</strong><br />
<strong>string throw_item(  item tothrow )</strong><br />
<strong>string throw_items(  item tothrow1,  item tothrow2 )</strong><br />
Returns a string containing the html response from sending the appropriate url request for the associated action while in battle.</p>


<p><strong>boolean cli_execute( string command )</strong><br />
<p><strong>boolean use_skill( int count, skill touse )</strong><br />
Executes the given command as if it were entered into the graphical CLI window. This can be used for CLI commands or, if you&#8217;re careful and not an asshat, for raw URLs.<br />
Will loop the specified number of times using the specified skill, never reconsulting the script until the loop is complete. This function is handled differently when not in battle.<br />
See the [http://kolmafia.sourceforge.net/scripting.html CLI manual] for more details.<br />
See [[Skills and Effects]]<br /></p>
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_4:_Hedging|Hedging]]</p>


<p><strong>void wait( int delay )</strong><br />
<p><strong>element monster_attack_element()</strong><br />
Does nothing for the desired number of seconds.</p>
<strong>element monster_defense_element()</strong><br />
Returns the element that the monster attacks with, or defends against accordingly.</p>


<p><strong>string get_property( string key )<br />
<p><strong>int monster_attack()</strong><br />
boolean set_property( string key, string value )</strong><br />
<strong>int monster_defense()</strong><br />
Gets or sets a stored property from your character&#8217;s .kcs file.<br />
<strong>int monster_hp()</strong><br />
The KoLmafia [[%28ASHRM%29_KoLMafia_Properties|properties]] page contains details on many of the keys that are available for access.<br />
returns the (current?) attack, defense, and hp of the monster.</p>
<em>Sample</em>:[[%28ASHRM%29_Code_Samples#Sample_2:_Battlefield_gather|Battlefield_gather]]</p>


<p><strong>boolean file_to_map( string file_to_load, map map_to_fill )<br />
<p><strong>boolean will_usually_miss()</strong><br />
boolean map_to_file( map map_to_save, string file_to_write )</strong><br />
<strong>boolean will_usually_dodge()</strong><br />
Loads and saves maps as tab-delimited text files.</p>
Returns if you will normally miss, or will usually be missed in battle.</p>
 
<p><strong>int random( int range )</strong><br />
Generates a random integer between 0 and (range-1) inclusive.</p>
 
<p><strong>int round( float ratio )<br />
int floor( float ratio )<br />
int ceil( float ratio )<br />
int truncate( float ratio )</strong><br />
Returns an integer near the given real number.  Respectively, it returns the nearest, next lowest, next highest, and decimal-stripped integer.</p>
 
<p><strong>int count( map )</strong><br />
Returns the number of defined keys for the aggregate.</p>
 
<p><strong>void clear( map )</strong><br />
Remove all keys from a map. </p>
 
<p><strong>void disable( string function_name )<br />
void enable( string function_name )</strong><br />
For debugging purposes disables or enables the indicated function</p>
 
<p><strong>float square_root( float value )</strong><br />
returns the square root of the passed value</p>
 
<p><strong>string today_to_string()</strong><br />
Returns today&#8217;s (real-world) date in the form yyyymmdd. It is based on your computer&#8217;s system date</p>

Revision as of 20:45, 9 September 2007

Part 6 - In-combat functions for consulting scripting

These functions are for use when handling a battle in a script using your custom combat settings. There is very little documentation of how to do this, and for most people these functions are useless.

string attack()
string runaway()
string use_skill( skill touse )
string throw_item( item tothrow )
string throw_items( item tothrow1, item tothrow2 )
Returns a string containing the html response from sending the appropriate url request for the associated action while in battle.

boolean use_skill( int count, skill touse )
Will loop the specified number of times using the specified skill, never reconsulting the script until the loop is complete. This function is handled differently when not in battle.
See Skills and Effects

element monster_attack_element()
element monster_defense_element()
Returns the element that the monster attacks with, or defends against accordingly.

int monster_attack()
int monster_defense()
int monster_hp()
returns the (current?) attack, defense, and hp of the monster.

boolean will_usually_miss()
boolean will_usually_dodge()
Returns if you will normally miss, or will usually be missed in battle.