{1\ # Initialization code goes here
   # Global variables for storing the Daily Brief text
   @Var(J2, J3, J4, J6, JOthers, BriefTurn, ExtraText);

   # Global variables for keeping track of who is killed per force
   @Var(Killed0, Killed1, Killed2, Killed3);
	
   # FirstFire flag.
   @Var(FirstFire);

   # Replacement and reinforcement values
   @Var(ReinforcementArrived, GroundReplacements, RFReplacements, AirReplacements);

   # Initialize the Daily Brief values
   J2      = "";
   J3      = "";
   J4      = "";
   J6      = "";
   JOthers = "";   
   BriefTurn = -1;
   ExtraText = "";

   # Initialize killed values
   Killed0 = 0;
   Killed1 = 0;
   Killed2 = 0;
   Killed3 = 0;

   FirstFire = -1;                  # Value to indicate whether the human player fired first

   # Initialize replacement and reinforcement values
   ReinforcementArrived = FALSE;
   GroundReplacements   = 0;
   RFReplacements       = 0;
   AirReplacements      = 0;

   # Use this to keep track of where units died...in order to resurrect them later
   @Var(UnitDiedX[GNumUnits], UnitDiedY[GNumUnits], DiedTurn[GNumUnits]);

   # For Agile Combat Support, keep a list of the objective unit type types
   @If(GCurrentScenario == "Agile Combat Support",
      # Then
      (
         # Create variables for storing the objective, objective search style, and current number
         @Var(Objectives[4], ObjectiveStyle[4], NumObjectives, AddObjectiveTurn);

         NumObjectives = 4;
         ObjectiveStyle[1] = 1;     # Looking at the type of unit type
         Objectives[1]     = 22;    # AD_HQ type
         ObjectiveStyle[2] = 1;     # Looking at the type of unit type
         Objectives[2]     = 10;    # HQ type
         ObjectiveStyle[3] = 1;     # Looking at the type of unit type
         Objectives[3]     = 17;    # HQ installation type
         ObjectiveStyle[4] = 2;     # Looking at the unit type name
         Objectives[4]     = "NK Power Station";

         # Pick a random turn to add new objectives, from 5 to MaxTurns - 2
         AddObjectiveTurn = 2 # @Rand(GMaxTurns - 7) + 5;
      ) # end then
   );

   # Remove initialization trigger
   @UnloadTrigger(1);
}

