From 7b43df3b6f3772d79bc1cfb899ddd076659ee2a6 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 4 Jun 2023 21:34:38 -0500 Subject: [PATCH] Add sprint command --- sig/App.java | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/sig/App.java b/sig/App.java index 5852ef1..3447af9 100644 --- a/sig/App.java +++ b/sig/App.java @@ -29,6 +29,7 @@ class Client { private DataOutputStream out = null; private static boolean run = true; + boolean altHeld=false; // constructor to put ip address and port public Client(String address, int port) { @@ -40,7 +41,6 @@ class Client { } keyboardHook.addKeyListener(new GlobalKeyAdapter() { - @Override public void keyPressed(GlobalKeyEvent event) { try { @@ -48,6 +48,9 @@ class Client { case GlobalKeyEvent.VK_NUMPAD7:{ out.writeUTF("FOLLOW"); }break; + case 187:{ + out.writeUTF("SPRINT"); + }break; case GlobalKeyEvent.VK_NUMPAD8: case GlobalKeyEvent.VK_UP:{ out.writeUTF("FORWARD"); @@ -66,10 +69,16 @@ class Client { }break; case GlobalKeyEvent.VK_NUMPAD1: case GlobalKeyEvent.VK_1: - case GlobalKeyEvent.VK_2: - case GlobalKeyEvent.VK_3:{ + case GlobalKeyEvent.VK_2:{ out.writeUTF("FIGHT"); }break; + case GlobalKeyEvent.VK_3:{ + if (altHeld){ + out.writeUTF("FIGHTAOE"); + } else { + out.writeUTF("FIGHT"); + } + }break; case GlobalKeyEvent.VK_Z: case GlobalKeyEvent.VK_X:{ out.writeUTF("FIGHTAOE"); @@ -83,6 +92,12 @@ class Client { case GlobalKeyEvent.VK_NUMPAD9:{ out.writeUTF("PASS"); }break; + case 18:{ + altHeld=true; + }break; + default:{ + //System.out.println(event.getVirtualKeyCode()); + } } } catch (IOException e) { e.printStackTrace(); @@ -94,7 +109,11 @@ class Client { @Override public void keyReleased(GlobalKeyEvent event) { - System.out.println(event); + switch (event.getVirtualKeyCode()){ + case 18:{ + altHeld=false; + }break; + } } }); @@ -349,6 +368,9 @@ class Server System.out.println("Aya's Health: "+GetAyaHealth()+"%"); System.out.println("Target's Health: "+GetTargetHealth()+"%"); }break; + case "SPRINT":{ + r.keyPress(KeyEvent.VK_N); + }break; case "UPDATE":{ }break;