Search in sources :

Example 11 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class CadenceRule method checkDualAttackCadence.

public static void checkDualAttackCadence(DC_UnitAction action, Unit unit) {
    if (action.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
        return;
    }
    boolean singleCadence = checkSingleWeaponCadence(unit, action);
    if (!UnitAnalyzer.checkDualWielding(unit) && !UnitAnalyzer.checkDualNaturalWeapons(unit) && !singleCadence) // || checkSingleCadence(action)
    {
        return;
    }
    Boolean offhand = null;
    if (action.checkProperty(PROP, MAIN_HAND)) {
        offhand = false;
    } else if (action.checkProperty(PROP, OFF_HAND)) {
        offhand = true;
    } else if (singleCadence) // offhand = !action.isOffhand();
    {
        offhand = false;
    }
    if (offhand == null) {
        return;
    }
    Ref ref = new Ref(unit.getGame(), unit.getId());
    DC_WeaponObj weapon = unit.getActiveWeapon(offhand);
    List<Obj> targets = new ArrayList<>();
    if (unit.getWeapon(!offhand) != null) {
        targets.add(unit.getWeapon(!offhand));
    }
    if (unit.getNaturalWeapon(!offhand) != null) {
        targets.add(unit.getNaturalWeapon(!offhand));
    }
    GroupImpl group = new GroupImpl(targets);
    LogMaster.log(LogMaster.RULES_DEBUG, "Cadence Rule applies to " + group);
    ref.setGroup(group);
    if (checkFocusBonusApplies(unit, action, singleCadence)) {
        Integer amount = action.getOwnerObj().getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getOwnerObj().getActiveWeapon(!offhand).getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        action.getOwnerObj().modifyParameter(PARAMS.C_FOCUS, amount, 100);
    }
    // INIT COST CADENCE EFFECTS
    Effects effects = new Effects();
    String cadence = unit.getParam(PARAMS.CADENCE_AP_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_AP_MOD + "";
    }
    ModifyValueEffect valueEffect = new ModifyValueEffect(PARAMS.ATTACK_AP_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    cadence = unit.getParam(PARAMS.CADENCE_STA_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_STA_MOD + "";
    }
    valueEffect = new ModifyValueEffect(PARAMS.ATTACK_STA_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    if (unit.getIntParam(PARAMS.CADENCE_DAMAGE_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.DAMAGE_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_DAMAGE_MOD)));
    }
    if (unit.getIntParam(PARAMS.CADENCE_ATTACK_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.ATTACK_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_ATTACK_MOD)));
    }
    String buffTypeName = (!offhand) ? buffTypeNameOffHand : buffTypeNameMainHand;
    // ADD REMOVE TRIGGER
    int percentage = 100 - unit.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - action.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - weapon.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE);
    Conditions conditions = new Conditions(new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE));
    if (percentage != 100) {
        conditions.add(new ChanceCondition(new Formula("" + percentage)));
    }
    effects.add(new AddTriggerEffect(STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, conditions, new ActiveAbility(new FixedTargeting(KEYS.BASIS), new RemoveBuffEffect(buffTypeName))));
    // effect = new AddBuffEffect(buffTypeName, effects, DURATION);
    // Condition condition = new StringComparison(StringMaster.getValueRef(KEYS.MATCH, PROP),
    // (offhand) ? MAIN_HAND : OFF_HAND, false);
    // retain condition - hero hasBuff()
    // add remove trigger on attack? either off/main hand, so there is no
    // stacking...
    // linked buffs?
    // effect.setIrresistible(false);
    AddBuffEffect addBuffEffect = new AddBuffEffect(buffTypeName, // new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ACTIONS, condition),
    effects, DURATION);
    // preCheck perk
    addBuffEffect.addEffect(new // what about
    AddTriggerEffect(// counters/AoO?
    STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE), new ActiveAbility(new FixedTargeting(KEYS.SOURCE), new RemoveBuffEffect(buffTypeName))));
    Integer param = unit.getIntParam(PARAMS.CADENCE_DEFENSE_MOD);
    if (param != 0) {
        addBuffEffect.addEffect(new ModifyValueEffect(PARAMS.DEFENSE_MOD, MOD.MODIFY_BY_CONST, "" + param));
    }
    addBuffEffect.setIrresistible(true);
    addBuffEffect.apply(ref);
