Search in sources :

Example 6 with AnimPhase

use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.

the class ArmorMaster method getShieldDamageBlocked.

public int getShieldDamageBlocked(Integer damage, Unit attacked, Unit attacker, DC_ActiveObj action, DC_WeaponObj weapon, DAMAGE_TYPE damage_type) {
    if (checkCanShieldBlock(action, attacked)) {
        return 0;
    }
    DC_WeaponObj shield = (DC_WeaponObj) attacked.getRef().getObj(KEYS.OFFHAND);
    String message;
    boolean spell = action.isSpell();
    boolean zone = action.isZone();
    boolean offhand = action.isOffhand();
    Integer chance = getShieldBlockChance(shield, attacked, attacker, weapon, action, offhand, spell);
    if (!zone) {
        if (// will be average instead
        !simulation) {
            if (!RandomWizard.chance(chance)) {
                message = StringMaster.getMessagePrefix(true, attacked.getOwner().isMe()) + attacked.getName() + " fails to use " + shield.getName() + " to block " + action.getName() + StringMaster.wrapInParenthesis(chance + "%");
                action.getGame().getLogManager().log(LOG.GAME_INFO, message, ENTRY_TYPE.DAMAGE);
                return 0;
            }
        }
    }
    Integer blockValue = getShieldBlockValue(damage, shield, attacked, attacker, weapon, action, zone);
    blockValue = Math.min(blockValue, damage);
    if (!simulation) {
        action.getRef().setID(KEYS.BLOCK, shield.getId());
        int durabilityLost = reduceDurability(blockValue, shield, spell, damage_type, attacker.getActiveWeapon(offhand), damage);
        // attacked.getIntParam(PARAMS.SHIELD_MASTERY)) / 100;
        if (blockValue <= 0) {
            action.getGame().getLogManager().log(LOG.GAME_INFO, shield.getName() + " is ineffective against " + action.getName() + "!", ENTRY_TYPE.DAMAGE);
            return 0;
        }
        DC_SoundMaster.playBlockedSound(attacker, attacked, shield, weapon, blockValue, damage);
        // durabilityMod);
        if (CoreEngine.isPhaseAnimsOn()) {
            PhaseAnimation animation = action.getGame().getAnimationManager().getAnimation(Attack.getAnimationKey(action));
            animation.addPhase(new AnimPhase(PHASE_TYPE.REDUCTION_SHIELD, chance, blockValue, durabilityLost, damage, damage_type, shield));
        }
        message = attacked.getName() + " uses " + shield.getName() + " to block" + "" + " " + blockValue + " out of " + damage + " " + damage_type + " damage from " + // StringMaster.wrapInParenthesis
        (action.getName());
        action.getGame().getLogManager().log(LOG.GAME_INFO, message, ENTRY_TYPE.DAMAGE);
    }
    return blockValue;
}
Also used : AnimPhase(main.system.graphics.AnimPhase) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) PhaseAnimation(eidolons.system.graphics.PhaseAnimation)

Example 7 with AnimPhase

use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.

the class MicroEffect method cleanAnimation.

