use of eidolons.ability.effects.containers.EnergyCostEffect 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;
}
Aggregations