From 3e4224c0954289f23fcf3c665b1ab788d6097746 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 29 May 2023 20:20:47 -0500 Subject: [PATCH] Test --- sig/App.java | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/sig/App.java b/sig/App.java index 3b75caf..46476ab 100644 --- a/sig/App.java +++ b/sig/App.java @@ -10,6 +10,7 @@ import java.util.Map.Entry; import javax.imageio.ImageIO; import java.awt.AWTException; +import java.awt.Color; import java.awt.Rectangle; import java.awt.Robot; import java.awt.event.KeyEvent; @@ -140,6 +141,11 @@ class Client { } } +enum Target{ + AYA, + MYTHRA +} + class Server { //initialize socket and input stream @@ -155,6 +161,10 @@ class Server r.keyRelease(keycode);r.delay(100); r.keyRelease(modifier); } + private void PressKey(int keycode) { + r.keyPress(keycode); + r.keyRelease(keycode); + } float GetMythraHealth(){ BufferedImage img=r.createScreenCapture(new Rectangle(92, 171, 86, 1)); @@ -165,6 +175,20 @@ class Server } return 0; } + boolean MythraHasShield(){ + BufferedImage img=r.createScreenCapture(new Rectangle(92, 163, 1, 1)); + Color c=new Color(img.getRGB(0,0)); + return c.getRed()==255&&c.getRed()==211&&c.getBlue()==0; + } + float GetMythraMana(){ + BufferedImage img=r.createScreenCapture(new Rectangle(196, 171, 86, 1)); + for (int i=img.getWidth()-1;i>=0;i--){ + if ((img.getRGB(i,0)&255)>100){ + return (float)i/(img.getWidth()-1)*100; + } + } + return 0; + } float GetAyaHealth(){ BufferedImage img=r.createScreenCapture(new Rectangle(92, 211, 86, 1)); for (int i=img.getWidth()-1;i>=0;i--){ @@ -174,6 +198,11 @@ class Server } return 0; } + boolean AyaHasShield(){ + BufferedImage img=r.createScreenCapture(new Rectangle(92, 203, 1, 1)); + Color c=new Color(img.getRGB(0,0)); + return c.getRed()==255&&c.getRed()==211&&c.getBlue()==0; + } float GetTargetHealth(){ BufferedImage img=r.createScreenCapture(new Rectangle(781, 134, 432, 1)); for (int i=img.getWidth()-1;i>=0;i--){ @@ -183,6 +212,46 @@ class Server } return 0; } + boolean MultipleTargets(){ + BufferedImage img=r.createScreenCapture(new Rectangle(75, 628, 1, 1)); + Color c=new Color(img.getRGB(0,0)); + return (c.getRed()==120&&c.getRed()==118&&c.getBlue()==120)||(c.getRed()==140&&c.getRed()==138&&c.getBlue()==140); + } + + + long bioTimer=0; + long lucidDreamingTimer=0; + long nextActionTimer=0; + long aetherflowTimer=0; + int aetherflowStacks=0; + long whisperingDawnTimer=0; + long feyIlluminationTimer=0; + boolean allowedToAetherflow=false; + + long lastFrame=System.currentTimeMillis(); + + void Heal(Target target){ + if (aetherflowStacks>0){ + PressKey(KeyEvent.VK_C); + aetherflowStacks--; + nextActionTimer=1000; + return; + } else + if (target==Target.AYA&&AyaHasShield()){ + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_3); + nextActionTimer=2500; + return; + } else + if (target==Target.MYTHRA&&MythraHasShield()){ + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_3); + nextActionTimer=2500; + return; + } else { + PressKey(KeyEvent.VK_5); + nextActionTimer=2500; + return; + } + } // constructor with port public Server(int port) @@ -263,6 +332,80 @@ class Server System.out.println(i); break; } + + fightLoop: + while (true){ + if (fighting){ + if (nextActionTimer==0){ + if (GetMythraMana()<80&&lucidDreamingTimer==0){ + lucidDreamingTimer=60000; + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_6); + nextActionTimer=1000; + break fightLoop; + } + } + if (allowedToAetherflow&&aetherflowTimer==0){ + PressKeyWithModifier(KeyEvent.VK_ALT, KeyEvent.VK_2); + nextActionTimer=1000; + aetherflowStacks=3; + break fightLoop; + } + float ayaHealth=GetAyaHealth(); + float mythraHealth=GetMythraHealth(); + if (ayaHealth<0.4){ + PressKey(KeyEvent.VK_F2); + Heal(Target.AYA); + break fightLoop; + } + if (ayaHealth<0.6){ + if (whisperingDawnTimer==0&&feyIlluminationTimer<60000){ + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_C); + whisperingDawnTimer=60000; + nextActionTimer=1000; + break fightLoop; + } else + if (feyIlluminationTimer==0&&whisperingDawnTimer<30000){ + PressKey(KeyEvent.VK_X); + feyIlluminationTimer=120000; + nextActionTimer=1000; + break fightLoop; + } + } + if (mythraHealth<0.4){ + PressKey(KeyEvent.VK_F1); + Heal(Target.MYTHRA); + break fightLoop; + } + //Looks like we're attacking. + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_8); + float targetHealth=GetTargetHealth(); + if (!MultipleTargets()){ + if (targetHealth>50&&bioTimer==0){ + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_2); + bioTimer=30000; + nextActionTimer=2500; + break fightLoop; + } else { + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_1); + nextActionTimer=2500; + break fightLoop; + } + } else { + PressKeyWithModifier(KeyEvent.VK_CONTROL, KeyEvent.VK_Z); + nextActionTimer=2500; + break fightLoop; + } + } + break fightLoop; + } + long difference=System.currentTimeMillis()-lastFrame; + bioTimer=Math.max(0,bioTimer-difference); + lucidDreamingTimer=Math.max(0,lucidDreamingTimer-difference); + nextActionTimer=Math.max(0,nextActionTimer-difference); + aetherflowTimer=Math.max(0,aetherflowTimer-difference); + whisperingDawnTimer=Math.max(0,whisperingDawnTimer-difference); + feyIlluminationTimer=Math.max(0,feyIlluminationTimer-difference); + lastFrame=System.currentTimeMillis(); } System.out.println("Closing connection");