25 lines
697 B
JavaScript
25 lines
697 B
JavaScript
import * as Math from '@/util/math.js';
|
|
|
|
export default function*({ecs, entity, other}) {
|
|
const playerEntity = ecs.lookupPlayerEntity(entity.Owned.owner);
|
|
if (playerEntity !== other && other.Vulnerable) {
|
|
const magnitude = Math.floor(Math.random() * 1);
|
|
other.Vulnerable.damage({
|
|
amount: -Math.floor(
|
|
Math.pow(10, magnitude)
|
|
+ Math.random() * (Math.pow(10, magnitude + 1) - Math.pow(10, magnitude)),
|
|
),
|
|
knockback: {
|
|
magnitude: 150,
|
|
origin: entity.Position,
|
|
},
|
|
lockout: {
|
|
duration: 0.5,
|
|
subject: entity,
|
|
},
|
|
position: other.Position.toJSON(),
|
|
type: other.Vulnerable.Types.PAIN,
|
|
})
|
|
}
|
|
}
|