You can PM me any feedback in Adam's discord @PlayingWithScissors.
- Duration: 2
- Cooldown: 5
- Bots: 2000
- CPU: 12000
- Chips: 4000
The variable being named array1 is required. Not sure if other arrays need to be array2/3/etc.
array1 = findEntities(ENEMY, BOT, false);
arrayLength = count(array1);
for (i = 0; i < arrayLength; i++ ) {
enemy = array1[i];
enemyX = getX(enemy);
enemyY = getY(enemy);
// Do something
}
- Numbers can be in scientific notation (ie, 1e10)
- Each phase has a maximum of 3000 ticks across ALL bots or 1000ms of execution time
- Bot that take longer than 15 ms to execute their scripts will get punished by getting ignore for a lot of time (broken scrips would only get 3-4 turns total)
- Chips affect ALL defender bots
- Setting a cloaked bot on fire will not turn off the cloak, it will simply reveal the bot for as long as the fire lasts
- Shielding an ally has a range of 5 and can target all friendly entities
These variables are named ownX/ownY because they can't be named x/y.
teleportIfPossible = function(ownX, ownY) {
if (canTeleport(ownX, ownY)) {
teleport(ownX, ownY);
}
}
moveToIfPossible = function(ownX, ownY) {
if (canMoveTo(ownX, ownY)) { // This will return false if ownX and ownY is not in sense range
moveTo(ownX, ownY);
}
}
Since arenaWidth and arenaHeight are static, these are better stored in init(). Also, the isAttacker is unnecessary and I need to rework this function. This also might get broken in future versions of BotLand.
moveTowardsCpu = function() {
if (isAttacker) {
destinationX = arenaWidth - 1;
destinationY = floor(arenaHeight / 2);
moveTo(destinationX, destinationY);
} else {
move();
}
}
calculateDistance = function(sourceX, sourceY, targetX, targetY) {
xDiff = abs(sourceX - targetX);
yDiff = abs(sourceY - targetY);
return xDiff + yDiff;
}
isInSenseRange = function(targetX, targetY) {
senseRange = 5;
if (areSensorsActivated()) {
senseRange = 7;
}
return (calculateDistance(x, y, targetX, targetY) <= senseRange)
}
isEntityInZappingDistance = function(entity) {
entityX = getX(entity);
entityY = getY(entity);
distance = getDistanceTo(entity);
if (distance === 1) {
return true;
} else if (distance === 2 && !(entityX === x || entityY === y)) {
return true;
}
return false;
}
healSelfOrAlly = function() {
healSelf();
healOrPersueFriendlyBot();
}
healSelf = function() {
if (willRepair() && life < healthToStopRepairing) {
repair();
}
}
healOrPersueFriendlyBot = function() {
myBotsInRange = findEntities(IS_OWNED_BY_ME, BOT, false);
repairTarget = filterEntities(myBotsInRange, [
SORT_BY_DISTANCE,
SORT_BY_LIFE
], [
SORT_ASCENDING,
SORT_ASCENDING
]);
if (exists(repairTarget) && getLife(repairTarget) < healthToStopRepairing) {
if (willRepair(repairTarget)) {
repair(repairTarget);
} else {
pursue(repairTarget);
}
}
}
The lastTurnHp = life;
needs to be before any terminator to avoid not recalculating the number in the next turn.
init = function() {
lastTurnHp = life;
}
update = function () {
tookDamage = didTakeDamage();
if (tookDamage) {
if (canReflect()) {
reflect();
}
}
}
didTakeDamage = function() {
tookDamage = false
if (life < lastTurnHp) {
tookDamage = true
}
lastTurnHp = life;
return tookDamage;
}