Search in sources :

Example 36 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class BfGridComp method drawSelectionGlowOverlay.

private void drawSelectionGlowOverlay(Graphics g, Obj obj, boolean info) {
    if (!game.isDebugMode()) {
        if (!VisionManager.checkVisible((DC_Obj) obj)) {
            return;
        }
    }
    CellComp comp = getCompForObject(obj);
    if (comp == null) {
        return;
    }
    if (comp.getTopObj() != null) {
        if (comp.getTopObj().getOutlineType() != null) {
        // VisibilityMaster.getEmitterPath(type, unit)
        // return;
        }
    }
    boolean single = !comp.isMultiObj();
    // preCheck overlaying
    Image selectionFrame = info ? getInfoGlowFrame(obj) : obj.isMine() ? BORDER.NEO_ACTIVE_SELECT_HIGHLIGHT.getImage() : BORDER.NEO_ACTIVE_ENEMY_SELECT_HIGHLIGHT.getImage();
    // if (!single)
    // selectionFrame = info ?
    // BORDER.NEO_INFO_SELECT_HIGHLIGHT_SQUARE_96.getEmitterPath() : obj
    // .isMine() ? BORDER.NEO_ACTIVE_SELECT_HIGHLIGHT_SQUARE_96.getEmitterPath()
    // : BORDER.NEO_ACTIVE_ENEMY_SELECT_HIGHLIGHT_SQUARE_96.getEmitterPath();
    int offsetX = (single ? 9 : 13 + comp.getObjects().size()) * zoom / 100;
    int offsetY = (single ? 9 : 13 + comp.getObjects().size()) * zoom / 100;
    if (single) {
        setStackedHighlightRelativeCoordinates(null, info);
    }
    if (getStackedHighlightRelativeCoordinates(info) != null) {
        offsetX -= getStackedHighlightRelativeCoordinates(info).x;
        offsetY -= getStackedHighlightRelativeCoordinates(info).y;
    }
    // TODO IF >100, USE 128
    if (comp.isMultiObj() || isLevelEditor()) {
        int size = getSelectedObjSize(info) + getSelectedObjSize(info) * 32 / 150;
        if (isLevelEditor()) {
            size = (getCellWidth() + getCellHeight()) * 23 / 40;
            offsetX -= 6 * zoom / 100;
            offsetY -= 6 * zoom / 100;
        }
        if (size > 0) {
            selectionFrame = ImageManager.getSizedVersion(selectionFrame, new Dimension(size, size));
        }
    }
    // }
    int x = getCellWidth() * (obj.getCoordinates().x - getOffsetX()) - offsetX;
    int y = getCellHeight() * (obj.getCoordinates().y - getOffsetY()) - offsetY;
    g.drawImage(selectionFrame, x, y, null);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BufferedImage(java.awt.image.BufferedImage)

Example 37 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class ClearShotCondition method check.

@Override
public boolean check(Ref ref) {
    Obj obj = game.getObjectById(ref.getId(str2));
    if (!(obj instanceof DC_Obj)) {
        return false;
    }
    DC_Obj target = (DC_Obj) game.getObjectById(ref.getId(str2));
    if (target == null) {
        return false;
    }
    Coordinates c2 = target.getCoordinates();
    if (c2 == null)
        return false;
    BattleFieldObject source = (BattleFieldObject) game.getObjectById(ref.getId(str1));
    if (source == null)
        return false;
    if (c2.equals(source.getCoordinates()))
        return true;
    if (target.isOverlaying()) {
        if (target instanceof BattleFieldObject) {
            DIRECTION d = ((BattleFieldObject) target).getDirection();
            DIRECTION d1 = DirectionMaster.getRelativeDirection(target, source);
            if (d != null) {
                if (d1 != d) {
                    if (Math.abs(d.getDegrees() - d1.getDegrees()) > 90)
                        return false;
                }
            }
        }
    }
    wallObstruction = false;
    Coordinates c1 = source.getCoordinates();
    boolean toCheck = true;
    boolean result = true;
    if (PositionMaster.inLine(c1, c2)) {
        result = PositionMaster.noObstaclesInLine(source, target, game.getBattleField().getGrid());
        toCheck = false;
        if (!result)
            return cacheResult(source, target, result);
    } else {
        // TODO TRANSPARENT FOR VISION!
        if (PositionMaster.inLineDiagonally(c1, c2)) {
            result = PositionMaster.noObstaclesInDiagonal(c1, c2, game.getBattleField().getGrid(), source);
            if (!result)
                return cacheResult(source, target, result);
            List<Coordinates> list = new ArrayList<>();
            if (!c2.isAdjacent(source.getCoordinates())) {
                DIRECTION direction = DirectionMaster.getRelativeDirection(source, target);
                list = (DC_PositionMaster.getLine(false, direction, source.getCoordinates(), // PositionMaster.getDistance(source,
                Math.abs(source.getX() - target.getX())));
            } else {
                list.add(target.getCoordinates());
            }
            for (Coordinates c : list) {
                if (checkWallObstruction(source, target, c))
                    return cacheResult(source, target, false);
            }
            return cacheResult(source, target, true);
        }
    }
    if (!result)
        return cacheResult(source, target, result);
    if (!toCheck)
        return cacheResult(source, target, result);
    result = checkClearShot(source, target);
    return cacheResult(source, target, result);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Example 38 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class FacingCondition method check.

@Override
public boolean check(Ref ref) {
    if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
        return false;
    }
    BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
    DC_Obj obj2;
    if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
        if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
            return false;
        }
        obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
    } else {
        obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
    }
    boolean result = false;
    if (getTemplate() != null) {
        Coordinates c = obj2.getCoordinates();
        if (obj2.isOverlaying())
            if (obj2 instanceof BattleFieldObject) {
                DIRECTION d = ((BattleFieldObject) obj2).getDirection();
                if (d != null) {
                    c = c.getAdjacentCoordinate(d.rotate180(), 2);
                }
            // the coordinate to which unit must be facing in order to face the overlaying obj on the other side
            }
        if (obj1 == null)
            return false;
        if (c == null)
            return false;
        FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
        result = Arrays.asList(templates).contains(facing);
        if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
            if (result) {
                if (left_right == null) {
                    left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
                }
                if (left_right) {
                    int degrees = obj1.getFacing().getDirection().getDegrees();
                    int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
                    boolean left = degrees > degrees2;
                    if (left) {
                        return left_right;
                    }
                    return !left_right;
                }
            }
        }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) BfObj(main.entity.obj.BfObj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 39 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class ModifyValueEffect method applyThis.

@Override
public boolean applyThis() {
    if (modString != null) {
        return EffectFinder.initParamModEffects(modString, ref).apply(ref);
    }
    if (param == null) {
        this.param = ContentManager.getPARAM(sparam);
        if (param == null) {
            if (param == null) {
                this.param = ContentManager.getMastery(sparam);
            }
        }
        if (param == null) {
            if (StringMaster.openContainer(sparam, StringMaster.AND_SEPARATOR).size() > 1) {
                params = game.getValueManager().getParamsFromContainer(sparam);
            } else {
                params = game.getValueManager().getValueGroupParams(sparam);
            }
        }
    }
    Obj obj = ref.getTargetObj();
    if (obj instanceof DC_Obj) {
        ((DC_Obj) obj).modified(this);
    }
    if (ref.getTargetObj() == null) {
        LogMaster.log(1, "null target!" + this);
        return false;
    }
    Map<PARAMETER, String> map = new HashMap<>();
    if (param == null) {
        if (params == null) {
            // TODO
            return new ModifyCounterEffect(sparam, mod_type, formula.toString()).apply(ref);
        }
        for (PARAMETER p : params) {
            if (p == null) {
                continue;
            }
            param = p;
            modify(obj, map);
        }
        param = null;
        return true;
    }
    // TODO how to determined when formula should be statically parsed?
    // what if some part of the formula depends on the target instead?
    boolean result = modify(obj, map);
    if (result) {
        if (!isAnimationDisabled()) {
            if (map != null) {
                if (!map.isEmpty()) {
                    if (getAnimation() != null) {
                        if (!isContinuousWrapped()) {
                            getAnimation().addPhaseArgs(PHASE_TYPE.PARAM_MODS, map);
                        // getAnimation().start(); // TODO sync?
                        } else {
                            wrapInBuffPhase(map);
                        }
                    }
                }
            }
        }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect) HashMap(java.util.HashMap) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj) PARAMETER(main.content.values.parameters.PARAMETER)

Example 40 with DC_Obj

use of eidolons.entity.obj.DC_Obj 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)

Aggregations

DC_Obj (eidolons.entity.obj.DC_Obj)49 Unit (eidolons.entity.obj.unit.Unit)13 Obj (main.entity.obj.Obj)13 Coordinates (main.game.bf.Coordinates)12 ArrayList (java.util.ArrayList)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 DIRECTION (main.game.bf.Coordinates.DIRECTION)7 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)5 DC_Cell (eidolons.entity.obj.DC_Cell)4 BufferedImage (java.awt.image.BufferedImage)4 List (java.util.List)3 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 HashMap (java.util.HashMap)2 PARAMETER (main.content.values.parameters.PARAMETER)2 Ref (main.entity.Ref)2 BuffObj (main.entity.obj.BuffObj)2 Pair (org.apache.commons.lang3.tuple.Pair)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1