// TODO defense mod effect
}
Also used : ChanceCondition(main.elements.conditions.standard.ChanceCondition) ActiveAbility(main.ability.ActiveAbility) ArrayList(java.util.ArrayList) RefCondition(main.elements.conditions.RefCondition) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Formula(main.system.math.Formula) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) FixedTargeting(main.elements.targeting.FixedTargeting) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) GroupImpl(main.entity.group.GroupImpl)

Example 12 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class StackingRule method actionMissed.

public static void actionMissed(DC_ActiveObj action) {
    if (RuleMaster.isRuleOn(RULE.MISSED_ATTACK_REDIRECTION))
        return;
    Ref ref = action.getRef();
    Obj target = ref.getTargetObj();
    List<BattleFieldObject> units = action.getGame().getObjectsAt(action.getOwnerObj().getCoordinates());
    units.addAll(action.getGame().getObjectsAt(target.getCoordinates()));
    units.remove(action.getOwnerObj());
    units.remove(target);
    if (units.isEmpty()) {
        return;
    }
    Map<BattleFieldObject, Integer> map = new HashMap<>();
    for (BattleFieldObject unit : units) {
        map.put(unit, unit.getIntParam(PARAMS.GIRTH));
    }
    BattleFieldObject randomTarget = new RandomWizard<BattleFieldObject>().getObjectByWeight(map);
    ref.setTarget(randomTarget.getId());
    // action.addProperty(G_PROPS.DYNAMIC_BOOLS,
    // DYNAMIC_BOOLS.MISSED_ALREADY); //NO RESTRAINTS! :)
    action.activatedOn(ref);
}
Also used : Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) HashMap(java.util.HashMap) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj)

Example 13 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class StackingRule method canBeMovedOnto.

private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
    HashMap<Coordinates, Boolean> bools = cache.get(unit);
    boolean result = false;
    if (maxSpaceTakenPercentage == 100) {
        if (bools != null) {
            if (bools.containsKey(c)) {
                return bools.get(c);
            }
        } else {
            bools = new HashMap<>();
            cache.put(unit, bools);
        }
    }
    // get all units on the cell
    DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
    for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
        if (!units.contains(u)) {
            if (!u.isAnnihilated())
                // continue; TODO why was Type necessary?
                units.addCast(!u.isDead() ? u.getType() : u);
            if (u.isWall())
                if (!u.isDead())
                    return false;
        }
    }
    // check if '1 unit per cell' is on
    if (maxSpaceTakenPercentage <= 0) {
        if (!units.isEmpty()) {
            return false;
        }
    }
    if (unit == null) {
        unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
    }
    Obj cell;
    if (!game.isSimulation()) {
        cell = game.getCellByCoordinate(c);
    } else {
        cell = new DC_Cell(c, game);
    }
    if (cell == null) {
        return false;
    }
    if (z == null) {
        if (unit instanceof Unit) {
            Unit heroObj = (Unit) unit;
            z = heroObj.getZ();
        }
    }
    // TODO ???
    if (game.isSimulation()) {
        if (units.size() > 1) {
            return false;
        }
    }
    // no passable/overlaying!
    int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
    if (c != null) {
        if (!game.isSimulation()) {
            space = cell.getIntParam(PARAMS.SPACE);
        }
    }
    int girth = 0;
    for (Entity u : units) {
        if (u == unit) {
            continue;
        }
        // }
        if (UnitAnalyzer.isWall(u)) {
            // if (!UnitAnalyzer.isFlying(unit)) {
            return false;
        // }
        }
        if (u.isDead())
            girth += u.getIntParam(PARAMS.GIRTH) / 3;
        else
            girth += u.getIntParam(PARAMS.GIRTH);
    // TODO  if (DoorMaster.isDoor((BattleFieldObject) u)) {
    // 
    // }
    // main.system.auxiliary.LogMaster.log(1, "****************** " +
    // u.getName()
    // + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
    }
    // [QUICK FIX]
    if (unit.getIntParam(PARAMS.GIRTH) == 0) {
        girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
    } else {
        girth += unit.getIntParam(PARAMS.GIRTH);
    }
    // main.system.auxiliary.LogMaster.log(1, "****************** " + space
    // + " Space vs " + girth
    // + " Girth on " + c + " for " + unit);
    space = space * maxSpaceTakenPercentage / 100;
    if (space >= girth) {
        result = true;
    } else {
        if (unit.getIntParam(PARAMS.GIRTH) > space) {
            if (units.isEmpty()) {
                result = true;
            }
        }
    }
    if (// only cache for default cases!
    maxSpaceTakenPercentage == 100) {
        bools.put(c, result);
    }
    return result;
}
Also used : Entity(main.entity.Entity) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Cell(eidolons.entity.obj.DC_Cell) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DequeImpl(main.system.datatypes.DequeImpl)

