Search in sources :

Example 36 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DC_EffectManager method checkNotResisted.

@Override
public boolean checkNotResisted(Effect effect) {
    if (effect.isIrresistible()) {
        return true;
    }
    if (!checkEffectType(effect)) {
        return true;
    }
    Ref ref = effect.getRef();
    try {
        if (!checkTargeting(effect)) {
            return true;
        }
        if (effect instanceof ReducedEffect) {
            DC_ActiveObj spell = (DC_ActiveObj) ref.getActive();
            if (spell == null) {
                return true;
            }
            if (spell.getResistanceType() != SpellEnums.RESISTANCE_TYPE.IRRESISTIBLE) {
                if (spell.getResistanceType() != SpellEnums.RESISTANCE_TYPE.CHANCE_TO_BLOCK) {
                    int mod = ResistanceRule.getResistanceMod(ref);
                    ((ReducedEffect) effect).setResistanceMod(mod);
                    return true;
                }
            }
        }
        if (checkResistanceAlreadyChecked(effect)) {
            return true;
        }
        return ResistanceRule.checkNotResisted(ref);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
        return true;
    }
}
Also used : Ref(main.entity.Ref) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 37 with Ref

use of main.entity.Ref 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 38 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ForceRule method isForceEnabled.

private static boolean isForceEnabled(DC_ActiveObj action) {
    if (action.isAttackAny()) {
        return true;
    }
    if (action.isSpell()) {
        Ref ref = action.getRef();
        // TODO won't be initialized here yet!!!
        DC_SpellObj spell = (DC_SpellObj) action;
        if (spell.isDamageSpell()) {
            if (spell.isMissile()) {
                if (spell.getResistanceType() == RESISTANCE_TYPE.REDUCE_DAMAGE) {
                    if (!DamageCalculator.isPeriodic(ref)) {
                        if (!ref.isTriggered()) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : Ref(main.entity.Ref) DC_SpellObj(eidolons.entity.active.DC_SpellObj)

Example 39 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ForceRule method applyDamage.

public static void applyDamage(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
    int damage = getDamage(force, target, target, target);
    // attack.modifyParameter(PARAMS.BASE_DAMAGE, damage);
    // if (target.getShield()!=null )
    Ref ref = attack.getRef().getCopy();
    ref.setTarget(target.getId());
    new DealDamageEffect(new Formula(damage + ""), GenericEnums.DAMAGE_TYPE.BLUDGEONING).apply(ref);
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect)

Example 40 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ForceRule method getDamageObject.

public static Damage getDamageObject(DC_ActiveObj action, BattleFieldObject attacker, BattleFieldObject attacked) {
    int amount = getDamage(action, attacker, attacked);
    if (amount <= 0) {
        return null;
    }
    DAMAGE_TYPE type = getForceDamageType(action);
    return DamageFactory.getGenericDamage(type, amount, new Ref(attacker, attacked));
}
Also used : Ref(main.entity.Ref) DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5