Search in sources :

Example 11 with DC_QuickItemObj

use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.

the class ArmorMaster method getBlockPercentage.

// % to block for shield; max % of attack's damage blocked for armor
private int getBlockPercentage(boolean shield, boolean spell, boolean canCritOrBlock, boolean average, DC_Obj armorObj, boolean offhand, Unit attacker, Unit attacked, DC_ActiveObj action) {
    if (!average)
        average = action.getGame().getCombatMaster().isDiceAverage();
    if (canCritOrBlock)
        canCritOrBlock = !action.getGame().getCombatMaster().isChancesOff();
    int covered = armorObj.getIntParam(PARAMS.COVER_PERCENTAGE);
    int uncovered = 100 - covered;
    DC_WeaponObj weapon = attacker.getActiveWeapon(offhand);
    Integer area = action.getIntParam(PARAMS.IMPACT_AREA);
    if (action.isRanged() && !action.isThrow()) {
        if (weapon.isRanged()) {
            try {
                DC_QuickItemObj ammo = (DC_QuickItemObj) weapon.getRef().getObj(KEYS.AMMO);
                if (ammo == null) // ammo = attacker.getAmmo(weapon); TODO
                {
                    ammo = attacker.getQuickItems().get(0);
                }
                weapon = ammo.getWrappedWeapon();
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
                area = 15;
            }
        }
    }
    if (!spell) {
        if (area == 0) {
            area = weapon.getIntParam(PARAMS.IMPACT_AREA);
        }
    }
    int maximum = covered;
    int minimum = area - uncovered;
    if (minimum < 0) {
        minimum = 0;
    }
    if (!canCritOrBlock) {
        if (simulation || average) {
            return MathMaster.getAverage(minimum, maximum);
        }
        return RandomWizard.getRandomIntBetween(minimum, maximum);
    }
    // sneak?
    int attack = DefenseVsAttackRule.getAttackValue(offhand, attacker, attacked, action);
    int defense = DefenseVsAttackRule.getDefenseValue(attacker, attacked, action);
    // sneakCondition.preCheck(attacker);
    boolean sneak = false;
    // boolean watched_attacker=false;// watchCondition.preCheck(attacker)
    // boolean watched_target=false;// watchCondition.preCheck(attacked)
    int def_coef = 100;
    int atk_coef = 100;
    if (sneak) {
        def_coef = 25;
    }
    if (shield) {
        defense = 10 + 2 * attacked.getIntParam(PARAMS.SHIELD_MASTERY);
    } else {
        def_coef += attacked.getIntParam(PARAMS.ARMORER_MASTERY);
        defense += attacked.getIntParam(PARAMS.ARMORER_MASTERY);
    }
    // TODO action must already have those params from attacker!
    if (!spell) {
        atk_coef = atk_coef * action.getIntParam(PARAMS.ARMOR_MOD) / 100;
        atk_coef += action.getIntParam(PARAMS.ARMOR_PENETRATION);
    }
    // else accuracy/resist penetr
    int blockPercBonus = (def_coef * defense - atk_coef * attack) / 100;
    if (shield) {
        return Math.max(0, MathMaster.addFactor((maximum + minimum) / 2, blockPercBonus));
    }
    // TODO OR MAKE REFLEX ROLL TO DOUBLE BLOCK CHANCE?
    if (simulation || average) {
        return (minimum + maximum) / 2;
    }
    boolean crit_or_block = RandomWizard.chance(Math.abs(blockPercBonus));
    if (crit_or_block) {
        if (blockPercBonus > 0) {
            return maximum;
        }
        return minimum;
    }
    int percentageBlocked = RandomWizard.getRandomIntBetween(minimum, maximum);
    return percentageBlocked;
}
Also used : DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj)

Example 12 with DC_QuickItemObj

use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.

the class ActionSequenceConstructor method getRangedReloadAction.

