use of eidolons.ability.effects.oneshot.unit.RaiseEffect 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.RaiseEffect 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;
}
Aggregations