Search in sources :

Example 1 with SummonEffect

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

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

Example 3 with SummonEffect

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();
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) SummonEffect(eidolons.ability.effects.oneshot.unit.SummonEffect) CreateObjectEffect(eidolons.ability.effects.oneshot.unit.CreateObjectEffect) Formula(main.system.math.Formula) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Player(main.game.logic.battle.player.Player) ObjType(main.entity.type.ObjType) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) ActiveObj(main.entity.obj.ActiveObj) Obj(main.entity.obj.Obj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) Unit(eidolons.entity.obj.unit.Unit) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Conditions(main.elements.conditions.Conditions)

Aggregations

SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)3 ObjType (main.entity.type.ObjType)3 CreateObjectEffect (eidolons.ability.effects.oneshot.unit.CreateObjectEffect)2 RaiseEffect (eidolons.ability.effects.oneshot.unit.RaiseEffect)2 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 Obj (main.entity.obj.Obj)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 GatewayEffect (eidolons.ability.effects.oneshot.unit.GatewayEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)1