Search in sources :

Example 66 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class PassiveAbilityObj method kill.

// @Override
// public boolean activate() {
// boolean result = true;
// 
// 
// return result;
// }
@Override
public boolean kill() {
    Ref REF = Ref.getCopy(ref);
    if (isDead()) {
        return false;
    }
    if (!game.fireEvent(new Event(STANDARD_EVENT_TYPE.PASSIVE_BEING_REMOVED, REF))) {
        return false;
    }
    setDead(true);
    game.getManager().attachmentRemoved(this, ownerObj);
    game.fireEvent(new Event(STANDARD_EVENT_TYPE.PASSIVE_REMOVED, REF));
    applied = false;
    return super.kill();
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

Example 67 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class PathChoiceMaster method getChoices.

List<Choice> getChoices(ActionPath path, Coordinates c_coordinate, Coordinates targetCoordinate, FACING_DIRECTION c_facing) {
    Chronos.mark("Finding choices for " + path);
    pathBuilder.adjustUnit();
    List<Choice> choices = new ArrayList<>();
    for (Coordinates c : getDefaultCoordinateTargets(path, c_coordinate)) {
        Choice stdMoveChoice = constructStdMoveChoice(c, c_coordinate, c_facing);
        if (stdMoveChoice != null) {
            choices.add(stdMoveChoice);
        }
    }
    Chronos.mark("Finding custom choices for " + path);
    List<Choice> specialChoices = new ArrayList<>();
    if (ListMaster.isNotEmpty(moveActions)) {
        for (DC_ActiveObj a : moveActions) {
            if (!a.canBeActivated()) {
                if (firstStep) {
                    if (!ReasonMaster.checkReasonCannotActivate(a, PARAMS.C_N_OF_ACTIONS.getName())) {
                        // exception for AP TODO
                        continue;
                    }
                }
            }
            if (path.hasAction(a)) {
                if (a.getIntParam(PARAMS.COOLDOWN) >= 0) {
                    continue;
                }
            }
            Targeting targeting = a.getTargeting();
            Collection<Obj> objects = null;
            if (targeting instanceof FixedTargeting) {
                Targeting t = a.getAbilities().getTargeting();
                if (t != null) {
                    objects = t.getFilter().getObjects(a.getRef());
                }
                Effect e = a.getAbilities().getEffects().getEffects().get(0);
                e.setRef(unit.getRef());
                if (e instanceof SelfMoveEffect) {
                    try {
                        Coordinates coordinates = ((SelfMoveEffect) e).getCoordinates();
                        if (coordinates != null) {
                            objects = new ArrayList<>(Arrays.asList(unit.getGame().getCellByCoordinate(coordinates)));
                        }
                    } catch (Exception ex) {
                        main.system.ExceptionMaster.printStackTrace(ex);
                    }
                }
            } else {
                pathBuilder.adjustUnit();
                objects = targeting.getFilter().getObjects(a.getRef());
            }
            if (objects != null) {
                List<Choice> choicesForAction = new ArrayList<>();
                for (Object obj : objects) {
                    if (obj instanceof DC_Cell) {
                        Coordinates coordinates = ((DC_Cell) obj).getCoordinates();
                        // if (a.getName().equals("Clumsy Leap"))
                        if (PositionMaster.getDistance(coordinates, c_coordinate) > Math.max(1, a.getIntParam(PARAMS.RANGE))) {
                            continue;
                        }
                        if (PositionMaster.getDistance(coordinates, targetCoordinate) > PositionMaster.getDistance(c_coordinate, targetCoordinate)) {
                            // TODO will this not eliminate good
                            continue;
                        }
                        // choices?
                        Ref ref = unit.getRef().getCopy();
                        ref.setTarget(((DC_Cell) obj).getId());
                        Choice choice = new Choice(coordinates, c_coordinate, new Action(a, ref));
                        choicesForAction.add(choice);
                    }
                }
                Chronos.mark("Filter custom choices for " + a);
                specialChoices.addAll(filterSpecialMoveChoices(choicesForAction, a, c_coordinate, path));
                Chronos.logTimeElapsedForMark("Filter custom choices for " + a);
            }
        // if (choices.size() > 1)
        }
    }
    Chronos.logTimeElapsedForMark("Finding custom choices for " + path);
    choices.addAll(specialChoices);
    Chronos.mark("Sort choices");
    sortChoices(choices);
    Chronos.logTimeElapsedForMark("Sort choices");
    // resetUnit();// TODO is that right?
    Chronos.logTimeElapsedForMark("Finding choices for " + path);
    // Chronos.logTimeElapsedForMark("Sorting choices for " + path);
    return choices;
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) Coordinates(main.game.bf.Coordinates) Ref(main.entity.Ref) FixedTargeting(main.elements.targeting.FixedTargeting) DC_Cell(eidolons.entity.obj.DC_Cell) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) Effect(main.ability.effects.Effect) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 68 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ReasonMaster method getReasonsCannotActivate.