Example 14 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class AnimationManager method actionResolves.

public void actionResolves(ImageIcon img, Ref ref) {
    if (ref.getGroup() != null) {
        for (Obj obj : ref.getGroup().getObjects()) {
            if (ListMaster.isNotEmpty(modifiedValues.get(obj))) {
                animateValuesModified(obj);
            } else {
                setOverlayingImage(obj, img.getImage());
                animate(actionDelay, getComp(obj));
            }
        }
    } else if (ref.getTargetObj() != null) {
        if (ListMaster.isNotEmpty(modifiedValues.get(ref.getTargetObj()))) {
            animateValuesModified(ref.getTargetObj());
        } else {
            setOverlayingImage(ref.getTargetObj(), img.getImage());
            animate(actionDelay, getComp(ref.getTargetObj()));
        }
    } else {
        return;
    }
    clearModValues();
// WaitMaster.waitForInput(WAIT_OPERATIONS.ANIMATION_FINISHED);
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj)

Example 15 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class RollMaster method roll.

/**
 * @return true if {failure} formula rolls more, false otherwise
 */
public static boolean roll(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logAppendix, String rollSource, Boolean logged) {
    Obj source = ref.getSourceObj();
    Obj target = ref.getTargetObj();
    // if (roll == null)
    roll = new Roll(roll_type, success, fail, 0);
    if (StringMaster.isEmpty(fail)) {
        fail = initStdFail(roll_type);
    }
    Formula failFormula = new Formula(fail);
    if (source != null) {
        failFormula.applyFactor(getFailFactor(roll_type));
    }
    Boolean result;
    int max1 = failFormula.getInt(ref);
    if (StringMaster.isEmpty(success)) {
        success = initStdSuccess(roll_type);
    }
    Formula successFormula = new Formula(success);
    successFormula.applyFactor(getSuccessFactor(roll_type));
    int max2 = successFormula.getInt(ref);
    int min1 = MathMaster.applyMod(max1, DEFAULT_MIN_ROLL_PERC);
    int min2 = MathMaster.applyMod(max2, DEFAULT_MIN_ROLL_PERC);
    if (min1 >= max2) {
        return true;
    }
    if (min2 >= max1) {
        return false;
    }
    // per die?
    rolledValue = RandomWizard.getRandomIntBetween(min1, max1);
    rolledValue2 = RandomWizard.getRandomIntBetween(min2, max2);
    roll.setRolledValue(rolledValue);
    roll.setRolledValue2(rolledValue2);
    result = rolledValue > rolledValue2;
    if (target == null) {
        target = ref.getEvent().getRef().getTargetObj();
    }
    // TODO display roll formulas if FULL_INFO is on!
    if (rollSource == null) {
        rollSource = rolledValue + " out of " + max1;
    } else {
        rollSource += StringMaster.wrapInParenthesis(rolledValue + " out of " + max1);
    }
    String rollTarget = rolledValue2 + " out of " + max2;
    logString = target.getName() + ((result) ? " fails" : " wins") + " a " + roll_type.getName() + " roll with " + rollTarget + " vs " + source.getName() + "'s " + rollSource;
    if (logAppendix != null) {
        if (isAppendixAdded(logAppendix, result)) {
            logString = logString + logAppendix.replace(getSuccessAppendixIdentifier(), "");
        }
    }
    if (logged == null) {
        logged = checkRollLogged(roll_type, result);
    }
    if (logged) {
        ref.getGame().getLogManager().log(logString);
    }
    ref.getGame().getLogManager();
    ref.getGame().getLogManager();
    if (!ref.isAnimationDisabled()) {
        PhaseAnimation anim = null;
        if (ref.getActive() != null) {
            // else ?
            anim = ((DC_ActiveObj) ref.getActive()).getAnimation();
        }
        if (anim != null) {
            anim.addPhaseArgs(PHASE_TYPE.ROLL, roll);
        }
    }
    roll.setResult(result);
    roll.setLogAppendix(logAppendix);
    roll.setRollSource(rollSource);
    roll.setRollTarget(rollTarget);
    return result;
}
Also used : Formula(main.system.math.Formula) PhaseAnimation(eidolons.system.graphics.PhaseAnimation) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj)

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6