Fix a few things for FX

This commit is contained in:
DemiPixel 2015-12-13 19:35:13 -08:00
parent 7d062ad169
commit d269b0a49d
3 changed files with 13 additions and 13 deletions

View file

@ -86,6 +86,17 @@ module.exports.entity=function(entity){
function clamp(a, b, c) {
return Math.max(a, Math.min(b, c));
}
function addVelocityWithMax(current, newVel, max) {
var x, y, z;
if (current.x > max.x || current.x < -max.x) x = current.x;
else x = Math.max(-max.x, Math.min(max.x, current.x + newVel.x));
if (current.y > max.y || current.y < -max.y) y = current.y;
else y = Math.max(-max.y, Math.min(max.y, current.y + newVel.y));
if (current.z > max.z || current.z < -max.z) z = current.z;
else z = Math.max(-max.z, Math.min(max.z, current.z + newVel.z));
return new Vec3(x, y, z);
}
};
module.exports.player = function(player, serv) {
@ -102,5 +113,5 @@ module.exports.player = function(player, serv) {
var vec = new Vec3(parseInt(params[2]), parseInt(params[3]), parseInt(params[4]));
selector.forEach(e => e.sendVelocity(vec, vec.scaled(5)));
}
})
});
}

View file

@ -45,7 +45,7 @@ module.exports.player=function(player,serv)
return str || false;
},
action(sel) {
var arr = serv.selectorString(sel, player.position.scaled(1/32), player.world);
var arr = player.selectorString(sel);
if (arr.length==0) throw new UserError('Could not find player');
arr.map(entity => entity.takeDamage({damage:20}));

View file

@ -123,15 +123,4 @@ module.exports.entity=function(entity,serv){
entity.teleport = (pos) => { // Overwritten in players inject above
entity.sendPosition(pos.scaled(32), false, true);
}
function addVelocityWithMax(current, newVel, max) {
var x, y, z;
if (current.x > max.x || current.x < -max.x) x = current.x;
else x = Math.max(-max.x, Math.min(max.x, current.x + newVel.x));
if (current.y > max.y || current.y < -max.y) y = current.y;
else y = Math.max(-max.y, Math.min(max.y, current.y + newVel.y));
if (current.z > max.z || current.z < -max.z) z = current.z;
else z = Math.max(-max.z, Math.min(max.z, current.z + newVel.z));
return new Vec3(x, y, z);
}
};