Search in sources :

Example 1 with KEYS

use of main.entity.Ref.KEYS 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 2 with KEYS

use of main.entity.Ref.KEYS 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 3 with KEYS

use of main.entity.Ref.KEYS in project Eidolons by IDemiurge.

the class DamageDealer method processDamageEvent.

// writes values to appropriate parameters of the damage-dealing action, checks event-interruptions
protected static boolean processDamageEvent(DAMAGE_TYPE damage_type, Ref ref, int amount, EVENT_TYPE event_type) {
    if (damage_type != null) {
        ref.setValue(KEYS.DAMAGE_TYPE, damage_type.toString());
    }
    ref.setAmount(amount);
    KEYS key = null;
    PARAMETER statsParam = null;
    boolean add = false;
    if (event_type == STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE) {
        key = KEYS.DAMAGE_AMOUNT;
        statsParam = PARAMS.DAMAGE_LAST_AMOUNT;
    } else if (event_type.equals(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PURE_DAMAGE)) {
        key = KEYS.DAMAGE_DEALT;
        statsParam = PARAMS.DAMAGE_LAST_DEALT;
    } else {
        if (((EventType) event_type).getType().equals(CONSTRUCTED_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_DAMAGE_OF_TYPE)) {
            key = KEYS.DAMAGE_TOTAL;
            statsParam = PARAMS.DAMAGE_TOTAL;
            add = true;
        }
    }
    if (ref.isQuiet()) {
        return true;
    }
    if (ref.getActive() != null && statsParam != null) {
        try {
            Ref REF = ref.getActive().getRef();
            if (add) {
                REF.setValue(key, (REF.getInteger(statsParam.toString()) + amount) + "");
                ref.getActive().modifyParameter(statsParam, amount);
            } else {
                REF.setValue(key, amount + "");
                ref.getActive().setParam(statsParam, amount);
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    Event event = new Event(event_type, ref);
    return (event.fire());
}
Also used : Ref(main.entity.Ref) EventType(main.game.logic.event.EventType) KEYS(main.entity.Ref.KEYS) Event(main.game.logic.event.Event) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

Ref (main.entity.Ref)3 KEYS (main.entity.Ref.KEYS)3 Effects (main.ability.effects.Effects)2 AddSpecialEffects (eidolons.ability.AddSpecialEffects)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 EnergyCostEffect (eidolons.ability.effects.containers.EnergyCostEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 AnimationEffect (eidolons.ability.effects.special.media.AnimationEffect)1 SoundEffect (eidolons.ability.effects.special.media.SoundEffect)1 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)1 CustomTargetEffect (main.ability.effects.continuous.CustomTargetEffect)1 PARAMETER (main.content.values.parameters.PARAMETER)1 Conditions (main.elements.conditions.Conditions)1 RefCondition (main.elements.conditions.RefCondition)1 GroupCondition (main.elements.conditions.standard.GroupCondition)1 NonTriggeredEventCondition (main.elements.conditions.standard.NonTriggeredEventCondition)1 AutoTargeting (main.elements.targeting.AutoTargeting)1