use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.
the class ParryRule method tryParry.
protected boolean tryParry(Attack attack) {
// absorbed!
if (!RuleMaster.isRuleTestOn(RULE.PARRYING)) {
if (!canParry(attack)) {
return false;
}
}
int attackValue = DefenseVsAttackRule.getAttackValue(attack);
int defenseValue = DefenseVsAttackRule.getDefenseValue(attack);
float chance = DefenseVsAttackRule.getProportionBasedChance(attackValue, defenseValue, false);
chance += attack.getAttackedUnit().getIntParam(PARAMS.PARRY_CHANCE);
chance += -attack.getAttacker().getIntParam(PARAMS.PARRY_PENETRATION);
Integer chanceRounded = Math.round(chance);
// if (!simulation)
if (attack.getAction().getGame().getCombatMaster().isChancesOff()) {
if (chanceRounded < 50)
chanceRounded = 0;
else
chanceRounded = 100;
}
game.getLogManager().newLogEntryNode(ENTRY_TYPE.PARRY, attack.getAttackedUnit().getName(), attack.getAction().getName(), attack.getAttacker().getName(), chanceRounded.toString());
if (!RandomWizard.chance(chanceRounded)) {
game.getLogManager().log(attack.getAttackedUnit().getName() + " fails to parry " + attack.getAction().getName() + " from " + attack.getAttacker().getNameIfKnown() + StringMaster.wrapInParenthesis(chanceRounded + "%"));
game.getLogManager().doneLogEntryNode();
if (!RuleMaster.isRuleTestOn(RULE.PARRYING)) {
return false;
}
}
Unit attacked = (Unit) attack.getAttackedUnit();
Unit attacker = attack.getAttacker();
boolean dual = false;
if (attacked.checkDualWielding()) {
dual = true;
}
int damage = // raw damage
attack.getPrecalculatedDamageAmount();
// attack.getDamage();
game.getLogManager().log(attack.getAttackedUnit().getName() + " parries " + attack.getAction().getName() + " from " + attack.getAttacker().getNameIfKnown() + StringMaster.wrapInParenthesis(chanceRounded + "%") + ", deflecting " + damage + " " + attack.getDamageType() + " damage");
int mod = DC_Formulas.DEFAULT_PARRY_DURABILITY_DAMAGE_MOD;
if (dual) {
mod /= 2;
}
AnimPhase animPhase = new AnimPhase(PHASE_TYPE.PARRY, chanceRounded);
int durabilityLost = attacked.getWeapon(false).reduceDurabilityForDamage(damage, damage, mod, false);
animPhase.addArg(durabilityLost);
if (dual) {
durabilityLost += attacked.getWeapon(true).reduceDurabilityForDamage(damage, damage, mod, false);
animPhase.addArg(durabilityLost);
}
// if (BROKEN)
// return false
mod = DC_Formulas.DEFAULT_PARRY_DURABILITY_DAMAGE_MOD;
durabilityLost = durabilityLost * mod / 100;
attacker.getActiveWeapon(attack.isOffhand()).reduceDurability(durabilityLost);
animPhase.addArg(durabilityLost);
attack.getAnimation().addPhase(animPhase);
// game.getLogManager().doneLogEntryNode(); ???
return true;
}
use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.
the class DC_BuffRule method playAnimation.
protected void playAnimation(Ref ref) {
DC_ActiveObj action = (DC_ActiveObj) ref.getObj(KEYS.ACTIVE);
if (action == null) {
action = target.getDummyAction();
}
EffectAnimation anim = new EffectAnimation(action);
anim.addPhase(new AnimPhase(PHASE_TYPE.BUFF, ref.getObj(KEYS.BUFF)));
getGame().getAnimationManager().newAnimation(anim);
animationQueued = false;
}
use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.
the class AttackCalculator method addSubPhase.
public void addSubPhase() {
if (anim == null) {
anim = attack.getAnimation();
}
anim.addPhase(new AnimPhase(PHASE_TYPE.ATTACK_EXTRA_MODS, extraMap));
anim.addPhase(new AnimPhase(PHASE_TYPE.DICE_ROLL, dieList, randomMap));
anim.addPhase(new AnimPhase(PHASE_TYPE.ATTACK_WEAPON_MODS, weaponMap));
anim.addPhase(new AnimPhase(PHASE_TYPE.ATTACK_ACTION_MODS, actionMap));
anim.addPhase(new AnimPhase(PHASE_TYPE.ATTACK_POSITION_MODS, posMap));
anim.addPhase(new AnimPhase(PHASE_TYPE.ATTACK_DEFENSE, atkModMap, atkMap, defModMap));
}
use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.
the class AnimationManager method cloneWithPhases.
public PhaseAnimation cloneWithPhases(PhaseAnimation anim, PHASE_TYPE... phaseTypes) {
PhaseAnimation newAnim = (PhaseAnimation) anim.clone();
List<PHASE_TYPE> phaseList = new ArrayList<>(Arrays.asList(phaseTypes));
for (AnimPhase phase : anim.getPhases()) {
if (phaseList.contains(phase.getType())) {
newAnim.addPhase(new AnimPhase(phase.getType(), phase.getArgs()));
}
}
return newAnim;
}
use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.
the class PhaseAnimator method initAttackAnimRawDamage.
public void initAttackAnimRawDamage(Attack attack) {
List<Damage> rawDamage = DamageCalculator.precalculateRawDamageForDisplay(attack);
attack.setRawDamage(rawDamage);
attack.getAnimation().addPhase(new AnimPhase(PHASE_TYPE.PRE_ATTACK, attack, rawDamage), 0);
}
Aggregations