# ----------------------------------------------------
{10\  # Daily brief
   # Set some default text for the daily brief for Info Superiority
   @If(GCurrentScenario == "Info Superiority",
      # Then
      @Switch(GCurrentTurn,
         ( # 1
            J2 = J2 + ((J2 != "") ? "\n\t" : "") + "Intel collection must be scheduled for tomorrow.";
            J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Ground forces:  dig in and do not initiate any hostilities.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Deployment schedule on track.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "All systems except Kunsan Ops are green.  Parts on order; estimated repair time:  3 days.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Public Affairs Officer:  If CNN increases coverage, we'll have a lot of questions to answer.";
         ), # end 1
         ( # 2
            J2 = "JCS announced JSTARS will deploy.  Be ready to schedule it near the DMZ area at a safe distance.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tJSTARS will help identify targets for ground and air-to-ground operations.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Schedule air supply missions for tomorrow.  Make sure the planners know these flights should repeat every day.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Kunsan Ops is still down.  Remaining systems are green.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Plans Officer: JCS reportedly is working around the clock to get build up rolling.";
         ), # end 2
         ( # 3
            J2 = "Finalizing collection schedule.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tEarly morning fog delayed the resupply scheduled this morning.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Valuable airlift mission due tomorrow.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Main switch for the backup SATCOM went down just after the midnight shift.  Overall comms are Yellow.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 3
         ( # 4
            J2 = "JSTARS arrives today. The NK Air Defense system working well...too well:\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tTomorrow a contingent of HTS F-16s is scheduled to arrive.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Supplies continue to flow into theater.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Comms status:  green.  Parts inventory needs help.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 4
         ( # 5
            J2 = "JSTARS ready to go.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tSortie rates 96%.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Pipeline starting to back up.  Shortage of ramp space storage is a problem.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "SATCOM connectivity with the States is back up now.  Overall comms are still yellow; lost two microwave relays.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Plans Officer: Marine staff liaison arrived to support defensive operations.";
         ), # end 5
         ( # 6
            J2 = "Pol/Mil analysis says North Koreans may be planning something as a distraction.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tSortie rate 88%.  Additional aircraft are on alert.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Supplies continue to flow.  Fuel is a concern based on increased alert requirements.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Overall comms are now back to green, sir.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 6
         ( # 7
            J2 = "PACOM/J2 has indications of ground activity our in-theater assets haven't picked up.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWorking on Oplan execution";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Unable to re-route fuel.  Working more tanker aircraft out of Kadena to reduce in-theater refueling frustrations.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Kunsan Ops is intermittent again.  Overall comms are yellow.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Set some default text for the daily brief for Close Air Support
   @If(GCurrentScenario == "Close Air Support",
      # Then
      @Switch(GCurrentTurn,
         ( # 1
            J2 = J2 + ((J2 != "") ? "\n\t" : "") + "Continuing intel collection.";
            J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Be careful of ambushes and special operations attacks.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Deployment continues.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Some landline problems popped up today.  Fixed ASAP.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 1
         ( # 2
            J2 = "We need to use fall-back orbits to prevent loss of platforms.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWe've got to use all available combat aircraft if Oplan implemented.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "We have fuel and munitions.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Marine support scheduled to arrive in the next few days.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 2
         ( # 3
            J2 = "We have unconfirmed reports of political struggles between the NK Premier and his military staff.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWe have lots of comm problems.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Message from CINCPAC:  more Apache support ready from Kadena.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Last minute change in status; SATCOM van out of operation.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Admin.: Lead elements of the 3422nd Support Group show up today.";
         ), # end 3
         ( # 4
            J2 = "Be alert to ambushes and sneak attacks.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWorking search and destroy planning against NK Special Ops.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Airlift assets are available for Kadena Apache support.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Marines landed on east coast.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Public Affairs Officer:  1030 appointment media for Q&A, photo ops.";
         ), # end 4
         ( # 5
            J2 = "No update on the NK political struggle.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tLooks like more SAM threats than anticipated.  Recommend J2 pay more attention to this area.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Supply to ROK allies is difficult.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Long night for comm folks.  Many systems down; overall comm is just barely yellow.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 5
         ( # 6
            J2 = "Collection continues.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\t\Sortie rate 92%.  Air crews need augmentation.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "More fuel available if we can just get to Kadena.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Overall comms are now back to green.  On-call teams deserve a break.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 6
         ( # 7
            J2 = "We provided update lists of priority targets to J3.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWe're working on it.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Ramp and storage space is a headache.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "All systems are green except Osan Ops secure fax.  Estimate job completed tomorrow afternoon.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Set some default text for the daily brief for Air Superiority
   @If(GCurrentScenario == "Air Superiority",
      # Then
      @Switch(GCurrentTurn,
         ( # 1
            J2 = J2 + ((J2 != "") ? "\n\t" : "") + "Intel is not scheduled.  Must be accomplished ASAP.";
            J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Success hinges on taking out North Korean combat capability.  Ensure missions are planned against the right targets.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Airlift under control.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Overall bandwidth distribution is looking pretty good.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Public Affairs Officer:  Sir, the SecDef is visiting in three days for photo ops, briefings, and a press conference.";
         ), # end 1
         ( # 2
            J2 = "Special analysis shows SA-2 movements.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "North Korean ground troops are a priority CAS target.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Marines coming in tomorrow.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "The TACC isn't cooperating at all on landline problems.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 2
         ( # 3
            J2 = "We have a revised target list.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "We have to use Tomahawks against rear echelon/deep targets.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Marines landed at Pohang!";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Marine communications set up.  Worked my crews all evening to get system connectivity with the carrier.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Protocol Officer: Tomorrow's your tour with the SecDef.";
         ), # end 3
         ( # 4
            J2 = "All Priority 1 targets enjoying a high rate of revisit from a combination of theater and national collectors.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Naval support is a little better with the new cruiser.  BDA is a problem.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Logistic support will continue unabated throughout the day, sir.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Computer virus trouble in the J1 (Admin.) section.  Recommend a review of Computer Security measures in association with OPSEC.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "SecDef:  I'm pleased with the level of effort going on here.  The American people are behind you 100%!";
         ), # end 4
         ( # 5
            J2 = "We're getting good support from the Joint Military Intelligence Center (JMIC).\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Recommend F-117s on targets farther north, B-1s and B-52s with escorts northwest of DMZ.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "We've seen the last of the reinforcements.  We have to fight with what we have now.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "All but two systems are green.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 5
         ( # 6
            J2 = "Nothing special to report.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "No problems associated with the ATO.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "A few second-priority creates will reach their destinations late tomorrow, and we're going to refurbish a back-up cargo loader at Osan.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Stateside contacts helping me bring in a piece of equipment to improve ground station comms range with our fighter aircraft.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Admin.:  Since SecDef's visit, received several high-level taskers on the suspense log.  Reminder to all personnel to keep on top of the staff work.";
         ), # end 6
         ( # 7
            J2 = "Dramatic decrease in enemy emitter activity!\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Similar down-turn in enemy missile launches and fighter engagements.  Keep coordinating the intel flights with the interdiction missions.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = ((J4 != "") ? J4 : "Nothing to report.");
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "The special equipment mentioned yesterday is likely to be deployed to theater.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Set some default text for the daily brief for Precision Engagement
   @If(GCurrentScenario == "Precision Engagement",
      # Then
      @Switch(GCurrentTurn,
         ( # 1
            J2 = J2 + ((J2 != "") ? "\n\t" : "") + "We should destroy eight bridges in the north half of North Korea, four bridges on the west, four on the east.  Six are further north than the major cities, and two are between Hamhung and Wonsan on the east coast.  If taken down, these bridges will prevent 80% of North Korean resupply.";
            J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Working.";
            J4 = ((J4 != "") ? J4 : "Nothing to report");
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Comm status good.  Two major systems in yellow status.  Should be fixed in 48 hours.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Special Ops Liaison: Special study being prepared on the effectiveness of launching a psyop campaign against the communities in and around the bridge targets.";
         ), # end 1
         ( # 2
            J2 = "Targeteers developing target packages for all the bridge-busting missions in the ATO.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Recommend a combination of F-117s and Tomahawks on the northern targets.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Fuel supply data shows some problems in the near future.  Teams going around doing physical inspection of the tanks.  Results tomorrow.";
            J6 = ((J6 != "") ? J6 : "Nothing to report, sir.");
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 2
         ( # 3
            J2 = "U-2 having trouble getting quality photos form so far south.  No stateside dedication of UAV assets, either.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tMarines available for tasking near Pohang.  Recommend using them to pounce on NK Special Ops.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Recommend tailoring fuel use by scheduling fewer missions.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Last night's small problems easily handled by on-call emergency teams.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Executive Officer:  Your next appointment is in ten minutes with the local leadership.";
         ), # end 3
         ( # 4
            J2 = "BDA not good.  Need re-eval\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tGlad to hear the J2 is finally doing his job.  Couldn't hardly trust the target packages anymore.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Four tankers coming in tomorrow to relieve the fuel problem.  Put flying schedule back up to max crew endurance.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "All systems are green!";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 4
         ( # 5
            J2 = "Still working BDA problems.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tGotta have the BDA to firm up the ATO.";
            J4 = ((J4 != "") ? J4 : "No other comments.");
            J6 = ((J6 != "") ? J6 : "No other comments.");
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 5
         ( # 6
            J2 = "CNN reports NK preparing to surrender.  Will keep you up-to-date.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Current sortie rates are down a bit.  I'll look into it.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Some of resupply areas near DMZ starting to show yellow ammo status.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "SATCOM connectivity with MILSAT degraded yesterday.  On-call comm team able to get transmission quality up to speed.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Special Ops Liaison:  Psyops study is in.  We need to use leaflet drops and Commando Solo.";
         ), # end 6
         ( # 7
            J2 = "Bridge destruction looking good.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Current sortie rates are down a little.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Yesterday's truck action worked out.  Ammo levels back to green.";
            J6 = ((J6 != "") ? J6 : "No other comments.");
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Set the first logical path text (before new objectives) for the daily brief for Agile Combat Support
   @If((GCurrentScenario == "Agile Combat Support") &&
       (GCurrentTurn     <  (AddObjectiveTurn - 1)),
      # Then
      @Switch(GCurrentTurn,
         ( # 1
            J2 = J2 + ((J2 != "") ? "\n\t" : "") + "Continuing to work BDA and target lists.";
            J3 = J3 + ((J3 != "") ? "\n\t" : "") + "JFACC staff working around the clock to update a strike ATO.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Logistics requirements are very heavy.  Will prioritize.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Don't worry about comms.  System well established.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 1
         ( # 2
            J2 = "Collection management and target package development OK.  Indications & Warnings board could use a quick review.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tEnsure bombing plan doesn't take our attention away from intel collection and analysis.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Monitoring fuel consumption rates matching and port deliveries.";
            J6 = ((J6 != "") ? J6 : "Nothing to report, sir.");
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 2
         ( # 3
            J2 = "Be aware of possibly increased NK SCUD threat.  SCUDs weren't imaged in their garrison locations.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "Marines have arrived on the SE coast.  Electronic protection available for air missions.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Moving ammo and fuel delivery routes.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Picked up early indications of computer trouble.  Perhaps a bug in the system.  Checking with AFCERT.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 3
         ( # 4
            J2 = "Working BDA.  Relying on national collection.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tNeed more strike packages.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "CINCPAC says more Apache support available.";
            J6 = ((J6 != "") ? J6 : "Nothing to report, sir.");
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 4
         ( # 5
            J2 = "Announcement on SCUD preparations two days ago should be reconsidered.  DIA and NAIC both say SCUD launch is not imminent.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tRecommend flying every aircraft every day, and using the ships' Tomahawks to maximum extent possible.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Fuel shouldn't be a problem.\n\tMore Marines in theater.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Three major systems in need of attention.  Status yellow.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 5
         ( # 6
            J2 = "Reviewing OB data - not the same as DIAs.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWord from CINCPAC: more reinforcements soon.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "C-5 out of Travis is NORS.  Could be a while before it gets out.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "One computer emergency yesterday.  Telephone switch countrol for HQ phones had data erased, but we found and reinstalled the backup files.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 6
         ( # 7
            J2 = "Still working OB problems!\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tThat's a priority.  Some targets are being hit unnecessarily.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Bad news.  Putting together NCO teams to double-check questionable data, but I'll let the J6 explain the situation . . .";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Computers at HQ have 'virus' written all over their system files.  No guarantee the supply system hasn't been copied or manipulated.  So far no data reported destroyed!";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Set the second logical path text (after new objectives) for the daily brief for Agile Combat Support
   @If((GCurrentScenario == "Agile Combat Support") &&
       (GCurrentTurn     >= (AddObjectiveTurn - 1)),
      # Then
      @Switch((AddObjectiveTurn - GCurrentTurn),
         ( # 1
            J2 = "SCUD Alert!  Several launchers imaged in primary firing locations with support vehicles present." + ((J2 != "") ? ("\n\t" + J2) : "");
            J3 = "All airbases and fireposts are to go to MOPP-4 immediately!\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Osan and Kunsan main depot inventories don't agree with each other.  Clerks trying to work it out at grassroots level.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "SCUD attacks on airbases could take out redundant systems along with priority lines.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Military Police:  Forces prepared for road and riot control in case of SCUD impact in neighboring communities.";
         ), # end 1
         ( # 2
            J2 = "Indications & Warnings board updated to reflect increased SCUD threat.  Launches imminent.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "The JCS wants SCUDs to be priority target; bridges still on the task list!\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Supply and support to ROK allis is getting difficult; can't promise its future viability.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Long night for comm.  Plenty of systems went down yesterday evening.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 2
         ( # 3
            J2 = "Message from DIA:  Gas-filled warheads for SCUDs is possible.  Must target chemical plants.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tIn the process of converting the ATO to SCUD-hunting.  70% complete.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Significant changes in logistics requirements!  We need some flexibility in the weapon requirements, please!";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Primarily focused on keeping stateside comms open and working.";
            JOthers = JOthers + ((JOthers != "") ? "\n\t" : "") + "Executive Officer:  Draft of the new OPORD is ready for review.";
         ), # end 3
         ( # 4
            J2 = "Intel analysis efforts are almost fully switched over to SCUDs.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tRecommend pounding SAM sites with F-16 HTS aircraft, since some SAM sites have begun regenerating their strike capability.";
            J4 = ((J4 != "") ? J4 : "Nothing to report");
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Three major comm systems in need of repair.  Expect two days until operational.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 4
         ( # 5
            J2 = "Working BDA again.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tOperationally, we're putting ourselves in a bad position.  My positions are over-extended and the flight crews are absolutely beat.";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "POL status is starting to wane.  Emergency sealift from the states is being generated for post-conflict conditions.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Comms looking good today.  Only a few systems at yellow; those will be fixed tomorrow.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 5
         ( # 6
            J2 = "Additional SCUD launch sites mapped out.  Intel passed to the flying units already.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = ((J3 != "") ? J3 : "No activity reported yesterday.") + "\n\tWe need more CAS!";
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "POL supplies are getting low.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Working on getting additional ground relay stations.";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ), # end 6
         ( # 7
            J2 = "Working BDA and OB problems.\n\t" + ((J2 != "") ? J2 : "No activity to report from yesterday");
            J3 = "This theater is not adequately prepared for post-conflict conditions.  Recommend a strong message be sent up to CINCPACOM.\n\t" + ((J3 != "") ? J3 : "No activity reported yesterday.");
            J4 = J4 + ((J4 != "") ? "\n\t" : "") + "Expect a major resupply in two days.";
            J6 = J6 + ((J6 != "") ? "\n\t" : "") + "Computers at HQ have 'virus' all over them.  Critical files at 80% integrity.  Security breaches in every major server file!";
            JOthers = ((JOthers != "") ? JOthers : "No other comments.");
         ) # end 7
      ) # end switch
   ); # end if

   # Add special brief text for objectives for Agile Combat Support
   @If(GCurrentScenario == "Agile Combat Support",
      # Then
      (
         # Find all the units that match the objectives.  Keep track of the killed ones, and display a % complete
         @Var(List[NumObjectives], UnitCount[NumObjectives], DeadCount[NumObjectives], Percent);

         ExtraText = "";

         @Var(i, j, Found);
         @For(i = 1, i <= NumObjectives, i = i + 1,
            (
               List[NumObjectives]      = "";
               UnitCount[NumObjectives] = 0;
               DeadCount[NumObjectives] = 0;
            )
         );

         @For(i = 0, i < GNumUnits, i = i + 1,
            # Look at valid enemy units.
            @If((@GetUnitValue(i, TYPE) > 0) &&
                (@GetUnitValue(i, FORCE) != GCurDispForce),
               # Then
               (
                  # See if this unit is one of the objectives
                  Found = FALSE;
                  @For(j = 1, (j <= NumObjectives) && !Found, j = j + 1,
                     @If((((ObjectiveStyle[j] == 1) &&
                           (@GetUnitValue(i, TYPETYPE) == Objectives[j])) ||
                          ((ObjectiveStyle[j] == 2) &&
                           @InStr(@GetUnitValue(i, TYPENAME), Objectives[j]))),
                        # Then
                        (
                           # If visible to player, add to count
                           @If(@VisibilityToForce(i, GCurDispForce) == 2,
                              # Then
                                 UnitCount[j] = UnitCount[j] + 1
                           ); # end if

                           # If it's dead, increment dead count
                           @If(@GetUnitValue(i, COMSTR) == 0,
                              # Then
                                 DeadCount[j] = DeadCount[j] + 1
                           ); # end if

                           # Add type name to objective display list if not there already
                           @If(!@InStr(List[j], @GetUnitValue(i, TYPENAME)),
                              # Then
                                 List[j] = List[j] + ((List[j] != "") ? ", " : "") + @GetUnitValue(i, TYPENAME)
                           ); # end if

                           Found = TRUE;
                        ) # end then
                     ) # end if
                  ) # end for j
               ) # end then
            ) # end if
         );# end for i

         # Add to extra text
         @For(i = 1, i <= NumObjectives, i = i + 1,
            (
               @If(UnitCount[i] < DeadCount[i],
                  # Then
                     UnitCount[i] = DeadCount[i]
               );

               @If(DeadCount[NumObjectives] > 0,
                  # Then
                     Percent = (UnitCount[i] / DeadCount[i]) * 100
                  ,
                  # Else
                     Percent = 0
               ); # end if

               # Add text if units were found of the objective
               @If(List[i] != "",
                  ExtraText = ExtraText + "{\cf4" + List[i] + "}\n{\cf5Found:}  " + @Int(UnitCount[i]) + "\t\t{\cf5Destroyed:}  " + @Int(DeadCount[i]) + "\t\t{\cf5Percent Complete:}  " + @Int(Percent) + "%\n"
               ) # end if
            )
         ); # end for
         @DeleteVar(i, j, Found);

         @If(ExtraText != "",
            # Then
               ExtraText = "{\f1\fs20\cf2\t\t\tObjectives}\n" + ExtraText + "\n"
         ); # end if

         @DeleteVar(List[NumObjectives], UnitCount[NumObjectives], DeadCount[NumObjectives], Percent);
      ) # end then
   ); # end if

   # Show the brief
   @Question("\o1440{\f2\fs20\cf1" + 
             "{\f1\fs28\cf1\t\tSituational Brief:  Day " + GCurrentTurn + " of " + GMaxTurns + "" + "}\n\n" +
             "{\f1\fs20\cf2Weather:\t}{\f1\cf5Current:  }Ground - " + GCurrentGroundWeather + "     Air - " + GCurrentAirWeather + "\n" +
             "{\f1\fs20\t}{\f1\cf5Forecast:  }Ground - " + GForecastGroundWeather + "     Air - " + GForecastAirWeather + "\n\n" +
             ExtraText + 
             "{\f1\fs20\cf2J-2(Intel):\t}" + ((J2 != "") ? J2 : "No report this turn.") + "\n" +
             "{\f1\fs20\cf2J-3(Ops):\t}"   + ((J3 != "") ? J3 : "No report this turn.") + "\n" +
             "{\f1\fs20\cf2J-4(Logs):\t}"  + ((J4 != "") ? J4 : "No report this turn.") + "\n" +
             "{\f1\fs20\cf2J-6(Comms):\t}" + ((J6 != "") ? J6 : "No report this turn.") + "\n" +
             "{\f1\fs20\cf2Others:\t}"     + ((JOthers != "") ? JOthers : "No report this turn.") + "\n" +
             "\n{\f1\fs20\cf5Hint:\t}"     + @GetHint(GCurDispForce) + "\n" + 
             "}"
            );

   J2      = "";
   J3      = "";
   J4      = "";
   J6      = "";    
   JOthers = "";
   BriefTurn = GCurrentTurn;
   ExtraText = "";
}

# ----------------------------------------------------
# ----------------------------------------------------
{100\ # Replacements, and reset reinforcement flag
   # If no reinforcement was placed, add some ground replacements
   @If(!ReinforcementArrived,
      # Then
         GroundReplacements = GroundReplacements + 15
   ); # end then

   ReinforcementArrived = FALSE;
}

# ----------------------------------------------------
{110\ # Conditional replacements
   @Var(CurUnit, Replaced, Continue);

   # Do ground replacements
   @If(GroundReplacements > 0,
      # Then
      (
         # Notify player via brief
         #J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Ground forces have added new troops.";

         CurUnit  = 0;
         Replaced = FALSE;
         Continue = TRUE;
         @While((GroundReplacements > 0) && Continue,
            (
               # If we're looking at a valid unit...
               @If((@GetUnitValue(CurUnit, TYPE)  > 0) &&
                   !@IsAnAirUnit(CurUnit)              &&
                   (@GetUnitValue(CurUnit, FORCE) == GCurDispForce) &&
                   (@GetUnitValue(CurUnit, COMSTR) < @GetUnitValue(CurUnit, MAXCOMSTR)),
                  # Then
                  (
                     @SetUnitValue(CurUnit, COMSTR, @GetUnitValue(CurUnit, COMSTR) + 1);
                     J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Replacements:  " + @GetUnitValue(CurUnit, NAME) + " has added new troops.";
                     GroundReplacements = GroundReplacements - 1;
                     Replaced           = TRUE;
                  ) # end Then
               ); # end if

               # Go to next unit
               CurUnit = CurUnit + 1;

               # If we're at the end of the unit list, 
               @If(CurUnit == GNumUnits,
                  # Then
                  (
                     # If we didn't find any units to do replacements, end...
                     Continue = Replaced;

                     # Reset "did we change anything this time around?" flag
                     Replaced = FALSE;

                     # Start at beginning of unit list
                     CurUnit = 0;
                  ) # end Then
               ) # end if
            )
         ) # end While
      ) # end Then
   ); # end if

   # Do RF replacements
   @If(RFReplacements > 0,
      # Then
      (
         # Notify player via brief
         #J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Ranged-fire ammunition arrived.";

         CurUnit  = 0;
         Replaced = FALSE;
         Continue = TRUE;
         @While((RFReplacements > 0) && Continue,
            (
               # If we're looking at a valid unit...
               @If((@GetUnitValue(CurUnit, TYPE)  > 0) &&
                   !@IsAnAirUnit(CurUnit)              &&
                   (@GetUnitValue(CurUnit, FORCE) == GCurDispForce) &&
                   (@GetUnitValue(CurUnit, RFSTR) < @GetUnitValue(CurUnit, MAXRFSTR)),
                  # Then
                  (
                     @SetUnitValue(CurUnit, RFSTR, @GetUnitValue(CurUnit, RFSTR) + 1);
                     J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Replacements:  " + @GetUnitValue(CurUnit, NAME) + " has received ammunition.";
                     RFReplacements = RFReplacements - 1;
                     Replaced       = TRUE;
                  ) # end Then
               ); # end if

               # Go to next unit
               CurUnit = CurUnit + 1;

               # If we're at the end of the unit list, 
               @If(CurUnit == GNumUnits,
                  # Then
                  (
                     # If we didn't find any units to do replacements, end...
                     Continue = Replaced;

                     # Reset "did we change anything this time around?" flag
                     Replaced = FALSE;

                     # Start at beginning of unit list
                     CurUnit = 0;
                  ) # end Then
               ) # end if
            )
         ) # end While
      ) # end Then
   ); # end if

   # Do Air replacements
   @If(AirReplacements > 0,
      # Then
      (
         # Notify player via brief
         #J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Damaged and destroyed airplanes have been replaced.";

         CurUnit  = 0;
         Replaced = FALSE;
         Continue = TRUE;
         @While((AirReplacements > 0) && Continue,
            (
               # If we're looking at a valid unit...
               @If((@GetUnitValue(CurUnit, TYPE)  > 0) &&
                    @IsAnAirUnit(CurUnit)              &&
                   (@GetUnitValue(CurUnit, FORCE) == GCurDispForce) &&
                   (@GetUnitValue(CurUnit, COMSTR) < @GetUnitValue(CurUnit, MAXCOMSTR)),
                  # Then
                  (
                     @SetUnitValue(CurUnit, COMSTR, @GetUnitValue(CurUnit, COMSTR) + 1);
                     J3 = J3 + ((J3 != "") ? "\n\t" : "") + "Replacements:  " + @GetUnitValue(CurUnit, NAME) + " has replaced damaged and destroyed aircraft.";
                     AirReplacements = AirReplacements - 1;
                     Replaced        = TRUE;
                  )
               );

               # Go to next unit
               CurUnit = CurUnit + 1;

               # If we're at the end of the unit list, 
               @If(CurUnit == GNumUnits,
                  # Then
                  (
                     # If we didn't find any units to do replacements, end...
                     Continue = Replaced;

                     # Reset "did we change anything this time around?" flag
                     Replaced = FALSE;

                     # Start at beginning of unit list
                     CurUnit = 0;
                  ) # end Then
               ) # end if
            )
         ) # end While
      ) # end Then
   ); # end if

   GroundReplacements = 0;
   RFReplacements     = 0;
   AirReplacements    = 0;

   @DeleteVar(CurUnit, Replaced, Continue);
}

# ----------------------------------------------------
{120\
   @Var(Index);

   Index = GKilledUnit + 1;
   UnitDiedX[Index] = @LocX(GKilledUnit);
   UnitDiedY[Index] = @LocY(GKilledUnit);
   DiedTurn[Index]  = GCurrentTurn;

   @DeleteVar(Index);
}

# ----------------------------------------------------
{130\ # Try to resurrect ground units dead for at least a turn
   @Var(i, Type);
   @For(i = 0, i < GNumUnits, i = i + 1,
      # If valid ground unit is dead, and it died before the current turn, try to resurrect 
      @If((@GetUnitValue(i, TYPE)   > 0)     &&  # Valid unit
          (@GetUnitValue(i, COMSTR) == 0)    &&  # Dead
          !@IsAnAirUnit(i)                   &&  # Not an air unit
          (Type = @GetUnitValue(i, TYPETYPE);    # Get the unit type's type.  Test for:
           ((Type == 3) ||                       #    Ground vehicle unit
            (Type == 4) ||                       #    Ground person unit
            (Type == 12)))                   &&  #    Radar/SAM unit
          (DiedTurn[i] < GCurrentTurn),          # Died before current turn
         # Then
            # Chance of resurrection is 85%
            @If(((@Rand(100) + 1) <= 85) &&
                (@UnitInLoc(UnitDiedX[i], UnitDiedY[i]) == -1),
               # Then
               (
                  @SetUnitValue(i, COMSTR, 3 * (@GetUnitValue(i, MAXCOMSTR) / 4));
                  @MoveUnit(i, UnitDiedX[i], UnitDiedY[i]);
               ) # end Then
            ) # end if
      ) # end if
   ); # end for
   @DeleteVar(i, Type);
}

# ----------------------------------------------------
# ----------------------------------------------------
{1000\ # Set all enemy air defense units RF strength to 0
   @Var(i, TypeType);
   @For(i = 0, i < GNumUnits, i = i + 1,
      (
         TypeType = @GetUnitValue(i, TYPETYPE);
         @If((@GetUnitValue(i, FORCE) != GCurDispForce) &&
             ((TypeType == 8)  ||           # Airbase unit types
              (TypeType == 22) ||           # AD HQ unit types  
              (TypeType == 12)),            # Radar-SAM unit types
            # Then
               @SetUnitValue(i, RFSTR, 0)
         ) # end if
      )
   );
   @DeleteVar(i, TypeType);
}

# ----------------------------------------------------
{1010\ # Change all living militia units to infantry
   @Var(i);
   @For(i = 0, i < GNumUnits, i = i + 1,
      @If(@InStr(@GetUnitValue(i, TYPENAME), "Militia") &&
          (@GetUnitValue(i, COMSTR) > 0),
         # Then
         (
            @If(@GetUnitValue(i, FORCE) == 0,
               # Then -- for NKPA militia units
                  @ChangeType(i, "NK infantry corps", @GetUnitValue(i, NAME)),
               # Else -- for ROK militia units
                  @ChangeType(i, "ROK Infantry corps", @GetUnitValue(i, NAME))
            ); # end if

            # Set com strength of new infantry unit to max
            @SetUnitValue(i, COMSTR, @GetUnitValue(i, MAXCOMSTR));
         ) # end then
      ) # end if
   ); # end for
   @DeleteVar(i);

   # Can get rid of these triggers
   @UnloadTrigger(1000);
   @UnloadTrigger(1010);
}

# ----------------------------------------------------
{1020\ # Set all forces to not fight
   @Var(i, j);
   @For(i = 0, i < 4, i = i + 1,
      @For(j = 0, j < 4, j = j + 1,
         @If(i != j, @CanNotFight(i, j))
      ) # end for
   ); # end for
   @DeleteVar(i, j);
}

# ----------------------------------------------------
{1030\ # Allow all forces to fight
   @Var(i, j);
   @For(i = 0, i < 4, i = i + 1,
      @For(j = 0, j < 4, j = j + 1,
         @If(i != j, @CanFight(i, j))
      ) # end for
   ); # end for
   @DeleteVar(i, j);

   # Go ahead and remove these triggers
   @UnloadTrigger(1020);
   @UnloadTrigger(1030);
}

# ----------------------------------------------------
{1100\ # Add new objectives on pre-selected turn
   @ReVar(ObjectiveStyle, NumObjectives, NumObjectives + 1);
   @ReVar(Objectives,     NumObjectives, NumObjectives + 1);

   NumObjectives = NumObjectives + 1;
   ObjectiveStyle[NumObjectives] = 2;     # Unit type name
   Objectives[NumObjectives]     = "SCUD";

   @UnloadTrigger(1100);
}

# ----------------------------------------------------
{1110\ # Add more objectives on pre-selected turn + 1
   @ReVar(ObjectiveStyle, NumObjectives, NumObjectives + 3);
   @ReVar(Objectives,     NumObjectives, NumObjectives + 3);

   # NOTE:  The staggered objective increase is because we can't have expressions
   # in the index of an array at this time.
   NumObjectives = NumObjectives + 1;
   ObjectiveStyle[NumObjectives] = 2;     # Unit type name
   Objectives[NumObjectives]     = "Chemical";

   NumObjectives = NumObjectives + 1;
   ObjectiveStyle[NumObjectives] = 2;     # Unit type name
   Objectives[NumObjectives]     = "Nuclear";

   NumObjectives = NumObjectives + 1;
   ObjectiveStyle[NumObjectives] = 2;     # Unit type name
   Objectives[NumObjectives]     = "POL Site";

   @UnloadTrigger(1110);
}

# ----------------------------------------------------
{1120\ # Add new objectives for turn 4
   @ReVar(ObjectiveStyle, NumObjectives, NumObjectives + 1);
   @ReVar(Objectives,     NumObjectives, NumObjectives + 1);

   NumObjectives = NumObjectives + 1;
   ObjectiveStyle[NumObjectives] = 1;     # Type of unit type name
   Objectives[NumObjectives]     = 21;    # Bridge type

   @UnloadTrigger(1120);
}

# ----------------------------------------------------
{1130\ # Final screen for air superiority

   # Find all the units that match the objectives.  Keep track of the killed ones, and display a % complete
   @Var(List[NumObjectives], UnitCount[NumObjectives], DeadCount[NumObjectives], Percent);

   ExtraText = "";

   @Var(i, j, Found);
   @For(i = 1, i <= NumObjectives, i = i + 1,
      (
         List[NumObjectives]      = "";
         UnitCount[NumObjectives] = 0;
         DeadCount[NumObjectives] = 0;
      )
   );

   @For(i = 0, i < GNumUnits, i = i + 1,
      # Look at valid enemy units.
      @If((@GetUnitValue(i, TYPE) > 0) &&
          (@GetUnitValue(i, FORCE) != GCurDispForce),
         # Then
         (
            # See if this unit is one of the objectives
            Found = FALSE;
            @For(j = 1, (j <= NumObjectives) && !Found, j = j + 1,
               @If((((ObjectiveStyle[j] == 1) &&
                     (@GetUnitValue(i, TYPETYPE) == Objectives[j])) ||
                    ((ObjectiveStyle[j] == 2) &&
                     @InStr(@GetUnitValue(i, TYPENAME), Objectives[j]))),
                  # Then
                  (
                     # If visible to player, add to count
                     @If(@VisibilityToForce(i, GCurDispForce) == 2,
                        # Then
                           UnitCount[j] = UnitCount[j] + 1
                     ); # end if

                     # If it's dead, increment dead count
                     @If(@GetUnitValue(i, COMSTR) == 0,
                        # Then
                           DeadCount[j] = DeadCount[j] + 1
                     ); # end if

                     # Add type name to objective display list if not there already
                     @If(!@InStr(List[j], @GetUnitValue(i, TYPENAME)),
                        # Then
                           List[j] = List[j] + ((List[j] != "") ? ", " : "") + @GetUnitValue(i, TYPENAME)
                     ); # end if

                     Found = TRUE;
                  ) # end then
               ) # end if
            ) # end for j
         ) # end then
      ) # end if
   );# end for i

   # Add to extra text
   @For(i = 1, i <= NumObjectives, i = i + 1,
      (
         @If(UnitCount[i] < DeadCount[i],
            # Then
               UnitCount[i] = DeadCount[i]
         );

         @If(DeadCount[NumObjectives] > 0,
            # Then
               Percent = (UnitCount[i] / DeadCount[i]) * 100
            ,
            # Else
               Percent = 0
         ); # end if

         # Add text if units were found of the objective
         @If(List[i] != "",
            ExtraText = ExtraText + "{\cf4" + List[i] + "}\n{\cf5Found:}  " + @Int(UnitCount[i]) + "\t\t{\cf5Destroyed:}  " + @Int(DeadCount[i]) + "\t\t{\cf5Percent Complete:}  " + @Int(Percent) + "%\n"
         ) # end if
      )
   ); # end for
   @DeleteVar(i, j, Found);

   @If(ExtraText != "",
      # Then
         ExtraText = "{\f1\fs20\cf2\t\t\tObjectives}\n" + ExtraText + "\n"
   ); # end if

   @DeleteVar(List[NumObjectives], UnitCount[NumObjectives], DeadCount[NumObjectives], Percent);

   # Show the screen
   @Question("{\f2\fs20\cf1" + 
             "{\f1\fs28\cf1\t\tFinal Objective Evaluation}\n\n" + ExtraText + 
             "}"
            );
}


# ----------------------------------------------------
{1200\ # Set all player's ground unit movement to 0
   @Var(i);
   @For(i = 0, i < GNumUnits, i = i + 1,
      @If((@GetUnitValue(i, TYPE) > 0)               &&
          (@GetUnitValue(i, FORCE) == GCurDispForce) &&
          !@IsAnAirUnit(i),
         # Then
            @SetUnitValue(i, MOVEPTS, 0)
      ) # end If
   ); # end for
   @DeleteVar(i);
}


# ----------------------------------------------------
{9000\ # Finalization code goes here

   # Delete global variables
   # Remove the Daily Brief stuff
   @DeleteVar(J2, J3, J4, J6, JOthers, BriefTurn, ExtraText);

   # Remove the kill counters
   @DeleteVar(Killed0, Killed1, Killed2, Killed3);

   @DeleteVar(FirstFire);

   # Remove replacement and reinforcement values
   @DeleteVar(ReinforcementArrived, GroundReplacements, RFReplacements, AirReplacements);

   # Remove dead unit stuff
   @DeleteVar(UnitDiedX[GNumUnits], UnitDiedY[GNumUnits], DiedTurn[GNumUnits]);

   # For Agile Combat Support, delete objective variables
   @If(GCurrentScenario == "Agile Combat Support",
      # Then
         @DeleteVar(Objectives[NumObjectives], ObjectiveStyle[NumObjectives], NumObjectives, AddObjectiveTurn)
   );
}
