Search in sources :

Example 96 with Unit

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

the class PatrolMaster method getBlockingUnit.

private static Unit getBlockingUnit(Patrol patrol, UnitAI ai) {
    Unit unit = ai.getUnit();
    DIRECTION direction = DirectionMaster.getRelativeDirection(unit.getCoordinates(), patrol.getDestination());
    // paths.getOrCreate(unit);
    Coordinates coordinates = unit.getCoordinates().getAdjacentCoordinate(direction);
    // TODO more than 1 coordinate?
    // unit.getGame().getUnitByCoordinate(coordinates);
    Unit unitByCoordinate = null;
    // preCheck leader?
    Collection<Unit> units = unit.getGame().getUnitsForCoordinates(coordinates);
    for (Obj u : units) {
        // sort?
        Unit blocker = (Unit) u;
        // if (u == leader)
        if (!blocker.isOwnedBy(ai.getUnit().getOwner())) {
            continue;
        }
        if (!blocker.canMove()) {
            continue;
        }
        unitByCoordinate = blocker;
    }
    return unitByCoordinate;
}
Also used : Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 97 with Unit

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

the class PatrolMaster method getWaitAction.

private static Action getWaitAction(Patrol patrol, UnitAI ai) {
    Unit unit = ai.getUnit();
    Unit blocker = getBlockingUnit(patrol, ai);
    if (blocker == null) {
        return null;
    }
    Ref ref = new Ref(unit);
    ref.setTarget(blocker.getId());
    new Action(ai.getUnit().getAction("Wait"), ref);
    return null;
}
Also used : Ref(main.entity.Ref) Action(eidolons.game.battlecraft.ai.elements.actions.Action) Unit(eidolons.entity.obj.unit.Unit)

Example 98 with Unit

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

the class Tavern method newHero.

public boolean newHero(boolean background, int xp) {
    // chance
    Unit hero;
    if (!background) {
        ObjType type = getRandomHeroType(xp);
        if (type == null) {
            return false;
        }
        hero = new Unit(type);
        initHeroHireParams(hero);
        HeroGenerator.alterHero(hero);
    } else {
        ObjType type = getRandomHeroBackground();
        hero = generateHeroFromBackground(type, xp);
    }
    hero.setHidden(true);
    if (hero == null) {
        return false;
    }
    return addHero(hero);
}
Also used : ObjType(main.entity.type.ObjType) Unit(eidolons.entity.obj.unit.Unit)

Example 99 with Unit

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

the class TavernMaster method buyDrinks.

public static void buyDrinks(Tavern tavern, MacroParty party) {
    /*
         *
		 */
    Boolean result = DialogMaster.askAndWait("I'll buy a drink for...", true, "all patrons!", "all of us", "myself");
    // int quality = tavern.getIntParam(MACRO_PARAMS.DRINK_QUALITY);
    List<Unit> drinkers = party.getMembers();
    if (result) {
        tavern.getHeroesForHire();
    } else {
        drinkers = new ListMaster<Unit>().getList(party.getLeader());
    }
    for (Unit member : drinkers) {
    // member.modifyParamByPercent(MACRO_PARAMS.COMBAT_READINESS,
    // quality - 100);
    }
// tavern.getIntParam(MACRO_PARAMS.DRINK_QUALITY);
// tavern.getIntParam(MACRO_PARAMS.DRINK_COST);
// dialog message
// reduce battle readiness, increase morale and loyalty (up to a limit)
}
Also used : ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit)

Example 100 with Unit

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

the class ModelManager method checkTypeModifications.

private static void checkTypeModifications(OBJ_TYPE obj_type) {
    if (obj_type == DC_TYPE.CHARS || obj_type == DC_TYPE.BF_OBJ || obj_type == DC_TYPE.UNITS) {
        if (obj_type == DC_TYPE.CHARS || obj_type == DC_TYPE.UNITS) {
            for (ObjType type : DataManager.getTypes(obj_type)) {
                DC_ContentManager.addDefaultValues(type, false);
            }
        }
        if (obj_type == DC_TYPE.CHARS) {
            for (ObjType type : DataManager.getTypes(obj_type)) {
                // ContentGenerator.generateArmorPerDamageType(type, null);
                if (type.getGroup().equals("Background")) {
                    PrincipleMaster.initPrincipleIdentification(type);
                }
            }
        }
    }
    checkPrincipleProcessing(obj_type);
    if (obj_type == DC_TYPE.PARTY) {
        ContentGenerator.adjustParties();
    }
    if (obj_type == DC_TYPE.SPELLS) {
        updateSpells();
    }
    if (obj_type == DC_TYPE.ARMOR) {
        generateNewArmorParams();
    } else if (obj_type == DC_TYPE.WEAPONS) {
        generateNewWeaponParams();
    } else if (obj_type == DC_TYPE.DEITIES) {
        for (ObjType type : DataManager.getTypes(obj_type)) // if (type.getGroup().equals("Background"))
        {
            PrincipleMaster.initPrincipleIdentification(type);
        }
    } else if (obj_type == DC_TYPE.ENCOUNTERS) {
        for (ObjType type : DataManager.getTypes(obj_type)) {
            type.setParam(PARAMS.POWER_MINIMUM, EncounterMaster.getMinimumPower(type));
            type.setParam(PARAMS.POWER_BASE, EncounterMaster.getPower(type, null));
            type.setParam(PARAMS.POWER_MAXIMUM, EncounterMaster.getPower(type, false));
        }
    } else if (obj_type == DC_TYPE.ACTIONS) {
        for (ObjType type : DataManager.getTypes(obj_type)) {
            ActionGenerator.addDefaultSneakModsToAction(type);
        }
    } else if (obj_type == DC_TYPE.SKILLS) {
        if (isSkillSdAutoAdjusting()) {
            autoAdjustSkills();
        }
    } else if (obj_type == DC_TYPE.CLASSES) // if (isClassAutoAdjustingOn())
    {
        autoAdjustClasses();
    }
    if (obj_type == DC_TYPE.ACTIONS) {
        for (ObjType type : DataManager.getTypes(obj_type)) {
            if (type.checkProperty(G_PROPS.ACTION_TYPE, ActionEnums.ACTION_TYPE.STANDARD_ATTACK.toString())) {
                DC_ContentManager.addDefaultValues(type, false);
            }
        }
    }
    if (obj_type == DC_TYPE.SPELLS) {
        for (ObjType type : DataManager.getTypes(obj_type)) // if (type.getIntParam(PARAMS.XP_COST) == 0)
        {
            if (!type.getGroup().equals(StringMaster.STANDARD)) {
                type.setParam(PARAMS.XP_COST, type.getIntParam(PARAMS.SPELL_DIFFICULTY) * DC_Formulas.XP_COST_PER_SPELL_DIFFICULTY);
            } else {
                type.setParam(PARAMS.XP_COST, type.getIntParam(PARAMS.SPELL_DIFFICULTY) * DC_Formulas.XP_COST_PER_SPELL_DIFFICULTY);
            }
        }
    }
    if (obj_type == DC_TYPE.WEAPONS || obj_type == DC_TYPE.ARMOR) {
        for (ObjType type : DataManager.getTypes(obj_type)) {
            DC_ContentManager.addDefaultValues(type, false);
        }
    }
    if (obj_type == DC_TYPE.BF_OBJ) {
        generateBfObjProps();
    }
    if (obj_type.isTreeEditType() || obj_type == DC_TYPE.CHARS || obj_type == DC_TYPE.UNITS) {
        if (obj_type == DC_TYPE.CHARS) {
        // XML_Reader.checkHeroesAdded();
        }
        for (ObjType type : DataManager.getTypes(obj_type)) {
            // }
            if (obj_type == DC_TYPE.CHARS) {
                if (!type.isInitialized()) {
                    Game.game.initType(type);
                }
                type.setParam(PARAMS.POWER, DC_MathManager.getUnitPower(type));
                if (StringMaster.isEmpty(type.getProperty(PROPS.OFFHAND_NATURAL_WEAPON))) {
                    type.setProperty((PROPS.OFFHAND_NATURAL_WEAPON), PROPS.NATURAL_WEAPON.getDefaultValue());
                }
                if (ArcaneVault.isSimulationOn()) {
                    int girth = 0;
                    Unit unit = SimulationManager.getUnit(type);
                    RACE race = unit.getRace();
                    if (race != null) {
                        switch(race) {
                            case DEMON:
                                girth = 200;
                                if (unit.getBackground() == HeroEnums.BACKGROUND.INFERI_WARPBORN) {
                                    girth = 80;
                                }
                                break;
                            case ELF:
                                girth = 50;
                                break;
                            case GOBLINOID:
                                girth = 135;
                                break;
                            case VAMPIRE:
                            case HUMAN:
                                girth = 100;
                                break;
                            case DWARF:
                                girth = 175;
                                break;
                        }
                    }
                    if (type.getGroup().equals(StringMaster.BACKGROUND)) {
                        LogMaster.setOff(true);
                        try {
                            unit.resetDefaultAttrs();
                        } catch (Exception e) {
                        } finally {
                            LogMaster.setOff(false);
                        }
                    } else {
                        girth += DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS).getIntParam(PARAMS.GIRTH);
                    }
                    if (!type.getName().equals(HeroCreator.BASE_HERO)) {
                        type.setParam(PARAMS.GIRTH, girth);
                    }
                }
            } else {
                type.setParam(PARAMS.TOTAL_XP, DC_MathManager.getUnitXP(type));
            // XML_Transformer.adjustProgressionToWeightForm(type,
            // true);
            // XML_Transformer.adjustProgressionToWeightForm(type,
            // false);
            }
        }
    }
}
Also used : ObjType(main.entity.type.ObjType) RACE(main.content.enums.entity.HeroEnums.RACE) 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