Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fighting #402

Merged
1 commit merged into from
Sep 15, 2017
Merged

Improve fighting #402

1 commit merged into from
Sep 15, 2017

Conversation

TooAngel
Copy link
Owner

@TooAngel TooAngel commented Sep 9, 2017

  • Defend reserved rooms
  • Autotrigger all attacks: autoattack, squad.start and attack42

Fixes #35

*
* USAGE: get a Room Object then .attack42('targetRoomName')
* e.g. Game.rooms[Memory.myRooms[0]].attack42('targetRoomName');
* TODO add an attack42 event if invader is seen by reserver, sourcer or carry
* e.g. `Game.rooms[Memory.myRooms[0]].attack42('targetRoomName')``;.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why thuses ```at start and end

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'`' usually marks executable code

if (pos.lookFor(LOOK_TERRAIN)[0] !== STRUCTURE_WALL && pos.lookFor(LOOK_CREEPS).length === 0) {
direction = direction + offset;
if (!pos.checkForWall() && pos.lookFor(LOOK_CREEPS).length === 0) {
direction = (direction + offset) % 8 + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= dir :) or l23 : direction = (direction + 1) % 8 + 1

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

player.lastAttacked = Game.time;
Memory.players[player.name] = player;
}
const lastAttacked = player.lastAttacked;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really need to be declared i think

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

attacks[`attack${player.level}`](this);
player.counter++;
if (player.counter > 10) {
player.level += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can reach lvl 2 and stop attack.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every level is triggered 10 times before changing to the next level

@@ -57,6 +80,7 @@ roles.scout.execute = function(creep) {
creep.memory.skip.push(creep.memory.search.target);
delete creep.memory.scoutSkip;
} else {
checkForDefender(creep);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better drop a defender on all rooms linked to reserved one no? the issue i supose with your logic is that get linear distance may focus rooms which are further than expected if some exits are closed. could use search.level I supose with level <= 2 but it will defend all roms around level 1.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defenders are called for rooms with linear distance 1 (https://github.com/TooAngel/screeps/pull/402/files#diff-362993a173ef9b2bb120bc815a19a4cfR41). Yes in some cases this can be a couple of rooms away, but for the start I think it is fine before getting more sophisticated.

return true;
}
return false;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creep.proto healMyCreeps may be used here. just need adapt it for findClosest with a new arg.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, true. Don't want to touch it here.

// creep.log('Execute!!!');
creep.log('Execute!!!');
creep.heal(creep);
creep.moveRandom();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's better to stop use execute no ? Maybe keep a log with debug config check for see if it is launch one day ^^
We should add execute calls to stats for see if we can remove them safely.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I enabled the log again.

@ghost
Copy link

ghost commented Sep 11, 2017

A new review, yeah.

Votes: 294/492
Coefficient: 0.59756097561
Merging in 3 days 4 hours
Age 0 days 20 hours

 - Defend reserved rooms
 - Autotrigger all attacks: autoattack, squad.start and attack42

Fixes #35
@ghost ghost merged commit 2dddbb4 into master Sep 15, 2017
@TooAngel TooAngel deleted the attack branch September 17, 2017 19:29
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants