mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
only adds lastMovedBy when there was no damage - fixes #108
This commit is contained in:
parent
b46c309dbe
commit
eb29a00012
1 changed files with 6 additions and 2 deletions
|
|
@ -54,6 +54,7 @@ function (Parent, Item, Box2D, Nc, Assert) {
|
||||||
var b2Math = Box2D.Common.Math.b2Math;
|
var b2Math = Box2D.Common.Math.b2Math;
|
||||||
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
||||||
var min = 1;
|
var min = 1;
|
||||||
|
var damage = 0;
|
||||||
|
|
||||||
if(absItemVelocity.x > min || absItemVelocity.y > min) {
|
if(absItemVelocity.x > min || absItemVelocity.y > min) {
|
||||||
if(item.lastMoved && item.lastMoved.player != this.player) {
|
if(item.lastMoved && item.lastMoved.player != this.player) {
|
||||||
|
|
@ -72,7 +73,7 @@ function (Parent, Item, Box2D, Nc, Assert) {
|
||||||
// + 0.5 and / 2: offsetting for lower velocity impact
|
// + 0.5 and / 2: offsetting for lower velocity impact
|
||||||
// * 300: tested imperically by throwing piano from deadly height
|
// * 300: tested imperically by throwing piano from deadly height
|
||||||
// * 80: tested imperically by throwing knife fast
|
// * 80: tested imperically by throwing knife fast
|
||||||
var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
||||||
|
|
||||||
var lastMovedPlayer = item.lastMoved.player;
|
var lastMovedPlayer = item.lastMoved.player;
|
||||||
var callback = function() {
|
var callback = function() {
|
||||||
|
|
@ -83,7 +84,10 @@ function (Parent, Item, Box2D, Nc, Assert) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setLastMovedBy(this.player);
|
// only set lastMovedBy if player wasn't hurt by collision
|
||||||
|
if (damage === 0) {
|
||||||
|
item.setLastMovedBy(this.player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue