use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.
the class DC_AttackMaster method attack.
private Boolean attack(Attack attack, Ref ref, boolean free, boolean canCounter, Effect onHit, Effect onKill, boolean offhand, boolean counter) {
ENTRY_TYPE type = ENTRY_TYPE.ATTACK;
boolean extraAttack = true;
if (attack.getAction().isCounterMode()) {
type = ENTRY_TYPE.COUNTER_ATTACK;
} else if (attack.getAction().isInstantMode()) {
type = ENTRY_TYPE.INSTANT_ATTACK;
} else if (attack.getAction().isAttackOfOpportunityMode()) {
type = ENTRY_TYPE.ATTACK_OF_OPPORTUNITY;
} else {
extraAttack = false;
}
// LogEntryNode entry = game.getLogManager().newLogEntryNode(type,
// attack.getAttacker().getName(), attack.getAttackedUnit().getName(), attack.getAction());
Boolean result = null;
if (!extraAttack) {
Unit guard = (Unit) GuardRule.checkTargetChanged(attack.getAction());
if (guard != null) {
game.getLogManager().log(guard.getNameIfKnown() + " intercepts " + attack.toLogString());
ref.setTarget(guard.getId());
attack.setRef(ref);
attack.setAttacked(guard);
}
}
attack.setSneak(SneakRule.checkSneak(ref));
try {
main.system.auxiliary.log.LogMaster.log(1, attack.getAttacker() + " attacks " + attack.getAttacked() + " with " + attack.getAction());
result = attackNow(attack, ref, free, canCounter, onHit, onKill, offhand, counter);
boolean countered = false;
if (result == null) {
// first strike
main.system.auxiliary.log.LogMaster.log(1, "Counter attack with first strike against " + attack.getAction());
ActiveObj action = counterRule.tryCounter(attack, false);
if (action != null) {
AttackEffect effect = EffectMaster.getAttackEffect(action);
waitForAttackAnimation(effect.getAttack());
}
attackNow(attack, ref, free, false, onHit, onKill, offhand, counter);
countered = true;
result = true;
}
if ((!countered) || attack.getAttacker().hasDoubleCounter()) {
if (canCounter) {
if (!counter) {
counterRule.tryCounter(attack);
}
}
}
} catch (Exception e) {
result = false;
main.system.ExceptionMaster.printStackTrace(e);
} finally {
if (!extraAttack) {
game.getLogManager().doneLogEntryNode(ENTRY_TYPE.ACTION);
}
game.getLogManager().doneLogEntryNode(type);
}
return result;
}
use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.
the class EffectFinder method getAttackFromAction.
public static Attack getAttackFromAction(DC_ActiveObj t) {
List<Effect> eff = getEffectsOfClass(t, AttackEffect.class);
AttackEffect e = (AttackEffect) eff.get(0);
return e.getAttack();
}
use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.
the class FutureBuilder method getDamage.
public static int getDamage(DC_ActiveObj active, Obj targetObj, Effect e, Boolean min_max_normal) {
Integer damage;
Ref ref = active.getOwnerObj().getRef().getCopy();
ref.setTarget(targetObj.getId());
ref.setID(KEYS.ACTIVE, active.getId());
e.setRef(ref);
if (e instanceof DealDamageEffect) {
ref.setAmount(e.getFormula().getInt(ref));
if (((DealDamageEffect) e).getDamageType() != null) {
ref.setValue(KEYS.DAMAGE_TYPE, ((DealDamageEffect) e).getDamageType().toString());
}
damage = DamageCalculator.precalculateDamage(ref);
} else {
Attack attack = ((AttackEffect) e).initAttack();
// attack.setAttacked((DC_HeroObj) targetObj);
Map<String, Integer> _cache = getCache(min_max_normal);
damage = _cache.get(getCacheKey(active, targetObj));
if (damage == null) {
damage = DamageCalculator.precalculateDamage(attack, min_max_normal);
_cache.put(getCacheKey(active, targetObj), damage);
}
}
// active.toBase();
LogMaster.log(1, active.getName() + " on " + targetObj.getName() + " - damage precalculated: " + damage);
return damage;
}
use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.
the class AttackCondition method check.
@Override
public boolean check(Ref ref) {
AttackEffect attackEffect = null;
if (ref.getEffect() instanceof AttackEffect) {
attackEffect = (AttackEffect) ref.getEffect();
} else {
try {
attackEffect = (AttackEffect) EffectFinder.getEffectsOfClass(ref.getActive().getAbilities(), AttackEffect.class).get(0);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
if (attackEffect == null) {
return false;
}
boolean result = false;
if (counter != null) {
result = attackEffect.getAttack().isCounter();
if (!counter) {
result = !result;
}
}
return result;
}
Aggregations