trying a new approach to calculating damager

This commit is contained in:
logsol 2015-04-02 19:35:10 +02:00
parent 16826b174a
commit f9d97c5a47
4 changed files with 64 additions and 20 deletions

View file

@ -60,17 +60,29 @@ function (Parent, Nc) {
}
};
Player.prototype.addDamage = function(damage, enemy, byItem) {
Player.prototype.addDamage = function(damage, enemy, byItem, reheal) {
this.stats.health -= damage;
if(this.stats.health > 100) this.stats.health = 100;
if(this.stats.health < 0) this.stats.health = 0;
/*
if(this.stats.health <= 0) {
if(enemy != this) enemy.score();
this.kill(enemy, byItem);
} else {
this.broadcastStats();
}
*/
this.broadcastStats();
if (!reheal) {
// reheal hack after 1 second
var self = this;
setTimeout(function(){
self.addDamage(-100, enemy, byItem, true);
}, 2500);
}
};
Player.prototype.spawn = function(x, y) {