Package megamek.common

Examples of megamek.common.Entity


        for (EntityAction o : attacks) {
            if (o instanceof ArtilleryAttackAction) {
                newAttacks.addElement(o);
            } else if (o instanceof WeaponAttackAction) {
                WeaponAttackAction waa = (WeaponAttackAction) o;
                Entity attacker = waa.getEntity(client.game);
                Targetable target1 = waa.getTarget(client.game);
                boolean curInFrontArc = Compute.isInArc(attacker.getPosition(),
                        attacker.getSecondaryFacing(), target1.getPosition(),
                        Compute.ARC_FORWARD);
                if (curInFrontArc) {
                    WeaponAttackAction waa2 = new WeaponAttackAction(waa
                            .getEntityId(), waa.getTargetType(), waa
                            .getTargetId(), waa.getWeaponId());
                    waa2.setAimedLocation(waa.getAimedLocation());
                    waa2.setAimingMode(waa.getAimingMode());
                    waa2.setOtherAttackInfo(waa.getOtherAttackInfo());
                    waa2.setAmmoId(waa.getAmmoId());
                    waa2.setBombPayload(waa.getBombPayload());
                    newAttacks.addElement(waa2);
                }
            } else {
                newAttacks.addElement(o);
            }
        }
        // now add the attacks in rear/arm arcs
        for (EntityAction o : attacks) {
            if (o instanceof ArtilleryAttackAction) {
                // newAttacks.addElement(o);
                continue;
            } else if (o instanceof WeaponAttackAction) {
                WeaponAttackAction waa = (WeaponAttackAction) o;
                Entity attacker = waa.getEntity(client.game);
                Targetable target1 = waa.getTarget(client.game);
                boolean curInFrontArc = Compute.isInArc(attacker.getPosition(),
                        attacker.getSecondaryFacing(), target1.getPosition(),
                        Compute.ARC_FORWARD);
                if (!curInFrontArc) {
                    WeaponAttackAction waa2 = new WeaponAttackAction(waa
                            .getEntityId(), waa.getTargetType(), waa
                            .getTargetId(), waa.getWeaponId());
View Full Code Here


            return "Attacker is evading.";
        }

        if (target.getTargetType() == Targetable.TYPE_ENTITY) {
            // Checks specific to entity targets
            Entity te = (Entity) target;

            // Can't target a transported entity.
            if (Entity.NONE != te.getTransportId()) {
                return "Target is a passenger.";
            }

            // can't target yourself
            if (ae.equals(te)) {
                return "You can't target yourself";
            }

            // Can't target a entity conducting a swarm attack.
            if (Entity.NONE != te.getSwarmTargetId()) {
                return "Target is swarming a Mek.";
            }

            if ( (ae.getGrappled() != Entity.NONE) &&
                    (ae.getGrappleSide() == Entity.GRAPPLE_BOTH) ) {
                    return "Locked in Grapple";

            }

            // target unit in building checks
            final boolean targetInBuilding = Compute.isInBuilding(game, te);
            if (targetInBuilding) {
                Building TargBldg = game.getBoard().getBuildingAt(
                        te.getPosition());

                // Can't target units in buildings (from the outside).
                if (!Compute.isInBuilding(game, ae)) {
                    return "Target is inside building";
                } else if (!game.getBoard().getBuildingAt(ae.getPosition())
                        .equals(TargBldg)) {
                    return "Target is inside different building";
                }
            }

            // can't physically attack mechs making dfa attacks
            if (te.isMakingDfa()) {
                return "Target is making a DFA attack";
            }

        }
View Full Code Here

        toHit.append(nightModifiers(game, target, null, ae, false));

        if (target.getTargetType() == Targetable.TYPE_ENTITY) {
            // Checks specific to entity targets
            Entity te = (Entity) target;

            // target movement
            toHit.append(Compute.getTargetMovementModifier(game, targetId));

            // target prone
            if (te.isProne()) {
                toHit.addModifier(-2, "target prone and adjacent");
            }

            IHex targHex = game.getBoard().getHex(te.getPosition());
            // water partial cover?
            if ((te.height() > 0) && (te.getElevation() == -1)
                    && (targHex.terrainLevel(Terrains.WATER) == te.height())) {
                toHit.addModifier(1, "target has partial cover");
            }

            // Pilot skills
            Compute.modifyPhysicalBTHForAdvantages(ae, te, toHit, game);

            //Attacking Weight Class Modifier.
            if ( game.getOptions().booleanOption("tacops_attack_physical_psr") ) {
                if ( ae.getWeightClass() == EntityWeightClass.WEIGHT_LIGHT ) {
                    toHit.addModifier(-2, "Weight Class Attack Modifier");
                }else if ( ae.getWeightClass() == EntityWeightClass.WEIGHT_MEDIUM ) {
                    toHit.addModifier(-1, "Weight Class Attack Modifier");
                }
            }

            //evading bonuses (
            if(te.isEvading()) {
                toHit.addModifier(te.getEvasionBonus(), "target is evading");
            }
        }
        if ((ae instanceof Mech) && ((Mech)ae).hasIndustrialTSM()) {
            toHit.addModifier(2, "industrial TSM");
        }
View Full Code Here

        // Are we ignoring events?
        if (isIgnoringEvents()) {
            return;
        }

        Entity e = client.game.getEntity(b.getEntityId());
        if (client.isMyTurn()) {
            if (client.getMyTurn().isValidEntity(e, client.game)) {
                selectEntity(e.getId());
            }
        } else {
            clientgui.setDisplayVisible(true);
            clientgui.mechD.displayEntity(e);
            if (e.isDeployed()) {
                clientgui.bv.centerOnHex(e.getPosition());
            }
        }
    }
View Full Code Here

            update((Entity)i.nextElement(), null);
        }

        if (GUIPreferences.getInstance().getShowWrecks()) {
            for (Enumeration<Entity> e = game.getWreckedEntities(); e.hasMoreElements();) {
                Entity entity = e.nextElement();
                if (!(entity instanceof Infantry)) {
                    update(entity, null);
                }
            }
        }
View Full Code Here

        if (e.getPosition() == null)
            return;

        if (e.hasC3i()) {
            for (java.util.Enumeration<Entity> i = game.getEntities(); i.hasMoreElements();) {
                final Entity fe = i.nextElement();
                if (fe.getPosition() != null && e.onSameC3NetworkAs(fe) && !fe.equals(e) &&
                        !Compute.isAffectedByECM(e, e.getPosition(), fe.getPosition())) {
                    C3LinkModel m = new C3LinkModel(e, fe, game, pos);
                    if (!c3links.containsKey(m)) {
                        addChild(m);
                        c3links.put(m, m);
                    }
                }
            }
        } else if (e.getC3Master() != null) {
            Entity eMaster = e.getC3Master();
            if (eMaster.getPosition() == null) return;

            if (!Compute.isAffectedByECM(e, e.getPosition(), eMaster.getPosition())
                    && !Compute.isAffectedByECM(eMaster, eMaster.getPosition(), eMaster.getPosition())) {
                C3LinkModel m = new C3LinkModel(e, eMaster, game, pos);
                if (!c3links.containsKey(m)) {
                    addChild(m);
                    c3links.put(m, m);
                }
View Full Code Here

        KBKeyFrame[] keyframes3 = new KBKeyFrame[knots+1];

        int pos = 0;
        Point3f scale = new Point3f(1.0f, 1.0f, 1.0f);
        Point3f zero = new Point3f();
        final Entity prev = (Entity)getUserData();
        final int mpos = (prev.isProne()?1:knots);
        final float pitchA = (float)-pitch(prev), pitchB = (float)-pitch(entity);
        final Point3f scaleA = new Point3f(scale(prev)), scaleB = new Point3f(scale(entity));
        IHex hex = gboard.getHex(prev.getPosition());
        int dir = prev.getFacing();
        if (dir == -1) dir = 0;
        keyframes1[pos] = new KBKeyFrame(
            pos*1.0f/knots,
            0,
            new Point3f(location(hex, prev.getPosition(), prev.getElevation(), height(pos < mpos?prev:entity))),
            0.0f, 0.0f, (float)facing(dir),
            scale,
            -1.0f, -0.7f, 0.2f
        );
        keyframes2[pos] = new KBKeyFrame(
            pos*1.0f/knots, 0,
            new Point3f(labelLocation(hex, prev.getPosition(), prev.getElevation())),
            0.0f, 0.0f, 0.0f, scale, -1.0f, -0.7f, 0.2f
        );
        keyframes3[pos] = new KBKeyFrame(
            pos*1.0f/knots, 0,
            zero,
View Full Code Here

        IHex hex = game.getBoard().getHex(c);
        int level = 0;
        try {
            level = hex.getElevation();
            Entity e = game.getEntities(c).nextElement();
            level += e.getElevation();
        } catch (Exception e) {
        }

        Transform3D v2i = new Transform3D();
        getVworldToImagePlate(v2i);
View Full Code Here

        /**
         * Adds a weapon to this attack
         */
        public void addWeapon(WeaponAttackAction attack) {
            final Entity entity = game.getEntity(attack.getEntityId());
            final WeaponType wtype = (WeaponType) entity.getEquipment(
                    attack.getWeaponId()).getType();
            final String roll = attack.toHit(game).getValueAsString();
            final String table = attack.toHit(game).getTableDesc();
            weaponDescs
            .add(wtype.getName()
View Full Code Here

                int grapple = ((Mech) ce()).getGrappled();
                if (grapple != Entity.NONE) {
                    lastTarget = grapple;
                }
            }
            Entity t = client.game.getEntity(lastTarget);
            target(t);

            if (!ce().isOffBoard()) {
                clientgui.getBoardView().highlight(ce().getPosition());
            }
View Full Code Here

TOP

Related Classes of megamek.common.Entity

Copyright © 2018 www.massapicom. 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.