Search in sources :

Example 36 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ParryRule method canParry.

// precalculateRawDamageForDisplay
private boolean canParry(Attack attack) {
    // if (!RuleMaster.isParryOn())return false;
    Unit attackedUnit = (Unit) attack.getAttackedUnit();
    if (attackedUnit == null)
        return false;
    if (attackedUnit.getIntParam(PARAMS.PARRY_CHANCE) <= 0) {
        return false;
    }
    if (attack.isSneak()) {
        return false;
    }
    if (attack.isCritical()) {
        return false;
    }
    if (attack.isRanged()) {
        return false;
    }
    if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.NATURAL) {
        return false;
    }
    if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.BLUNT) {
        return false;
    }
    // if (attack.getWeapon().getWeaponSize() == WEAPON_SIZE.TINY)
    // {
    // TODO
    DC_WeaponObj parryWeapon = attackedUnit.getActiveWeapon(false);
    if (Math.abs(DC_ContentManager.compareSize(parryWeapon.getWeaponSize(), attack.getWeapon().getWeaponSize())) > 2) {
        if (attackedUnit.checkDualWielding()) {
        } else {
            return false;
        }
    }
    // }
    return true;
}
Also used : DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) Unit(eidolons.entity.obj.unit.Unit)

Example 37 with Unit

use of eidolons.entity.obj.unit.Unit 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 38 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ScenarioPartyManager method gameStarted.

@Override
public void gameStarted() {
    Unit hero = getGame().getMaster().getUnitByName(PartyManager.selectedHero, true, null, null, getGame().getPlayer(true), null);
    // will find 1st if name==null
    mainHeroSelected(party, hero);
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 39 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ScenarioPrecombatMaster method newScenario.

public static void newScenario() {
    final ScenarioChoiceView scv = new ScenarioChoiceView();
    final ChoiceSequence choiceSequence = new ChoiceSequence(scv);
    final ScenarioModeChoiceView smcv = new ScenarioModeChoiceView(choiceSequence, SCENARIO_MODES.class);
    // TODO only if there are choices!
    choiceSequence.addView(smcv);
    choiceSequence.start();
    choiceSequence.setManager(new SequenceManager() {

        @Override
        public void doneSelection() {
            ObjType type = scv.getSelectedItem();
            scenario = new Scenario(type);
            SCENARIO_MODES mode = smcv.getSelectedItem();
            if (mode == SCENARIO_MODES.STORY_MODE) {
                String prop = scenario.getProperty(MACRO_PROPS.MISSION_PARTY);
                List<Unit> heroes;
                if (!DataManager.isTypeName(prop, DC_TYPE.PARTY)) {
                    prop = scenario.getProperty(MACRO_PROPS.MISSION_CUSTOM_PARTY);
                    heroes = new ArrayList<>();
                    String leaderName = prop.split(";")[0];
                    Unit leader = Launcher.getMainManager().initSelectedHero(leaderName);
                    // prop = prop.replace(leaderName, "");
                    // for (String s : StringMaster.open(prop)) {
                    // }
                    heroes.add(leader);
                    PartyHelper.newParty(leader);
                    Launcher.getMainManager().launchHC();
                    return;
                } else {
                    heroes = PartyHelper.loadParty(prop);
                }
                Launcher.getMainManager().launchHC(heroes);
                return;
            }
            Launcher.resetView(VIEWS.MENU);
        }

        @Override
        public void cancelSelection() {
            Launcher.getMainManager().exitToMainMenu();
        }
    });
}
Also used : ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) ChoiceSequence(eidolons.client.cc.gui.neo.choice.ChoiceSequence) ArrayList(java.util.ArrayList) List(java.util.List) Unit(eidolons.entity.obj.unit.Unit) ScenarioChoiceView(eidolons.client.cc.gui.neo.choice.ScenarioChoiceView) ScenarioModeChoiceView(eidolons.client.cc.gui.neo.choice.ScenarioModeChoiceView) SequenceManager(eidolons.client.dc.SequenceManager)

Example 40 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class PartyHelper method addCreepParty.

public static Party addCreepParty(Unit leader, String name, List<Unit> units, ObjType newType) {
    newType.setName(name);
    Party p = createParty(newType, leader);
    for (Unit unit : units) {
        p.addMember(unit);
    }
    parties.add(p);
    return p;
}
Also used : Party(eidolons.client.cc.logic.party.Party) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7