Search in sources :

Example 1 with Conditions

use of main.elements.conditions.Conditions in project Eidolons by IDemiurge.

the class TurnSequenceConstructor method getTurnSequence.

public List<Action> getTurnSequence(Action action) {
    Conditions conditions = (action.getTargeting().getFilter().getConditions());
    FacingCondition condition = null;
    FACING_SINGLE template = null;
    DC_Obj target = action.getTarget();
    Unit source = (Unit) action.getRef().getSourceObj();
    for (Condition c : conditions) {
        if (c instanceof FacingCondition) {
            condition = (FacingCondition) c;
            break;
        }
        List<Object> list = ClassMaster.getInstances(c, FacingCondition.class);
        if (!list.isEmpty()) {
            List<Action> front_sequence = getTurnSequence(FACING_SINGLE.IN_FRONT, source, target.getCoordinates());
            List<Action> side_sequence = null;
            if (action.getSource().hasBroadReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.BROAD_REACH)) // front_sequence.remove(front_sequence.size() - 1);
            {
                side_sequence = getTurnSequence(FACING_SINGLE.TO_THE_SIDE, source, target.getCoordinates());
            }
            List<Action> hind_sequence = null;
            if (action.getSource().hasHindReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.HIND_REACH)) {
                hind_sequence = getTurnSequence(FACING_SINGLE.BEHIND, source, target.getCoordinates());
            }
            return new ListMaster<Action>().getSmallest(front_sequence, hind_sequence, side_sequence);
        }
    }
    // }
    if (condition == null) {
        return new ArrayList<>();
    }
    if (ArrayMaster.isNotEmpty(condition.getTemplate())) {
        template = condition.getTemplate()[0];
    }
    return getTurnSequence(template, source, target.getCoordinates());
}
Also used : FacingCondition(eidolons.ability.conditions.FacingCondition) Condition(main.elements.conditions.Condition) DC_Obj(eidolons.entity.obj.DC_Obj) Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ArrayList(java.util.ArrayList) FacingCondition(eidolons.ability.conditions.FacingCondition) Unit(eidolons.entity.obj.unit.Unit) Conditions(main.elements.conditions.Conditions) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 2 with Conditions

use of main.elements.conditions.Conditions in project Eidolons by IDemiurge.

the class ShapeEffect method initTargeting.

@Override
public void initTargeting() {
    // init unit group
    Coordinates baseCoordinate = getBaseCoordinate();
    int base_width = radius.getInt(ref);
    int distance = this.distance.getInt(ref);
    coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
    DequeImpl<Obj> objects = new DequeImpl<>();
    objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
    Filter.filter(objects, targetType);
    if (allyOrEnemyOnly != null) {
        if (allyOrEnemyOnly) {
            FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
        } else {
            FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
        }
    }
    if (notSelf) {
        FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
    }
    if (targetType.equals(DC_TYPE.TERRAIN)) {
        // C_TYPE equals if contains() !
        objects.addAll(game.getCellsForCoordinates(coordinates));
    }
    targeting = new AutoTargeting(new GroupImpl(objects));
    setFilteringConditions(new Conditions());
    targeting.setConditions(getFilteringConditions());
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) DequeImpl(main.system.datatypes.DequeImpl) Conditions(main.elements.conditions.Conditions)

Example 3 with Conditions

use of main.elements.conditions.Conditions in project Eidolons by IDemiurge.

the class SleepEffect method applyThis.

@Override
public boolean applyThis() {
    // makes another throw each time when hit?
    // statically parsed Spellpower/Mastery?
    // add roll on hit - dmg vs max toughness
    RollEffect rollEffect = new RollEffect(GenericEnums.ROLL_TYPES.MIND_AFFECTING, new RemoveBuffEffect(getBuffName()));
    Conditions conditions = new Conditions(new RefCondition(KEYS.EVENT_TARGET, KEYS.TARGET));
    return new AddBuffEffect(getBuffName(), new Effects(new AddStatusEffect(UnitEnums.STATUS.ASLEEP), new AddTriggerEffect(STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE, conditions, KEYS.EVENT_TARGET, rollEffect))).apply(ref);
// roll ref needs to be tested!
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) RefCondition(main.elements.conditions.RefCondition) Effects(main.ability.effects.Effects) AddStatusEffect(main.ability.effects.common.AddStatusEffect) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect)

Example 4 with Conditions

use of main.elements.conditions.Conditions in project Eidolons by IDemiurge.

the class CadenceRule method checkDualAttackCadence.

public static void checkDualAttackCadence(DC_UnitAction action, Unit unit) {
    if (action.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
        return;
    }
    boolean singleCadence = checkSingleWeaponCadence(unit, action);
    if (!UnitAnalyzer.checkDualWielding(unit) && !UnitAnalyzer.checkDualNaturalWeapons(unit) && !singleCadence) // || checkSingleCadence(action)
    {
        return;
    }
    Boolean offhand = null;
    if (action.checkProperty(PROP, MAIN_HAND)) {
        offhand = false;
    } else if (action.checkProperty(PROP, OFF_HAND)) {
        offhand = true;
    } else if (singleCadence) // offhand = !action.isOffhand();
    {
        offhand = false;
    }
    if (offhand == null) {
        return;
    }
    Ref ref = new Ref(unit.getGame(), unit.getId());
    DC_WeaponObj weapon = unit.getActiveWeapon(offhand);
    List<Obj> targets = new ArrayList<>();
    if (unit.getWeapon(!offhand) != null) {
        targets.add(unit.getWeapon(!offhand));
    }
    if (unit.getNaturalWeapon(!offhand) != null) {
        targets.add(unit.getNaturalWeapon(!offhand));
    }
    GroupImpl group = new GroupImpl(targets);
    LogMaster.log(LogMaster.RULES_DEBUG, "Cadence Rule applies to " + group);
    ref.setGroup(group);
    if (checkFocusBonusApplies(unit, action, singleCadence)) {
        Integer amount = action.getOwnerObj().getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getOwnerObj().getActiveWeapon(!offhand).getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        action.getOwnerObj().modifyParameter(PARAMS.C_FOCUS, amount, 100);
    }
    // INIT COST CADENCE EFFECTS
    Effects effects = new Effects();
    String cadence = unit.getParam(PARAMS.CADENCE_AP_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_AP_MOD + "";
    }
    ModifyValueEffect valueEffect = new ModifyValueEffect(PARAMS.ATTACK_AP_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    cadence = unit.getParam(PARAMS.CADENCE_STA_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_STA_MOD + "";
    }
    valueEffect = new ModifyValueEffect(PARAMS.ATTACK_STA_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    if (unit.getIntParam(PARAMS.CADENCE_DAMAGE_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.DAMAGE_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_DAMAGE_MOD)));
    }
    if (unit.getIntParam(PARAMS.CADENCE_ATTACK_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.ATTACK_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_ATTACK_MOD)));
    }
    String buffTypeName = (!offhand) ? buffTypeNameOffHand : buffTypeNameMainHand;
    // ADD REMOVE TRIGGER
    int percentage = 100 - unit.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - action.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - weapon.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE);
    Conditions conditions = new Conditions(new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE));
    if (percentage != 100) {
        conditions.add(new ChanceCondition(new Formula("" + percentage)));
    }
    effects.add(new AddTriggerEffect(STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, conditions, new ActiveAbility(new FixedTargeting(KEYS.BASIS), new RemoveBuffEffect(buffTypeName))));
    // effect = new AddBuffEffect(buffTypeName, effects, DURATION);
    // Condition condition = new StringComparison(StringMaster.getValueRef(KEYS.MATCH, PROP),
    // (offhand) ? MAIN_HAND : OFF_HAND, false);
    // retain condition - hero hasBuff()
    // add remove trigger on attack? either off/main hand, so there is no
    // stacking...
    // linked buffs?
    // effect.setIrresistible(false);
    AddBuffEffect addBuffEffect = new AddBuffEffect(buffTypeName, // new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ACTIONS, condition),
    effects, DURATION);
    // preCheck perk
    addBuffEffect.addEffect(new // what about
    AddTriggerEffect(// counters/AoO?
    STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE), new ActiveAbility(new FixedTargeting(KEYS.SOURCE), new RemoveBuffEffect(buffTypeName))));
    Integer param = unit.getIntParam(PARAMS.CADENCE_DEFENSE_MOD);
    if (param != 0) {
        addBuffEffect.addEffect(new ModifyValueEffect(PARAMS.DEFENSE_MOD, MOD.MODIFY_BY_CONST, "" + param));
    }
    addBuffEffect.setIrresistible(true);
    addBuffEffect.apply(ref);
// TODO defense mod effect
}
Also used : ChanceCondition(main.elements.conditions.standard.ChanceCondition) ActiveAbility(main.ability.ActiveAbility) ArrayList(java.util.ArrayList) RefCondition(main.elements.conditions.RefCondition) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Formula(main.system.math.Formula) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) FixedTargeting(main.elements.targeting.FixedTargeting) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) GroupImpl(main.entity.group.GroupImpl)

Example 5 with Conditions

use of main.elements.conditions.Conditions in project Eidolons by IDemiurge.

the class DC_BuffRule method initEffects.

@Override
public void initEffects() {
    Effect[] array = effectCache.get(target);
    if (array != null) {
        effects = array[level];
        if (effects != null) {
            return;
        }
    }
    Conditions conditions = null;
    Effect effect = getEffect();
    effect.setForceStaticParse(false);
    effect.setForcedLayer(Effect.BUFF_RULE);
    effects = new AddBuffEffect(conditions, getBuffTypeName(), effect);
    effects.setIrresistible(true);
    effects.setForcedLayer(Effect.BUFF_RULE);
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Effect(main.ability.effects.Effect) Conditions(main.elements.conditions.Conditions)

Aggregations

Conditions (main.elements.conditions.Conditions)43 Ref (main.entity.Ref)12 Condition (main.elements.conditions.Condition)7 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)6 Obj (main.entity.obj.Obj)6 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)5 ArrayList (java.util.ArrayList)5 NumericCondition (main.elements.conditions.NumericCondition)5 AutoTargeting (main.elements.targeting.AutoTargeting)5 Unit (eidolons.entity.obj.unit.Unit)4 ObjType (main.entity.type.ObjType)4 Coordinates (main.game.bf.Coordinates)4 FacingCondition (eidolons.ability.conditions.FacingCondition)3 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)3 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)3 Effects (main.ability.effects.Effects)3 OrConditions (main.elements.conditions.OrConditions)3 RefCondition (main.elements.conditions.RefCondition)3 Targeting (main.elements.targeting.Targeting)3 GroupImpl (main.entity.group.GroupImpl)3