private void cleanAnimation() {
    if (!CoreEngine.isPhaseAnimsOn())
        return;
    AnimPhase lastPhase = getAnimation().getPhases().isEmpty() ? null : getAnimation().getPhases().get(getAnimation().getPhases().size() - 1);
    // getActiveObj().initAnimation();
    // setAnimation(getActiveObj().getAnimation());
    ANIM newAnim = getAnimation().cloneAndAdd();
    if (lastPhase != null) {
        try {
            // TODO clone phase?
            // if (lastPhase.getType() !=
            // getAnimation().getPhases().get(
            // getAnimation().getPhases().size() - 1).getType())
            newAnim.addPhase(lastPhase);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    newAnim.start();
// ListMaster.removeIndicesAllExcept(getAnimation().getPhases(),
// getAnimation().getPhases().size() - 1);
}
Also used : AnimPhase(main.system.graphics.AnimPhase) ANIM(main.system.graphics.ANIM)

Example 8 with AnimPhase

use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.

the class DeathMaster method unitDies.

public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
    if (_killed.isDead())
        return;
    String message = null;
    if (_killed == _killer) {
        // + _killed.getInfoString();
        message = _killed + " dies ";
    } else
        message = _killed + " killed by " + _killer + " with " + activeObj;
    SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
    _killed.setDead(true);
    BattleFieldObject killed = (BattleFieldObject) _killed;
    BattleFieldObject killer = (BattleFieldObject) _killer;
    Ref ref = Ref.getCopy(killed.getRef());
    ref.setSource(killer.getId());
    ref.setTarget(killed.getId());
    for (AbilityObj abil : killed.getPassives()) {
        abil.kill();
    }
    if (killed.getBuffs() != null) {
        for (Attachment attach : killed.getBuffs()) {
            if (!attach.isRetainAfterDeath()) {
                getState().getAttachmentsMap().get(killed).remove(attach);
                attach.remove();
            }
        }
    }
    if (!leaveCorpse) {
    // leave a *ghost*?
    // destroy items?
    } else {
        if (killed instanceof Unit) {
            try {
                getGame().getDroppedItemManager().dropDead((Unit) killed);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
        try {
            getGame().getGraveyardManager().unitDies(killed);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    // getGame().getBattleField().remove(killed); // TODO GRAVEYARD
    if (!quietly) {
        Ref REF = Ref.getCopy(killer.getRef());
        REF.setTarget(killed.getId());
        REF.setSource(killer.getId());
        if (activeObj != null)
            REF.setObj(KEYS.ACTIVE, activeObj);
        if (killed instanceof Unit) {
            getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
        }
        LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
        if (killer.getRef().getAnimationActive() != null) {
            ANIM animation = killer.getRef().getAnimationActive().getAnimation();
            if (animation != null) {
                animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
                node.setLinkedAnimation(animation);
            }
        }
        DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
        game.getLogManager().logDeath(killed, killer);
        getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
        game.getLogManager().doneLogEntryNode();
    } else {
        GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
    }
// refreshAll();
}
Also used : AbilityObj(main.ability.AbilityObj) Ref(main.entity.Ref) AnimPhase(main.system.graphics.AnimPhase) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) Attachment(main.entity.obj.Attachment) Unit(eidolons.entity.obj.unit.Unit) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 9 with AnimPhase

use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.

the class BfMouseListener method checkAnimationClick.

public boolean checkAnimationClick(MouseEvent e) {
    point = e.getPoint();
    DequeImpl<PhaseAnimation> animations = new DequeImpl<>(gridComp.getGame().getAnimationManager().getAnimations());
    animations.addAll(gridComp.getGame().getAnimationManager().getTempAnims());
    if (SwingUtilities.isRightMouseButton(e)) {
        for (PhaseAnimation anim : animations) {
            if (checkToggleTooltip(anim, e)) {
                return true;
            }
            if (anim.contains(e.getPoint())) {
                if (e.getClickCount() > 1) {
                    if (anim.isPaused()) {
                        anim.resume();
                    } else {
                        anim.pause();
                    }
                    return true;
                }
                AnimPhase phase = anim.getPhase();
                if (phase != null) {
                    if (anim.subPhaseClosed()) {
                        DC_SoundMaster.playStandardSound(STD_SOUNDS.BACK);
                        return true;
                    }
                }
            }
        }
    }
    for (PhaseAnimation anim : animations) {
        if (anim.getMouseMap() != null) {
            for (Rectangle rect : anim.getMouseMap().keySet()) {
                if (rect.contains(point)) {
                    MouseItem item = anim.getMouseMap().get(rect);
                    return itemClicked(item, anim);
                }
            }
        }
    }
    return false;
}
Also used : AnimPhase(main.system.graphics.AnimPhase) PhaseAnimation(eidolons.system.graphics.PhaseAnimation) MouseItem(eidolons.system.graphics.AnimationManager.MouseItem) DequeImpl(main.system.datatypes.DequeImpl)

Example 10 with AnimPhase

use of main.system.graphics.AnimPhase in project Eidolons by IDemiurge.

the class ArmorMaster method getArmorBlockDamage.

private int getArmorBlockDamage(boolean shield, boolean spell, boolean canCritOrBlock, boolean average, Integer damage, Unit attacked, Unit attacker, boolean offhand, DAMAGE_TYPE dmg_type, DC_ActiveObj action) {
    /*
         * if blocks, apply armor's resistance values too
		 */
    if (action == null) {
        return 0;
    }
    if (!offhand) {
        offhand = action.isOffhand();
    }
    DC_ArmorObj armorObj = attacked.getArmor();
    if (armorObj == null) {
        return 0;
    }
    if (dmg_type == null) {
        dmg_type = action.getDamageType();
    }
    if (simulation) {
        average = true;
        canCritOrBlock = true;
    }
    int blockedPercentage = getBlockPercentage(shield, spell, canCritOrBlock, average, armorObj, offhand, attacker, attacked, action);
    // action.getGame().getLogManager().newLogEntryNode(type, args)
    // TODO ??? damage =
    // getReducedDamageForArmorResistances(blockedPercentage, armorObj,
    // damage, dmg_type);
    int maxBlockValue = damage * blockedPercentage / 100;
    int blocked = Math.min(getArmorValue(armorObj, dmg_type), maxBlockValue);
    // blocked = MathMaster.applyMod(amount, mod);
    // blocked -= penetration;
    String name = "[No Weapon]";
    if (spell) {
        name = action.getName();
    } else if (attacker.getActiveWeapon(offhand) != null) {
        name = attacker.getActiveWeapon(offhand).getName();
    }
    if (!simulation) {
        action.getRef().setID(KEYS.BLOCK, armorObj.getId());
        String entry = armorObj.getName() + " takes " + blockedPercentage + "% of " + action.getName() + StringMaster.wrapInParenthesis(name) + " absorbing " + blocked + " " + dmg_type.getName() + " damage";
        if (blockedPercentage == 0 || blocked == 0) {
            entry = attacker.getNameIfKnown() + " penetrates " + armorObj.getName() + " with " + name + (action.getName().equals("Attack") ? "" : StringMaster.wrapInParenthesis(action.getName())) + "!";
        } else {
            DC_SoundMaster.playAttackImpactSound(attacker.getActiveWeapon(offhand), attacker, attacked, damage, blocked);
            int durabilityLost = reduceDurability(blocked, armorObj, spell, dmg_type, attacker.getActiveWeapon(offhand), damage);
            if (CoreEngine.isPhaseAnimsOn())
                if (!simulation) {
                    if (!shield) {
                        PhaseAnimation animation = action.getGame().getAnimationManager().getAnimation(Attack.getAnimationKey(action));
                        animation.addPhase(new AnimPhase(PHASE_TYPE.REDUCTION_ARMOR, blockedPercentage, blocked, durabilityLost, damage, dmg_type, armorObj));
                    }
                }
        }
        if (!simulation) {
            action.getGame().getLogManager().log(LOG.GAME_INFO, entry, ENTRY_TYPE.DAMAGE);
        }
    }
    return blocked;
}
Also used : AnimPhase(main.system.graphics.AnimPhase) PhaseAnimation(eidolons.system.graphics.PhaseAnimation) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj)

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