Examples of AmmoType


Examples of megamek.common.AmmoType

        // don't need to check for BAs, because BA can't mount ATMs
        if ((target instanceof Infantry) && !(target instanceof BattleArmor)) {
            return 1;
        }
        int hits;
        AmmoType atype = (AmmoType) ammo.getType();
        //TacOPs p.84 Cluster Hit Penalites will only effect ATM HE
        if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) {
            hits = super.calcHits(vPhaseReport);
        }else {
            hits = calcStandardAndExtendedAmmoHits(vPhaseReport);
        }
        // change to 5 damage clusters here, after AMS has been done
View Full Code Here

Examples of megamek.common.AmmoType

    @Override
    protected int calcAttackValue() {
        int distance = ae.getPosition().distance(target.getPosition());
        int av = 0;
        int range = RangeType.rangeBracket(distance, wtype.getATRanges(), true);
        AmmoType atype = (AmmoType) ammo.getType();
        if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) {
            if(range == WeaponType.RANGE_SHORT) {
                av = wtype.getRoundShortAV();
                av = av + av/2;
            }
        } else if (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE) {
            if(range == WeaponType.RANGE_SHORT) {
                av = wtype.getRoundShortAV();
            } else if(range == WeaponType.RANGE_MED) {
                av = wtype.getRoundMedAV();
            } else if (range == WeaponType.RANGE_LONG) {
View Full Code Here

Examples of megamek.common.AmmoType

        boolean bMekStealthActive = false;
        if (ae instanceof Mech) {
            bMekStealthActive = ae.isStealthActive();
        }
        Mounted mLinker = weapon.getLinkedBy();
        AmmoType atype = (AmmoType) ammo.getType();
        // is any hex in the flight path of the missile ECM affected?
        boolean bECMAffected = false;
        // if the attacker is affected by ECM or the target is protected by ECM
        // then
        // act as if effected.
        if (Compute.isAffectedByECM(ae, ae.getPosition(), target.getPosition())) {
            bECMAffected = true;
        }

        if (((mLinker != null) && (mLinker.getType() instanceof MiscType)
                && !mLinker.isDestroyed() && !mLinker.isMissing()
                && !mLinker.isBreached() && mLinker.getType().hasFlag(
                MiscType.F_ARTEMIS))
                && (atype.getMunitionType() == AmmoType.M_ARTEMIS_CAPABLE)) {
            if (bECMAffected) {
                // ECM prevents bonus
                r = new Report(3330);
                r.subject = subjectId;
                r.newlines = 0;
                vPhaseReport.addElement(r);
            } else if (bMekStealthActive) {
                // stealth prevents bonus
                r = new Report(3335);
                r.subject = subjectId;
                r.newlines = 0;
                vPhaseReport.addElement(r);
            } else {
                nMissilesModifier += 2;
            }
        } else if (atype.getAmmoType() == AmmoType.T_ATM) {
            if (bECMAffected) {
                // ECM prevents bonus
                r = new Report(3330);
                r.subject = subjectId;
                r.newlines = 0;
                vPhaseReport.addElement(r);
            } else if (bMekStealthActive) {
                // stealth prevents bonus
                r = new Report(3335);
                r.subject = subjectId;
                r.newlines = 0;
                vPhaseReport.addElement(r);
            } else {
                nMissilesModifier += 2;
            }
        } else if ((entityTarget != null)
                && (entityTarget.isNarcedBy(ae.getOwner().getTeam()) || entityTarget
                        .isINarcedBy(ae.getOwner().getTeam()))) {
            // only apply Narc bonus if we're not suffering ECM effect
            // and we are using narc ammo, and we're not firing indirectly.
            // narc capable missiles are only affected if the narc pod, which
            // sits on the target, is ECM affected
            boolean bTargetECMAffected = false;
            bTargetECMAffected = Compute.isAffectedByECM(ae,
                    target.getPosition(), target.getPosition());
            if (((atype.getAmmoType() == AmmoType.T_LRM) ||
                 (atype.getAmmoType() == AmmoType.T_SRM)) ||
                 ((atype.getAmmoType() == AmmoType.T_MML)
                    && (atype.getMunitionType() == AmmoType.M_NARC_CAPABLE)
                    && ((weapon.curMode() == null) || !weapon.curMode().equals(
                            "Indirect")))) {
                if (bTargetECMAffected) {
                    // ECM prevents bonus
                    r = new Report(3330);
View Full Code Here

Examples of megamek.common.AmmoType

     *      megamek.common.actions.WeaponAttackAction, megamek.common.Game,
     *      megamek.server.Server)
     */
    protected AttackHandler getCorrectHandler(ToHitData toHit,
            WeaponAttackAction waa, IGame game, Server server) {
        AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId())
                .getEquipment(waa.getWeaponId()).getLinked().getType();
        if (atype.hasFlag(AmmoType.F_MML_LRM)) {
            if (atype.getMunitionType() == AmmoType.M_FRAGMENTATION) {
                return new LRMFragHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_ANTI_TSM) {
                return new LRMAntiTSMHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_THUNDER
                    || atype.getMunitionType() == AmmoType.M_THUNDER_ACTIVE
                    || atype.getMunitionType() == AmmoType.M_THUNDER_AUGMENTED
                    || atype.getMunitionType() == AmmoType.M_THUNDER_INFERNO
                    || atype.getMunitionType() == AmmoType.M_THUNDER_VIBRABOMB) {
                return new LRMScatterableHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_SWARM) {
                return new LRMSwarmHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_SWARM_I) {
                return new LRMSwarmIHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_DEAD_FIRE) {
                return new LRMDeadFireHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_FOLLOW_THE_LEADER) {
                return new LRMFollowTheLeaderHandler(toHit, waa, game, server);
            }

            return new LRMHandler(toHit, waa, game, server);

        } else {
            if (atype.getMunitionType() == AmmoType.M_FRAGMENTATION) {
                return new SRMFragHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_AX_HEAD) {
                return new SRMAXHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_ANTI_TSM) {
                return new SRMAntiTSMHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_INFERNO) {
                return new SRMInfernoHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_DEAD_FIRE) {
                return new SRMDeadFireHandler(toHit, waa, game, server);
            }
            if (atype.getMunitionType() == AmmoType.M_TANDEM_CHARGE) {
                return new SRMTandemChargeHandler(toHit, waa, game, server);
            }

            return new SRMHandler(toHit, waa, game, server);

View Full Code Here

Examples of megamek.common.AmmoType

     *      megamek.common.Entity, boolean)
     */
    protected boolean specialResolution(Vector<Report> vPhaseReport,
            Entity entityTarget, boolean bMissed) {
        Coords coords = target.getPosition();
        AmmoType atype = (AmmoType) ammo.getType();
        //only report to player if mine delivery
        int whoReport = Report.PLAYER;
        if(atype.getMunitionType() == AmmoType.M_FLARE) {
            whoReport = Report.PUBLIC;
        }   
        if (!bMissed) {
            r = new Report(3190, whoReport);
            r.subject = subjectId;
            r.add(coords.getBoardNum());
            vPhaseReport.addElement(r);
        } else {
            // according to http://www.classicbattletech.com/forums/index.php/topic,41188.0.html
            // scatterable LRMs scatter like dive bombing
            coords = Compute.scatterDiveBombs(coords);
            if (game.getBoard().contains(coords)) {
                // misses and scatters to another hex
                r = new Report(3195, whoReport);
                r.subject = subjectId;
                r.add(coords.getBoardNum());
                vPhaseReport.addElement(r);
            } else {
                // misses and scatters off-board
                r = new Report(3200);
                r.subject = subjectId;
                vPhaseReport.addElement(r);
                return !bMissed;
            }
        }

        // Handle the thunder munitions.
        if (atype.getMunitionType() == AmmoType.M_THUNDER_AUGMENTED) {
            server.deliverThunderAugMinefield(coords, ae.getOwner().getId(),
                    atype.getRackSize(), ae.getId());
        } else if (atype.getMunitionType() == AmmoType.M_THUNDER) {
            server.deliverThunderMinefield(coords, ae.getOwner().getId(), atype
                    .getRackSize(), ae.getId());
        } else if (atype.getMunitionType() == AmmoType.M_THUNDER_INFERNO) {
            server.deliverThunderInfernoMinefield(coords,
                    ae.getOwner().getId(), atype.getRackSize(), ae.getId());
        } else if (atype.getMunitionType() == AmmoType.M_THUNDER_VIBRABOMB) {
            server.deliverThunderVibraMinefield(coords, ae.getOwner().getId(),
                    atype.getRackSize(), waa.getOtherAttackInfo(), ae.getId());
        } else if (atype.getMunitionType() == AmmoType.M_THUNDER_ACTIVE) {
            server.deliverThunderActiveMinefield(coords, ae.getOwner().getId(),
                    atype.getRackSize(), ae.getId());
        }
        return true;
    }
View Full Code Here

Examples of megamek.common.AmmoType

     * megamek.common.actions.WeaponAttackAction, megamek.common.IGame,
     * megamek.server.Server)
     */
    @Override
    protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) {
        AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()).getEquipment(waa.getWeaponId()).getLinked().getType();
        Mounted weapon = game.getEntity(waa.getEntityId()).getEquipment(waa.getWeaponId());
        if (weapon.curMode().equals("Rapid")) {
            return new RapidfireACWeaponHandler(toHit, waa, game, server);
        }
        if (atype.getMunitionType() == AmmoType.M_ARMOR_PIERCING) {
            return new ACAPHandler(toHit, waa, game, server);
        }

        if (atype.getMunitionType() == AmmoType.M_FLECHETTE) {
            return new ACFlechetteHandler(toHit, waa, game, server);
        }

        if (atype.getMunitionType() == AmmoType.M_INCENDIARY_AC) {
            return new ACIncendiaryHandler(toHit, waa, game, server);
        }

        if (atype.getMunitionType() == AmmoType.M_TRACER) {
            return new ACTracerHandler(toHit, waa, game, server);
        }

        if (atype.getMunitionType() == AmmoType.M_FLAK) {
            return new ACFlakHandler(toHit, waa, game, server);
        }

        return new ACWeaponHandler(toHit, waa, game, server);

View Full Code Here

Examples of megamek.common.AmmoType

     * @see megamek.common.weapons.Weapon#getCorrectHandler(megamek.common.ToHitData,
     *      megamek.common.actions.WeaponAttackAction, megamek.common.IGame)
     */
    protected AttackHandler getCorrectHandler(ToHitData toHit,
            WeaponAttackAction waa, IGame game, Server server) {
        AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId())
        .getEquipment(waa.getWeaponId()).getLinked().getType();
        if(atype.hasFlag(AmmoType.F_TELE_MISSILE))
            return new BarracudaTHandler(toHit, waa, game, server);
        else
            return new BarracudaHandler(toHit, waa, game, server);
    }
