Skip to content

Commit 1352103

Browse files
author
Ian Gonzalez Hermosillo
committed
add destroy units to schema, defense towers buff aoe attacks
1 parent 3a75cb9 commit 1352103

5 files changed

Lines changed: 19 additions & 12 deletions

File tree

engine/src/main/battlecode/common/GameConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public class GameConstants {
125125
/** The increase in extra damage for ally towers for upgrading a defense tower */
126126
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 5;
127127

128+
/** The percent of the defense tower damage buff that is applied to AoE attacks */
129+
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 50;
130+
128131
/** Maximum amount of turns a robot can go at 0 paint without dying */
129132
public static final int MAX_TURNS_WITHOUT_PAINT = 10;
130133

engine/src/main/battlecode/schema/WinType.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ public final class WinType {
77
private WinType() { }
88
public static final byte RESIGNATION = 0;
99
public static final byte MAJORITY_PAINTED = 1;
10-
public static final byte AREA_PAINTED = 2;
11-
public static final byte MORE_TOWERS = 3;
12-
public static final byte MORE_MONEY = 4;
13-
public static final byte MORE_STORED_PAINT = 5;
14-
public static final byte MORE_ROBOTS = 6;
15-
public static final byte COIN_FLIP = 7;
10+
public static final byte ALL_UNITS_DESTROYED = 2;
11+
public static final byte AREA_PAINTED = 3;
12+
public static final byte MORE_TOWERS = 4;
13+
public static final byte MORE_MONEY = 5;
14+
public static final byte MORE_STORED_PAINT = 6;
15+
public static final byte MORE_ROBOTS = 7;
16+
public static final byte COIN_FLIP = 8;
1617

17-
public static final String[] names = { "RESIGNATION", "MAJORITY_PAINTED", "AREA_PAINTED", "MORE_TOWERS", "MORE_MONEY", "MORE_STORED_PAINT", "MORE_ROBOTS", "COIN_FLIP", };
18+
public static final String[] names = { "RESIGNATION", "MAJORITY_PAINTED", "ALL_UNITS_DESTROYED", "AREA_PAINTED", "MORE_TOWERS", "MORE_MONEY", "MORE_STORED_PAINT", "MORE_ROBOTS", "COIN_FLIP", };
1819

1920
public static String name(int e) { return names[e]; }
20-
}
21-
21+
}

engine/src/main/battlecode/util/FlatHelpers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public static byte getWinTypeFromDominationFactor(DominationFactor factor) {
7878
switch (factor) {
7979
case PAINT_ENOUGH_AREA:
8080
return WinType.MAJORITY_PAINTED;
81+
case DESTROY_ALL_UNITS:
82+
return WinType.ALL_UNITS_DESTROYED;
8183
case MORE_SQUARES_PAINTED:
8284
return WinType.AREA_PAINTED;
8385
case MORE_TOWERS_ALIVE:

engine/src/main/battlecode/world/InternalRobot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,17 @@ public void towerAttack(MapLocation loc) {
429429

430430
if(loc == null) { // area attack
431431
this.towerHasAreaAttacked = true;
432+
int aoeDamage = this.type.aoeAttackStrength + (int) Math.round(this.gameWorld.getDefenseTowerDamageIncrease(team) * GameConstants.DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS/100.0);
432433

433434
MapLocation[] allLocs = this.gameWorld.getAllLocationsWithinRadiusSquared(this.getLocation(), this.type.actionRadiusSquared);
434435
for(MapLocation newLoc : allLocs) {
435436
// Attack if there is a unit (only if different team)
436437
if(this.gameWorld.getRobot(newLoc) != null) {
437438
InternalRobot unit = this.gameWorld.getRobot(newLoc);
438439
if(this.team != unit.getTeam()){
439-
unit.addHealth(-this.type.aoeAttackStrength);
440+
unit.addHealth(-aoeDamage);
440441
this.gameWorld.getMatchMaker().addAttackAction(unit.getID());
441-
this.gameWorld.getMatchMaker().addDamageAction(unit.getID(), this.type.attackStrength);
442+
this.gameWorld.getMatchMaker().addDamageAction(unit.getID(), aoeDamage);
442443
}
443444
}
444445
}

schema/battlecode.fbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum RobotType: byte {
2323
enum WinType: byte {
2424
RESIGNATION,
2525
MAJORITY_PAINTED,
26+
ALL_UNITS_DESTROYED,
2627
AREA_PAINTED,
2728
MORE_TOWERS,
2829
MORE_MONEY,
@@ -364,4 +365,4 @@ table GameWrapper {
364365
matchHeaders: [int];
365366
/// The indices of the footers of the matches, in order.
366367
matchFooters: [int];
367-
}
368+
}

0 commit comments

Comments
 (0)