Difference between revisions of "Mp cost"

From Kolmafia
Jump to navigation Jump to search
(Created page.)
 
imported>Bale
m
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''int mp_cost([[skill]] touse)'''
+
{{
 +
#vardefine:name|mp_cost}}{{
 +
#vardefine:return_type|int}}{{
  
Will return the MP cost to cast the specified skill.
+
FunctionPage|
  
MP reduction items are taken into account.
+
name={{#var:name}}|
  
<code>
+
function1={{Function|
mp_cost($skill[Empathy]);
+
name={{#var:name}}|
</code><br>
+
aggregate={{#var:aggregate}}|
Will return the MP a cast of empathy will cost.
+
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|skill|use_me}}|
 +
p1desc={{Pspan|use_me}} is the skill to check the cost of|
 +
}}|
 +
 
 +
function_description=Returns the current MP cost for the next cast of the given skill {{pspan|use_me}} with all current MP cost modifiers accounted for.|
 +
 
 +
code1={{CodeSample|
 +
title=Semi-practical Example|
 +
description=Burns MP gained from adventuring by casting Summon BRICKOs as many times as possible.|
 +
code=
 +
<syntaxhighlight>
 +
boolean brickoCaster( int adv_to_use ) {
 +
  if(have_skill($skill[Summon BRICKOs]) return false;
 +
  // You can't exactly burn MP by casting Summon BRICKOs if you don't have the skill, Einstein!
 +
  int c = to_int(get_property("libramSummons"));
 +
  int i = 0;
 +
  while (my_mp()-12>(i*(i+1)*(i+2)/6)-(i*(i-1)/2)-(c*(c+1)*(c+2)/6)-(c*(c-1)/2)) {
 +
  // This bit calculates how many times you can cast Summon BRICKOs before beginning the adventuring loop.
 +
      i=i+1;
 +
  }
 +
  use_skill(i, $skill[Summon BRICKOs]);
 +
  while ( adv_to_use > 0 ) {
 +
      adventure(1, $location[Giants Castle]);
 +
      if ( my_mp() > mp_cost($skill[Summon BRICKOs]) + 12 )
 +
      // We're leaving this much mana for Disco Nirvana, which has been worked into your CCS (if you're a DB), right?
 +
        use_skill(1, $skill[Summon BRICKOs]);
 +
      adv_to_use = adv_to_use - 1;
 +
  }
 +
  return true;
 +
}
 +
 
 +
// Note: This scriptlet will use a specified number of turns in the Giant's Castle, assuming you can adventure there.
 +
</syntaxhighlight>}}|
 +
 
 +
}}
 +
 
 +
[[Category:Skills and Effects]]

Latest revision as of 22:14, 21 May 2010

Function Syntax

int mp_cost(skill use_me )

  • use_me is the skill to check the cost of

Returns the current MP cost for the next cast of the given skill use_me with all current MP cost modifiers accounted for.

Semi-practical Example

Burns MP gained from adventuring by casting Summon BRICKOs as many times as possible.

boolean brickoCaster( int adv_to_use ) {
   if(have_skill($skill[Summon BRICKOs]) return false;
   // You can't exactly burn MP by casting Summon BRICKOs if you don't have the skill, Einstein!
   int c = to_int(get_property("libramSummons"));
   int i = 0;
   while (my_mp()-12>(i*(i+1)*(i+2)/6)-(i*(i-1)/2)-(c*(c+1)*(c+2)/6)-(c*(c-1)/2)) {
   // This bit calculates how many times you can cast Summon BRICKOs before beginning the adventuring loop.
      i=i+1;
   }
   use_skill(i, $skill[Summon BRICKOs]); 
   while ( adv_to_use > 0 ) {
      adventure(1, $location[Giants Castle]);
      if ( my_mp() > mp_cost($skill[Summon BRICKOs]) + 12 )
      // We're leaving this much mana for Disco Nirvana, which has been worked into your CCS (if you're a DB), right?
         use_skill(1, $skill[Summon BRICKOs]);
      adv_to_use = adv_to_use - 1;
   }
   return true;
}

// Note: This scriptlet will use a specified number of turns in the Giant's Castle, assuming you can adventure there.