Search in sources :

Example 41 with Effect

use of main.ability.effects.Effect in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getSpellCustomHostileEffectPriority.

@Override
public int getSpellCustomHostileEffectPriority(DC_Obj target, DC_ActiveObj action, Effect e) {
    if (e instanceof AddBuffEffect) {
        AddBuffEffect buffEffect = (AddBuffEffect) e;
        // duration
        int mod = 100;
        // getDurationPriorityMod(buffEffect.getDurationFormula().getInt(action.getRef()));
        return getSpellCustomHostileEffectPriority(target, action, buffEffect.getEffect()) * mod / 100;
    }
    if (e instanceof Effects) {
        Effects effects = (Effects) e;
        int p = 0;
        for (Effect eff : effects) {
            p += getSpellCustomHostileEffectPriority(target, action, eff);
        }
        return p;
    }
    if (e instanceof RollEffect) {
        RollEffect rollEffect = (RollEffect) e;
        int mod = getRollPriorityMod(rollEffect);
        return getSpellCustomHostileEffectPriority(target, action, rollEffect.getEffect()) * mod / 100;
    }
    if (e instanceof InstantDeathEffect) {
        return 2 * getUnitPriority(target, true);
    }
    if (e instanceof BehaviorModeEffect) {
        int duration = new Formula(action.getParam(G_PARAMS.DURATION)).getInt(action.getRef());
        BehaviorModeEffect behaviorModeEffect = (BehaviorModeEffect) e;
        switch(behaviorModeEffect.getMode()) {
            case BERSERK:
                return getUnitPriority(target, true) * (Math.min(4, duration / 5 * 3));
            case CONFUSED:
                return getUnitPriority(target, true) * (Math.min(2, duration / 2));
            case PANIC:
                return getUnitPriority(target, true) * (Math.min(3, duration / 3 * 2));
            default:
                break;
        }
    }
    if (e instanceof OwnershipChangeEffect) {
        int duration = new Formula(action.getParam(G_PARAMS.DURATION)).getInt(action.getRef());
        return getUnitPriority(target, true) * (Math.min(5, duration));
    }
    return 0;
}
Also used : BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Formula(main.system.math.Formula) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) Effects(main.ability.effects.Effects)

Example 42 with Effect

use of main.ability.effects.Effect in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getDamagePriority.

@Override
public int getDamagePriority(DC_ActiveObj action, Obj targetObj, boolean attack) {
    int damage = 0;
    List<Effect> effects = EffectFinder.getEffectsOfClass(action, (attack) ? AttackEffect.class : DealDamageEffect.class);
    initRollMap(action, effects);
    for (Effect e : effects) {
        try {
            int mod = 100;
            RollEffect roll = rollMap.get(e);
            if (roll != null) {
                roll.getRef().setTarget(targetObj.getId());
                mod = getRollPriorityMod(roll);
            }
            damage += FutureBuilder.getDamage(action, targetObj, e) * mod / 100;
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
    float mod = getConstValue(AiConst.DAMAGE_PRIORITY_MOD);
    if (DamageCalculator.isUnconscious(damage, targetObj)) {
        if (checkKillPrioritized(targetObj, action)) {
            return getUnconsciousDamagePriority() * (int) (mod * 100) / 100;
        }
    }
    if (checkKillPrioritized(targetObj, action)) {
        if (DamageCalculator.isLethal(damage, targetObj)) {
            int p = getLethalDamagePriority();
            if (targetObj instanceof Unit) {
                if (((Unit) targetObj).isUnconscious())
                    p = getConstInt(AiConst.LETHAL_DAMAGE_MOD_VS_UNCONSCIOUS);
            }
            return p * (int) (mod * 100) / 100;
        }
    }
    int e = targetObj.getIntParam(PARAMS.C_ENDURANCE);
    int t = targetObj.getIntParam(PARAMS.C_TOUGHNESS);
    e = MathMaster.getCentimalPercentage(damage, e);
    t = MathMaster.getCentimalPercentage(damage, t);
    // TODO unconscious rule specifics
    return damage + Math.max(e, t * 2 / 3) * (int) (mod * 100) / 100;
}
Also used : RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) Unit(eidolons.entity.obj.unit.Unit)

Example 43 with Effect

use of main.ability.effects.Effect in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getCoatingPriority.

@Override
public int getCoatingPriority(DC_ActiveObj active, DC_Obj targetObj) {
    List<Effect> effects = EffectFinder.getEffectsOfClass(active, ModifyCounterEffect.class);
    if (effects.isEmpty()) {
        return priority;
    }
    ModifyCounterEffect e = (ModifyCounterEffect) effects.get(0);
    setBasePriority(getUnitPriority(getUnit(), true));
    addConstant(getItemPriority(targetObj), targetObj.getName());
    Integer amount = e.getFormula().getInt(active.getRef());
    int mod = amount;
    mod *= DC_CounterMaster.getCounterPriority(e.getCounterName(), targetObj);
    addMultiplier(mod, e.getCounterName() + " coating " + StringMaster.wrapInParenthesis(amount + ""));
    if (targetObj.getCounter(e.getCounterName()) > 0) {
        addMultiplier(-75 * targetObj.getCounter(e.getCounterName()) / amount, e.getCounterName() + " - Already Coated " + StringMaster.wrapInParenthesis(targetObj.getCounter(e.getCounterName()) + ""));
    }
    // TODO if (quick) if (ammo) if (alreadyCoated)
    return priority;
}
Also used : ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect)

Example 44 with Effect

use of main.ability.effects.Effect in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getParamModSpellPriority.

