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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations