use of eidolons.entity.item.DC_WeaponObj in project Eidolons by IDemiurge.
the class UnitCalculator method calculateDamage.
@Deprecated
public Integer calculateDamage(boolean offhand, boolean set) {
int dmg = DamageCalculator.getUnitAttackDamage(getEntity(), offhand);
Integer mod;
mod = getIntParam((offhand) ? PARAMS.OFFHAND_DAMAGE_MOD : PARAMS.DAMAGE_MOD);
if (mod != 0) {
dmg = dmg * mod / 100;
}
PARAMS minDamage = (offhand) ? PARAMS.OFF_HAND_MIN_DAMAGE : PARAMS.MIN_DAMAGE;
if (set) {
setParam(minDamage, dmg);
}
PARAMS damage = (offhand) ? PARAMS.OFF_HAND_DAMAGE : PARAMS.DAMAGE;
DC_WeaponObj weapon = getEntity().getWeapon(offhand);
if (weapon == null) {
weapon = getEntity().getNaturalWeapon(offhand);
}
Integer dieSize = (weapon == null) ? getIntParam(PARAMS.DIE_SIZE) : weapon.getIntParam(PARAMS.DIE_SIZE);
if (mod != 0) {
dieSize = dieSize * mod / 100;
}
if (set) {
setParam(damage, MathMaster.getAverage(dmg, dmg + dieSize));
}
PARAMS maxDamage = (offhand) ? PARAMS.OFF_HAND_MAX_DAMAGE : PARAMS.MAX_DAMAGE;
if (set) {
setParam(maxDamage, dmg + dieSize);
}
if (isDiceAccountedElsewhere()) {
// TODO review this
Integer min = getIntParam(minDamage);
setParameter(damage, min);
setParameter(maxDamage, min);
return min;
}
return MathMaster.getAverage(dmg, dmg + dieSize);
}
use of eidolons.entity.item.DC_WeaponObj in project Eidolons by IDemiurge.
the class ThrowEffect method applyThis.
@Override
public boolean applyThis() {
if (stormOfMissiles) {
fromHand = true;
DC_WeaponObj weapon = (DC_WeaponObj) ref.getObj(KEYS.WEAPON);
boolean result = throwWeapon(weapon);
weapon = (DC_WeaponObj) ref.getObj(KEYS.OFFHAND);
if (weapon != null) {
offhand = true;
result = throwWeapon(weapon);
}
Unit hero = (Unit) ref.getObj(KEYS.SOURCE);
fromHand = false;
for (DC_QuickItemObj q : hero.getQuickItems()) {
weapon = q.getWrappedWeapon();
if (weapon != null) {
result &= throwWeapon(weapon);
}
}
return result;
}
DC_WeaponObj weapon = (DC_WeaponObj) ref.getObj(KEYS.WEAPON);
try {
if (offhand || ref.getObj(KEYS.ACTIVE).checkProperty(G_PROPS.ACTION_TAGS, "" + ActionEnums.ACTION_TAGS.OFF_HAND)) {
weapon = (DC_WeaponObj) ref.getObj(KEYS.OFFHAND);
offhand = true;
}
// offhand mods?
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
return throwWeapon(weapon);
}
use of eidolons.entity.item.DC_WeaponObj in project Eidolons by IDemiurge.
the class ParryRule method canParry.
// precalculateRawDamageForDisplay
private boolean canParry(Attack attack) {
// if (!RuleMaster.isParryOn())return false;
Unit attackedUnit = (Unit) attack.getAttackedUnit();
if (attackedUnit == null)
return false;
if (attackedUnit.getIntParam(PARAMS.PARRY_CHANCE) <= 0) {
return false;
}
if (attack.isSneak()) {
return false;
}
if (attack.isCritical()) {
return false;
}
if (attack.isRanged()) {
return false;
}
if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.NATURAL) {
return false;
}
if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.BLUNT) {
return false;
}
// if (attack.getWeapon().getWeaponSize() == WEAPON_SIZE.TINY)
// {
// TODO
DC_WeaponObj parryWeapon = attackedUnit.getActiveWeapon(false);
if (Math.abs(DC_ContentManager.compareSize(parryWeapon.getWeaponSize(), attack.getWeapon().getWeaponSize())) > 2) {
if (attackedUnit.checkDualWielding()) {
} else {
return false;
}
}
// }
return true;
}
use of eidolons.entity.item.DC_WeaponObj in project Eidolons by IDemiurge.
the class CadenceRule method checkDualAttackCadence.
public static void checkDualAttackCadence(DC_UnitAction action, Unit unit) {
if (action.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
return;
}
boolean singleCadence = checkSingleWeaponCadence(unit, action);
if (!UnitAnalyzer.checkDualWielding(unit) && !UnitAnalyzer.checkDualNaturalWeapons(unit) && !singleCadence) // || checkSingleCadence(action)
{
return;
}
Boolean offhand = null;
if (action.checkProperty(PROP, MAIN_HAND)) {
offhand = false;
} else if (action.checkProperty(PROP, OFF_HAND)) {
offhand = true;
} else if (singleCadence) // offhand = !action.isOffhand();
{
offhand = false;
}
if (offhand == null) {
return;
}
Ref ref = new Ref(unit.getGame(), unit.getId());
DC_WeaponObj weapon = unit.getActiveWeapon(offhand);
List<Obj> targets = new ArrayList<>();
if (unit.getWeapon(!offhand) != null) {
targets.add(unit.getWeapon(!offhand));
}
if (unit.getNaturalWeapon(!offhand) != null) {
targets.add(unit.getNaturalWeapon(!offhand));
}
GroupImpl group = new GroupImpl(targets);
LogMaster.log(LogMaster.RULES_DEBUG, "Cadence Rule applies to " + group);
ref.setGroup(group);
if (checkFocusBonusApplies(unit, action, singleCadence)) {
Integer amount = action.getOwnerObj().getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
amount += action.getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
amount += action.getOwnerObj().getActiveWeapon(!offhand).getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
action.getOwnerObj().modifyParameter(PARAMS.C_FOCUS, amount, 100);
}
// INIT COST CADENCE EFFECTS
Effects effects = new Effects();
String cadence = unit.getParam(PARAMS.CADENCE_AP_MOD);
if (cadence.isEmpty()) {
cadence = DC_Formulas.DEFAULT_CADENCE_AP_MOD + "";
}
ModifyValueEffect valueEffect = new ModifyValueEffect(PARAMS.ATTACK_AP_PENALTY, MOD.MODIFY_BY_CONST, cadence);
valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
effects.add(valueEffect);
cadence = unit.getParam(PARAMS.CADENCE_STA_MOD);
if (cadence.isEmpty()) {
cadence = DC_Formulas.DEFAULT_CADENCE_STA_MOD + "";
}
valueEffect = new ModifyValueEffect(PARAMS.ATTACK_STA_PENALTY, MOD.MODIFY_BY_CONST, cadence);
valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
effects.add(valueEffect);
if (unit.getIntParam(PARAMS.CADENCE_DAMAGE_MOD) > 0) {
effects.add(new ModifyValueEffect(PARAMS.DAMAGE_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_DAMAGE_MOD)));
}
if (unit.getIntParam(PARAMS.CADENCE_ATTACK_MOD) > 0) {
effects.add(new ModifyValueEffect(PARAMS.ATTACK_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_ATTACK_MOD)));
}
String buffTypeName = (!offhand) ? buffTypeNameOffHand : buffTypeNameMainHand;
// ADD REMOVE TRIGGER
int percentage = 100 - unit.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - action.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - weapon.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE);
Conditions conditions = new Conditions(new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE));
if (percentage != 100) {
conditions.add(new ChanceCondition(new Formula("" + percentage)));
}
effects.add(new AddTriggerEffect(STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, conditions, new ActiveAbility(new FixedTargeting(KEYS.BASIS), new RemoveBuffEffect(buffTypeName))));
// effect = new AddBuffEffect(buffTypeName, effects, DURATION);
// Condition condition = new StringComparison(StringMaster.getValueRef(KEYS.MATCH, PROP),
// (offhand) ? MAIN_HAND : OFF_HAND, false);
// retain condition - hero hasBuff()
// add remove trigger on attack? either off/main hand, so there is no
// stacking...
// linked buffs?
// effect.setIrresistible(false);
AddBuffEffect addBuffEffect = new AddBuffEffect(buffTypeName, // new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ACTIONS, condition),
effects, DURATION);
// preCheck perk
addBuffEffect.addEffect(new // what about
AddTriggerEffect(// counters/AoO?
STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE), new ActiveAbility(new FixedTargeting(KEYS.SOURCE), new RemoveBuffEffect(buffTypeName))));
Integer param = unit.getIntParam(PARAMS.CADENCE_DEFENSE_MOD);
if (param != 0) {
addBuffEffect.addEffect(new ModifyValueEffect(PARAMS.DEFENSE_MOD, MOD.MODIFY_BY_CONST, "" + param));
}
addBuffEffect.setIrresistible(true);
addBuffEffect.apply(ref);
// TODO defense mod effect
}
use of eidolons.entity.item.DC_WeaponObj in project Eidolons by IDemiurge.
the class DC_SoundMaster method playParrySound.
public static void playParrySound(Unit attacked, DC_WeaponObj attackWeapon) {
// TODO double weapon sound
setPositionFor(attacked.getCoordinates());
DC_WeaponObj parryWeapon = attacked.getActiveWeapon(true);
getPlayer().playRandomSoundFromFolder("soundsets\\" + "weapon\\" + attackWeapon.getWeaponGroup() + "\\");
getPlayer().playRandomSoundVariant("soundsets\\" + "weapon\\" + "parry\\" + parryWeapon.getDamageType(), false);
}
Aggregations