@Override
public int getParamModSpellPriority(Action action, Boolean buff) {
    DC_ActiveObj spell = action.getActive();
    DC_Obj target = action.getTarget();
    if (buff == null) {
        buff = EffectFinder.check(spell.getAbilities(), AddBuffEffect.class);
    }
    if (buff) {
        if (!spell.checkBool(GenericEnums.STD_BOOLS.STACKING)) {
            try {
                List<ObjType> buffsFromSpell = BuffMaster.getBuffsFromSpell(spell);
                if (buffsFromSpell.isEmpty()) {
                    priority = 0;
                    return 0;
                }
                ObjType objType = buffsFromSpell.get(0);
                if (!objType.checkBool(GenericEnums.STD_BOOLS.STACKING)) {
                    if (target.hasBuff(objType.getName())) {
                        priority = 0;
                        return 0;
                    }
                }
            } catch (Exception e) {
            }
        }
    }
    int priority = (getUnitPriority(target, false));
    boolean ally = target.getOwner().equals(getUnit().getOwner());
    // boolean mod = EffectMaster.preCheck(spell.getAbilities(),
    // ModifyValueEffect.class);
    List<Effect> effects = EffectFinder.getEffectsOfClass(spell.getAbilities(), (buff) ? AddBuffEffect.class : ModifyValueEffect.class);
    if (buff) {
        List<Effect> list = new ArrayList<>();
        for (Effect e : effects) {
            list.addAll(EffectFinder.getBuffEffects(e, ModifyValueEffect.class));
        }
        // TODO count the duration from buffEffect
        effects = list;
    }
    initRollMap(spell, effects);
    boolean valid = false;
    for (Effect e : effects) {
        ModifyValueEffect valueEffect = (ModifyValueEffect) e;
        for (String sparam : StringMaster.open(valueEffect.getParamString())) {
            for (PARAMETER param : DC_ContentManager.getParams(sparam)) {
                // TODO apply generic fix!
                if (param == PARAMS.C_INITIATIVE_BONUS)
                    param = PARAMS.C_INITIATIVE;
                if (TextParser.checkHasValueRefs(valueEffect.getFormula().toString())) {
                    String parsed = TextParser.parse(valueEffect.getFormula().toString(), action.getRef(), TextParser.ACTIVE_PARSING_CODE);
                    parsed = TextParser.replaceCodes(parsed);
                    valueEffect.setFormula(new Formula(parsed));
                }
                int amount = valueEffect.getFormula().getInt(action.getRef());
                if (valueEffect.getMod_type() == MOD.MODIFY_BY_PERCENT) {
                    amount = MathMaster.getFractionValueCentimal(target.getIntParam(param, valueEffect.getFormula().toString().contains(StringMaster.BASE_CHAR)), amount);
                }
                boolean drain = (e instanceof DrainEffect);
                int final_value = target.getIntParam(param) + amount;
                int min_max = valueEffect.initMinMaxAmount(target, amount);
                if (min_max != Integer.MAX_VALUE && min_max != Integer.MIN_VALUE) {
                    if (amount >= 0) {
                        if (final_value > min_max) {
                            amount = min_max - target.getIntParam(param);
                        }
                    } else {
                        if (amount < min_max) {
                            amount = target.getIntParam(param) - min_max;
                        }
                    }
                }
                if (!ally && !drain) {
                    amount = -amount;
                }
                priority = (int) (priority * getParamModFactor(target, e, param, amount));
                if (drain) {
                    // TODO limit the amount!
                    priority = (int) (priority * getParamModFactor(getUnit(), null, param, amount));
                }
            }
        }
        if (!buff) {
            if (!ally && valid) {
                applyResistPenalty(action);
            }
        } else {
            priority = priority * (getDurationMultiplier(action)) / 100;
        }
    }
    if (!valid) {
        return 0;
    // applyMultiplier(0, "Empty");
    }
    return priority;
}
Also used : ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) DC_Obj(eidolons.entity.obj.DC_Obj) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Formula(main.system.math.Formula) ObjType(main.entity.type.ObjType) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) PARAMETER(main.content.values.parameters.PARAMETER) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect)

Example 45 with Effect

use of main.ability.effects.Effect in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getSpellCustomHostilePriority.

@Override
public int getSpellCustomHostilePriority(Action action) {
    Effects effects = EffectFinder.getEffectsFromSpell(action.getActive());
    // TODO targets???
    for (Effect e : effects) {
        addConstant(getSpellCustomHostileEffectPriority(action.getTarget(), action.getActive(), e), e.toString());
    }
    applyResistPenalty(action);
    return priority;
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) Effects(main.ability.effects.Effects)

Aggregations

Effect (main.ability.effects.Effect)55 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)31 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)18 Effects (main.ability.effects.Effects)17 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)16 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)16 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)15 OwnershipChangeEffect (main.ability.effects.common.OwnershipChangeEffect)14 BehaviorModeEffect (eidolons.ability.effects.continuous.BehaviorModeEffect)13 AttackEffect (eidolons.ability.effects.oneshot.attack.AttackEffect)13 InstantDeathEffect (main.ability.effects.oneshot.InstantDeathEffect)13 DrainEffect (eidolons.ability.effects.oneshot.mechanic.DrainEffect)12 RaiseEffect (eidolons.ability.effects.oneshot.unit.RaiseEffect)12 SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)12 ArrayList (java.util.ArrayList)10 WaveEffect (eidolons.ability.effects.containers.customtarget.WaveEffect)8 DC_Effect (eidolons.ability.effects.DC_Effect)7 Ref (main.entity.Ref)7 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)6 SpecialTargetingEffect (main.ability.effects.container.SpecialTargetingEffect)6