You're not using the counter for anything. By "check", I meant to explicitly use an if statement to check if it's equal to 0.
if (counter == 0)
That for loop is also still wrong. It will always run for as much max MP as Link has, regardless of how much he's missing. It also all runs in one frame, and I think you wanted the MP refill to be gradual?
global script Slot2
{
void run(){
int counter = 0;
int tempMP = Link->MP;
int magic_cooldown;
while (true){
Enemies(); // Zero Damage Enemies
counter = (counter + 1) % 120;
if(counter == 0 && magic_cooldown == 0 && Link->MP < Link->MaxMP){
Link->MP++;
}
if (Link->MP < tempMP){
magic_cooldown = 300;
}
if (magic_cooldown > 0){
magic_cooldown--;
}
tempMP = Link->MP;
Waitframe();
}
}
}
This will give Link 1 MP every 2 seconds. There's 32 MP per magic container, so unless you've adjusted the MP cost for all the items in your quest similarly you'll want to notch those numbers up. I also added in the cooldown timer you were talking about, which will activate whenever Link uses MP for any reason. If you want to go through the tedium of adding an action script to every magic item, you could make the cooldown timer a global variable and have individualized timers for every item.
Edited by Lejes, 24 February 2015 - 04:52 PM.