Search in sources :

Example 56 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class RestCondition method check.

@Override
public boolean check(Ref ref) {
    // check whole party!
    // check anyone has food
    List<Unit> allies = getGame().getMetaMaster().getPartyManager().getParty().getMembers();
    boolean hasFood = false;
    for (Unit sub : allies) {
        int distance = getGame().getAiManager().getAnalyzer().getClosestEnemyDistance(sub);
        // return false;
        if (new SearchMaster<DC_HeroItemObj>().find(FOOD_ITEM, sub.getInventory(), true) != null)
            hasFood = true;
    }
    if (true)
        return true;
    return hasFood;
}
Also used : SearchMaster(main.system.auxiliary.SearchMaster) Unit(eidolons.entity.obj.unit.Unit)

Example 57 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class SneakCondition method checkSneak.

public boolean checkSneak(Ref ref) {
    if (!(ref.getObj(key) instanceof Unit)) {
        return false;
    }
    Unit attacked = (Unit) ref.getObj(key);
    if (attacked.isBfObj()) {
        return false;
    }
    if (attacked.checkPassive(UnitEnums.STANDARD_PASSIVES.SNEAK_IMMUNE)) {
        return false;
    }
    if (attacked.checkStatus(UnitEnums.STATUS.IMMOBILE)) {
        return true;
    }
    if (attacked.checkStatus(UnitEnums.STATUS.CHARMED)) {
        return true;
    }
    Unit attacker = (Unit) ref.getSourceObj();
    DC_ActiveObj action = (DC_ActiveObj) ref.getObj(KEYS.ACTIVE);
    if (!attacker.checkInSightForUnit(attacked)) {
        if (// TODO wake up?
        attacked.getMode().equals(STD_MODES.ALERT)) {
            return false;
        }
        if (!action.isRanged()) {
            if (attacker.getActivePlayerVisionStatus() == PLAYER_VISION.UNKNOWN || !VisionManager.checkVisible(attacker)) {
                return true;
            } else {
                // TODO allow sneak in front for specialists
                return FacingMaster.getSingleFacing(attacked, attacker) == UnitEnums.FACING_SINGLE.BEHIND;
            }
        }
    }
    return false;
}
Also used : Unit(eidolons.entity.obj.unit.Unit) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 58 with Unit

use of eidolons.entity.obj.unit.Unit 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 59 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class DamageCalculator method precalculateDamage.

/**
 * Calculates damage for AI's FutureBuilder (DealDamageEffect)
 *
 * @param ref
 * @return
 */
public static int precalculateDamage(Ref ref) {
    Unit sourceObj = (Unit) ref.getSourceObj();
    Damage damage = DamageFactory.getDamageForPrecalculate(ref);
    int amount = damage.getAmount();
    DAMAGE_TYPE damageType = damage.getDmgType();
    if (damage.getTarget() instanceof Unit) {
        int blocked = sourceObj.getGame().getArmorSimulator().getArmorBlockDamage(damage);
        amount -= blocked;
    }
    amount -= amount * ResistMaster.getResistanceForDamageType((Unit) ref.getTargetObj(), sourceObj, damageType) / 100;
    // applySpellArmorReduction(amount, (DC_HeroObj)
    return amount;
// ref.getTargetObj(), ref.getSourceObj());
}
Also used : DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) Unit(eidolons.entity.obj.unit.Unit)

Example 60 with Unit

use of eidolons.entity.obj.unit.Unit 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)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7