mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 19:20:54 +00:00
Fix a few things for FX
This commit is contained in:
parent
7d062ad169
commit
d269b0a49d
3 changed files with 13 additions and 13 deletions
|
|
@ -86,6 +86,17 @@ module.exports.entity=function(entity){
|
||||||
function clamp(a, b, c) {
|
function clamp(a, b, c) {
|
||||||
return Math.max(a, Math.min(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) {
|
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]));
|
var vec = new Vec3(parseInt(params[2]), parseInt(params[3]), parseInt(params[4]));
|
||||||
selector.forEach(e => e.sendVelocity(vec, vec.scaled(5)));
|
selector.forEach(e => e.sendVelocity(vec, vec.scaled(5)));
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ module.exports.player=function(player,serv)
|
||||||
return str || false;
|
return str || false;
|
||||||
},
|
},
|
||||||
action(sel) {
|
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');
|
if (arr.length==0) throw new UserError('Could not find player');
|
||||||
|
|
||||||
arr.map(entity => entity.takeDamage({damage:20}));
|
arr.map(entity => entity.takeDamage({damage:20}));
|
||||||
|
|
|
||||||
|
|
@ -123,15 +123,4 @@ module.exports.entity=function(entity,serv){
|
||||||
entity.teleport = (pos) => { // Overwritten in players inject above
|
entity.teleport = (pos) => { // Overwritten in players inject above
|
||||||
entity.sendPosition(pos.scaled(32), false, true);
|
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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue