Search in sources :

Example 1 with GroupImpl

use of main.entity.group.GroupImpl 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 2 with GroupImpl

use of main.entity.group.GroupImpl 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 3 with GroupImpl

use of main.entity.group.GroupImpl in project Eidolons by IDemiurge.

the class EffectImpl method apply.

@Override
public boolean apply(Ref ref) {
    setRef(ref);
    // for logging
    boolean active = getLayer() != BUFF_RULE && ref.getObj(KEYS.ACTIVE) != null && (!(ref.getObj(KEYS.ABILITY) instanceof PassiveAbilityObj));
    if ((ref.getGroup() == null && targetGroup == null) || isIgnoreGroupTargeting()) {
        // single-target effect
        return apply();
    } else {
        // multi-target effect, applies to each target
        GroupImpl group = ref.getGroup();
        if (group == null) {
            group = targetGroup;
        } else if (targetGroup == null) {
            // group.setIgnoreGroupTargeting(true);// TODO later instead?
            targetGroup = group;
        }
        if (group.isIgnoreGroupTargeting()) {
            return apply();
        }
        List<Integer> groupIds = group.getObjectIds();
        boolean result = true;
        for (Integer id : groupIds) {
            if (isInterrupted()) {
                break;
            }
            Ref REF = this.ref.getCopy();
            // REF.setGroup(new GroupImpl(targetGroup));
            REF.getGroup().setIgnoreGroupTargeting(true);
            REF.setTarget(id);
            if (construct != null) {
                result &= getCopy().apply(REF);
            } else {
                // this.ref.setTarget(id);
                setIgnoreGroupTargeting(true);
                result &= apply(REF);
                setIgnoreGroupTargeting(false);
            }
        }
        // game.getManager().refreshAll();
        return result;
    }
}
Also used : Ref(main.entity.Ref) PassiveAbilityObj(main.ability.PassiveAbilityObj) GroupImpl(main.entity.group.GroupImpl)

Example 4 with GroupImpl

use of main.entity.group.GroupImpl in project Eidolons by IDemiurge.

the class BindingDamageEffect method applyThis.

@Override
public boolean applyThis() {
    // Can be initialized() just once
    GroupImpl group = ref.getGroup();
    Effects effects = new Effects();
    STANDARD_EVENT_TYPE event_type;
    if (shareOrRedirect) {
        // TODO splitMode!
        event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
            }
        }
    } else {
        effects.add(new AlteringEffect(false, formula.getNegative().toString()));
        event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
            }
        }
    }
    Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
    new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
    effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
    /*
         * ensure there is no deadlock
		 */
    conditions = new Conditions();
    conditions.add(new NonTriggeredEventCondition());
    KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
    conditions.add(new GroupCondition(OBJ_REF, group));
    // has the group...
    Ref REF = Ref.getCopy(ref);
    // REF.setTarget(null); // ???
    new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
    return true;
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Targeting(main.elements.targeting.Targeting) AutoTargeting(main.elements.targeting.AutoTargeting) NonTriggeredEventCondition(main.elements.conditions.standard.NonTriggeredEventCondition) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) RefCondition(main.elements.conditions.RefCondition) CustomTargetEffect(main.ability.effects.continuous.CustomTargetEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Ref(main.entity.Ref) GroupImpl(main.entity.group.GroupImpl) KEYS(main.entity.Ref.KEYS) AlteringEffect(eidolons.ability.effects.oneshot.misc.AlteringEffect) GroupCondition(main.elements.conditions.standard.GroupCondition)

Example 5 with GroupImpl

use of main.entity.group.GroupImpl in project Eidolons by IDemiurge.

the class AutoTargeting method select.

@Override
public boolean select(Ref ref) {
    if (group != null) {
        if (getConditions() != null) {
            Set<Obj> filteredGroup = new Filter<Obj>(group.getObjects(), ref, getConditions()).getObjects();
            group = new GroupImpl(filteredGroup);
        }
        ref.setGroup(this.group);
        return true;
    }
    if (keyword != null) {
        Obj obj = ref.getObj(keyword);
        if (obj == null) {
            return false;
        }
        ref.setTarget(obj.getId());
        return true;
    }
    filter = new Filter<>(ref, getConditions());
    filter.setTYPE(TYPE);
    if (TYPES != null) {
        ArrayList<OBJ_TYPE> types = new ArrayList<>();
        for (String s : StringMaster.open(TYPES)) {
            types.add(ContentManager.getOBJ_TYPE(s));
        }
        filter.setTYPES(types);
    }
    setRef(ref);
    if (unlimitedTargets) {
        ref.setGroup(filter.getGroup());
    } else {
        setLastTarget(ref.getTargetObj());
        int nOfTargets = numberOfTargets.getInt(ref);
        if (nOfTargets <= 0) {
            return false;
        }
        Set<Obj> objects = filter.getObjects();
        if (nOfTargets == 1) {
            Obj obj = selectObj(objects);
            ref.setTarget(obj.getId());
        } else {
            GroupImpl group = filterGroup(filter.getGroup(), nOfTargets);
            ref.setGroup(group);
        }
    }
    return true;
}
Also used : OBJ_TYPE(main.content.OBJ_TYPE) Obj(main.entity.obj.Obj) GroupImpl(main.entity.group.GroupImpl) ArrayList(java.util.ArrayList)

Aggregations

GroupImpl (main.entity.group.GroupImpl)7 Ref (main.entity.Ref)4 ArrayList (java.util.ArrayList)3 Conditions (main.elements.conditions.Conditions)3 Obj (main.entity.obj.Obj)3 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)2 Effects (main.ability.effects.Effects)2 RefCondition (main.elements.conditions.RefCondition)2 AutoTargeting (main.elements.targeting.AutoTargeting)2 Coordinates (main.game.bf.Coordinates)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 ActiveAbility (main.ability.ActiveAbility)1