Search in sources :

Example 1 with TemplateSelectiveTargeting

use of eidolons.ability.targeting.TemplateSelectiveTargeting in project Eidolons by IDemiurge.

the class ActivesConstructor method getTargeting.

public static Targeting getTargeting(TARGETING_MODE mode, DC_ActiveObj obj) {
    Targeting targeting = null;
    switch(mode) {
        case BF_OBJ:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.BF_OBJ);
            break;
        case CORPSE:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.GRAVE_CELL);
            break;
        case BOLT_ANY:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.SHOT);
            break;
        case BOLT_UNITS:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.SHOT, ConditionMaster.getBFObjTypesCondition());
            break;
        case SELF:
            targeting = getSelfTargeting(obj);
            break;
        case SINGLE:
            targeting = getSingleTargeting(obj);
            break;
        case RAY:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.RAY);
            break;
        case CELL:
            // bolt-targeting?
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.CELL);
            break;
        case BLAST:
            // bolt-targeting?
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.BLAST);
            break;
        case DOUBLE:
            targeting = new MultiTargeting(getSingleTargeting(obj), getSingleTargeting(obj));
            ((MultiTargeting) targeting).setIgnoreGroupTargeting(false);
            break;
        case MULTI:
        case TRIPPLE:
            break;
        case ALL_UNITS:
            targeting = new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ALL_UNITS);
            break;
        case ANY_UNIT:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_UNIT);
            break;
        case ANY_ENEMY:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_ENEMY);
            break;
        case ANY_ALLY:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_ALLY);
            break;
        case ALL_ALLIES:
            targeting = new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ALL_ALLIES);
            break;
        case ALL_ENEMIES:
            targeting = new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ALL_ENEMIES);
            break;
        case ALL:
            targeting = new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ALL);
            break;
        case NOVA:
            targeting = new FixedTargeting(KEYS.SOURCE);
            break;
        case WAVE:
            targeting = new FixedTargeting(KEYS.SOURCE);
            break;
        case SPRAY:
            targeting = new FixedTargeting(KEYS.SOURCE);
            break;
        case TRAP:
            break;
        case ANY_ARMOR:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_ARMOR);
            break;
        case ANY_ITEM:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_ITEM);
            break;
        case ANY_WEAPON:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ANY_WEAPON);
            break;
        case ENEMY_ARMOR:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ENEMY_ARMOR);
            break;
        case ENEMY_ITEM:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ENEMY_ITEM);
            break;
        case ENEMY_WEAPON:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ENEMY_WEAPON);
            break;
        case MY_ARMOR:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.MY_ARMOR);
            break;
        case MY_ITEM:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.MY_ITEM);
            break;
        case MY_WEAPON:
            targeting = new TemplateSelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON);
            break;
        default:
            break;
    }
    if (targeting == null) {
        targeting = getSingleTargeting(obj);
    }
    if (targeting != null) {
        if (!targeting.isModsAdded()) {
            addTargetingMods(targeting, obj);
        }
    }
    return targeting;
}
Also used : TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) 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) FixedTargeting(main.elements.targeting.FixedTargeting) MultiTargeting(main.elements.targeting.MultiTargeting) TemplateAutoTargeting(eidolons.ability.targeting.TemplateAutoTargeting)

Example 2 with TemplateSelectiveTargeting

use of eidolons.ability.targeting.TemplateSelectiveTargeting in project Eidolons by IDemiurge.

the class ActivesConstructor method addTargetingMods.

