Java JNA triggerbot experiment problem
I'm attempting to make a triggerbot in java JNA, please no "java is shit", I've recentlly really gotten into JNA after I made a small hack for this game, the reason I use JAVA is because I'm more comfortable with GUI making and overrall in the language, yes I understand C++ is much more efficient and realiable for game hacking but AGAIN this is an experiment. The number one problem I have is I don't know how to getModules in JNA , I don't know how the hell it processes MODULEENTRY32 so I can't really get the client.dll or engine.dll, right now when I enable the triggerbot it starts shooting every couple of seconds or some shit like that, the "ReadMemory" works as I've tested it on many games. Anyone here who knows JNA , I would really appreciate the help.
Code:
public class TriggerBot extends CSHack {
private long EntityList = 0x4A43844;
private long LocalPlayer = 0xA9D44C;
private int LifeState = 0x25B;
private int Team = 0xF0;
private int CrosshairId = 0xA904;
private int EntitySize = 0x10;
private Robot robot;
public TriggerBot() {
super("Trigger-Bot");
try {
robot = new Robot();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void onEnable() {
while (true) {
try {
Thread.sleep(1);
int playerNumber = 0;
getCrosshairId(playerNumber);
if (playerNumber < 64 && playerNumber >= 0 && getTeam(playerNumber) != getTeam() && isPlayerDead(playerNumber) == false) {
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(1);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
private int getBaseEntity(int playerNumber) {
return MemoryProcessor.readMemory(getProcess(), EntityList + (EntitySize * playerNumber), 4).getInt(0L);
}
private boolean isPlayerDead(int playerNumber) {
int BaseEntity = getBaseEntity(playerNumber);
return MemoryProcessor.readMemory(getProcess(), BaseEntity + LifeState, 4).getInt(0) != 0;
}
private int getTeam(int playerNumber) {
int BaseEntity = getBaseEntity(playerNumber);
return MemoryProcessor.readMemory(getProcess(), BaseEntity + Team, 4).getInt(0);
}
private void getPlayerBase(int returnAddress) {
returnAddress = MemoryProcessor.readMemory(getProcess(), LocalPlayer, 4).getInt(0);
}
private int getTeam() {
int playerBase = 0;
getPlayerBase(playerBase);
return MemoryProcessor.readMemory(getProcess(), playerBase + Team, 4).getInt(0);
}
private void getCrosshairId(int returnAddress) {
int playerBase = 0;
getPlayerBase(playerBase);
returnAddress = MemoryProcessor.readMemory(getProcess(), playerBase + CrosshairId, 4).getInt(0) - 1;
}
}