Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Add HuntForPrey (experimental) #275 + #292
Browse files Browse the repository at this point in the history
  • Loading branch information
clemens-tolboom committed Jul 11, 2016
1 parent 93dce01 commit 8cf3125
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions bot.user.js
Expand Up @@ -899,6 +899,50 @@ var scheduler = window.scheduler = (function() {
// TODO: checkCollision() needs refactoring; it should return but not set direction
}
},
{
id: 'HuntForPrey (experimental)',
active: false,
description: 'Try to catch a pray',

// Priority to use when activated
triggerPriority: 450,

// How often to check
frequency: 0,
// step
step: 0,

getPriority: function() {
// Init
if (this.frequency === 0) {
// A prey is food too!
this.frequency = bot.opt.foodFrames
}

if (this.step < this.frequency) {
this.step++;
return 0;
}
this.step = 0;
if (window.preys.length> 0) {
return this.triggerPriority;
}
// No preys to catch
return 0;
},
execute: function() {
if (window.preys.length> 0) {
// TODO decide what prey to catch. For now we take first
var prey = window.preys[0];
window.setAcceleration(1);

bot.currentFood = {x:prey.xx, y:prey.yy};
window.goalCoordinates = bot.currentFood;
canvasUtil.setMouseCoordinates(canvasUtil.mapToMouse(window.goalCoordinates));
}

}
},
{
id: 'CheckForFood',
active: true,
Expand Down

0 comments on commit 8cf3125

Please sign in to comment.