<commit_before>'use strict';

Darwinator.RangedWeapon = function (game, coolDown, bulletSpeed, damage, owner) {
    Darwinator.Weapon.call(this, game, coolDown, damage, owner);
    
    var baseCoolDown  = coolDown - owner.attributes.intellect * 20;
    this.coolDown     = baseCoolDown > 200 ? baseCoolDown : 100;
    this.bullets      = this.game.add.group();
    this.bulletSpeed  = bulletSpeed;
};

Darwinator.RangedWeapon.prototype = Object.create(Darwinator.Weapon.prototype);

Darwinator.RangedWeapon.prototype.fire = function (x, y) {
    var angle = this.takeAim(x,y);
    var bullet = this.loadGun(angle);
    if (bullet) {
        bullet.rotation = angle;
        this.game.physics.arcade.velocityFromRotation(angle, this.bulletSpeed, bullet.body.velocity);
    } 
};

Darwinator.RangedWeapon.prototype.fireInDirection = function (angle) {
    var bullet = this.loadGun(angle);
    if (bullet) {
        bullet.rotation = angle;
        this.game.physics.arcade.velocityFromRotation(angle, this.bulletSpeed, bullet.body.velocity);
    } 
}

Darwinator.RangedWeapon.prototype.loadGun = function (angle) {
    if (!this.onCooldown() && this.bullets.countDead() > 0) {
        var bullet    = this.bullets.getFirstDead();
        bullet.reset(this.owner.x, this.owner.y); // resets sprite and body
        bullet.target = Darwinator.Enemy;
        bullet.owner = this.owner;
        this.lastAttack = Date.now();
        return bullet;
    } else {<commit_msg>Make ranged_weapon fire from center of owner<commit_after>'use strict';

Darwinator.RangedWeapon = function (game, coolDown, bulletSpeed, damage, owner) {
    Darwinator.Weapon.call(this, game, coolDown, damage, owner);
    
    var baseCoolDown  = coolDown - owner.attributes.intellect * 20;
    this.coolDown     = baseCoolDown > 200 ? baseCoolDown : 100;
    this.bullets      = this.game.add.group();
    this.bulletSpeed  = bulletSpeed;
};

Darwinator.RangedWeapon.prototype = Object.create(Darwinator.Weapon.prototype);

Darwinator.RangedWeapon.prototype.fire = function (x, y) {
    var angle = this.takeAim(x,y);
    var bullet = this.loadGun(angle);
    if (bullet) {
        bullet.rotation = angle;
        this.game.physics.arcade.velocityFromRotation(angle, this.bulletSpeed, bullet.body.velocity);
    } 
};

Darwinator.RangedWeapon.prototype.fireInDirection = function (angle) {
    var bullet = this.loadGun(angle);
    if (bullet) {
        bullet.rotation = angle;
        this.game.physics.arcade.velocityFromRotation(angle, this.bulletSpeed, bullet.body.velocity);
    } 
}

Darwinator.RangedWeapon.prototype.loadGun = function (angle) {
    if (!this.onCooldown() && this.bullets.countDead() > 0) {
        var bullet    = this.bullets.getFirstDead();
        var center = {x: this.owner.x + this.owner.width / 2,
                      y: this.owner.y + this.owner.height / 2};
        bullet.reset(center.x, center.y); // resets sprite and body
        bullet.target = Darwinator.Enemy;
        bullet.owner = this.owner;
        this.lastAttack = Date.now();
        return bullet;
    } else {
{'fraction_non_alphanumeric': 0.12544570502431118, 'fraction_numerical': 0.006482982171799027, 'mean_word_length': 3.071240105540897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '643255', 'n_tokens_mistral': 1036, 'n_tokens_neox': 979, 'n_words': 186}