title says it all, moving on from my kronos project. gonna be dropping some stuff that i did.
Code:
package io.ruin.model.skills.magic.spells.ancient;
import io.ruin.cache.ItemDef;
import io.ruin.model.combat.Hit;
import io.ruin.model.entity.Entity;
import io.ruin.model.entity.player.Player;
import io.ruin.model.item.containers.Equipment;
import io.ruin.model.skills.magic.spells.TargetSpell;
/**
*
* @Author Morrigan
*
* checks for tome before & after properly
*
*
*/
public abstract class BloodSpell extends TargetSpell {
static {
ItemDef.cached.values().stream().filter(def -> def.name.toLowerCase().contains("blood bark")).forEach(def -> def.bloodBarkEquip = true);
}
public static int bloodBarkEquipped(Player player) {
int count = 0;
ItemDef shieldDef = player.getEquipment().getDef(Equipment.SLOT_SHIELD);
ItemDef glovesDef = player.getEquipment().getDef(Equipment.SLOT_HANDS);
ItemDef bodyDef = player.getEquipment().getDef(Equipment.SLOT_CHEST);
ItemDef legsDef = player.getEquipment().getDef(Equipment.SLOT_LEGS);
ItemDef hatDef = player.getEquipment().getDef(Equipment.SLOT_HAT);
if (shieldDef != null && shieldDef.bloodBarkEquip) {
count++;
}
if (glovesDef != null && glovesDef.bloodBarkEquip) {
count++;
}
if (bodyDef != null && bodyDef.bloodBarkEquip) {
count++;
}
if (legsDef != null && legsDef.bloodBarkEquip) {
count++;
}
if (hatDef != null && hatDef.bloodBarkEquip) {
count++;
}
return count;
}
@Override
protected void beforeHit(Hit hit, Entity target) {
super.beforeHit(hit, target);
if (hit.attacker != null && hit.attacker.player != null) {
int count = bloodBarkEquipped(hit.attacker.player);
if (hit.damage > 0 && count > 0) {
int healAmount = (int) (hit.damage * (0.25 + (count * 0.015)));
hit.attacker.incrementHp(healAmount);
}
}
}
protected void afterHit (Hit hit, Entity target){
if (hit.damage > 0) {
int healAmount = hit.damage / 4;
hit.attacker.incrementHp(healAmount);
}
}
}
thanks for @Polar for sharing knowledge with me and helping me figure out the algorithm cause my maths is bad.