Search in sources :

Example 11 with Targeting

use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.

the class ActivesConstructor method constructActive.

public static void constructActive(TARGETING_MODE mode, DC_ActiveObj entity) {
    if (mode == AbilityEnums.TARGETING_MODE.MULTI) {
        addMultiTargetingMods(entity);
        return;
    }
    if (entity.checkBool(GenericEnums.STD_BOOLS.MULTI_TARGETING)) {
        // constructMultiAbilities(entity);
        return;
    }
    if (entity.getActives() == null) {
        return;
    }
    List<ActiveObj> list = new ArrayList<>(entity.getActives());
    Effects effects = new Effects();
    for (Active active : list) {
        for (Ability abil : ((AbilityObj) active).getAbilities().getAbils()) {
            for (Effect effect : abil.getEffects().getEffects()) {
                // anything?
                if (effect instanceof DC_Effect) {
                    DC_Effect effect2 = (DC_Effect) effect;
                    effect2.setAnimationActive(entity);
                }
                effects.add(effect);
            }
        }
    }
    // TODO what if the effects should have different targetings like in
    // damage+light?
    String saveRoll = entity.getProperty(PROPS.ROLL_TYPES_TO_SAVE);
    if (!StringMaster.isEmpty(saveRoll)) {
        wrapInSaveRollEffect(effects, saveRoll);
    }
    String wrap = entity.getProperty(PROPS.EFFECTS_WRAP);
    Effect wrappedEffect;
    if (StringMaster.isEmpty(wrap)) {
        wrappedEffect = wrapEffects(mode, effects, entity);
    } else {
        EFFECTS_WRAP WRAP = new EnumMaster<EFFECTS_WRAP>().retrieveEnumConst(EFFECTS_WRAP.class, wrap);
        wrappedEffect = wrapEffects(WRAP, effects, entity);
    }
    Targeting targeting = getTargeting(mode, entity);
    if (targeting == null) {
        try {
            targeting = entity.getActives().get(0).getActives().get(0).getTargeting();
        } catch (Exception e) {
        // targeting = getDefaultSingleTargeting(entity);TODO necessary?
        }
    }
    if (targeting != null)
        entity.setTargeting(targeting);
    Abilities abilities = new Abilities();
    abilities.add(new ActiveAbility(null, wrappedEffect));
    entity.setAbilities(abilities);
// TODO wrapping in RollEffect - each single effect or the resulting
// wrapped Effects?
}
Also used : FixedTargeting(main.elements.targeting.FixedTargeting) TemplateAutoTargeting(eidolons.ability.targeting.TemplateAutoTargeting) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Targeting(main.elements.targeting.Targeting) MultiTargeting(main.elements.targeting.MultiTargeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) DC_Effect(eidolons.ability.effects.DC_Effect) ArrayList(java.util.ArrayList) Effects(main.ability.effects.Effects) Active(main.entity.obj.Active) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) ActiveObj(main.entity.obj.ActiveObj) EFFECTS_WRAP(main.content.enums.entity.AbilityEnums.EFFECTS_WRAP) DC_Effect(eidolons.ability.effects.DC_Effect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) RayEffect(eidolons.ability.effects.containers.customtarget.RayEffect) WaveEffect(eidolons.ability.effects.containers.customtarget.WaveEffect) ZoneEffect(eidolons.ability.effects.containers.customtarget.ZoneEffect)

Example 12 with Targeting

use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.

the class DamageInversionEffect method applyThis.

@Override
public boolean applyThis() {
    // endurance damage; modify endurance only? above base?
    Targeting targeting = new FixedTargeting(KEYS.SOURCE);
    Effects effects = new Effects();
    if (restoreEndurance) {
        ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_ENDURANCE, code, formula.toString());
        if (!restoreEnduranceAboveBase) {
            effect.setMaxParam(PARAMS.ENDURANCE);
        }
        effects.add(effect);
    }
    if (restoreToughness) {
        ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_TOUGHNESS, code, formula.toString());
        if (!restoreToughnessAboveBase) {
            effect.setMaxParam(PARAMS.TOUGHNESS);
        }
        effects.add(effect);
    }
    ActiveAbility ability = new ActiveAbility(targeting, effects);
    new AddTriggerEffect(event_type, conditions, ability).apply(ref);
    return true;
}
Also used : ActiveAbility(main.ability.ActiveAbility) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) FixedTargeting(main.elements.targeting.FixedTargeting) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect)

