You need to have standard short score(sc), trigger to work in Bat Client. Standard sc is:
hp: {colorhp} (<maxhp>) [{diffhp}] sp: {colorsp} (<maxsp>) [{diffsp}] ep: {colorep} (<maxep>) [{diffep}] cash: <cash> [{diffcash}] exp: <exp> [{diffexp}]
SCRIPT_NAME = "balance";
SCRIPT_DESC = "Pisano's Balance Triggers, Improved by Valger";
SCRIPT_OFF = false;
// you need to have following sc!
//hp: {colorhp} (<maxhp>) [{diffhp}] sp: {colorsp} (<maxsp>) [{diffsp}] ep: {colorep} (<maxep>) [{diffep}] cash: <cash> [{diffcash}] exp: <exp> [{diffexp}]
/**
* author: pisano
* last updated: 1/31/2018
* version: 0.2
*/
Color green = new Color(0, 127, 0);
Color red = new Color(200, 50, 50);
long lastBalanceTime = 0;
hp=0;
sp=0;
diff=0;
canBalance=false;
lowerLimit = 300;
upperLimit = 400;
void help() {
clientGUI.printText("general", "*************************\n");
clientGUI.printText("general", "Balance triggers Help\n");
clientGUI.printText("general", "\nMake a hotkey or command for \"$balance\", this will display the balance timer.\n");
clientGUI.printText("general", "You can balance every 25 minutes. When you balance the timer will reset.\n");
clientGUI.printText("general", "*************************\n");
}
void bootup()
{
clientGUI.printText("general", "LOADED: " + SCRIPT_NAME + " ('$"+SCRIPT_NAME+".help' for more info.)\n");
triggerManager.newTrigger("hpTrig",
"hp: ([0-9]+) \\([0-9]+\\) \\[(|[-]0-9|[+]0-9]+)\\] sp: ([0-9]+) \\([0-9]+\\) \\[|[-]0-9|[+]0-9]+\\] ep: [0-9]+ \\([0-9]+\\) \\[|[-]0-9|[+]0-9]+\\] cash: [0-9]+ \\[|[-]0-9|[+]0-9]+\\] exp: [0-9]+ \\[|[-]0-9|[+]0-9]+\\]$",
"$"+SCRIPT_NAME+".hpFunc");
triggerManager.newTrigger("balance_reset",
"^You feel balanced.$",
"$"+SCRIPT_NAME+".resetBalanceTimer");
// when you wear sleeves it starts the timer over again.
triggerManager.newTrigger("balance_reset2",
"^You wear a pair of pure white flowing sleeves",
"$"+SCRIPT_NAME+".resetBalanceTimer");
triggerManager.newTrigger("balance",
"^You feel balanced.$",
"", false, true, false,
new Color[] { green }, Font.PLAIN);
// Balance timer not ready yet.
triggerManager.newTrigger("balance_unable",
"^The sleeves seem unable to grant balance at the time.$",
"", false, true, false,
new Color[] { red }, Font.PLAIN);
// Balance available, but you are at max health/sps
triggerManager.newTrigger("balance_unable2",
"^The sleeves are unable to balance you further.$",
"", false, true, false,
new Color[] { red }, Font.PLAIN);
resetBalanceTimer();
}
void hpFunc(){
hp = Integer.parseInt(vars.get(1));
sp = Integer.parseInt(vars.get(3));
diff = hp-sp;
if(canBalance) {
if(diff > 100 && diff < lowerLimit) {
clientGUI.printText("general", "Not recomended to balance. Diff is "+diff+"\n", "CC8800");
}
if(diff > lowerLimit && diff < upperLimit){
clientGUI.printText("general", "BALANCE now. Diff is "+diff+"\n", "22cc22");
clientGUI.printText("general", "BALANCE now. Diff is "+diff+"\n", "22cc22");
}
if(diff > upperLimit && diff < 470) {
clientGUI.printText("general", "Not recomended to balance. Diff is "+diff+"\n", "CC8800");
}
}
}
void resetBalanceTimer() {
lastBalanceTime = System.currentTimeMillis();
clientGUI.printText("general", "Reset Balance timer.\n" );
startBalanceTimer();
}
void showBalanceTimer() {
// clientGUI.printText("general", "[balance] showBalanceTimer()\n", "ff0000");
long now = System.currentTimeMillis();
long elapsed = now - lastBalanceTime;
Date timeSinceLastBalance = new Date(elapsed);
//clientGUI.doCommand("party report " + lastTime.toString());
//long seconds = (elapsed / 1000) % 60;
long milliseconds = elapsed;
int seconds = (int) (milliseconds / 1000) % 60 ;
int minutes = (int) ((milliseconds / (1000*60)) % 60);
int hours = (int) ((milliseconds / (1000*60*60)) % 24);
String secondsStr = seconds < 10 ? "0" + seconds : "" + seconds;
String timeStr = minutes + ":" + secondsStr;
if (hours > 0) {
timeStr = hours + ":" + timeStr;
}
clientGUI.printText("general", "*** REPORT: Last Balance was: " + timeStr + " ago. (Can balance every 25 min)\n", "CC8800");
// clientGUI.doCommand("party report Last Balance was...");
}
void run() {
showBalanceTimer();
// clientGUI.printText("general", "[balance] run()\n", "ff0000");
}
void startBalanceTimer() {
clientGUI.printText("general", "starting balance timer\n", "ff0000");
canBalance=false;
try {
int seconds = 25*60; // 25 mins
new CommandThread(seconds, "ignore");
} catch (Exception e) {
clientGUI.printText("general", "----------Failed to run $threads script: " + e, "ff0000");
}
}
public class CommandThread extends Thread {
int seconds;
String command;
public CommandThread(int seconds, String command) {
this.seconds = seconds;
this.command = command;
start();
}
public void run() {
//clientGUI.printText("general", "[balance] command thread run\n", "ff0000");
// The sleep method in threads throw an exception we must catch.
try {
sleep(seconds * 1000); // Sleep x ms
} catch (Exception e) {
clientGUI.printText("general", "Eeeek, exception occured in our thread\n");
}
// Now we will issue the command by sending it over the net object
// to the server. The net object is one of the defined variables that
// all scripts have access to.
clientGUI.printText("general", "Can Balance Again\n", "22cc22");
canBalance=true;
// net.send(command);
}
}