Search in sources :

Example 51 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class ForceRule method getForceFromAttack.

// or spell!
public static int getForceFromAttack(DC_ActiveObj attack) {
    boolean offhand = attack.isOffhand();
    Obj weapon = attack.getOwnerObj().getActiveWeapon(offhand);
    if (attack.isRanged()) {
        if (!attack.isThrow()) {
            weapon = weapon.getRef().getObj(KEYS.AMMO);
        }
    }
    if (weapon == null) {
        return 0;
    }
    Integer weightModifier = getAttackerWeightModifier(attack, weapon);
    double strengthModifier = getStrengthModifier(attack, weapon);
    int force = weightModifier + (int) strengthModifier;
    force = MathMaster.applyModIfNotZero(force, attack.getIntParam(PARAMS.FORCE_MOD));
    attack.setParam(PARAMS.FORCE, force);
    LogMaster.log(1, "getForceFromAttack = weightModifier" + weightModifier + "+strengthModifier* " + new Float(attack.getIntParam(PARAMS.FORCE_MOD)) / 100 + " = " + force);
    return force;
}
Also used : DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj)

Example 52 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class RollMaster method rollLogged.

/**
 * @param logString  to be appended to the logged string; for success by default,
 *                   for failure if contains @
 * @param rollSource special descriptor for logging, e.g. if rolling vs Ensnare
 * @returns false if target has resisted ('wins roll')
 */
public static boolean rollLogged(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logString, String rollSource) {
    boolean result = roll(roll_type, success, fail, ref, logString, rollSource, false);
    if (!checkRollLogged(roll_type, result)) {
        return result;
    }
    Object[] args = { roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
    if (roll_type.isLogToTop()) {
        args = new Object[] { main.system.text.LogManager.WRITE_TO_TOP, roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
    }
    LogEntryNode entry = ref.getGame().getLogManager().newLogEntryNode(result ? ENTRY_TYPE.ROLL_LOST : ENTRY_TYPE.ROLL_WON, args);
    ref.getGame().getLogManager().log(RollMaster.logString);
    ref.getGame().getLogManager().doneLogEntryNode();
    if (CoreEngine.isPhaseAnimsOn())
        if (ref.getActive() != null) {
            ANIM anim = new EffectAnimation((DC_ActiveObj) ref.getActive());
            anim.addPhase(new AnimPhase(PHASE_TYPE.ROLL, roll));
            entry.setLinkedAnimation(anim);
        }
    // PHASE_TYPE.ROLL));
    if (ref.getGame().isDummyMode()) {
        return true;
    }
    return result;
}
Also used : EffectAnimation(eidolons.system.graphics.EffectAnimation) AnimPhase(main.system.graphics.AnimPhase) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 53 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj 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 54 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj 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;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) FixedTargeting(main.elements.targeting.FixedTargeting) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_HeroAttachedObj(eidolons.entity.obj.attach.DC_HeroAttachedObj) Obj(main.entity.obj.Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 55 with DC_ActiveObj

use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getAttackOfOpportunityPenalty.

@Override
public int getAttackOfOpportunityPenalty(DC_ActiveObj action, Unit targetObj) {
    int penalty = 0;
    List<DC_ActiveObj> list = AttackOfOpportunityRule.getAttacks(action);
    for (DC_ActiveObj a : list) {
        penalty -= getDamagePriority(a, getUnit()) / 2;
    }
    return penalty;
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Aggregations

DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)73 Unit (eidolons.entity.obj.unit.Unit)22 ArrayList (java.util.ArrayList)17 Obj (main.entity.obj.Obj)15 DC_UnitAction (eidolons.entity.active.DC_UnitAction)12 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 ActiveObj (main.entity.obj.ActiveObj)7 Effect (main.ability.effects.Effect)5 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)5 Targeting (main.elements.targeting.Targeting)5 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)4 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)4 FixedTargeting (main.elements.targeting.FixedTargeting)4 Coordinates (main.game.bf.Coordinates)4 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)3 ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)3