Mp cost: Difference between revisions
Jump to navigation
Jump to search
imported>Grotfang mNo edit summary |
imported>Heeheehee Code sample with plenty of documentation/explanatory comments. |
||
Line 19: | Line 19: | ||
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.| | 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>}}| | |||
}} | }} |
Revision as of 04:24, 12 March 2010
Function Syntax
- 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.