Search in sources :

Example 1 with DurabilityReductionEffect

use of eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect in project Eidolons by IDemiurge.

the class DurabilityRule method physicalDamage.

public static int physicalDamage(int damage, int blocked, DAMAGE_TYPE damage_type, DC_HeroSlotItem armor, DC_WeaponObj weapon, boolean simulation) {
    int self_damage_mod = armor.getIntParam(DC_ContentManager.getArmorSelfDamageParamForDmgType(damage_type));
    if (!RuleMaster.isRuleOn(RULE.DURABILITY))
        self_damage_mod = 0;
    else if (self_damage_mod == 0)
        self_damage_mod = 100;
    // new EnumMaster<ENUM>().retrieveEnumConst(ENUM.class, )
    MATERIAL m1 = armor.getMaterial();
    MATERIAL m2 = weapon.getMaterial();
    int armor_vs_weapon = m1.getHardness() - m2.getHardness();
    int armor_amount = blocked * self_damage_mod / 100;
    armor_amount = MathMaster.addFactor(armor_amount, armor_vs_weapon);
    DurabilityReductionEffect durabilityReductionEffect = new DurabilityReductionEffect(false, armor_amount);
    durabilityReductionEffect.setSimulation(simulation);
    Ref ref = Ref.getSelfTargetingRefCopy(armor);
    ref.setID(KEYS.WEAPON, weapon.getId());
    if (armor_amount > 0)
        durabilityReductionEffect.apply(ref);
    self_damage_mod = weapon.getIntParam(DC_ContentManager.getArmorSelfDamageParamForDmgType(damage_type));
    int weapon_amount = blocked * self_damage_mod / 100;
    weapon_amount = MathMaster.addFactor(weapon_amount, armor_vs_weapon);
    durabilityReductionEffect = new DurabilityReductionEffect(true, weapon_amount);
    durabilityReductionEffect.setSimulation(simulation);
    durabilityReductionEffect.apply(Ref.getSelfTargetingRefCopy(weapon));
    return durabilityReductionEffect.getDurabilityLost();
}
Also used : DurabilityReductionEffect(eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect) Ref(main.entity.Ref) MATERIAL(main.content.enums.entity.ItemEnums.MATERIAL)

Example 2 with DurabilityReductionEffect

use of eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect in project Eidolons by IDemiurge.

the class DurabilityRule method getAttackItemDurabilityReductionEffects.

public static Effects getAttackItemDurabilityReductionEffects(int amount) {
    String source_ref = "{EVENT_SOURCE}";
    String target_ref = "{EVENT_TARGET}";
    return new Effects(new ConditionalEffect(new OrConditions(new ItemCondition(source_ref, ItemEnums.ITEM_SLOT.MAIN_HAND.getProp().getName()), new ItemCondition(source_ref, ItemEnums.ITEM_SLOT.OFF_HAND.getProp().getName())), new DurabilityReductionEffect(true, amount)), new ConditionalEffect(new ItemCondition(target_ref, ItemEnums.ITEM_SLOT.ARMOR.getProp().getName()), new DurabilityReductionEffect(false, amount)));
}
Also used : ConditionalEffect(main.ability.effects.container.ConditionalEffect) DurabilityReductionEffect(eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect) OrConditions(main.elements.conditions.OrConditions) Effects(main.ability.effects.Effects) ItemCondition(eidolons.ability.conditions.req.ItemCondition)

Example 3 with DurabilityReductionEffect

use of eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect in project Eidolons by IDemiurge.

the class DurabilityRule method spellDamage.

public static int spellDamage(int damage, int blocked, DAMAGE_TYPE damage_type, DC_HeroSlotItem armor, boolean simulation) {
    int self_damage_mod = armor.getIntParam(DC_ContentManager.getArmorSelfDamageParamForDmgType(damage_type));
    // special cases may apply for Damage
    int amount = blocked * self_damage_mod / 100;
    DurabilityReductionEffect durabilityReductionEffect = new DurabilityReductionEffect(null, amount);
    durabilityReductionEffect.setSimulation(simulation);
    durabilityReductionEffect.apply(Ref.getSelfTargetingRefCopy(armor));
    return durabilityReductionEffect.getDurabilityLost();
}
Also used : DurabilityReductionEffect(eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect)

Aggregations

DurabilityReductionEffect (eidolons.ability.effects.oneshot.rule.DurabilityReductionEffect)3 ItemCondition (eidolons.ability.conditions.req.ItemCondition)1 Effects (main.ability.effects.Effects)1 ConditionalEffect (main.ability.effects.container.ConditionalEffect)1 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)1 OrConditions (main.elements.conditions.OrConditions)1 Ref (main.entity.Ref)1