SCRIPT_NAME = "demon_control";
SCRIPT_DESC = "Demon control by Valger";
SCRIPT_OFF = false;
boolean demon_on = false;
//you need your pesonal times. Check with clock whats yours
int personal_demon_drain_time_from_drain = 115;
int personal_demon_drain_time_from_control = 83;
int time=0;
int count=0;
void bootup()
{
triggerManager.newTrigger("demon_gone",
"You succeed in the banishment!",
"$"+SCRIPT_NAME+".demonGone");
triggerManager.newTrigger("demon_gone2",
"You die.",
"$"+SCRIPT_NAME+".demonGone");
triggerManager.newTrigger("demon_summoned",
"You chant 'I command you demon to come and serve me! Come now or suffer",
"$"+SCRIPT_NAME+".demonSummoned");
triggerManager.newTrigger("demon_control",
"^You feed ([ A-ZDEVa-zde',._-]+)'s spider demon's hunger with your ritual.",
"$"+SCRIPT_NAME+".demonControl");
triggerManager.newTrigger("demon_drain",
"^([ A-ZDEVa-zde',._-]+)'s spider demon draws power from you.",
"$"+SCRIPT_NAME+".demonDrain");
triggerManager.newTrigger("inBattle",
"^\\*+ Round ([0-9]+) \\*+$",
"$"+SCRIPT_NAME+".demonDrain");
triggerManager.newTrigger("queenSmiles",
"^Spider Queen smiles upon you and helps you control the demon.$",
"$"+SCRIPT_NAME+".demonDrain");
}
void demonGone() {
demon_on = false;
clientGUI.printText("general", "DEMON GONE\n", "22cc22");
}
void demonSummoned() {
demon_on = true;
clientGUI.printText("general", "DEMON summoned\n", "22cc22");
startControlTimer();
}
void demonControl() {
demon_on = true;
time=personal_demon_drain_time_from_control;
startControlTimer();
}
void demonDrain() {
time=personal_demon_drain_time_from_drain;
startControlTimer();
}
void startControlTimer() {
count=count+1;
int seconds = time;
//clientGUI.printText("general", "starting control timer. time left: "+seconds+"seconds \n", "ff0000");
try {
//clientGUI.printText("general", "seconds: "+seconds+"\n", "ff0000");
new CommandThread(seconds, "ignore", count);
//clientGUI.printText("general", "starting control timer "+CommandThread.getThread().getThreadName()+" \n", "ff0000");
} catch (Exception e) {
clientGUI.printText("general", "----------Failed to run $threads script: " + e, "ff0000");
}
}
public class CommandThread extends Thread {
int seconds;
String command;
int counter;
public CommandThread(int seconds, String command, int counter) {
this.seconds = seconds;
this.command = command;
this.counter = counter;
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", "counter: "+counter+"\n", "64b2c6");
//clientGUI.printText("general", "count: "+count+"\n", "64b2c6");
if(demon_on && counter==count) {
clientGUI.printText("general", "CONTROL DEMON NOW!!\n", "64b2c6");
clientGUI.printText("general", "CONTROL DEMON NOW!!\n", "64b2c6");
}
stop();
}
}