better feedback on killing. fixes #109

This commit is contained in:
logsol 2015-03-02 00:13:21 +01:00
parent 81f5990e0c
commit 5007ab5b02
8 changed files with 95 additions and 22 deletions

View file

@ -58,14 +58,14 @@ function (Parent, Nc) {
this.addDamage(100, this);
};
Player.prototype.addDamage = function(damage, enemy) {
Player.prototype.addDamage = function(damage, enemy, byItem) {
this.stats.health -= damage;
if(this.stats.health < 0) this.stats.health = 0;
if(this.stats.health <= 0) {
if(enemy != this) enemy.score();
this.kill(enemy);
this.kill(enemy, byItem);
} else {
this.broadcastStats();
}
@ -77,7 +77,7 @@ function (Parent, Nc) {
this.broadcastStats();
};
Player.prototype.kill = function(killedByPlayer) {
Player.prototype.kill = function(killedByPlayer, byItem) {
this.stats.deaths++;
var ragDollId = this.stats.deaths;
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
@ -86,9 +86,12 @@ function (Parent, Nc) {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
playerId: this.id,
killedByPlayerId: killedByPlayer.id,
ragDollId: ragDollId
ragDollId: ragDollId,
item: byItem.options.name
});
Nc.trigger(Nc.ns.channel.events.game.player.killed, this, killedByPlayer); // sends endround
if(this.ragDoll) {