inflate ranges by entity radii
This commit is contained in:
+13
-30
@@ -49,7 +49,7 @@ export default class Ability {
|
||||
speed: ability.speed,
|
||||
})
|
||||
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range))
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range + caster.radius))
|
||||
caster.game?.spawnProjectile(projectile)
|
||||
caster.cooldown(ability.id)
|
||||
},
|
||||
@@ -60,31 +60,22 @@ export default class Ability {
|
||||
name: 'Ranged Attack',
|
||||
castTime: 0.25,
|
||||
cooldown: 1.25,
|
||||
damage: 5,
|
||||
damage: 25,
|
||||
radius: 5,
|
||||
range: 500,
|
||||
speed: 600,
|
||||
effect: function rangedAttackEffect(caster, cursor) {
|
||||
const ability = this
|
||||
let closest = null
|
||||
let distance = Infinity
|
||||
caster.game?.entities.filter((e) => e.team != caster.team && e.position.clone().sub(caster.position).length() < ability.range).forEach((e) => {
|
||||
const newDistance = e.position.clone().sub(cursor).length()
|
||||
if (newDistance < distance) {
|
||||
closest = e
|
||||
distance = newDistance
|
||||
}
|
||||
})
|
||||
|
||||
if (closest == null) { return }
|
||||
const target = caster.closestTargetTo(cursor, ability.range)
|
||||
if (target == null) { return }
|
||||
|
||||
const rangedAttackAfter = function rangedAttackAfter() {
|
||||
closest.damage(ability.damage)
|
||||
target.damage(ability.damage)
|
||||
}
|
||||
|
||||
const projectile = new Projectile({
|
||||
after: rangedAttackAfter,
|
||||
homingTarget: closest,
|
||||
homingTarget: target,
|
||||
owner: caster,
|
||||
position: caster.position.clone(),
|
||||
radius: ability.radius,
|
||||
@@ -106,19 +97,10 @@ export default class Ability {
|
||||
range: 100,
|
||||
effect: function meleeAttackEffect(caster, cursor) {
|
||||
const ability = this
|
||||
let closest = null
|
||||
let distance = Infinity
|
||||
caster.game?.entities.filter((e) => e.team != caster.team && e.position.clone().sub(caster.position).length() < ability.range).forEach((e) => {
|
||||
const newDistance = e.position.clone().sub(cursor).length() < distance
|
||||
if (newDistance < distance) {
|
||||
closest = e
|
||||
distance = newDistance
|
||||
}
|
||||
})
|
||||
const target = caster.closestTargetTo(cursor, ability.range)
|
||||
if (target == null) { return }
|
||||
|
||||
if (closest == null) { return }
|
||||
|
||||
closest.damage(ability.damage)
|
||||
target.damage(ability.damage)
|
||||
caster.cooldown(ability.id)
|
||||
},
|
||||
})
|
||||
@@ -153,7 +135,7 @@ export default class Ability {
|
||||
speed: ability.speed,
|
||||
})
|
||||
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range))
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range + caster.radius))
|
||||
caster.game?.spawnProjectile(projectile)
|
||||
caster.cooldown(ability.id)
|
||||
},
|
||||
@@ -168,8 +150,9 @@ export default class Ability {
|
||||
effect: function blinkEffect(caster, cursor) {
|
||||
const ability = this
|
||||
const direction = cursor.clone().sub(caster.position)
|
||||
if (direction.length() > ability.range) {
|
||||
direction.normalize().multiplyScalar(ability.range)
|
||||
const realRange = ability.range + caster.radius
|
||||
if (direction.length() > realRange) {
|
||||
direction.normalize().multiplyScalar(realRange)
|
||||
}
|
||||
|
||||
const destination = caster.position.clone().add(direction)
|
||||
|
||||
Reference in New Issue
Block a user