Search in sources :

Example 16 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ChangeRefEffect method applyThis.

@Override
public boolean applyThis() {
    // so I need the active to have ref with the ammo as AMMO, not weapon?
    Ref REF = this.ref;
    if (keyWhoseRefToModify != null) {
        REF = REF.getObj(keyWhoseRefToModify).getRef();
    } else {
    // for (KEYS key :
    // add_remove ? autoCheckedKeysAdd : autoCheckedKeysRemove)
    // {
    // if (REF.getObj(key)!=null )
    // if (REF.getObj(key).getRef().getId(this.keyToAddOrRemoveForRef) != null) {
    // REF = ref.getObj(key).getRef();
    // break;
    // }
    // }
    }
    Integer id = REF.getId(keyToAddOrRemoveForRef);
    if (id == null) {
        if (ref.getActive() instanceof DC_ActiveObj) {
            DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
            if (activeObj.getParentAction() != null) {
                id = activeObj.getParentAction().getRef().getId(keyToAddOrRemoveForRef);
            }
        }
    }
    if (add_remove) {
        REF.getTargetObj().getRef().setID(keyToAddOrRemoveForRef, id);
    } else {
        REF.removeValue(keyToAddOrRemoveForRef);
    }
    return true;
}
Also used : Ref(main.entity.Ref) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 17 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class CastNewSpellEffect method applyThis.

// TODO spellpower/mastery mods!!!
@Override
public boolean applyThis() {
    ObjType type = DataManager.getType(spelltype, DC_TYPE.SPELLS);
    Ref REF = new Ref(ref.getGame(), ref.getSource());
    Obj obj = game.createSpell(type, ref.getSourceObj().getOwner(), REF);
    DC_SpellObj spell = (DC_SpellObj) obj;
    spell.setFree(free);
    spell.setQuietMode(true);
    if (group) {
        REF.setGroup(ref.getGroup());
        return spell.activatedOn(REF);
    }
    if (chooseTarget) {
        spell.getTargeting().select(REF);
    } else {
        REF.setTarget(ref.getId(target_key));
    }
    return spell.activatedOn(REF);
}
Also used : Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj)

Example 18 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ForcedActionEffect method applyThis.

@Override
public boolean applyThis() {
    Unit unit = (Unit) ref.getTargetObj();
    Ref REF = unit.getRef();
    if (key != null) {
        REF.setTarget(ref.getId(key));
    }
    Action action = new Action(unit.getAction(actionName), REF);
    unit.getGame().getAiManager().getAI(unit).getForcedActions().add(action);
    return true;
}
Also used : Ref(main.entity.Ref) Action(eidolons.game.battlecraft.ai.elements.actions.Action) Unit(eidolons.entity.obj.unit.Unit)

Example 19 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ModifyCounterEffect method applyThis.

@Override
public boolean applyThis() {
    Ref REF = Ref.getCopy(ref);
    Integer amount = formula.getInt(ref);
    // MODIFY_BY_CONST Counter: {ACTIVE_PARAMS.BLEEDING_MOD}/100*(20-({TARGET_C_TOUGHNESS}*100/{TARGET_TOUGHNESS})*10/100)
    if (getResistanceMod() != null) {
        amount = MathMaster.applyMod(amount, getResistanceMod());
    }
    int mod = 0;
    if (ref.getTargetObj() instanceof DC_HeroItemObj) {
        try {
            mod = ref.getSourceObj().getIntParam(DC_ContentManager.getCoatingAppliedModParam(CounterMaster.findCounterConst(counterName)));
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    Integer modValue = MathMaster.addFactor(amount, mod);
    REF.setAmount(modValue);
    REF.setValue(KEYS.STRING, counterName);
    new Event(STANDARD_EVENT_TYPE.COUNTER_BEING_MODIFIED, REF).fire();
    boolean result = false;
    switch(modtype) {
        case MODIFY_BY_CONST:
            result = ref.getTargetObj().modifyCounter(counterName, modValue);
            break;
        case MODIFY_BY_PERCENT:
            result = ref.getTargetObj().modifyCounter(counterName, modValue);
            break;
        case SET:
            result = ref.getTargetObj().setCounter(counterName, modValue);
            break;
        default:
            break;
    }
    if (CoreEngine.isPhaseAnimsOn())
        if (result) {
            try {
                getAnimation().addPhaseArgs(PHASE_TYPE.COUNTER, counterName, modtype, modValue);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        } else {
            return false;
        }
    REF.setAmount(ref.getTargetObj().getCounter(counterName));
    return new Event(STANDARD_EVENT_TYPE.COUNTER_MODIFIED, REF).fire();
}
Also used : Ref(main.entity.Ref) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) Event(main.game.logic.event.Event)

Example 20 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class GuardRule method checkTargetChanged.

public static BattleFieldObject checkTargetChanged(DC_ActiveObj action) {
    BattleFieldObject target = (BattleFieldObject) action.getTargetObj();
    // attack.getAttackedUnit();
    List<Unit> guards = new ArrayList<>();
    Collection<Unit> units = target.getGame().getUnitsForCoordinates(target.getCoordinates());
    for (Unit unit : units) {
        if (unit.isAlliedTo(target.getOwner())) {
            if (unit.getMode() == STD_MODES.GUARDING || unit.checkStatus(STATUS.GUARDING)) {
                Ref ref = Ref.getCopy(action.getRef());
                ref.setTarget(target.getId());
                if (!SneakRule.checkSneak(ref))
                    guards.add(unit);
            }
        }
    }
    // TODO sort
    for (Unit guard : guards) {
        if (guard == target)
            continue;
        if (action.isAttackAny()) {
            if (action.isRanged()) {
                if (checkDefenderTakesMissile(action, guard))
                    return guard;
                continue;
            }
            Attack attack = EffectFinder.getAttackFromAction(action);
            if (checkDefenderTakesAttack(attack, guard))
                return guard;
        } else {
            if (checkDefenderTakesMissile(action, guard))
                return guard;
        }
    }
    // what kind of animation would there be?
    return null;
}
Also used : Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5