# ****************************************************************************
# CUI
#
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
#
# The use, dissemination or disclosure of data in this file is subject to
# limitation or restriction. See accompanying README and LICENSE for details.
# ****************************************************************************



##############################################################################
### signatures
##############################################################################
infrared_signature SIMPLE_INFRARED_SIGNATURE
   constant 1 watts/steradian
end_infrared_signature
optical_signature  SIMPLE_OPTICAL_SIGNATURE
   constant 1 m^2
end_optical_signature
radar_signature    SIMPLE_RADAR_SIGNATURE
   constant 1 m^2
end_radar_signature
weapon_effects SIMPLE_EFFECT WSF_GRADUATED_LETHALITY
   radius_and_pk  100.0 m  0.75
end_weapon_effects


##############################################################################
### antenna patterns
##############################################################################
antenna_pattern weapon_datalink_gain
   constant 10 dB
end_antenna_pattern


##############################################################################
### weapon platform that requires an uplink, and will go active
##############################################################################
platform_type MEDIUM_RANGE_UPLINK_MISSILE WSF_PLATFORM

   script_variables
      bool mDrawTarget = false;
      WsfDraw draw = WsfDraw();
   end_script_variables

   execute at_interval_of 1 sec
      if (mDrawTarget)
      {
         WsfTrack tgt = PLATFORM.CurrentTargetTrack();
         if (tgt.IsValid())
         {
            draw.SetDuration(1.0);  //same as execute interval
            draw.SetColor(1, 0, 1); //purple
            draw.SetLineSize(2);    //double thick
            draw.BeginLines();
               draw.Vertex(PLATFORM.Location());
               draw.Vertex(tgt.CurrentLocation());
            draw.End();
         }
      }
   end_execute

   weapon_effects SIMPLE_EFFECT
   icon Scud_Missile
   infrared_signature SIMPLE_INFRARED_SIGNATURE
   optical_signature  SIMPLE_OPTICAL_SIGNATURE
   radar_signature    SIMPLE_RADAR_SIGNATURE

   ###########################################################################
   ### straight line movers guide themselves, towards the platform's target
   ###########################################################################
   mover WSF_STRAIGHT_LINE_MOVER
      average_speed           3221.5 kts     # mach 5
      update_interval         0.006  sec
      update_time_tolerance   0.0006 sec     # this mover travels 1 meter in 0.00060339 seconds
      maximum_lateral_acceleration  15.0 g   # average turner
      guidance_mode           lead_pursuit   # or pure_pursuit
      guide_to_truth          false          # guide to perception
   end_mover

   ###########################################################################
   ### simple fuse
   ###########################################################################
   processor fuse WSF_AIR_TARGET_FUSE
      max_time_of_flight_to_detonate  100.0 sec
   end_processor

   ###########################################################################
   ### perfect trackers provide target truth data for the missile
   ###   no uplink or tracking required for this missile
   ###########################################################################
   #processor seeker WSF_PERFECT_TRACKER
   #   update_interval  0.5 s
   #end_processor

   ###########################################################################
   ### comm to receive target uplink track reports for weapon manuevering
   ###########################################################################
   comm weapon_downlink WSF_RADIO_RCVR
      network_name weapons_subnet
      internal_link track_mgr
      receiver
         antenna_pattern weapon_datalink_gain
         frequency 10 GHz
         bandwidth 500 MHz
         detection_threshold 0 dB
      end_receiver
   end_comm

   ###########################################################################
   ### simple track manager.  make sure comm & sensor feed it
   ###########################################################################
   processor track_mgr WSF_TRACK_PROCESSOR
      master_track_processor
   end_processor

   ###########################################################################
   ### turns on the weapon radar at the right time
   ###########################################################################
   processor weapon_manager WSF_WEAPON_TRACK_PROCESSOR
      coast_time      100 s
      ignore_uplink_target_change   #the processor ignores track messages that dont pertain to the current target
      uplink_required true          #this version is command guided missile only (no missile-active state)
   end_processor
end_platform_type


##############################################################################
### simple missile to use, requires uplink
##############################################################################
weapon MEDIUM_RANGE_UPLINK_MISSILE WSF_EXPLICIT_WEAPON
   launched_platform_type MEDIUM_RANGE_UPLINK_MISSILE
   weapon_effects SIMPLE_EFFECT
   quantity               4
   firing_delay           0.5 sec
   salvo_interval         5.0 sec
   slew_mode              azimuth_and_elevation
   azimuth_slew_limits    -180.0 deg 180.0 deg
end_weapon

