artyAttacker.aTracker.setModifier ( weapon, artyAttacker.aTracker.getModifier ( weapon, targetPos ) - 1, targetPos );
int curmod = artyAttacker.aTracker.getModifier( weapon, targetPos ); if(curmod != ToHitData.AUTOMATIC_SUCCESS) { artyAttacker.aTracker.setModifier ( weapon, curmod - 1, targetPos ); }
    private void resolveIndirectArtilleryAttacks()  {        Vector results = new Vector(game.getArtillerySize());        Vector attacks = new Vector(game.getArtillerySize());        // loop thru received attack actions, getting weapon results        for (Enumeration i = game.getArtilleryAttacks(); i.hasMoreElements();) {            ArtilleryAttackAction aaa =                (ArtilleryAttackAction) i.nextElement();            // Does the attack land this turn?            if (aaa.turnsTilHit <= 0) {                WeaponResult wr = aaa.getWR();                //HACK, for correct hit table resolution.                wr.artyAttackerCoords=aaa.getCoords();                final Vector spottersBefore=aaa.getSpotterIds();                final Targetable target = wr.waa.getTarget(game);                final Coords targetPos = target.getPosition();                final int playerId = aaa.getPlayerId();                Entity bestSpotter=null;                Entity ae = game.getEntity(wr.waa.getEntityId());                if (ae == null) {                  ae = game.getOutOfGameEntity( wr.waa.getEntityId() );                }                Mounted ammo = ae.getEquipment(wr.waa.getAmmoId());                final AmmoType atype = ammo == null ? null : (AmmoType) ammo.getType();                if(atype != null && atype.getMunitionType() == AmmoType.M_HOMING) {                    wr = convertHomingShotToEntityTarget(aaa, ae);                } else {                    // Are there any valid spotters?                    if ( null != spottersBefore ) {                        //fetch possible spotters now                        Enumeration 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 = (Entity) 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;                        wr.toHit.addModifier(mod, "Spotting modifier");                    }                    // Is the attacker still alive?                    Entity artyAttacker = wr.waa.getEntity( game );                    if (null != artyAttacker) {                        // Get the arty weapon.                        Mounted weapon = artyAttacker.getEquipment                            ( wr.waa.getWeaponId() );                        // If the shot hit the target hex, then all subsequent                        // fire will hit the hex automatically.                        if(wr.roll >= wr.toHit.getValue()) {                            artyAttacker.aTracker.setModifier                                ( weapon,                                  ToHitData.AUTOMATIC_SUCCESS,                                  targetPos );                        }                        // 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 );                        }                    } // End artyAttacker-alive                }                // Schedule this attack to be resolved.                results.addElement(wr);                attacks.addElement( aaa );            } // End attack-hits-this-turn            // This attack is one round closer to hitting.            aaa.turnsTilHit--;        } // Handle the next attack        // loop through weapon results and resolve        int lastEntityId = Entity.NONE;        for (Enumeration i = results.elements();i.hasMoreElements();) {            WeaponResult wr = (WeaponResult) i.nextElement();            resolveWeaponAttack(wr, lastEntityId);            lastEntityId = wr.waa.getEntityId();        }        // Clear out all resolved attacks.        for (Enumeration i = attacks.elements(); i.hasMoreElements();) {            game.removeArtilleryAttack                ( (ArtilleryAttackAction) i.nextElement() );        }        for(Enumeration i = game.getPlayers();i.hasMoreElements();) {            Player player = (Player)i.nextElement();            int connId = player.getId();            send(connId, createArtilleryPacket(player));        }    }