Skip to content
TTevita edited this page Sep 11, 2022 · 1 revision

Back to Skills

Bleed Code

Bleed length and damage

The bleed effect is intended to do small amounts of damage each second, which becomes more impactful as the total damage accumulates over time. The bleed currently does 35 damage total over a 7 second period (5 damage/s). The bleed effect wears off after 7 seconds.

Applying bleed effect to enemy

If the bleed skill is currently equipped by the player, an event listener will trigger when the player attacks an enemy (the listener calls hitBleed() seen below). If the player has activated the skill and the event has been triggered, then the bleeding condition will be applied to the attacked enemy. If the player has not activated the skill, nothing will happen on event trigger.

public void hitBleed(Entity target) {
        if (!this.bleedApplied) {
            return;
        }
        this.enemy = target;
        this.bleeding = true;
        this.bleedStart = System.currentTimeMillis();
    }

Apply bleed damage to enemy

The below function is called each frame while bleed is applied to an enemy, inflicting 5 damage every second. If the enemy dies from bleed damage they are disposed and removed from the game.

if (System.currentTimeMillis() > this.bleedEnd + BLEED_LENGTH) {
            CombatStatsComponent enemyStats = target.getComponent(CombatStatsComponent.class);
            enemyStats.setHealth(enemyStats.getHealth() - BLEED_DAMAGE);
...
Clone this wiki locally