Example 13 with Targeting

use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getZoneSpellPriority.

@Override
public int getZoneSpellPriority(Action action, boolean damage) {
    int base_priority = 0;
    DC_ActiveObj active = action.getActive();
    Targeting targeting = active.getTargeting();
    if (targeting instanceof FixedTargeting || targeting instanceof SelectiveTargeting) {
        targeting = TargetingMaster.getZoneEffect(active);
    }
    // Set<Obj> objects = targeting.getFilter().getObjects(action.getRef());
    Ref REF = action.getRef().getCopy();
    targeting.select(REF);
    List<Obj> objects = (REF.getGroup() != null) ? REF.getGroup().getObjects() : new ArrayList<>(targeting.getFilter().getObjects(action.getRef()));
    for (Obj obj : objects) {
        // TODO
        if (obj instanceof Unit) {
            if (obj.isNeutral() || obj.isDead()) {
                continue;
            }
            Unit target = (Unit) obj;
            int p = (damage) ? getDamagePriority(active, target, false) : getParamModSpellPriority(action);
            Boolean less_or_more_for_health = null;
            if (p == 200) {
                // ?
                less_or_more_for_health = null;
            }
            p = getUnitPriority(target, less_or_more_for_health) * p / 100;
            boolean ally = target.isOwnedBy(getUnit().getOwner());
            if (ally) {
                if (action.getSource().checkAiMod(AI_MODIFIERS.CRUEL)) {
                    p /= 2;
                }
                if (action.getSource().checkAiMod(AI_MODIFIERS.MERCIFUL)) {
                    p *= 2;
                }
                base_priority -= p;
            } else {
                if (action.getSource().checkAiMod(AI_MODIFIERS.TRUE_BRUTE)) {
                    p *= 2;
                }
                base_priority += p;
                base_priority += base_priority / 6;
            }
        }
    }
    return base_priority;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) FixedTargeting(main.elements.targeting.FixedTargeting) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_HeroAttachedObj(eidolons.entity.obj.attach.DC_HeroAttachedObj) Obj(main.entity.obj.Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 14 with Targeting

use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.

the class AI_SpellMaster method getLogicByTargeting.

private static AI_LOGIC getLogicByTargeting(DC_ActiveObj spell) {
    Targeting t = spell.getTargeting();
    TARGETING_MODE mode = spell.getTargetingMode();
    if (mode == null) {
        if (t instanceof TemplateSelectiveTargeting) {
            mode = ((TemplateSelectiveTargeting) t).getTemplate().getMode();
        }
        if (t instanceof TemplateAutoTargeting) {
            mode = ((TemplateAutoTargeting) t).getTemplate().getMode();
        }
    }
    Abilities actives = spell.getAbilities();
    if (mode != null) {
        switch(mode) {
            case ENEMY_WEAPON:
            case ENEMY_ARMOR:
                return AiEnums.AI_LOGIC.BUFF_NEGATIVE;
            case MY_WEAPON:
            case MY_ARMOR:
            case SELF:
                return AiEnums.AI_LOGIC.SELF;
            case ANY_ALLY:
                if (EffectFinder.check(actives, AddBuffEffect.class)) {
                    return AiEnums.AI_LOGIC.BUFF_POSITIVE;
                }
                if (EffectFinder.check(actives, ModifyValueEffect.class)) {
                    return AiEnums.AI_LOGIC.RESTORE;
                }
            case ANY_ENEMY:
                if (EffectFinder.check(actives, DealDamageEffect.class)) {
                    return AiEnums.AI_LOGIC.DAMAGE;
                }
                if (EffectFinder.check(actives, AddBuffEffect.class)) {
                    return AiEnums.AI_LOGIC.BUFF_NEGATIVE;
                }
                if (EffectFinder.check(actives, ModifyValueEffect.class)) {
                    return AiEnums.AI_LOGIC.DEBILITATE;
                }
                if (EffectFinder.check(actives, DrainEffect.class)) {
                    return AiEnums.AI_LOGIC.DEBILITATE;
                }
                break;
            case ANY_UNIT:
                if (EffectFinder.check(actives, AddBuffEffect.class)) {
                    if (((AddBuffEffect) EffectFinder.getEffectsOfClass(actives, AddBuffEffect.class).get(0)).getEffect().getFormula().getInt(spell.getOwnerObj().getRef()) > 0) {
                        return AiEnums.AI_LOGIC.BUFF_POSITIVE;
                    } else {
                        return AiEnums.AI_LOGIC.BUFF_NEGATIVE;
                    }
                }
                List<Effect> effects = EffectFinder.getEffectsOfClass(actives, ModifyValueEffect.class);
                if (effects.isEmpty()) {
                    effects = EffectFinder.getEffectsOfClass(actives, ModifyCounterEffect.class);
                }
                Effect effect = effects.get(0);
                if (effect instanceof ModifyCounterEffect) {
                    ModifyCounterEffect counterEffect = (ModifyCounterEffect) effect;
                    boolean positive = isCounterEffectPositive(spell, counterEffect);
                    if (positive) {
                        return AiEnums.AI_LOGIC.RESTORE;
                    }
                    return AiEnums.AI_LOGIC.DEBILITATE;
                }
                if (effect instanceof ModifyValueEffect) {
                    if (isModifyValueEffectPositive(spell, effect)) {
                        return AiEnums.AI_LOGIC.RESTORE;
                    }
                    return AiEnums.AI_LOGIC.DEBILITATE;
                }
                break;
            case BLAST:
                break;
            case CELL:
                break;
            case RAY:
                break;
            default:
                break;
        }
    }
    return null;
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) TARGETING_MODE(main.content.enums.entity.AbilityEnums.TARGETING_MODE) Abilities(main.ability.Abilities) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) Targeting(main.elements.targeting.Targeting) TemplateAutoTargeting(eidolons.ability.targeting.TemplateAutoTargeting) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) WaveEffect(eidolons.ability.effects.containers.customtarget.WaveEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) GatewayEffect(eidolons.ability.effects.oneshot.unit.GatewayEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) ShapeEffect(eidolons.ability.effects.containers.customtarget.ShapeEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) MoveEffect(eidolons.ability.effects.oneshot.move.MoveEffect) SpecialTargetingEffect(main.ability.effects.container.SpecialTargetingEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) CreateObjectEffect(eidolons.ability.effects.oneshot.unit.CreateObjectEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) TemplateAutoTargeting(eidolons.ability.targeting.TemplateAutoTargeting)

Example 15 with Targeting

use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.

the class TargetingMaster method findTargeting.

public static Targeting findTargeting(ActiveObj active, Class<SelectiveTargeting> CLASS) {
    Targeting t = active.getTargeting();
    if (checkTargeting(CLASS, t)) {
        return t;
    }
    t = findTargetingInAbils(active, CLASS);
    if (t != null) {
        return t;
    }
    for (ActiveObj a : active.getActives()) {
        if (// 2 layers maximum, i hope
        active instanceof DC_ActiveObj) {
            t = findTargeting(a, CLASS);
        }
        if (t != null) {
            return t;
        } else {
            for (ActiveObj a2 : a.getActives()) {
                t = findTargetingInAbils(a2, CLASS);
                if (t != null) {
                    return t;
                }
            }
        }
    }
    return null;
}
Also used : ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Targeting(main.elements.targeting.Targeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Aggregations

Targeting (main.elements.targeting.Targeting)18 FixedTargeting (main.elements.targeting.FixedTargeting)12 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)9 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)7 Effects (main.ability.effects.Effects)6 MultiTargeting (main.elements.targeting.MultiTargeting)6 TemplateAutoTargeting (eidolons.ability.targeting.TemplateAutoTargeting)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)5 AutoTargeting (main.elements.targeting.AutoTargeting)5 Ref (main.entity.Ref)5 Effect (main.ability.effects.Effect)4 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)3 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)3 ActiveAbility (main.ability.ActiveAbility)3 Conditions (main.elements.conditions.Conditions)3 ActiveObj (main.entity.obj.ActiveObj)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 WaveEffect (eidolons.ability.effects.containers.customtarget.WaveEffect)2 ZoneEffect (eidolons.ability.effects.containers.customtarget.ZoneEffect)2 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)2