From 10b64c4775a27e3025e02c102122cd4cff86dbec Mon Sep 17 00:00:00 2001 From: Jusctsch5 Date: Sat, 7 Mar 2015 17:39:50 -0600 Subject: [PATCH] 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. --- scripts/rpgmana.cs | 12 ++++++++++++ scripts/rpgspells.cs | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/rpgmana.cs b/scripts/rpgmana.cs index e9c9d32..79bdfa6 100644 --- a/scripts/rpgmana.cs +++ b/scripts/rpgmana.cs @@ -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)) diff --git a/scripts/rpgspells.cs b/scripts/rpgspells.cs index 5f6b303..b948e25 100644 --- a/scripts/rpgspells.cs +++ b/scripts/rpgspells.cs @@ -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);