Search in sources :

Example 16 with DC_WeaponObj

use of eidolons.entity.item.DC_WeaponObj 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 17 with DC_WeaponObj

use of eidolons.entity.item.DC_WeaponObj 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 18 with DC_WeaponObj

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

the class AutoTestMaster method initSimulation.

private void initSimulation(AutoTest test) {
    int x = game.getDungeon().getCellsX() / 2;
    int y = game.getDungeon().getCellsY() / 2;
    String arg = test.getArg(TEST_ARGS.SOURCE);
    source = DC_Game.game.createUnit(DataManager.getType(arg, DC_TYPE.CHARS), x, y, game.getPlayer(true), new Ref(game));
    y--;
    arg = test.getArg(TEST_ARGS.TARGET);
    target = DC_Game.game.createUnit(DataManager.getType(arg, DC_TYPE.CHARS), x, y, game.getPlayer(true), new Ref(game));
    arg = test.getArg(TEST_ARGS.WEAPON);
    ObjType weaponType = DataManager.getType(arg, DC_TYPE.WEAPONS);
    if (weaponType != null) {
        getSource().setWeapon(new DC_WeaponObj(weaponType, getSource()));
        AbilityConstructor.constructActives(source);
    }
    test.setEntity(initEntity(test.getTestType()));
    // graphicsOn = test.isGraphicsOn();
    Ref ref = new Ref(getSource());
    ref.setTarget(getTestTarget().getId());
    test.setRef(ref);
}
Also used : Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj)

Example 19 with DC_WeaponObj

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

the class WeaponSkillTest method createEntity.

@Before
public void createEntity() {
    // ObjType type = DataManager.getType(typeName, DC_TYPE.UNITS);
    // entity = (Unit) game.getManager().getObjCreator().createUnit(type, 0, 0, game.getPlayer(true), new Ref(game));
    skill = new DC_FeatObj(DataManager.getType(skillName, DC_TYPE.SKILLS), entity.getRef());
    dagger = new DC_WeaponObj(DataManager.getType(itemName, DC_TYPE.WEAPONS), entity);
}
Also used : DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) Before(org.junit.Before)

Example 20 with DC_WeaponObj

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

the class ItemGenerator method createItem.

public DC_HeroItemObj createItem(ObjType type, Ref ref, boolean addMaterialParams) {
    // if (addMaterialParams)//if building from blueprint type
    // type = generateItem_(quality, material, type, params, mod_params);
    MicroGame game = (MicroGame) ref.getGame();
    DC_HeroItemObj item = (type.getOBJ_TYPE_ENUM() == DC_TYPE.WEAPONS) ? new DC_WeaponObj(type, ref.getPlayer(), game, ref) : new DC_ArmorObj(type, ref.getPlayer(), game, ref);
    return item;
}
Also used : DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) MicroGame(main.game.core.game.MicroGame) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj)

Aggregations

DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)22 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)7 Unit (eidolons.entity.obj.unit.Unit)3 ArrayList (java.util.ArrayList)3 PARAMS (eidolons.content.PARAMS)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)2 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)2 Ref (main.entity.Ref)2 Obj (main.entity.obj.Obj)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)1 UNIT_INFO_PARAMS (eidolons.content.UNIT_INFO_PARAMS)1 ValuePages (eidolons.content.ValuePages)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)1 DC_FeatObj (eidolons.entity.obj.attach.DC_FeatObj)1