View Full Code Here

Examples of megamek.common.AmmoType

        if(ae == null) {
            System.err.println("Artillery Entity is null!");
            return true;
        }
        Mounted ammo = ae.getEquipment(aaa.getAmmoId());
        final AmmoType atype = ammo == null ? null : (AmmoType) ammo.getType();
        // Are there any valid spotters?
        if ((null != spottersBefore) && !isFlak) {
            // fetch possible spotters now
            Enumeration<Entity> spottersAfter = game
                    .getSelectedEntities(new EntitySelector() {
                        public int player = playerId;

                        public Targetable targ = target;

                        public boolean accept(Entity entity) {
                            Integer id = new Integer(entity.getId());
                            if ((player == entity.getOwnerId())
                                    && spottersBefore.contains(id)
                                    && !(LosEffects.calculateLos(game, entity
                                            .getId(), targ)).isBlocked()
                                    && entity.isActive()
                                    && !entity.isINarcedWith(INarcPod.HAYWIRE)) {
                                return true;
                            }
                            return false;
                        }
                    });

            // Out of any valid spotters, pick the best.
            while (spottersAfter.hasMoreElements()) {
                Entity ent = spottersAfter.nextElement();
                if ((bestSpotter == null)
                        || (ent.crew.getGunnery() < bestSpotter.crew
                                .getGunnery())) {
                    bestSpotter = ent;
                }
            }

        } // End have-valid-spotters

        // If at least one valid spotter, then get the benefits thereof.
        if (null != bestSpotter) {
            int mod = (bestSpotter.crew.getGunnery() - 4) / 2;
            toHit.addModifier(mod, "Spotting modifier");
        }

        // Is the attacker still alive and we're not shooting FLAK?
        // then adjust the target
        Entity artyAttacker = aaa.getEntity(game);
        if ((null != artyAttacker) && !isFlak) {

            // Get the arty weapon.
            Mounted weapon = artyAttacker.getEquipment(aaa.getWeaponId());

            // If the shot hit the target hex, then all subsequent
            // fire will hit the hex automatically.
            if (roll >= toHit.getValue()) {
                artyAttacker.aTracker.setModifier(weapon,
                        TargetRoll.AUTOMATIC_SUCCESS, targetPos);

                game.getBoard().addSpecialHexDisplay(targetPos,
                        new SpecialHexDisplay(
                                SpecialHexDisplay.Type.ARTILLERY_AUTOHIT,
                                game.getRoundCount(),
                                game.getPlayer(aaa.getPlayerId()).getName(),
                                "Artilery AutoHit. Better text later.",
                                false
                        )
                 );
            }
            // If the shot missed, but was adjusted by a
            // spotter, future shots are more likely to hit.
            else if (null != bestSpotter) {
                artyAttacker.aTracker.setModifier(weapon, artyAttacker.aTracker
                        .getModifier(weapon, targetPos) - 1, targetPos);

                game.getBoard().addSpecialHexDisplay(targetPos,
                        new SpecialHexDisplay(
                            SpecialHexDisplay.Type.ARTILLERY_ADJUSTED,
                            game.getRoundCount(),
                            game.getPlayer(aaa.getPlayerId()).getName(),
                            "Artilery toHit Adjusted. Better text later.",
                            false
                        )
                );
            }

        } // End artyAttacker-alive

        // Report weapon attack and its to-hit value.
        r = new Report(3120);
        r.indent();
        r.newlines = 0;
        r.subject = subjectId;
        if (wtype != null) {
            r.add(wtype.getName());
        } else {
            r.add("Error: From Nowhwere");
        }

        r.add(target.getDisplayName(), true);
        vPhaseReport.addElement(r);
        if (toHit.getValue() == TargetRoll.IMPOSSIBLE) {
            r = new Report(3135);
            r.subject = subjectId;
            r.add(toHit.getDesc());
            vPhaseReport.addElement(r);
            return false;
        } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) {
            r = new Report(3140);
            r.newlines = 0;
            r.subject = subjectId;
            r.add(toHit.getDesc());
            vPhaseReport.addElement(r);
        } else if (toHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) {
            r = new Report(3145);
            r.newlines = 0;
            r.subject = subjectId;
            r.add(toHit.getDesc());
            vPhaseReport.addElement(r);
        } else {
            // roll to hit
            r = new Report(3150);
            r.newlines = 0;
            r.subject = subjectId;
            r.add(toHit.getValue());
            vPhaseReport.addElement(r);
        }

        // dice have been rolled, thanks
        r = new Report(3155);
        r.newlines = 0;
        r.subject = subjectId;
        r.add(roll);
        vPhaseReport.addElement(r);

        if (!isFlak) {
            game.getBoard().addSpecialHexDisplay(
                    targetPos,
                    new SpecialHexDisplay(SpecialHexDisplay.Type.ARTILLERY_TARGET,
                            game.getRoundCount(),
                            game.getPlayer(aaa.getPlayerId()).getName(),
                            "Artilery Target. Better text later.",
                            false
                    )
            );
        }

        // do we hit?
        bMissed = roll < toHit.getValue();
        // Set Margin of Success/Failure.
        toHit.setMoS(roll-Math.max(2,toHit.getValue()));

        // Do this stuff first, because some weapon's miss report reference the
        // amount of shots fired and stuff.
        if (!handledAmmoAndReport) {
            addHeat();
        }
        Coords coords = target.getPosition();
        if (!bMissed) {
            if (!isFlak) {
                r = new Report(3190);
            } else {
                r = new Report(3191);
            }
            r.subject = subjectId;
            r.add(coords.getBoardNum());
            vPhaseReport.addElement(r);

            game.getBoard().addSpecialHexDisplay(targetPos,
                    new SpecialHexDisplay(SpecialHexDisplay.Type.ARTILLERY_HIT,
                            game.getRoundCount(),
                            "Artilery Hit. Better text later."));

        } else {
            // direct fire artillery only scatters by one d6
            // we do this here to avoid duplicating handle()
            // in the ArtilleryWeaponDirectFireHandler
            if (phase == IGame.Phase.PHASE_FIRING) {
                coords = Compute.scatterDirectArty(coords);
            } else {
                coords = Compute.scatter(coords, Math.abs(toHit.getMoS()));
            }
            if (game.getBoard().contains(coords)) {
                // misses and scatters to another hex
                if (!isFlak) {
                    r = new Report(3195);
                    game.getBoard().addSpecialHexDisplay(
                        coords,
                        new SpecialHexDisplay(
                                SpecialHexDisplay.Type.ARTILLERY_HIT,
                                game.getRoundCount(),
                                "Artilery Scatered Here. Better text later."
                        )
                    );
                } else {
                    r = new Report(3192);
                }
                r.subject = subjectId;
                r.add(coords.getBoardNum());
                vPhaseReport.addElement(r);
            } else {
                // misses and scatters off-board
                if (isFlak) {
                    r = new Report(3193);
                } else {
                    r = new Report(3200);
                }
                r.subject = subjectId;
                vPhaseReport.addElement(r);
                return !bMissed;
            }
        }

        if (atype.getMunitionType() == AmmoType.M_FLARE) {
            int radius;
            if (atype.getAmmoType() == AmmoType.T_ARROW_IV) {
                radius = 4;
            } else if (atype.getAmmoType() == AmmoType.T_LONG_TOM) {
                radius = 3;
            } else if (atype.getAmmoType() == AmmoType.T_SNIPER) {
                radius = 2;
            } else {
                radius = 1;
            }
            server.deliverArtilleryFlare(coords, radius);
            return false;
        }
        if (atype.getMunitionType() == AmmoType.M_DAVY_CROCKETT_M) {
            // The appropriate term here is "Bwahahahahaha..."
            server.doNuclearExplosion(coords, 1, vPhaseReport);
            return false;
        }
        if (atype.getMunitionType() == AmmoType.M_FASCAM) {
            server.deliverFASCAMMinefield(coords, ae.getOwner().getId(), atype.getRackSize(), ae.getId());
            return false;
        }
        if (atype.getMunitionType() == AmmoType.M_INFERNO_IV) {
            server.deliverArtilleryInferno(coords, artyAttacker, subjectId, vPhaseReport);
            return false;
        }
        if (atype.getMunitionType() == AmmoType.M_VIBRABOMB_IV) {
            server.deliverThunderVibraMinefield(coords, ae.getOwner().getId(),
                    atype.getRackSize(), waa.getOtherAttackInfo(), ae.getId());
            return false;
        }
        if (atype.getMunitionType() == AmmoType.M_SMOKE) {
            server.deliverArtillerySmoke(coords, vPhaseReport);
            return false;
        }
        int altitude = 0;
        if (isFlak) {
View Full Code Here

Examples of megamek.common.AmmoType

    protected void handleEntityDamage(Entity entityTarget,
            Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster,
            int nDamPerHit, int bldgAbsorbs) {
        HitData hit = entityTarget.rollHitLocation(toHit.getHitTable(), toHit
                .getSideTable(), waa.getAimedLocation(), waa.getAimingMode());
        AmmoType atype = (AmmoType) ammo.getType();
        if (atype.getAmmoType() == AmmoType.T_NARC) {
            // narced
            NarcPod pod = new NarcPod(ae.getOwner().getTeam(), hit
                    .getLocation());
            r = new Report(3250);
            r.subject = subjectId;
            r.add(entityTarget.getDisplayName());
            r.add(entityTarget.getLocationAbbr(hit));
            vPhaseReport.addElement(r);
            entityTarget.attachNarcPod(pod);
        } else if (atype.getAmmoType() == AmmoType.T_INARC) {
            // iNarced
            INarcPod pod = null;
            if (atype.getMunitionType() == AmmoType.M_ECM) {
                pod = new INarcPod(ae.getOwner().getTeam(), INarcPod.ECM, hit
                        .getLocation());
                r = new Report(3251);
                r.subject = subjectId;
                r.add(entityTarget.getDisplayName());
                r.add(entityTarget.getLocationAbbr(hit));
                vPhaseReport.addElement(r);
            } else if (atype.getMunitionType() == AmmoType.M_HAYWIRE) {
                pod = new INarcPod(ae.getOwner().getTeam(), INarcPod.HAYWIRE,
                        hit.getLocation());
                r = new Report(3252);
                r.subject = subjectId;
                r.add(entityTarget.getDisplayName());
                r.add(entityTarget.getLocationAbbr(hit));
                vPhaseReport.addElement(r);
            } else if (atype.getMunitionType() == AmmoType.M_NEMESIS) {
                pod = new INarcPod(ae.getOwner().getTeam(), INarcPod.NEMESIS,
                        hit.getLocation());
                r = new Report(3253);
                r.add(entityTarget.getDisplayName());
                r.add(entityTarget.getLocationAbbr(hit));
View Full Code Here

Examples of megamek.common.AmmoType

     * @see megamek.common.weapons.Weapon#getCorrectHandler(megamek.common.ToHitData,
     *      megamek.common.actions.WeaponAttackAction, megamek.common.IGame)
     */
    protected AttackHandler getCorrectHandler(ToHitData toHit,
            WeaponAttackAction waa, IGame game, Server server) {
        AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()).getEquipment(waa.getWeaponId()).getLinked().getType();
        if (atype.hasFlag(AmmoType.F_NUCLEAR)) {
            return new SantaAnnaHandler(toHit, waa, game, server);
        }
        if (atype.hasFlag(AmmoType.F_TELE_MISSILE)) {
            return new TeleMissileHandler(toHit, waa, game, server);
        }
        return new KillerWhaleHandler(toHit, waa, game, server);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.