Search in sources :

Example 61 with Unit

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

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

the class TimeRule method newRound.

public void newRound() {
    if (DC_Engine.isAtbMode()) {
        return;
    }
    active = false;
    threshold = null;
    int totalTime = 0;
    for (Unit unit : game.getUnits()) {
        Integer totalInitiative = unit.getIntParam(PARAMS.C_INITIATIVE) - unit.getIntParam(PARAMS.C_INITIATIVE_BONUS);
        if (totalInitiative > totalTime) {
            totalTime = totalInitiative;
        }
    }
    baseTime = totalTime;
    maxTime = 0;
    timeRemaining = baseTime;
    timeMap.clear();
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 63 with Unit

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

the class UpkeepRule method apply.

@Override
public void apply(Unit unit) {
    // TODO getOrCreate all buffs/units with this SOURCE /summoner
    List<Obj> payObjects = new ArrayList<>();
    List<Obj> destroyObjects = new ArrayList<>();
    boolean destroy = unit.isDead() || unit.isUnconscious();
    for (Unit u : game.getUnits()) {
        if (destroy || u.isDead() || u.isUnconscious()) {
            destroyObjects.add(u);
        } else if (u.getRef().getObj(KEYS.SUMMONER) == unit) {
            if (checkHasUpkeep(u)) {
                payObjects.add(u);
            }
        }
    }
    for (Obj buff : game.getObjects(DC_TYPE.BUFFS)) {
        try {
            Obj spell = (Obj) buff.getRef().getActive();
            if (spell == null) {
                continue;
            }
            if (spell.getRef().getSourceObj() == unit) {
                // TODO summoner?
                if (checkHasUpkeep(buff)) {
                    payObjects.add(buff);
                }
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    for (Obj payObj : destroyObjects) {
        enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
    }
    for (Obj payObj : payObjects) {
        if (!checkCanUpkeep(unit, payObj)) {
            // positive upkeep?
            enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
        } else {
            subtractUpkeep(unit, payObj);
        }
    }
}
Also used : BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Example 64 with Unit

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

the class CleaveRule method initNextTarget.

private void initNextTarget() {
    boolean first = false;
    if (clockwise == null) {
        // find targets TODO
        first = true;
    }
    // preCheck facing! always try the longest arc first, if
    clockwise = true;
    // it fails, then short one
    DIRECTION direction = DirectionMaster.getRelativeDirection(source, currentTarget);
    Obj objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
    if (objectByCoordinate instanceof Unit) {
        currentTarget = (Unit) objectByCoordinate;
    } else if (first) {
        clockwise = false;
        objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
        if (objectByCoordinate != null) {
            currentTarget = (Unit) objectByCoordinate;
        }
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) Unit(eidolons.entity.obj.unit.Unit)

Example 65 with Unit

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

the class CounterMasterAdvanced method afterRoundEnds.

public static void afterRoundEnds(Unit unit) {
    // some interactions should happen immediately - e.g. moist vs blaze
    // so we need to Interact, Convert and Transfer... what's the order? probably exactly that!
    Map<COUNTER, Integer> map = createCounterMap(unit);
    map.forEach((counter, value) -> map.forEach((counter2, value2) -> {
        if (counter != counter2) {
            COUNTER_INTERACTION interaction = getInteraction(counter, counter2);
            int max = getMaxInteractionValue(unit, counter, counter2, value, value2);
            interact(counter, counter2, interaction, max, unit);
        }
    }));
    Map<COUNTER, Integer> convertMap = createCounterMap(unit);
    map.forEach((counter, value) -> {
        COUNTER counter2 = getConvertion(counter);
        int max = getMaxConvertionValue(unit, counter, counter2, value);
        convertCounters(counter, counter2, max, unit);
    });
    Map<COUNTER, Integer> transferMap = createCounterMap(unit);
    map.forEach((counter, value) -> map.forEach((counter2, value2) -> {
        if (counter != counter2) {
            COUNTER_INTERACTION interaction = getInteraction(counter, counter2);
            int max = getMaxInteractionValue(unit, counter, counter2, value, value2);
            interact(counter, counter2, interaction, max, unit);
        }
    }));
}
Also used : COUNTER_INTERACTION(main.content.enums.entity.UnitEnums.COUNTER_INTERACTION) COUNTER_OPERATION(main.content.enums.entity.UnitEnums.COUNTER_OPERATION) COUNTER(main.content.enums.entity.UnitEnums.COUNTER) Map(java.util.Map) XLinkedMap(main.data.XLinkedMap) HashMap(java.util.HashMap) Unit(eidolons.entity.obj.unit.Unit) CounterMaster(main.system.entity.CounterMaster) COUNTER_INTERACTION(main.content.enums.entity.UnitEnums.COUNTER_INTERACTION) COUNTER(main.content.enums.entity.UnitEnums.COUNTER)

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