Search in sources :

Example 91 with Unit

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

the class HeroGenerator method generateHero.

public static Unit generateHero(ObjType type, int xp, Tavern tavern) {
    type = new ObjType(type);
    type.initType();
    // apply random changes to base
    applyBackgroundChanges(type, getMaxApplied(xp, true) + 1);
    Unit hero = new Unit(type, DC_Game.game);
    // set XP/gold percentages and plans!
    // award classes!
    UnitTrainer.train(hero);
    UnitLibrary.learnSpellsForUnit(hero);
    UnitShop.buyItemsForUnit(hero);
    // generate name
    return hero;
}
Also used : ObjType(main.entity.type.ObjType) Unit(eidolons.entity.obj.unit.Unit)

Example 92 with Unit

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

the class AggroMaster method getAggroGroup.

public static List<Unit> getAggroGroup() {
    // Unit hero = (Unit) DC_Game.game.getPlayer(true).getHeroObj();
    List<Unit> list = new ArrayList<>();
    for (Unit ally : DC_Game.game.getPlayer(true).getControlledUnits_()) {
        // }
        for (Unit unit : getAggroGroup(ally)) {
            if (!list.contains(unit))
                list.add(unit);
        }
    }
    main.system.auxiliary.log.LogMaster.log(1, "Aggro group: " + list + "; last: " + lastAggroGroup);
    if (!ExplorationMaster.isExplorationOn())
        if (!list.isEmpty()) {
            logAggro(list);
        }
    if (lastAggroGroup != null)
        if (lastAggroGroup.size() > list.size()) {
            main.system.auxiliary.log.LogMaster.log(1, "Aggro group reduced: " + lastAggroGroup + " last vs new: " + list);
        }
    lastAggroGroup = list;
    return list;
}
Also used : ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Example 93 with Unit

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

the class AggroMaster method getAggroGroup.

public static Set<Unit> getAggroGroup(Unit hero) {
    Set<Unit> set = new ConcurrentHashSet<>();
    // Analyzer.getEnemies(hero, false, false, false);
    // if (ExplorationMaster.isExplorationOn())
    boolean newAggro = false;
    for (Unit unit : DC_Game.game.getUnits()) {
        if (unit.isDead())
            continue;
        if (unit.isUnconscious())
            continue;
        if (!unit.isEnemyTo(DC_Game.game.getPlayer(true)))
            continue;
        if (unit.getAI().getEngagementDuration() > 0) {
            set.add(unit);
        }
        if (unit.getAI().isEngaged()) {
            set.add(unit);
            newAggro = true;
            unit.getAI().setEngaged(false);
        }
        if (!unit.getGame().getVisionMaster().getVisionRule().isAggro(hero, unit))
            continue;
        // TODO these units will instead 'surprise attack' you or stalk
        newAggro = true;
        set.add(unit);
    // }
    }
    for (Unit unit : set) {
        if (unit.getAI().getGroup() != null) {
            for (Unit sub : unit.getAI().getGroup().getMembers()) {
                set.add(sub);
                if (newAggro) {
                    int duration = getEngagementDuration(sub.getAI());
                    sub.getAI().setEngagementDuration(duration);
                }
            }
        }
    }
    for (Unit unit : set) {
        if (unit.getAI().getEngagementDuration() <= 1)
            return set;
    }
    return set;
}
Also used : ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) Unit(eidolons.entity.obj.unit.Unit)

Example 94 with Unit

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

the class AggroMaster method checkEngaged.

public static boolean checkEngaged(UnitAI ai) {
    Unit unit = ai.getUnit();
    // PERCEPTION_STATUS_PLAYER status =
    // ai.getGroup().getPerceptionStatus();
    // after each action? some events may trigger it separately
    // any hostile action triggers Engagement with the group, even if they
    // don't see you
    // HEARING would be an important factor...
    // for (DC_HeroObj unit : getCreeps()) {
    List<Unit> relevantEnemies = getRelevantEnemies(unit);
    for (Unit hero : relevantEnemies) {
        if (VisionManager.checkVisible(hero)) {
            return true;
        }
    }
    return false;
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 95 with Unit

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

the class PatrolMaster method isArrived.

public static boolean isArrived(Patrol patrol, GroupAI group) {
    Coordinates destination = patrol.getDestination();
    Unit obj = group.getLeader();
    isBlocked(destination, obj);
    return false;
}
Also used : Coordinates(main.game.bf.Coordinates) 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