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