public static void addTargetingMods(Targeting targeting, DC_ActiveObj obj) {
    Conditions c = new Conditions();
    String property = obj.getProperty(PROPS.TARGETING_MODIFIERS);
    if (obj.getActionGroup() == ActionEnums.ACTION_TYPE_GROUPS.MOVE) {
        // SPELL_TAGS.TELEPORT
        if (!obj.checkProperty(G_PROPS.ACTION_TAGS, ActionEnums.ACTION_TAGS.FLYING.toString())) {
            if (!obj.checkProperty(PROPS.TARGETING_MODIFIERS, AbilityEnums.TARGETING_MODIFIERS.CLEAR_SHOT.toString())) {
                property += AbilityEnums.TARGETING_MODIFIERS.CLEAR_SHOT.toString();
            }
            if (!obj.checkProperty(PROPS.TARGETING_MODIFIERS, AbilityEnums.TARGETING_MODIFIERS.SPACE.toString())) {
                property += AbilityEnums.TARGETING_MODIFIERS.SPACE.toString();
            }
        }
    }
    if (StringMaster.isEmpty(property)) {
        return;
    }
    for (String mod : StringMaster.open(property)) {
        Condition targetingModConditions;
        TARGETING_MODIFIERS MOD = new EnumMaster<TARGETING_MODIFIERS>().retrieveEnumConst(TARGETING_MODIFIERS.class, mod);
        if (MOD == null) {
            targetingModConditions = ConditionMaster.toConditions(mod);
        } else {
            targetingModConditions = DC_ConditionMaster.getTargetingModConditions(MOD);
        }
        if (targetingModConditions != null) {
            if (!c.contains(targetingModConditions)) // if (ConditionMaster.contains(c,
            // targetingModConditions.getClass())) //you sure?
            {
                c.add(targetingModConditions);
            }
        }
    }
    if (targeting instanceof TemplateSelectiveTargeting) {
        TemplateSelectiveTargeting tst = (TemplateSelectiveTargeting) targeting;
        if (tst.getTemplate() == SELECTIVE_TARGETING_TEMPLATES.GRAVE_CELL) {
            // TODO
            if (tst.getConditions() != null) {
                try {
                    ((GraveCondition) tst.getConditions().get(0)).getConditions().add(c);
                } catch (Exception e) {
                    main.system.auxiliary.log.LogMaster.log(1, tst.getConditions().get(0) + " in " + obj);
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
    }
    if (!c.isEmpty()) {
        targeting.getFilter().addCondition(c);
    }
    targeting.setModsAdded(true);
}
Also used : Condition(main.elements.conditions.Condition) GraveCondition(eidolons.ability.conditions.special.GraveCondition) TARGETING_MODIFIERS(main.content.enums.entity.AbilityEnums.TARGETING_MODIFIERS) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Conditions(main.elements.conditions.Conditions)

Example 3 with TemplateSelectiveTargeting

use of eidolons.ability.targeting.TemplateSelectiveTargeting in project Eidolons by IDemiurge.

the class EnchantItemEffect method applyThis.

@Override
public boolean applyThis() {
    // TODO select spell to use!
    // perhaps it is better to invoke spell with a special effect!
    // Ref REF = ref.getCopy();
    // this should be an effect - for other things too like traps
    // add spell filter!!!
    // if (selectSpell)
    // game.getManager().infoSelect(ref.getSourceObj());
    spell = (DC_SpellObj) ref.getTargetObj();
    Effects effects = EffectFinder.getEffectsFromSpell(spell);
    effects.add(new AnimationEffect(spell));
    effects.add(new SoundEffect(SOUNDS.IMPACT, ref.getTargetObj()));
    // TODO why was only that 1st spell in SB filtered in???
    if (!new TemplateSelectiveTargeting((weapon) ? SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON : SELECTIVE_TARGETING_TEMPLATES.MY_ARMOR).select(ref)) {
        return false;
    }
    // new ModifyPropertyEffect(G_PROPS.PASSIVES, MOD_PROP_TYPE.ADD,
    // passive)
    // .apply(ref);
    // 
    KEYS key;
    if (!weapon) {
        key = KEYS.ARMOR;
    } else {
        if (ref.getTargetObj() == ref.getObj(KEYS.WEAPON)) {
            key = KEYS.WEAPON;
        } else {
            key = KEYS.OFFHAND;
        }
    }
    int cost = Enchanter.calculateSpellEnergyCost(spell);
    if (case_type == null) {
        case_type = (weapon) ? SPECIAL_EFFECTS_CASE.ON_ATTACK : SPECIAL_EFFECTS_CASE.ON_HIT;
    }
    // another layer of customTargetEffect if ON SELF or so ! Some may even
    // be Zone-targeted!
    BuffType t = new BuffType(new Ref(ref.getGame(), ref.getSource()));
    t.setImage(ref.getActive().getProperty(G_PROPS.IMAGE, false));
    t.setName(buffName + " " + StringMaster.wrapInParenthesis(spell.getName()));
    t.setParam(G_PARAMS.DURATION, ref.getActive().getIntParam(G_PARAMS.DURATION, false));
    new AddBuffEffect(t, new AddSpecialEffects(case_type, new EnergyCostEffect(cost, key, effects))).apply(ref);
    ModifyValueEffect addEnergyEffect = new ModifyValueEffect(PARAMS.C_ENERGY, MOD.MODIFY_BY_CONST, energy);
    addEnergyEffect.setValueOverMax(true);
    addEnergyEffect.apply(ref);
    return true;
}
Also used : SoundEffect(eidolons.ability.effects.special.media.SoundEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Ref(main.entity.Ref) AddSpecialEffects(eidolons.ability.AddSpecialEffects) KEYS(main.entity.Ref.KEYS) BuffType(main.entity.type.BuffType) EnergyCostEffect(eidolons.ability.effects.containers.EnergyCostEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) AnimationEffect(eidolons.ability.effects.special.media.AnimationEffect) Effects(main.ability.effects.Effects) AddSpecialEffects(eidolons.ability.AddSpecialEffects)

Example 4 with TemplateSelectiveTargeting

use of eidolons.ability.targeting.TemplateSelectiveTargeting 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 5 with TemplateSelectiveTargeting

use of eidolons.ability.targeting.TemplateSelectiveTargeting in project Eidolons by IDemiurge.

the class Targeter method canBeTargeted.

public boolean canBeTargeted(Integer id, boolean caching) {
    Targeting targeting = getTargeting();
    Map<FACING_DIRECTION, Map<Integer, Boolean>> map = getTargetingCache().get(getOwnerObj().getCoordinates());
    if (map == null) {
        map = new HashMap<>();
        getTargetingCache().put(getOwnerObj().getCoordinates(), map);
    }
    Map<Integer, Boolean> map2 = map.get(getOwnerObj().getFacing());
    if (map2 == null) {
        map2 = new HashMap<>();
        map.put(getOwnerObj().getFacing(), map2);
    }
    // TODO for ai?
    Boolean result = map2.get(id);
    if (caching) {
        if (result != null)
            return result;
    }
    if (targeting == null) {
        // TODO ??
        if (getEntity().getActives().size() > 1) {
            return true;
        }
        if (!getEntity().getActives().isEmpty()) {
            if (getEntity().getActives().get(0).getAbilities().getAbils().size() > 1) {
                return true;
            }
        }
        return false;
    }
    Ref REF = getEntity().getRef().getCopy();
    REF.setMatch(id);
    if (targeting instanceof MultiTargeting) {
    // TODO ??
    }
    Conditions conditions = targeting.getFilter().getConditions();
    if (result != null) {
        if (result) {
            if (!conditions.preCheck(REF)) {
                return false;
            }
        }
        if (!result) {
            if (conditions.preCheck(REF)) {
                return true;
            }
        }
    }
    if (conditions.isEmpty())
        if (targeting instanceof TemplateSelectiveTargeting)
            ((TemplateSelectiveTargeting) targeting).initTargeting();
    getEntity().getRef().getSourceObj().getRef().setInfoEntity(getEntity());
    result = conditions.preCheck(REF);
    map2.put(id, result);
    return result;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Ref(main.entity.Ref) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Targeting(main.elements.targeting.Targeting) MultiTargeting(main.elements.targeting.MultiTargeting) AutoTargeting(main.elements.targeting.AutoTargeting) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) MultiTargeting(main.elements.targeting.MultiTargeting) HashMap(java.util.HashMap) Map(java.util.Map) Conditions(main.elements.conditions.Conditions)

Aggregations

TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)5 Targeting (main.elements.targeting.Targeting)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)2 TemplateAutoTargeting (eidolons.ability.targeting.TemplateAutoTargeting)2 Conditions (main.elements.conditions.Conditions)2 MultiTargeting (main.elements.targeting.MultiTargeting)2 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 Ref (main.entity.Ref)2 AddSpecialEffects (eidolons.ability.AddSpecialEffects)1 GraveCondition (eidolons.ability.conditions.special.GraveCondition)1 EnergyCostEffect (eidolons.ability.effects.containers.EnergyCostEffect)1 ShapeEffect (eidolons.ability.effects.containers.customtarget.ShapeEffect)1 WaveEffect (eidolons.ability.effects.containers.customtarget.WaveEffect)1 BehaviorModeEffect (eidolons.ability.effects.continuous.BehaviorModeEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 DrainEffect (eidolons.ability.effects.oneshot.mechanic.DrainEffect)1 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)1 MoveEffect (eidolons.ability.effects.oneshot.move.MoveEffect)1 CreateObjectEffect (eidolons.ability.effects.oneshot.unit.CreateObjectEffect)1