Skip to content

Commit 42606a6

Browse files
author
Bytekeeper
committed
Minor changes.
1 parent d83a1ab commit 42606a6

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/main/java/org/bk/ass/AgentUtil.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
import static java.lang.Math.*;
88

99
public class AgentUtil {
10-
1110
private static final SplittableRandom rnd = new SplittableRandom();
1211

12+
// Retrieved from OpenBW
13+
private static final int STIM_TIMER = 37;
14+
private static final int STIM_ENERGY_COST_SHIFTED = 10 << 8;
15+
16+
1317
private AgentUtil() {
1418
// Utility class
1519
}
@@ -188,4 +192,9 @@ public static int reduceDamageByTargetSizeAndDamageType(
188192
}
189193
return damageShifted;
190194
}
195+
196+
public static void stim(Agent agent) {
197+
agent.remainingStimFrames = STIM_TIMER;
198+
agent.healthShifted -= STIM_ENERGY_COST_SHIFTED;
199+
}
191200
}

src/main/java/org/bk/ass/AttackerBehavior.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
public class AttackerBehavior implements Behavior {
1111

12-
// Retrieved from OpenBW
13-
public static final int STIM_TIMER = 37;
14-
public static final int STIM_ENERGY_COST_SHIFTED = 10 << 8;
15-
1612
@Override
1713
public boolean simUnit(
1814
Agent agent, UnorderedCollection<Agent> allies, UnorderedCollection<Agent> enemies) {
@@ -24,7 +20,7 @@ public boolean simUnit(
2420
Weapon selectedWeapon = null;
2521
int selectedDistanceSquared = Integer.MAX_VALUE;
2622

27-
if (agent.attackTarget != null && agent.attackTarget.healthShifted >= 0) {
23+
if (agent.attackTarget != null && agent.attackTarget.healthShifted > 0) {
2824
int dstSq = distanceSquared(agent, agent.attackTarget);
2925
selectedWeapon = agent.weaponVs(agent.attackTarget);
3026
if (dstSq >= selectedWeapon.minRangeSquared && dstSq <= selectedWeapon.maxRangeSquared) {
@@ -41,7 +37,7 @@ public boolean simUnit(
4137
selectedEnemy == null
4238
? 1
4339
: enemy.attackTargetPriority.compareTo(selectedEnemy.attackTargetPriority);
44-
if (enemy.healthShifted >= 1
40+
if (enemy.healthShifted > 0
4541
&& wpn.damageShifted != 0
4642
&& enemy.detected
4743
&& !enemy.isStasised
@@ -94,8 +90,7 @@ private void simAttack(
9490
if (agent.canStim
9591
&& agent.remainingStimFrames == 0
9692
&& agent.healthShifted >= agent.maxHealthShifted / 2) {
97-
agent.remainingStimFrames = STIM_TIMER;
98-
agent.healthShifted -= STIM_ENERGY_COST_SHIFTED;
93+
AgentUtil.stim(agent);
9994
}
10095
dealDamage(agent, selectedWeapon, selectedEnemy);
10196
switch (selectedWeapon.splashType) {

src/main/java/org/bk/ass/Simulator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class Simulator {
2727

2828
private static final int MAX_MAP_DIMENSION = 8192;
2929
private static final int TILE_SIZE = 16;
30+
// Hack to fix DTs not being able to hit a target in another TILE due to collision
3031
public static final int MIN_SIMULATION_RANGE =
3132
(TILE_SIZE + TILE_SIZE / 2) * (TILE_SIZE + TILE_SIZE / 2);
3233
private static final int COLLISION_MAP_DIMENSION = MAX_MAP_DIMENSION / TILE_SIZE;

0 commit comments

Comments
 (0)