fix shielding logic
This commit is contained in:
+7
-3
@@ -270,7 +270,7 @@ export default class Entity {
|
||||
}
|
||||
|
||||
applyBuff(id, sourceId = null) {
|
||||
const buff = (this.game?.buffs ?? []).find((it) => it.id, id)
|
||||
const buff = (this.game?.buffs ?? []).find((it) => it.id == id)
|
||||
if (buff == null) { return false }
|
||||
|
||||
const index = this.buffs.findIndex((it) => it.id == id)
|
||||
@@ -348,14 +348,14 @@ export default class Entity {
|
||||
}
|
||||
}
|
||||
|
||||
const buffs = (source?.buffs ?? [])
|
||||
const buffs = this.buffs ?? []
|
||||
const damageMultiplerBuffs = buffs.map((it) => it.getBuff).filter((it) => it != null && it.damageMultiplier != null)
|
||||
const buffPassiveDamageMultiplier = damageMultiplerBuffs.reduce((it) => it.damageMultiplier - 1, 0)
|
||||
|
||||
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
||||
let damage = amount * damageMultipler
|
||||
|
||||
if (damage <= 0) {
|
||||
if (damage >= 0) {
|
||||
buffs.filter((it) => it.shield != null && it.shield > 0).forEach((it) => {
|
||||
if (damage <= 0) { return }
|
||||
|
||||
@@ -419,6 +419,10 @@ export default class Entity {
|
||||
return { ...buffDefinition, ...entityBuff }
|
||||
}
|
||||
|
||||
getBuffs() {
|
||||
return this.buffs.map((it) => this.getBuff(it.id)).filter((it) => it != null)
|
||||
}
|
||||
|
||||
hasBuff(id) {
|
||||
if (this.dead) { return false }
|
||||
|
||||
|
||||
+17
-3
@@ -5,9 +5,9 @@ import Team from './team.js'
|
||||
export default class Template {
|
||||
static basilisk(overrides) {
|
||||
return {
|
||||
abilities: {},
|
||||
abilities: { a: Ability.rangedAttack.id },
|
||||
logic: this.#basiliskLogic(),
|
||||
maxHealth: 3000,
|
||||
maxHealth: 300,
|
||||
model: 'models/generic-bam-placeholder.gltf',
|
||||
radius: 180,
|
||||
speed: 230,
|
||||
@@ -55,9 +55,11 @@ export default class Template {
|
||||
|
||||
static #basiliskLogic() {
|
||||
let diedOnTick = null
|
||||
let targetInRangeSince = null
|
||||
|
||||
return function builtBasiliskLogic() {
|
||||
const entity = this
|
||||
const attackDelaySec = 2
|
||||
const despawnDelaySec = 5
|
||||
|
||||
const despawnDelay = entity.game?.secToTick(despawnDelaySec) ?? 1
|
||||
@@ -69,7 +71,19 @@ export default class Template {
|
||||
if (entity.dead) { return }
|
||||
|
||||
const target = entity.closestTargetTo(entity.position, 500)
|
||||
if (target == null) { return }
|
||||
if (target == null) {
|
||||
targetInRangeSince = null
|
||||
return
|
||||
}
|
||||
|
||||
if (targetInRangeSince == null) {
|
||||
targetInRangeSince = timestamp
|
||||
}
|
||||
|
||||
const attackDelay = entity.game?.secToTick(attackDelaySec) ?? 1
|
||||
if (targetInRangeSince + attackDelay < timestamp) {
|
||||
entity.attackAction(target.position)
|
||||
}
|
||||
|
||||
const directionToTarget = target.position.clone().sub(entity.position).normalize()
|
||||
const entityRotationVector = new Vector2(1, 0).rotateAround(new Vector2(), entity.rotation)
|
||||
|
||||
Reference in New Issue
Block a user