if(night_modifier > 0 && te != null && te instanceof Mech && ((Mech)te).hasLaserHeatSinks()) { boolean lhsused=false; if(te.heat > 0) { toHit.addModifier(-night_modifier, "target overheated with laser heatsinks"); night_modifier=0; }  else if(te.heatBuildup > 0 || te.isStealthActive()) { lhsused=true; } else {    for(Enumeration actions=game.getActions();actions.hasMoreElements();) { Object a = actions.nextElement(); if(a instanceof WeaponAttackAction) { WeaponAttackAction waa = (WeaponAttackAction)a; if(waa.getEntityId() == te.getId()) { Mounted weapon = te.getEquipment(waa.getWeaponId()); WeaponType wtype = (WeaponType)weapon.getType(); if(wtype.getHeat() != 0 || weapon.isRapidfire()) {  lhsused = true; break; } } } } }  if(lhsused) { toHit.addModifier(-1, "target uses laser heatsinks"); } }
    public static ToHitData nightModifiers(IGame game, Targetable target, AmmoType atype) {        ToHitData toHit = null;        if(game.getOptions().booleanOption("night_battle")) {            Entity te = null;            if ( target.getTargetType() == Targetable.TYPE_ENTITY ) {                te = (Entity) target;            }            toHit = new ToHitData();            //The base night penalty            int night_modifier;            if(game.getOptions().booleanOption("dusk")) {                night_modifier = 1;                toHit.addModifier(night_modifier, "Dusk");            } else {                night_modifier = 2;                toHit.addModifier(night_modifier, "Night");            }            boolean illuminated = false;            if(te!=null) {                illuminated = te.isIlluminated();                //hack for unresolved actions so client shows right BTH                if(!illuminated) {                    for(Enumeration actions=game.getActions();actions.hasMoreElements();) {                        Object a = actions.nextElement();                        if(a instanceof SearchlightAttackAction) {                            SearchlightAttackAction saa = (SearchlightAttackAction)a;                            if(saa.willIlluminate(game, te)) {                                illuminated = true;                                break;                            }                        }                    }                }            }            //Searchlights reduce the penalty to zero            if(te!=null && te.isUsingSpotlight()) {                toHit.addModifier(-night_modifier, "target using searchlight");            }            else if(illuminated) {                toHit.addModifier(-night_modifier, "target illuminated by searchlight");            }            //So do flares            else if(game.isPositionIlluminated(target.getPosition())) {                toHit.addModifier(-night_modifier, "target illuminated by flare");            }            //Certain ammunitions reduce the penalty            else if(atype != null) {                if(atype.getAmmoType() == AmmoType.T_AC &&                   (atype.getMunitionType() == AmmoType.M_INCENDIARY_AC ||                    atype.getMunitionType() == AmmoType.M_TRACER)) {                    toHit.addModifier(-1, "incendiary/tracer ammo");                    night_modifier--;                }            }        }        return toHit;    }