mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
better feedback on killing. fixes #109
This commit is contained in:
parent
81f5990e0c
commit
5007ab5b02
8 changed files with 95 additions and 22 deletions
|
|
@ -70,7 +70,7 @@ function (Parent, Item, Box2D, Nc) {
|
|||
var player = item.lastMoved.player;
|
||||
|
||||
var callback = function() {
|
||||
self.player.addDamage(damage, player);
|
||||
self.player.addDamage(damage, player, item);
|
||||
}
|
||||
|
||||
Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue