Hello there, I'm posting here because I'm running into issues with a looping variable system I designed for a custom magic system. It was working fine until the point where I decided to make it more complex and changed the number of variables the system was keeping track of from 1 to 4.
MP would go up an amount every round and was used for most custom script spells.
TP would only go up during combat every round and would be reset to 0 if not in combat. It was used for the more advanced spells.
LP is a counter that would go up each time a spell was used. It would also reset to 0 once combat ended.
And AL was used for the specific spell Auto-Life, which actually works not how it sounds. That spell simply tags the player as Immortal and then fires when they're at 1 hp.
Anywho, those are the variables and the functions they are supposed to follow. However, when I updated the script to include them all it suddenly decided to break, and I can't understand why. Here is the script that hopefully someone better at scripting than I can discover my mistakes and explain them to me.
#include "nw_i0_spells"
#include "x0_i0_spells"
object oPC = GetItemActivator();
object oItem = GetItemActivated();
int iLevel = GetHitDice(oPC);
int iIntel = GetAbilityModifier(ABILITY_INTELLIGENCE , oPC);
int iMP = (10 + iLevel + iIntel) * 2;
int cMP;
string MP;
int tMP;
int cTP;
string TP;
int cLP;
string LP;
string AL;
effect eTime = EffectTimeStop();
effect eVis1 = EffectVisualEffect(VFX_FNF_NATURES_BALANCE);
effect eVis2 = EffectVisualEffect(VFX_FNF_TIME_STOP);
void mana()
{
if (GetCurrentHitPoints(oPC) > 1)
{
if (GetLocalInt(oItem, AL) == 3)
{
SendMessageToPC(oPC, "Autolife: Delta");
}
if (GetLocalInt(oItem, AL) == 2)
{
SendMessageToPC(oPC, "Autolife: Beta");
}
if (GetLocalInt(oItem, AL) == 1)
{
SendMessageToPC(oPC, "Autolife: Alpha");
}
}
if (GetCurrentHitPoints(oPC) == 1)
{
if (GetLocalInt(oItem, AL) == 3)
{
SendMessageToPC(oPC, "Autolife: Delta");
SetLocalInt(oItem, MP, iMP);
ExecuteScript("healtime",oPC);
ExecuteScript("shield",oPC);
ExecuteScript("reflect",oPC);
SetLocalInt(oItem, AL, 0);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oPC);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTime, oPC, 30.0);
DelayCommand(7.0, SetImmortal(oPC, FALSE));
}
if (GetLocalInt(oItem, AL) == 2)
{
SendMessageToPC(oPC, "Autolife: Beta");
SetLocalInt(oItem, MP, iMP);
ExecuteScript("healtime",oPC);
ExecuteScript("shield",oPC);
ExecuteScript("reflect",oPC);
SetLocalInt(oItem, AL, 0);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oPC);
DelayCommand(7.0, SetImmortal(oPC, FALSE));
}
if (GetLocalInt(oItem, AL) == 1)
{
SendMessageToPC(oPC, "Autolife: Alpha");
ExecuteScript("healtime",oPC);
SetLocalInt(oItem, AL, 0);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oPC);
DelayCommand(7.0, SetImmortal(oPC, FALSE));
}
}
if (GetIsInCombat(oPC) == TRUE)
{
cTP = GetLocalInt(oItem, TP) + 1;
SendMessageToPC(oPC, "TP: " + IntToString(cTP));
DelayCommand(1.0, SetLocalInt(oItem, TP, cTP));
if (GetLocalInt(oItem, LP) >
{
SendMessageToPC(oPC, "Delta");
}
else if (GetLocalInt(oItem, LP) > 4 && GetLocalInt(oItem, LP) < 9)
{
SendMessageToPC(oPC, "Beta");
}
else if (GetLocalInt(oItem, LP) < 5)
{
SendMessageToPC(oPC, "Alpha");
}
}
if (GetIsInCombat(oPC) == FALSE)
{
SendMessageToPC(oPC, "Time Out");
SetLocalInt(oItem, TP, 0);
SetLocalInt(oItem, LP, 0);
}
// if (tMP == 3)
// {
// SendMessageToPC(oPC, "Mana System Deactivated");
// }
if (GetLocalInt(oItem, MP) < 1)
{
SetLocalInt(oItem, MP, 1);
SendMessageToPC(oPC, "Mana System Initiated");
DelayCommand(6.0, mana());
}
else if (GetLocalInt(oItem, MP) == iMP)
{
SendMessageToPC(oPC, "Mana at full capacity");
tMP++;
DelayCommand(6.0, mana());
}
else if (GetLocalInt(oItem, MP) > 0)
{
cMP = GetLocalInt(oItem, MP) + 3;
SendMessageToPC(oPC, "MP: " + IntToString(cMP));
DelayCommand(1.0, SetLocalInt(oItem, MP, cMP));
DelayCommand(6.0, mana());
}
}
void main()
{ int tMP = 0;
SetLocalInt(oItem, TP, 0);
SetLocalInt(oItem, LP, 0);
mana();
}