T2RPG: Write RestoreMana method

Provide method to restore mana and use it as a refund when casting Flow
and Bound more than once during its duration. The application of this
method in this way is kind of a kludge, but it works and the method is
definitely helpful.
This commit is contained in:
Jusctsch5 2015-03-07 17:39:50 -06:00
parent 58bd654aa9
commit 10b64c4775
2 changed files with 17 additions and 3 deletions

View file

@ -19,6 +19,18 @@ function refreshMANA(%client, %value)
{
setMANA(%client, (fetchData(%client, "MANA") - %value));
}
// Positively increase mana and not worry about overrunning the maximum allowed.
function restoreMANA(%client, %value)
{
%maxMana = fetchData(%client, "MaxMANA");
%currentMana = fetchData(%client, "MANA");
if (%value + %currentMana > %maxMana)
setMANA(%client, %maxMana);
else
setMANA(%client, %currentMana + %value);
}
function refreshMANAREGEN(%client)
{
if(isobject(%client) && isobject(%client.player))

View file

@ -1581,6 +1581,7 @@ function DoFlowSpellCast(%client, %spell, %sdata, %params)
// Make sure an existing flow isn't active.
if (%client.flowActive == true)
{
restoreMANA($spelldata[%sdata, Cost]);
return;
}
@ -1604,7 +1605,7 @@ function DoFlowSpellCast(%client, %spell, %sdata, %params)
%client.player.getDataBlock().minImpactSpeed += %increase;
// Update that skill had been successfully cast
UseSkill(%client, $skill::NeutralCasting, true, true, 1, false);
// UseSkill(%client, $skill::NeutralCasting, true, true, 1, false);
// Set end of skill to terminate bonuses, want to close it slightly before.
%duration = $spelldata[%sdata, duration] - (1 * 1000);
@ -1631,7 +1632,8 @@ function DoBoundSpellCast(%client, %spell, %sdata, %params)
// Make sure an existing Bound isn't active.
if (%client.BoundActive == true)
{
return;
restoreMANA($spelldata[%sdata, Cost]);
return;
}
%client.BoundActive = true;
@ -1649,7 +1651,7 @@ function DoBoundSpellCast(%client, %spell, %sdata, %params)
// Update that skill had been successfully cast
UseSkill(%client, $skill::NeutralCasting, true, true, 1, false);
// UseSkill(%client, $skill::NeutralCasting, true, true, 1, false);
// Set end of skill to terminate bonuses, want to close it slightly before.
%duration = $spelldata[%sdata, duration] - (1 * 1000);