所以即时创建模拟用户鼠标移动的应用程序。
我的格式为 [步数,方向]
pattern.put(Weapon.NAME_TEST_DOWN2, new int[][]{ //sens: 1.0 steps:5,10ms delay
{600, DOWN},
{100, RIGHT | DOWN},
{400, LEFT | DOWN},
{100, LEFT},
{200, NONE},
{600, RIGHT},
{400, NONE},
{400, LEFT}
});
事情工作精细芽显然摩苏运动是活泼的,需要被平滑以使它看起来像人类那样,形象:
整个鼠标移动的功能是:
private final int stepAmount = 1;
@SuppressWarnings("FieldMayBeFinal")
private int delay = (int) (2 * CsgoRr.getModel().getAppPrefs().getIngameSensitivity()); // increments of 1 1.5 2 2.5 etc
@SuppressWarnings("CallToPrintStackTrace")
public void reduceRecoil() {
@SuppressWarnings("UnusedAssignment")
int directionFlag = 0;
int previousDirectionFlag;
int nextDirectionFlag = RecoilPatternInfo.NONE;
for (int row = 0; row < recoilPattern.length; row++) {
if (weapon.isTriggerPulled()) {
int duration = recoilPattern[row][0];
directionFlag = recoilPattern[row][1];
previousDirectionFlag = (row != 0) ? recoilPattern[row - 1][1] : RecoilPatternInfo.NONE;
try {
nextDirectionFlag = recoilPattern[row + 1][1];
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
switch (directionFlag) {
case (RecoilPatternInfo.DOWN): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x,
MouseInfo.getPointerInfo().getLocation().y + stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.DOWN | RecoilPatternInfo.LEFT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x - stepAmount,
MouseInfo.getPointerInfo().getLocation().y + stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.DOWN | RecoilPatternInfo.RIGHT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x + stepAmount,
MouseInfo.getPointerInfo().getLocation().y + stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.LEFT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x - stepAmount,
MouseInfo.getPointerInfo().getLocation().y);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.RIGHT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x + stepAmount,
MouseInfo.getPointerInfo().getLocation().y);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.UP): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x,
MouseInfo.getPointerInfo().getLocation().y - stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.UP | RecoilPatternInfo.LEFT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x - stepAmount,
MouseInfo.getPointerInfo().getLocation().y - stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
case (RecoilPatternInfo.UP | RecoilPatternInfo.RIGHT): {
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x + stepAmount,
MouseInfo.getPointerInfo().getLocation().y - stepAmount);
} else {
return;
}
this.delay(delay);
}
break;
}
default: {//RecoilPatternInfo.NONE
while ((duration -= delay) > 0) {
if (weapon.isTriggerPulled()) {
mouseMove(MouseInfo.getPointerInfo().getLocation().x,
MouseInfo.getPointerInfo().getLocation().y);
} else {
return;
}
this.delay(delay);
}
}
}
}
}
}
我知道接下来我将向哪个方向移动,我知道在方向改变之前还有多少步骤,我应该能够做到这一点。
我在想的是增加/减少移动值到下一个/上一个移动方向的侧/上/下只有最后/前20%的步数。然后逐渐增加/减少这个移动芽整个事物应该是非常大的SWITCH声明,很多工作而且效率不高。
有没有更好的方法呢?或者我会被迫进入我的第一个想法?
关于最有效的工作解决方案的任何想法?
答案 0 :(得分:0)
好的,经过大量的论文工作(是的,我把它写在纸上),我设法做到了这一点,没有使用一些复杂的数学或样条api等。
我所做的是按照我的第一个想法,考虑下一个方向并且慢慢转弯,使用基于patern百分比的平滑因子的偏差和到目前为止所做的步骤。
这种方法非常有效,性能在曲线中增加了较少的细节。
它绝不是完美的萌芽和额外的用户输入,随机数添加它几乎是我的想法。