Search in sources :

Example 1 with AnimPhase

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;
}
Also used : AnimPhase(main.system.graphics.AnimPhase) Unit(eidolons.entity.obj.unit.Unit)

Example 2 with AnimPhase

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;
}
Also used : EffectAnimation(eidolons.system.graphics.EffectAnimation) AnimPhase(main.system.graphics.AnimPhase) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 3 with AnimPhase

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));
}
Also used : AnimPhase(main.system.graphics.AnimPhase)

Example 4 with AnimPhase

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;
}
Also used : AnimPhase(main.system.graphics.AnimPhase) PHASE_TYPE(main.system.graphics.AnimPhase.PHASE_TYPE)

Example 5 with AnimPhase

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);
}
Also used : AnimPhase(main.system.graphics.AnimPhase) Damage(eidolons.game.battlecraft.rules.combat.damage.Damage)

Aggregations

AnimPhase (main.system.graphics.AnimPhase)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3 Unit (eidolons.entity.obj.unit.Unit)3 PhaseAnimation (eidolons.system.graphics.PhaseAnimation)3 ANIM (main.system.graphics.ANIM)3 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)2 Damage (eidolons.game.battlecraft.rules.combat.damage.Damage)2 EffectAnimation (eidolons.system.graphics.EffectAnimation)2 Ref (main.entity.Ref)2 Event (main.game.logic.event.Event)2 LogEntryNode (main.system.text.LogEntryNode)2 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 MouseItem (eidolons.system.graphics.AnimationManager.MouseItem)1 AbilityObj (main.ability.AbilityObj)1 DAMAGE_TYPE (main.content.enums.GenericEnums.DAMAGE_TYPE)1 Attachment (main.entity.obj.Attachment)1 DequeImpl (main.system.datatypes.DequeImpl)1 PHASE_TYPE (main.system.graphics.AnimPhase.PHASE_TYPE)1