Search in sources :

Example 41 with BattleFieldObject

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

the class ForceRule method applyForceEffects.

public static void applyForceEffects(int force, DC_ActiveObj action) {
    if (!(action.getRef().getTargetObj() instanceof Unit))
        return;
    Unit target = (Unit) action.getRef().getTargetObj();
    BattleFieldObject source = (BattleFieldObject) action.getRef().getSourceObj();
    Boolean result = null;
    // TODO DEXTERITY ROLL TO AVOID ALL?
    if (target.getIntParam(PARAMS.TOTAL_WEIGHT) < getMinWeightKnock(action)) {
        result = RollMaster.rollForceKnockdown(target, action, force);
        if (BooleanMaster.isFalse(result)) {
            // ALWAYS INTERRUPT AT LEAST
            result = null;
        }
    } else if (target.getIntParam(PARAMS.TOTAL_WEIGHT) > getMaxWeightKnock(action)) {
        result = false;
    } else {
        result = RollMaster.rollForceKnockdown(target, action, force);
    }
    if (isTestMode()) {
        result = true;
    }
    if (result == null) {
        InterruptRule.interrupt(target);
    } else if (result) {
        KnockdownRule.knockdown(target);
    }
    applyPush(force, action, source, target);
// if (action.isSpell()) {
// applyDamage(force, action, source, target);
// }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Unit(eidolons.entity.obj.unit.Unit)

Example 42 with BattleFieldObject

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

the class ForceRule method addForceEffects.

public static void addForceEffects(DC_ActiveObj action) {
    if (!isForceEnabled(action)) {
        return;
    }
    if (!(action.getRef().getTargetObj() instanceof BattleFieldObject)) {
        return;
    }
    BattleFieldObject source = action.getOwnerObj();
    BattleFieldObject target = (BattleFieldObject) action.getRef().getTargetObj();
    Damage dmg = getDamageObject(action, source, target);
    Effect effects = getForceEffects(action);
    if (effects != null) {
        action.addSpecialEffect(action.isSpell() ? SPECIAL_EFFECTS_CASE.SPELL_IMPACT : SPECIAL_EFFECTS_CASE.ON_ATTACK, effects);
    }
    if (dmg != null) {
        action.addBonusDamage(action.isSpell() ? DAMAGE_CASE.SPELL : DAMAGE_CASE.ATTACK, dmg);
    }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ForceEffect(eidolons.ability.effects.oneshot.attack.force.ForceEffect) KnockdownEffect(eidolons.ability.effects.oneshot.attack.force.KnockdownEffect) MoveEffect(eidolons.ability.effects.oneshot.move.MoveEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Damage(eidolons.game.battlecraft.rules.combat.damage.Damage)

Example 43 with BattleFieldObject

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

the class DC_MovementManager method move.

public boolean move(Unit obj, DC_Cell cell, boolean free, Path path, MOVE_MODIFIER mod, Ref ref) {
    // if (path == null) {
    // if (!free)
    // path = getPath(obj, cell); // TODO just preCheck if it's blocked
    // }
    // if (!free)
    // if (!canMove(obj, cell))
    // return false;
    Ref REF = new Ref(obj.getGame());
    REF.setTarget(cell.getId());
    REF.setSource(obj.getId());
    LogMaster.log(LogMaster.MOVEMENT_DEBUG, "Moving " + obj + " to " + cell);
    Event event = new Event(STANDARD_EVENT_TYPE.UNIT_BEING_MOVED, REF);
    if (!game.fireEvent(event)) {
        return false;
    }
    // double cost = (!free) ? path.traverse(obj) : 0;
    // int _cost = getIntegerCost(cost);
    // for AI simulation only!
    // obj.modifyParameter(PARAMS.C_N_OF_MOVES, -_cost, 0);
    // obj.modifyParameter(PARAMS.C_N_OF_ACTIONS, -_cost, 0);
    Coordinates c = cell.getCoordinates();
    if (mod != MOVE_MODIFIER.TELEPORT) {
        // TODO UPDATE!
        Unit moveObj = (Unit) getGrid().getObj(cell.getCoordinates());
        if (moveObj != null) {
            if (ref.getActive() instanceof DC_ActiveObj) {
                DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
                if (moveObj instanceof Unit) {
                    Unit heroObj = moveObj;
                    c = CollisionRule.collision(ref, activeObj, moveObj, heroObj, false, activeObj.getIntParam(PARAMS.FORCE));
                    if (c == null) {
                        // displaced by Collision rule?
                        return true;
                    }
                }
            }
        }
    }
    if (obj.isDead()) {
        return false;
    }
    if (!game.getRules().getStackingRule().canBeMovedOnto(obj, c)) {
        return false;
    }
    if (game.getObjectByCoordinate(c) instanceof BattleFieldObject) {
        if (((BattleFieldObject) game.getObjectByCoordinate(c)).isWall()) {
            return false;
        }
    }
    if (!game.getRules().getEngagedRule().unitMoved(obj, c.x, c.y)) {
        return false;
    }
    obj.setCoordinates(c);
    event = new Event(STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING, REF);
    return game.fireEvent(event);
}
Also used : Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 44 with BattleFieldObject

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

the class DC_ObjInitializer method initDirectionMap.

public static void initDirectionMap(int z, Map<String, DIRECTION> directionMap) {
    for (String data : directionMap.keySet()) {
        Coordinates c = getCoordinatesFromObjString(data);
        DIRECTION d = directionMap.get(data);
        for (BattleFieldObject obj : DC_Game.game.getObjectsOnCoordinate(z, c, null, false, false)) {
            String name = getNameFromObjString(data);
            if (name.contains(MULTI_DIRECTION_SUFFIX)) {
                name = name.split(MULTI_DIRECTION_SUFFIX)[0];
            }
            if (!name.equals(obj.getName())) {
                continue;
            }
            Map<BattleFieldObject, DIRECTION> map = obj.getGame().getDirectionMap().get(c);
            if (map == null) {
                map = new HashMap<>();
                obj.getGame().getDirectionMap().put(c, map);
            }
            obj.setDirection(d);
            map.put(obj, d);
        }
    }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Example 45 with BattleFieldObject

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

the class DC_ObjInitializer method initFlipMap.

public static void initFlipMap(int z, Map<String, FLIP> flipMap) {
    if (flipMap != null) {
        for (String data : flipMap.keySet()) {
            Coordinates c = getCoordinatesFromObjString(data);
            FLIP d = flipMap.get(data);
            for (BattleFieldObject obj : DC_Game.game.getObjectsOnCoordinate(z, c, null, false, false)) {
                String name = getNameFromObjString(data);
                if (name.contains(MULTI_DIRECTION_SUFFIX)) {
                    name = name.split(MULTI_DIRECTION_SUFFIX)[0];
                }
                if (!name.equals(obj.getName())) {
                    continue;
                }
                Map<BattleFieldObject, FLIP> map = obj.getGame().getFlipMap().get(c);
                if (map == null) {
                    map = new HashMap<>();
                    obj.getGame().getFlipMap().put(c, map);
                }
                map.put(obj, d);
            }
        }
    }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) FLIP(main.content.CONTENT_CONSTS.FLIP)

Aggregations

BattleFieldObject (eidolons.entity.obj.BattleFieldObject)52 Unit (eidolons.entity.obj.unit.Unit)24 Coordinates (main.game.bf.Coordinates)22 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)12 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 Obj (main.entity.obj.Obj)9 DequeImpl (main.system.datatypes.DequeImpl)8 Event (main.game.logic.event.Event)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 DIRECTION (main.game.bf.Coordinates.DIRECTION)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Vector2 (com.badlogic.gdx.math.Vector2)4 Align (com.badlogic.gdx.utils.Align)4 Eidolons (eidolons.game.core.Eidolons)4 Gdx (com.badlogic.gdx.Gdx)3 Keys (com.badlogic.gdx.Input.Keys)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)3 Group (com.badlogic.gdx.scenes.scene2d.Group)3