// now replaced with Atomic logic?
private List<AiQuickItemAction> getRangedReloadAction(Action action) {
    Obj weapon = action.getActive().getRef().getObj(KEYS.RANGED);
    WEAPON_GROUP weapon_group = null;
    List<AiQuickItemAction> list = new ArrayList<>();
    if (weapon instanceof DC_WeaponObj) {
        DC_WeaponObj dc_WeaponObj = (DC_WeaponObj) weapon;
        if (dc_WeaponObj.getWeaponGroup() == ItemEnums.WEAPON_GROUP.BOWS) {
            weapon_group = ItemEnums.WEAPON_GROUP.ARROWS;
        }
        if (dc_WeaponObj.getWeaponGroup() == ItemEnums.WEAPON_GROUP.CROSSBOWS) {
            weapon_group = ItemEnums.WEAPON_GROUP.BOLTS;
        }
        for (DC_QuickItemObj ammo : action.getSource().getQuickItems()) {
            if (!ammo.isAmmo()) {
                continue;
            }
            ammo.construct();
            if (ammo.getWrappedWeapon().getWeaponGroup() == weapon_group) {
                AiQuickItemAction qia = new AiQuickItemAction(ammo);
                if (qia.canBeActivated()) {
                    list.add(qia);
                }
            }
        }
    }
    return list;
}
Also used : AiQuickItemAction(eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) WEAPON_GROUP(main.content.enums.entity.ItemEnums.WEAPON_GROUP) ArrayList(java.util.ArrayList) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj)

Example 13 with DC_QuickItemObj

use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.

the class AtomicAi method getReloadAction.

private Action getReloadAction(UnitAI ai) {
    DC_QuickItemObj ammo = null;
    Integer maxCost = 0;
    for (DC_QuickItemObj a : ai.getUnit().getQuickItems()) {
        if (a.isAmmo()) {
            Integer cost = a.getWrappedWeapon().getIntParam(PARAMS.GOLD_COST);
            if (cost > maxCost) {
                ammo = a;
            }
        }
    }
    if (ammo != null) {
        return AiActionFactory.newAction(ammo.getActive(), new Ref(ai.getUnit()));
    }
    return null;
}
Also used : Ref(main.entity.Ref) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj)

Example 14 with DC_QuickItemObj

use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.

the class DC_HeroManager method removeQuickSlotItem.

@Override
public void removeQuickSlotItem(Unit hero, Entity type) {
    DC_QuickItemObj item = null;
    if (type instanceof DC_QuickItemObj) {
        item = (DC_QuickItemObj) type;
    }
    for (DC_QuickItemObj itemObj : hero.getQuickItems()) {
        if (itemObj.getType() == type) {
            item = itemObj;
            break;
        }
    }
    hero.removeQuickItem(item);
    hero.addItemToInventory(item);
    // if (hero.getQuickItems().isEmpty())
    // hero.setQuickItems(null); //in DC_HeroObj for now
    update(hero);
}
Also used : DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj)

Example 15 with DC_QuickItemObj

use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.

the class DC_HeroManager method setHeroItem.

@Override
public int setHeroItem(Unit hero, ITEM_SLOT slot, Entity type) {
    int result = 0;
    if (slot == ItemEnums.ITEM_SLOT.ARMOR) {
        if (!hero.checkBool(GenericEnums.STD_BOOLS.ARMOR_CHANGE)) {
            return 0;
        }
        result++;
    }
    DC_HeroItemObj slotItem = null;
    DC_QuickItemObj quick = null;
    if (type instanceof DC_QuickItemObj) {
        quick = ((DC_QuickItemObj) type);
        slotItem = quick.getWrappedWeapon();
    }
    if (type instanceof DC_HeroItemObj) {
        slotItem = (DC_HeroItemObj) type;
    } else {
        for (DC_HeroItemObj item : hero.getInventory()) {
            if (item.getType() == type) {
                slotItem = item;
                break;
            }
        }
    // item
    }
    hero.setItem(slotItem, slot);
    if (quick != null) {
        hero.removeQuickItem(quick);
    } else {
        hero.removeFromInventory(slotItem);
    }
    result++;
    if (result > 0) {
        update(hero);
    }
    return result;
}
Also used : DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj)

Aggregations

DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)17 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)6 Ref (main.entity.Ref)4 Unit (eidolons.entity.obj.unit.Unit)3 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 Obj (main.entity.obj.Obj)2 CanActCondition (eidolons.ability.conditions.special.CanActCondition)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 DC_JewelryObj (eidolons.entity.item.DC_JewelryObj)1 AiQuickItemAction (eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction)1 ActionValueContainer (eidolons.libgdx.gui.panels.dc.actionpanel.ActionValueContainer)1 ActionCostTooltip (eidolons.libgdx.gui.panels.dc.actionpanel.tooltips.ActionCostTooltip)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Effects (main.ability.effects.Effects)1 ITEM_SLOT (main.content.enums.entity.ItemEnums.ITEM_SLOT)1 WEAPON_GROUP (main.content.enums.entity.ItemEnums.WEAPON_GROUP)1