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