public static List<String> getReasonsCannotActivate(Action action) {
    // action.getActive().getCosts().getReasons()
    Ref REF = action.getRef().getCopy();
    REF.setMatch(action.getRef().getTarget());
    REF.setID(KEYS.PAYEE, action.getSource().getId());
    return getReasonsCannotActivate(action.getActive(), REF);
// Map<String, Condition> reqs =
// action.getActive().getCosts().getRequirements().getReqMap();
// for (Condition c : reqs.values()) {
// if (!c.preCheck(REF)) {
// reasons.add
// (new MapMaster<String, Condition>().getKeyForValue(reqs, c));
// }
// }
// 
// return reasons;
}
Also used : Ref(main.entity.Ref)

Example 69 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ReasonMaster method getReasonsCannotTarget.

public static List<FILTER_REASON> getReasonsCannotTarget(Action action, boolean useConditionResultCache, Boolean checkMiscOrOnly, FILTER_REASON searchedReason) {
    Ref REF = action.getRef().getCopy();
    REF.setMatch(action.getRef().getTarget());
    Targeting targeting = action.getActive().getTargeting();
    if (targeting == null) {
        targeting = TargetingMaster.findTargeting(action.getActive());
    }
    if (targeting == null) {
        return new ArrayList<>();
    }
    Conditions conditions = targeting.getFilter().getConditions();
    // conditions.preCheck(REF);
    List<FILTER_REASON> reasons = new ArrayList<>();
    for (Condition c : conditions) {
        FILTER_REASON reason = getReason(c);
        if (searchedReason != null) {
            if (reason != searchedReason) {
                continue;
            }
        }
        if (checkMiscOrOnly == null) {
            if (reason != FILTER_REASON.OTHER) {
                continue;
            }
        } else if (!checkMiscOrOnly) {
            if (reason == FILTER_REASON.OTHER) {
                continue;
            }
        }
        boolean result = c.isTrue();
        if (!useConditionResultCache) {
            result = c.preCheck(REF);
        } else {
        // LogMaster.log(0, c + " uses cached result " + result);
        }
        if (!result) {
            if (reason != null) {
                reasons.add(reason);
            }
        }
    }
    return reasons;
}
Also used : DistanceCondition(main.elements.conditions.DistanceCondition) VisibilityCondition(eidolons.ability.conditions.VisibilityCondition) FacingCondition(eidolons.ability.conditions.FacingCondition) Condition(main.elements.conditions.Condition) Ref(main.entity.Ref) Targeting(main.elements.targeting.Targeting) ArrayList(java.util.ArrayList) Conditions(main.elements.conditions.Conditions)

Example 70 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ReasonMaster method getReasonsCannotActivate.

public static List<String> getReasonsCannotActivate(DC_ActiveObj action) {
    Ref REF = action.getRef().getCopy();
    REF.setMatch(action.getRef().getTarget());
    REF.setID(KEYS.PAYEE, action.getOwnerObj().getId());
    return getReasonsCannotActivate(action, REF);
}
Also used : Ref(main.entity.Ref)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5