fix pathfinding issues
This commit is contained in:
+67
-12
@@ -28,7 +28,7 @@ export default class Ability {
|
||||
id: 'straight_shot',
|
||||
name: 'Straight Shot',
|
||||
castTime: 0.1,
|
||||
cooldown: 7,
|
||||
cooldown: 1,
|
||||
damage: 10,
|
||||
radius: 7,
|
||||
range: 800,
|
||||
@@ -54,20 +54,20 @@ export default class Ability {
|
||||
},
|
||||
})
|
||||
|
||||
static basicAttack = new Ability({
|
||||
id: 'basic_attack',
|
||||
name: 'Basic Attack',
|
||||
static rangedAttack = new Ability({
|
||||
id: 'ranged_attack',
|
||||
name: 'Ranged Attack',
|
||||
castTime: 0.25,
|
||||
cooldown: 1.25,
|
||||
damage: 5,
|
||||
radius: 5,
|
||||
range: 600,
|
||||
range: 500,
|
||||
speed: 600,
|
||||
effect: function basicAttackEffect(caster, cursor) {
|
||||
effect: function rangedAttackEffect(caster, cursor) {
|
||||
const ability = this
|
||||
let closest = null
|
||||
let distance = Infinity
|
||||
caster.game?.entities.filter((e) => e.id != caster.id && e.position.clone().sub(caster.position).length() < ability.range).forEach((e) => {
|
||||
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
|
||||
@@ -77,12 +77,12 @@ export default class Ability {
|
||||
|
||||
if (closest == null) { return }
|
||||
|
||||
const basicAttackAfter = function basicAttackAfter() {
|
||||
const rangedAttackAfter = function rangedAttackAfter() {
|
||||
closest.damage(ability.damage)
|
||||
}
|
||||
|
||||
const projectile = new Projectile({
|
||||
after: basicAttackAfter,
|
||||
after: rangedAttackAfter,
|
||||
homingTarget: closest,
|
||||
owner: caster,
|
||||
position: caster.position.clone(),
|
||||
@@ -95,12 +95,67 @@ export default class Ability {
|
||||
},
|
||||
})
|
||||
|
||||
static meleeAttack = new Ability({
|
||||
id: 'melee_attack',
|
||||
name: 'Melee Attack',
|
||||
castTime: 0.1,
|
||||
cooldown: 1.75,
|
||||
damage: 10,
|
||||
radius: 5,
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
if (closest == null) { return }
|
||||
|
||||
closest.damage(ability.damage)
|
||||
caster.cooldown(ability.id)
|
||||
},
|
||||
})
|
||||
|
||||
static shieldThrow = new Ability({
|
||||
id: 'shield_throw',
|
||||
name: 'Shield Throw',
|
||||
castTime: 0.1,
|
||||
cooldown: 7,
|
||||
effect: function shieldThrowEffect(caster, cursor) { },
|
||||
castTime: 0.15,
|
||||
cooldown: 5,
|
||||
radius: 20,
|
||||
range: 1000,
|
||||
speed: 2000,
|
||||
effect: function shieldThrowEffect(caster, cursor) {
|
||||
const ability = this
|
||||
const shieldThrowReturn = function shieldThrowReturn(projectile, homingTarget) {
|
||||
const returnProjectile = new Projectile({
|
||||
owner: caster,
|
||||
position: projectile.position.clone(),
|
||||
radius: ability.radius,
|
||||
speed: ability.speed,
|
||||
homingTarget: caster,
|
||||
})
|
||||
|
||||
caster.game?.spawnProjectile(returnProjectile)
|
||||
}
|
||||
|
||||
const projectile = new Projectile({
|
||||
after: shieldThrowReturn,
|
||||
owner: caster,
|
||||
position: caster.position.clone(),
|
||||
radius: ability.radius,
|
||||
speed: ability.speed,
|
||||
})
|
||||
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range))
|
||||
caster.game?.spawnProjectile(projectile)
|
||||
caster.cooldown(ability.id)
|
||||
},
|
||||
})
|
||||
|
||||
static blink = new Ability({
|
||||
|
||||
Reference in New Issue
Block a user