Search in sources :

Example 21 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class InstantAttackRule method checkInstantAttacksInterrupt.

public static boolean checkInstantAttacksInterrupt(DC_ActiveObj action) {
    if (!RuleMaster.isRuleOn(RULE.INSTANT_ATTACK)) {
        return false;
    }
    Boolean retreat_passage_none = canMakeInstantAttackAgainst(action);
    if (RuleMaster.isRuleTestOn(RULE.INSTANT_ATTACK)) {
        retreat_passage_none = true;
    }
    if (!retreat_passage_none) {
        return false;
    }
    Set<Unit> set = getPotentialInstantAttackers(action);
    for (Unit unit : set) {
        // INSTANT_ATTACK_TYPE type = getInstantAttackType(unit, action);
        DC_ActiveObj attack = getInstantAttack(action, unit);
        if (attack == null) {
            continue;
        }
        boolean result = triggerInstantAttack(unit, action, attack);
        if (result) {
            return true;
        }
    }
    return false;
}
Also used : Unit(eidolons.entity.obj.unit.Unit) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 22 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class DamageCalculator method getBonusDamageList.

public static List<Damage> getBonusDamageList(Ref ref, DAMAGE_CASE CASE) {
    List<Damage> list = new ArrayList<>();
    // TODO make BonusDamage all add to source?
    DC_Obj obj = (DC_Obj) ref.getSourceObj();
    for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
        if (e == CASE) {
            list.addAll(obj.getBonusDamage().get(e));
        }
    }
    obj = (DC_Obj) ref.getObj(KEYS.ACTIVE);
    for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
        if (e == CASE) {
            list.addAll(obj.getBonusDamage().get(e));
        }
    }
    if (obj instanceof DC_ActiveObj) {
        obj = ((DC_ActiveObj) obj).getActiveWeapon();
        if (obj != null) {
            for (DAMAGE_CASE e : obj.getBonusDamage().keySet()) {
                if (e == CASE) {
                    list.addAll(obj.getBonusDamage().get(e));
                }
            }
        }
    }
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) ArrayList(java.util.ArrayList) DAMAGE_CASE(main.content.enums.GenericEnums.DAMAGE_CASE) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 23 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class DamageDealer method dealDamage.

// proceeds to deal the damage - to toughness and endurance separately and with appropriate events
private static int dealDamage(Ref ref, boolean magical, DAMAGE_TYPE dmg_type) {
    Event event = new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE, ref);
    if (!event.fire()) {
        return -1;
    }
    int amount = ref.getAmount();
    if (amount <= 0) {
        return 0;
    }
    ref = Ref.getCopy(ref);
    DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
    Unit attacker = (Unit) ref.getSourceObj();
    BattleFieldObject attacked = (BattleFieldObject) ref.getTargetObj();
    if (dmg_type == null) {
        dmg_type = active.getEnergyType();
    }
    int blocked = 0;
    if (attacked instanceof Unit)
        if (!DamageCalculator.isUnblockable(ref)) {
            if (ref.getSource() != ref.getTarget()) {
                if (isAttack(ref)) {
                    blocked = attacked.getGame().getArmorMaster().getArmorBlockDamage(amount, (Unit) attacked, attacker, active);
                } else {
                    blocked = attacked.getGame().getArmorMaster().getArmorBlockForActionDamage(amount, dmg_type, attacker, active);
                }
            }
        }
    int t_damage = DamageCalculator.calculateToughnessDamage(attacked, attacker, amount, ref, blocked, dmg_type);
    int e_damage = DamageCalculator.calculateEnduranceDamage(attacked, attacker, amount, ref, blocked, dmg_type);
    // PhaseAnimator.handleDamageAnimAndLog(ref, attacked, magical, dmg_type);
    ref.setAmount(e_damage);
    // TODO separate event types?
    if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_ENDURANCE_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_ENDURANCE_DAMAGE, ref).fire()) {
        return 0;
    }
    ref.setAmount(t_damage);
    if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_TOUGHNESS_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_TOUGHNESS_DAMAGE, ref).fire()) {
        return 0;
    }
    int result = dealPureDamage(attacked, attacker, t_damage, e_damage, ref);
    ref.setAmount(result);
    new Event(magical ? STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE, ref).fire();
    if (isLogOn()) {
        attacked.getGame().getLogManager().doneLogEntryNode(ENTRY_TYPE.DAMAGE, attacked, amount);
    }
    return result;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 24 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class DamageDealer method dealDamageOfType.

