Search in sources :

Example 1 with RaiseEffect

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;
}
Also used : SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) ObjType(main.entity.type.ObjType) GatewayEffect(eidolons.ability.effects.oneshot.unit.GatewayEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) WaveEffect(eidolons.ability.effects.containers.customtarget.WaveEffect) DrainEffect(eidolons.ability.effects.oneshot.mechanic.DrainEffect) GatewayEffect(eidolons.ability.effects.oneshot.unit.GatewayEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) ShapeEffect(eidolons.ability.effects.containers.customtarget.ShapeEffect) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) BehaviorModeEffect(eidolons.ability.effects.continuous.BehaviorModeEffect) MoveEffect(eidolons.ability.effects.oneshot.move.MoveEffect) SpecialTargetingEffect(main.ability.effects.container.SpecialTargetingEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) OwnershipChangeEffect(main.ability.effects.common.OwnershipChangeEffect) CreateObjectEffect(eidolons.ability.effects.oneshot.unit.CreateObjectEffect) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) InstantDeathEffect(main.ability.effects.oneshot.InstantDeathEffect) ModifyCounterEffect(eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)

Example 2 with RaiseEffect

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;
}
Also used : SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) Entity(main.entity.Entity) RaiseEffect(eidolons.ability.effects.oneshot.unit.RaiseEffect) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_HeroAttachedObj(eidolons.entity.obj.attach.DC_HeroAttachedObj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates)

Aggregations

RaiseEffect (eidolons.ability.effects.oneshot.unit.RaiseEffect)2 SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)2 ObjType (main.entity.type.ObjType)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ShapeEffect (eidolons.ability.effects.containers.customtarget.ShapeEffect)1 WaveEffect (eidolons.ability.effects.containers.customtarget.WaveEffect)1 BehaviorModeEffect (eidolons.ability.effects.continuous.BehaviorModeEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 DrainEffect (eidolons.ability.effects.oneshot.mechanic.DrainEffect)1 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)1 MoveEffect (eidolons.ability.effects.oneshot.move.MoveEffect)1 CreateObjectEffect (eidolons.ability.effects.oneshot.unit.CreateObjectEffect)1 GatewayEffect (eidolons.ability.effects.oneshot.unit.GatewayEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 DC_HeroAttachedObj (eidolons.entity.obj.attach.DC_HeroAttachedObj)1 Effect (main.ability.effects.Effect)1