fix shielding logic
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-2
@@ -416,7 +416,7 @@ function connectWebSocket() {
|
|||||||
|
|
||||||
entity.children.at(0).visible = !e.dead
|
entity.children.at(0).visible = !e.dead
|
||||||
entity.children.at(1).visible = !e.dead
|
entity.children.at(1).visible = !e.dead
|
||||||
entity.children.at(2).visible = e.buffs.some((it) => it.id == 'exposed') // TODO: only works for Exposed now
|
entity.children.at(2).visible = !e.dead && e.buffs.some((it) => it.id == 'exposed') // TODO: only works for Exposed now
|
||||||
|
|
||||||
const animations = animationActions[e.id] ?? {}
|
const animations = animationActions[e.id] ?? {}
|
||||||
const fadeIn = created ? 0 : 0.15
|
const fadeIn = created ? 0 : 0.15
|
||||||
@@ -458,7 +458,7 @@ function connectWebSocket() {
|
|||||||
hp.scale.x = percentageHp
|
hp.scale.x = percentageHp
|
||||||
hp.position.x = -(1 - percentageHp) / 2
|
hp.position.x = -(1 - percentageHp) / 2
|
||||||
|
|
||||||
entity.children.at(3).visible = e.id == playerId
|
entity.children.at(3).visible = !e.dead && e.id == playerId
|
||||||
// entity.children.at(5).visible = !e.dead && e.team == playerTeam
|
// entity.children.at(5).visible = !e.dead && e.team == playerTeam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -270,7 +270,7 @@ export default class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyBuff(id, sourceId = null) {
|
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 }
|
if (buff == null) { return false }
|
||||||
|
|
||||||
const index = this.buffs.findIndex((it) => it.id == id)
|
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 damageMultiplerBuffs = buffs.map((it) => it.getBuff).filter((it) => it != null && it.damageMultiplier != null)
|
||||||
const buffPassiveDamageMultiplier = damageMultiplerBuffs.reduce((it) => it.damageMultiplier - 1, 0)
|
const buffPassiveDamageMultiplier = damageMultiplerBuffs.reduce((it) => it.damageMultiplier - 1, 0)
|
||||||
|
|
||||||
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
||||||
let damage = amount * damageMultipler
|
let damage = amount * damageMultipler
|
||||||
|
|
||||||
if (damage <= 0) {
|
if (damage >= 0) {
|
||||||
buffs.filter((it) => it.shield != null && it.shield > 0).forEach((it) => {
|
buffs.filter((it) => it.shield != null && it.shield > 0).forEach((it) => {
|
||||||
if (damage <= 0) { return }
|
if (damage <= 0) { return }
|
||||||
|
|
||||||
@@ -419,6 +419,10 @@ export default class Entity {
|
|||||||
return { ...buffDefinition, ...entityBuff }
|
return { ...buffDefinition, ...entityBuff }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBuffs() {
|
||||||
|
return this.buffs.map((it) => this.getBuff(it.id)).filter((it) => it != null)
|
||||||
|
}
|
||||||
|
|
||||||
hasBuff(id) {
|
hasBuff(id) {
|
||||||
if (this.dead) { return false }
|
if (this.dead) { return false }
|
||||||
|
|
||||||
|
|||||||
+17
-3
@@ -5,9 +5,9 @@ import Team from './team.js'
|
|||||||
export default class Template {
|
export default class Template {
|
||||||
static basilisk(overrides) {
|
static basilisk(overrides) {
|
||||||
return {
|
return {
|
||||||
abilities: {},
|
abilities: { a: Ability.rangedAttack.id },
|
||||||
logic: this.#basiliskLogic(),
|
logic: this.#basiliskLogic(),
|
||||||
maxHealth: 3000,
|
maxHealth: 300,
|
||||||
model: 'models/generic-bam-placeholder.gltf',
|
model: 'models/generic-bam-placeholder.gltf',
|
||||||
radius: 180,
|
radius: 180,
|
||||||
speed: 230,
|
speed: 230,
|
||||||
@@ -55,9 +55,11 @@ export default class Template {
|
|||||||
|
|
||||||
static #basiliskLogic() {
|
static #basiliskLogic() {
|
||||||
let diedOnTick = null
|
let diedOnTick = null
|
||||||
|
let targetInRangeSince = null
|
||||||
|
|
||||||
return function builtBasiliskLogic() {
|
return function builtBasiliskLogic() {
|
||||||
const entity = this
|
const entity = this
|
||||||
|
const attackDelaySec = 2
|
||||||
const despawnDelaySec = 5
|
const despawnDelaySec = 5
|
||||||
|
|
||||||
const despawnDelay = entity.game?.secToTick(despawnDelaySec) ?? 1
|
const despawnDelay = entity.game?.secToTick(despawnDelaySec) ?? 1
|
||||||
@@ -69,7 +71,19 @@ export default class Template {
|
|||||||
if (entity.dead) { return }
|
if (entity.dead) { return }
|
||||||
|
|
||||||
const target = entity.closestTargetTo(entity.position, 500)
|
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 directionToTarget = target.position.clone().sub(entity.position).normalize()
|
||||||
const entityRotationVector = new Vector2(1, 0).rotateAround(new Vector2(), entity.rotation)
|
const entityRotationVector = new Vector2(1, 0).rotateAround(new Vector2(), entity.rotation)
|
||||||
|
|||||||
Reference in New Issue
Block a user