/**
 * This method accepts amount of damage already reduced by everything <b>except Resistance and Armor</b>  (defense, shield...)
 *
 * @param damage_type enum const, null will be set to active.getEnergyType()
 * @param targetObj   unit to deal dmg to
 * @param ref         contains all the other info we may need
 * @param amount      total amount of damage to be reduced by Resistance and Armor (unless damage_type==PURE) and dealt as PURE
 * @return actual amount of damage dealt ( max(min(Toughness*(1-DEATH_BARRIER), Toughness dmg),min(Endurance, Endurance dmg))
 */
private static int dealDamageOfType(DAMAGE_TYPE damage_type, BattleFieldObject targetObj, Ref ref, int amount, boolean bonus) {
    Unit attacker = (Unit) ref.getSourceObj();
    // amount *= OptionsMaster.getGameOptions.getOption(global_damage_mod)/100;
    if (!processDamageEvent(damage_type, ref, amount, STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE)) {
        return -1;
    }
    // VITAL!
    amount = ref.getAmount();
    if (isLogOn()) {
        ref.getGame().getLogManager().logDamageBeingDealt(amount, attacker, targetObj, damage_type);
    }
    if (!processDamageEvent(damage_type, ref, amount, new EventType(CONSTRUCTED_EVENT_TYPE.UNIT_IS_DEALT_DAMAGE_OF_TYPE, damage_type.toString()))) {
        return 0;
    }
    DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
    int damageDealt = 0;
    if (damage_type == DAMAGE_TYPE.PURE) {
        damageDealt = dealPureDamage(targetObj, attacker, amount, (DamageCalculator.isEnduranceOnly(ref) ? 0 : amount), ref);
    } else {
        damageDealt = dealDamage(ref, !isAttack(ref), damage_type);
    }
    if (!ref.isQuiet()) {
        try {
            active.getRef().setValue(KEYS.DAMAGE_DEALT, damageDealt + "");
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    addDamageDealt(active, damage_type, damageDealt, !bonus);
    return damageDealt;
}
Also used : EventType(main.game.logic.event.EventType) Unit(eidolons.entity.obj.unit.Unit) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 25 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class DamageFactory method getDamageForPrecalculate.

public static Damage getDamageForPrecalculate(Ref ref) {
    Damage dmg = new Damage();
    int amount = ref.getAmount();
    // if (ref.getActive().isSpell())
    DAMAGE_TYPE damageType = ref.getDamageType();
    if (ref.getActive() instanceof DC_ActiveObj) {
        DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
        dmg.setAction(activeObj);
        if (damageType == null) {
            damageType = activeObj.getDamageType();
        }
    }
    dmg.setRef(ref);
    dmg.setAmount(amount);
    dmg.setDmgType(damageType);
    return dmg;
}
Also used : DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Aggregations

DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)73 Unit (eidolons.entity.obj.unit.Unit)22 ArrayList (java.util.ArrayList)17 Obj (main.entity.obj.Obj)15 DC_UnitAction (eidolons.entity.active.DC_UnitAction)12 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 ActiveObj (main.entity.obj.ActiveObj)7 Effect (main.ability.effects.Effect)5 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)5 Targeting (main.elements.targeting.Targeting)5 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)4 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)4 FixedTargeting (main.elements.targeting.FixedTargeting)4 Coordinates (main.game.bf.Coordinates)4 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)3 ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)3