mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
better handling of dangerousnes, etc. fixes #107
This commit is contained in:
parent
46f14c22c6
commit
aff23e8de0
4 changed files with 9 additions and 18 deletions
|
|
@ -69,7 +69,10 @@ function (Parent, Item, Box2D, Nc, Assert) {
|
|||
// Max danger of knife: 3
|
||||
var dangerDamage = item.options.danger / 3;
|
||||
|
||||
var damage = velocityDamage * (weightDamage * 180 + dangerDamage * 80);
|
||||
// + 0.5 and / 2: offsetting for lower velocity impact
|
||||
// * 300: tested imperically by throwing piano from deadly height
|
||||
// * 80: tested imperically by throwing knife fast
|
||||
var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
||||
|
||||
var callback = function() {
|
||||
self.player.addDamage(damage, item.lastMoved.player, item);
|
||||
|
|
|
|||
|
|
@ -60,29 +60,19 @@ function (Parent, Nc) {
|
|||
}
|
||||
};
|
||||
|
||||
Player.prototype.addDamage = function(damage, enemy, byItem, reheal) {
|
||||
Player.prototype.addDamage = function(damage, enemy, byItem) {
|
||||
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) {
|
||||
|
|
@ -104,8 +94,6 @@ function (Parent, Nc) {
|
|||
item: byItem ? byItem.options.name : "Suicide"
|
||||
});
|
||||
|
||||
|
||||
|
||||
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