add shield buff property
This commit is contained in:
@@ -159,6 +159,7 @@
|
|||||||
|
|
||||||
.buff:hover {
|
.buff:hover {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
height: fit-content;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +168,7 @@
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
min-width: 200px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+3
-3
@@ -235,7 +235,7 @@ export default class Ability {
|
|||||||
const entityId = collidingEntity.id
|
const entityId = collidingEntity.id
|
||||||
|
|
||||||
if (!collided.has(entityId)) {
|
if (!collided.has(entityId)) {
|
||||||
collidingEntity.heal(amount, caster)
|
collidingEntity.applyBuff(Buff.shieldThrowShield.id, caster.id)
|
||||||
collided.add(entityId)
|
collided.add(entityId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,8 @@ export default class Ability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const shieldThrowSecondAfter = function shieldThrowSecondAfter(projectile, homingTarget) {
|
const shieldThrowSecondAfter = function shieldThrowSecondAfter(projectile, homingTarget) {
|
||||||
caster.heal(amount, caster)
|
caster.applyBuff(Buff.shieldThrowShield.id, caster.id)
|
||||||
caster.heal(amount, caster) // NOTE: duplicated on purpose
|
caster.applyBuff(Buff.shieldThrowShield.id, caster.id) // NOTE: duplicated on purpose
|
||||||
}
|
}
|
||||||
|
|
||||||
const shieldThrowFirstAfter = function shieldThrowFirstAfter(projectile, homingTarget) {
|
const shieldThrowFirstAfter = function shieldThrowFirstAfter(projectile, homingTarget) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export default class Buff {
|
|||||||
|
|
||||||
damageMultiplier = null
|
damageMultiplier = null
|
||||||
duration = 0
|
duration = 0
|
||||||
|
shield = null
|
||||||
|
|
||||||
#effect = null
|
#effect = null
|
||||||
|
|
||||||
@@ -25,4 +26,11 @@ export default class Buff {
|
|||||||
duration: 4,
|
duration: 4,
|
||||||
onHitMultiplier: 3,
|
onHitMultiplier: 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
static shieldThrowShield = new Buff({
|
||||||
|
id: 'shield_throw_shield',
|
||||||
|
name: 'Shield (of Shield Throw)',
|
||||||
|
duration: 5,
|
||||||
|
shield: 200,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-15
@@ -28,21 +28,22 @@ export default class Entity {
|
|||||||
visionRange = 900
|
visionRange = 900
|
||||||
visualRadius = null
|
visualRadius = null
|
||||||
|
|
||||||
#collision = true
|
|
||||||
#ghostable = true
|
|
||||||
#attacking = false
|
#attacking = false
|
||||||
#bbox = new Float32Array(4)
|
#bbox = new Float32Array(4)
|
||||||
#colliders = []
|
#colliders = []
|
||||||
#entitiesInVision = []
|
#collision = true
|
||||||
#projectilesInVision = []
|
|
||||||
#pathfindingCooldown = 0
|
|
||||||
#pathfindingObstacleLimit = null
|
|
||||||
#dest = null
|
#dest = null
|
||||||
|
#entitiesInVision = []
|
||||||
#game = null
|
#game = null
|
||||||
|
#ghostable = true
|
||||||
#logic = null
|
#logic = null
|
||||||
#moving = false
|
#moving = false
|
||||||
#path = []
|
|
||||||
#noPathfindingUntil = 0
|
#noPathfindingUntil = 0
|
||||||
|
#path = []
|
||||||
|
#pathfindingCooldown = 0
|
||||||
|
#pathfindingObstacleLimit = null
|
||||||
|
#projectilesInVision = []
|
||||||
|
#queuedAction = null
|
||||||
#spawnPosition = new Vector2()
|
#spawnPosition = new Vector2()
|
||||||
|
|
||||||
static bbox(x, y, radius) {
|
static bbox(x, y, radius) {
|
||||||
@@ -177,7 +178,6 @@ export default class Entity {
|
|||||||
this.moveAction(cursor, true)
|
this.moveAction(cursor, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: buffer skill inputs
|
|
||||||
castAction(slot, cursor, halt = false) {
|
castAction(slot, cursor, halt = false) {
|
||||||
if (this.dead) { return }
|
if (this.dead) { return }
|
||||||
|
|
||||||
@@ -267,16 +267,27 @@ export default class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyBuff(id, sourceId = null) {
|
applyBuff(id, sourceId = null) {
|
||||||
|
const buff = (this.game?.buffs ?? []).find((it) => it.id, id)
|
||||||
|
if (buff == null) { return false }
|
||||||
|
|
||||||
const index = this.buffs.findIndex((it) => it.id == id)
|
const index = this.buffs.findIndex((it) => it.id == id)
|
||||||
const source = sourceId ?? this.id
|
const source = sourceId ?? this.id
|
||||||
const timestamp = this.game?.currentTick ?? 0
|
const timestamp = this.game?.currentTick ?? 0
|
||||||
|
|
||||||
if (index > -1) {
|
if (index < 0) {
|
||||||
this.buffs[index].timestamp = timestamp
|
const entityBuff = { id, source, timestamp }
|
||||||
this.buffs[index].source = source
|
if (buff.shield != null) {
|
||||||
|
entityBuff.shield = buff.shield
|
||||||
|
}
|
||||||
|
|
||||||
|
this.buffs.push(entityBuff)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.buffs.push({ id, source, timestamp })
|
this.buffs[index].timestamp = timestamp
|
||||||
|
this.buffs[index].source = source
|
||||||
|
if (buff.shield != null) {
|
||||||
|
this.buffs[index].shield = (this.buffs[index].shield ?? 0) + buff.shield
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +333,6 @@ export default class Entity {
|
|||||||
return entitiesAndTerrains.filter((it) => !it.dead && it.collision && !((this.ghosting && it.ghostable) || (this.ghostable && it.ghosting)) && SATX.bboxCheck(bbox, it.bbox))
|
return entitiesAndTerrains.filter((it) => !it.dead && it.collision && !((this.ghosting && it.ghostable) || (this.ghostable && it.ghosting)) && SATX.bboxCheck(bbox, it.bbox))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add shielding logic
|
|
||||||
damage(amount, source = null) {
|
damage(amount, source = null) {
|
||||||
if (this.dead) { return }
|
if (this.dead) { return }
|
||||||
|
|
||||||
@@ -335,11 +345,22 @@ export default class Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const damageMultiplerBuffs = (source?.buffs ?? []).map((it) => it.getBuff).filter((it) => it != null && it.damageMultiplier != null)
|
const buffs = (source?.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 buffPassiveDamageMultiplier = damageMultiplerBuffs.reduce((it) => it.damageMultiplier - 1, 0)
|
||||||
|
|
||||||
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
||||||
const damage = amount * damageMultipler
|
let damage = amount * damageMultipler
|
||||||
|
|
||||||
|
if (damage <= 0) {
|
||||||
|
buffs.filter((it) => it.shield != null && it.shield > 0).forEach((it) => {
|
||||||
|
if (damage <= 0) { return }
|
||||||
|
|
||||||
|
const shielded = Math.max(0, Math.min(damage, it.shield))
|
||||||
|
it.shield -= shielded
|
||||||
|
damage -= shielded
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.health = Math.min(Math.max(0, this.health - damage), this.maxHealth)
|
this.health = Math.min(Math.max(0, this.health - damage), this.maxHealth)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export class Dungeon {
|
|||||||
game.spawnEntity(new Entity(Template.player({ id: '2', spawnPosition: new Vector2(1500, 700), team, dead: true })))
|
game.spawnEntity(new Entity(Template.player({ id: '2', spawnPosition: new Vector2(1500, 700), team, dead: true })))
|
||||||
|
|
||||||
game.spawnEntity(new Entity(Template.basilisk({ id: 'boss', spawnPosition: new Vector2(2200, 750), team: Team.neutral })))
|
game.spawnEntity(new Entity(Template.basilisk({ id: 'boss', spawnPosition: new Vector2(2200, 750), team: Team.neutral })))
|
||||||
game.entities.find((it) => it.id == 'boss').damage(9999)
|
|
||||||
|
|
||||||
game.start()
|
game.start()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user