mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
trying a new approach to calculating damager
This commit is contained in:
parent
16826b174a
commit
f9d97c5a47
4 changed files with 64 additions and 20 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue