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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations