I know most of you pi users use this as your run energy alternative [Only registered and activated users can see links. ]
which uses process, so i thought id convert it to a task for ya to help you yet again remove something out of process and hopefully help you understand that there are always alternatives than just throwing things in process
Code:
package com.divine.fate.main.cycle.event;
import com.divine.fate.main.cycle.CycleEvent;
import com.divine.fate.main.cycle.CycleEventContainer;
import game.model.entity.players.Player;
public class RunEnergyTask extends CycleEvent {
private Player player;
public RunEnergyTask(Player player) {
this.player = player;
}
@Override
public void execute(CycleEventContainer container) {
if (player.playerEnergy == 100 || player.playerEnergy > 100) {
container.stop();
}
if (player.playerEnergy < 100 && !player.isRunning()) {
if (System.currentTimeMillis() > player.getPA()
.getAgilityRunRestore() + player.lastRunRecovery) {
player.playerEnergy++;
player.lastRunRecovery = System.currentTimeMillis();
player.getPA().sendFrame126(player.playerEnergy + "%", 149);
}
}
}
@Override
public void stop() {
player.playerEnergy = 100;
}
}
now just call the task under where you have this declared, runEnergy--;
[Only registered and activated users can see links. ] [Only registered and activated users can see links. ] [Only registered and activated users can see links. ]
iirc even pi has support for attaching objects to tasks so checking is not needed, all tasks with the attached player will be stopped automatically when the player logs out
he doesn't seem to be attaching the player instance though lol
iirc even pi has support for attaching objects to tasks so checking is not needed, all tasks with the attached player will be stopped automatically when the player logs out
he doesn't seem to be attaching the player instance though lol
I'm not sure what you're meaning by me not attaching the player instance. I am currently calling it as
CycleEventContainer.getSingleton().addEvent(this, new RunEnergyTask(this), 1);
The first this is in the field of where you specify the object owner, is it not?