better handling of dangerousnes, etc. fixes #107

This commit is contained in:
Jeena 2015-04-02 22:49:43 +02:00
parent 46f14c22c6
commit aff23e8de0
4 changed files with 9 additions and 18 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -186,7 +186,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
setTimeout(function(){self.ping.innerHTML = "Reload in 3...".replace(/ /g, '&nbsp;');}, 6000);
setTimeout(function(){self.ping.innerHTML = "Reload in 2...".replace(/ /g, '&nbsp;');}, 7000);
setTimeout(function(){self.ping.innerHTML = "Reload in 1...".replace(/ /g, '&nbsp;');}, 8000);
setTimeout(function(){self.ping.innerHTML = "Reload now. ".replace(/ /g, '&nbsp;'); location.reload(); }, 1000);
setTimeout(function(){self.ping.innerHTML = "Reload now. ".replace(/ /g, '&nbsp;'); location.reload(); }, 9000);
}
};

View file

@ -367,7 +367,7 @@ function () {
"category": "livingroom",
"image": "piano.gif",
"weight": "15",
"weight": "10",
"width": "66",
"height": "48",