use of eidolons.ability.effects.oneshot.unit.SummonEffect in project Eidolons by IDemiurge.
the class AI_SpellMaster method getSummonedUnit.
public static ObjType getSummonedUnit(DC_ActiveObj active, Ref ref) {
ObjType type;
List<Effect> list = EffectFinder.getEffectsOfClass(active.getAbilities(), GatewayEffect.class);
if (!list.isEmpty()) {
GatewayEffect effect = (GatewayEffect) list.get(0);
return DataManager.getType(effect.getUnitType(), C_OBJ_TYPE.BF_OBJ);
}
SummonEffect effect = null;
try {
effect = (SummonEffect) EffectFinder.getEffectsOfClass(active.getAbilities(), SummonEffect.class).get(0);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (effect instanceof RaiseEffect) {
RaiseEffect raiseEffect = (RaiseEffect) effect;
effect.setRef(ref);
return DataManager.getType(raiseEffect.getUnitType(), C_OBJ_TYPE.BF_OBJ);
}
if (effect != null) {
type = DataManager.getType(effect.getTypeName(), C_OBJ_TYPE.BF_OBJ);
return type;
}
if (effect instanceof RaiseEffect) {
RaiseEffect raiseEffect = (RaiseEffect) effect;
return DataManager.getType(raiseEffect.getUnitType(), C_OBJ_TYPE.BF_OBJ);
}
if (effect instanceof RaiseEffect) {
RaiseEffect raiseEffect = (RaiseEffect) effect;
return DataManager.getType(raiseEffect.getUnitType(), C_OBJ_TYPE.BF_OBJ);
}
return null;
}
use of eidolons.ability.effects.oneshot.unit.SummonEffect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getSummonPriority.
@Override
public int getSummonPriority(Action action) {
// TODO precalculate summoned unit power, its initiative, its
// positioning...
ObjType summoned = AI_SpellMaster.getSummonedUnit(action.getActive(), action.getRef());
Integer unitXp = 0;
if (summoned == null) {
return 0;
}
try {
SummonEffect summonEffect = (SummonEffect) EffectFinder.getEffectsOfClass(action.getActive().getAbilities(), SummonEffect.class).get(0);
unitXp = summonEffect.getSummonedUnitXp().getInt(action.getRef());
if (summonEffect instanceof RaiseEffect) {
RaiseEffect raiseEffect = (RaiseEffect) summonEffect;
unitXp += raiseEffect.getCorpse().getIntParam(PARAMS.TOTAL_XP) / 5;
// TODO for items!
Obj weapon = raiseEffect.getCorpse().getRef().getObj(KEYS.WEAPON);
if (weapon != null) {
unitXp += weapon.getIntParam(PARAMS.GOLD_COST) / 5;
}
Obj armor = raiseEffect.getCorpse().getRef().getObj(KEYS.ARMOR);
if (armor != null) {
unitXp += armor.getIntParam(PARAMS.GOLD_COST) / 5;
}
Obj weapon2 = raiseEffect.getCorpse().getRef().getObj(KEYS.OFFHAND);
if (weapon2 != null) {
unitXp += weapon2.getIntParam(PARAMS.GOLD_COST) / 5;
}
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
int power = summoned.getIntParam(PARAMS.POWER) + unitXp / DC_Formulas.POWER_XP_FACTOR;
setBasePriority(power);
if (summoned.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
}
// getUnitPriority(targetObj)
// try to getOrCreate as close to enemies as possible...
Coordinates coordinate = action.getRef().getTargetObj().getCoordinates();
boolean prefer_melee = UnitAnalyzer.isMeleePreferred(summoned);
if (prefer_melee) {
prefer_melee = UnitAnalyzer.isOffensePreferred(summoned);
}
// TODO special for forcefield - add consts per enemy path blocked
for (Entity entity : !prefer_melee ? Analyzer.getAllies(getUnitAi()) : Analyzer.getAdjacentEnemies(getUnit(), false)) {
// getOrCreate distance?
if (entity instanceof Obj) {
Obj obj = (Obj) entity;
int distance = Math.max(1, PositionMaster.getDistance(coordinate, obj.getCoordinates()));
// if (prefer_melee)
addMultiplier(getUnitPriority(obj) / distance, obj.getName() + "'s proximity");
}
}
// create unit quietly? precalc its best moves?
applyMultiplier(getConstInt(AiConst.SUMMON_PRIORITY_MOD), "SUMMON_PRIORITY_MOD");
// AI_SUMMON_PRIORITY_MOD!
return priority;
}
use of eidolons.ability.effects.oneshot.unit.SummonEffect in project Eidolons by IDemiurge.
the class DebugMaster method summon.
private void summon(Boolean me, DC_TYPE units, Ref ref) {
Player player = Player.NEUTRAL;
if (me != null) {
player = game.getPlayer(me);
if (!me) {
if (ALT_AI_PLAYER) {
if (altAiPlayer == null) {
altAiPlayer = new DC_Player("", null, false);
}
player = altAiPlayer;
}
}
}
/*
* alt mode: >> random >> preset >> last
*/
ref.setPlayer(player);
String typeName;
if (arg instanceof Unit) {
Obj obj = arg;
typeName = (obj.getType().getName());
}
if (altMode) {
typeName = lastType;
// RandomWizard.getRandomType(units).getName();
} else {
typeName = ListChooser.chooseType(units);
}
if (!DataManager.isTypeName(typeName)) {
typeName = DialogMaster.inputText("Then enter it yourself...");
}
if (typeName == null) {
return;
}
if (!DataManager.isTypeName(typeName)) {
ObjType foundType = DataManager.findType(typeName, units);
if (foundType == null) {
return;
}
typeName = foundType.getName();
}
if (arg instanceof Obj) {
Obj obj = arg;
ref.setTarget(game.getCellByCoordinate(obj.getCoordinates()).getId());
} else if (!new SelectiveTargeting(new Conditions(ConditionMaster.getTYPECondition(DC_TYPE.TERRAIN))).select(ref)) {
return;
}
lastType = typeName;
SummonEffect effect = (me == null) ? new CreateObjectEffect(typeName, true) : new SummonEffect(typeName);
if (units == DC_TYPE.UNITS) {
if (checkAddXp()) {
Formula xp = new Formula("" + (DC_Formulas.getTotalXpForLevel(DataManager.getType(typeName, DC_TYPE.UNITS).getIntParam(PARAMS.LEVEL) + DialogMaster.inputInt()) - DC_Formulas.getTotalXpForLevel(DataManager.getType(typeName, DC_TYPE.UNITS).getIntParam(PARAMS.LEVEL))));
effect = new SummonEffect(typeName, xp);
}
}
effect.setOwner(player);
effect.apply(ref);
if (player.isAi()) {
game.getAiManager().getCustomUnitGroup((Unit) effect.getUnit()).add(effect.getUnit());
}
game.getManager().refreshAll();
}
Aggregations