home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_UnarmedPatrol.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  4.9 KB  |  170 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_UnarmedPatrol : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_UnarmedPatrol:
  12. //   Follows a path and runs from enemies.
  13.  
  14. // NOTE: this script requires a CombatAI (or MechAI) to work properly!!!
  15.  
  16. //------------------------------------------------------------------
  17.  
  18.  
  19.  
  20. //------------------------------------------------------------------
  21. //     Constants
  22. //------------------------------------------------------------------
  23.  
  24.     const
  25.         #include_ <content\ABLScripts\mwconst.abi>
  26.  
  27. //------------------------------------------------------------------
  28. //     Types
  29. //------------------------------------------------------------------
  30.  
  31.     type
  32.         #include_ <content\ABLScripts\mwtype.abi>
  33.     
  34.  
  35. //------------------------------------------------------------------
  36. //     Variables
  37. //------------------------------------------------------------------
  38.  
  39.     var
  40.         static integer            fleeRange;            // At what range do I start running?
  41.         static integer            stopFleeingRange;    // At what range do I consider myself out of danger?
  42.         static integer            fleeSpeed;            // How fast I flee
  43.  
  44.         static integer            path;                // My path
  45.         static integer            moveType;            // How I move along the path
  46.  
  47.         static integer            piloting;            // Piloting skill
  48.         static integer            gunnery;            // Gunnery skill/chance to hit
  49.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  50.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  51.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  52.                                                     // and other things.  It indicates a general level of combat experience.
  53.         static integer            attackThrottle;        // My attack throttle
  54.  
  55.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  56.  
  57.         static integer             attackSound;        // The attack sound I play when I first attack
  58.         static integer             deathSound;            // The sound I play when I die
  59.         
  60.         static integer            mood;                // My default mood.
  61.         static integer            speed;                // The speed at which I move along the path
  62.  
  63.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  64.  
  65. //------------------------------------------------------------------
  66. //     Init: my initialization function
  67. //------------------------------------------------------------------
  68.  
  69. function Init;
  70.     code
  71.         // script-specific variables
  72.         fleeRange        = 500;
  73.         stopFleeingRange    = fleeRange + 500;
  74.         path            = -1;
  75.         moveType        = move_circle;
  76.         speed            = 600;
  77.         fleeSpeed        = 600;
  78.  
  79.         takeOffDistance    = 150;
  80.  
  81.         // driver settings
  82.         piloting        = 50;
  83.         gunnery            = 30;
  84.         minDelay        = 1.5;
  85.         maxDelay        = 3.0;
  86.         eliteLevel        = 30;
  87.         attackThrottle    = 80;
  88.         isShotRadius    = 120;
  89.         attackSound        = -1; // no sound
  90.         deathSound        = -1; // no sound
  91.         mood            = NEUTRAL_START;
  92.  
  93. endfunction;
  94.  
  95. //------------------------------------------------------------------
  96. //    StartState: my initial state
  97. //------------------------------------------------------------------
  98.  
  99. state StartState;
  100.  
  101.     code
  102.         SetFiringDelay            (ME,minDelay,maxDelay);
  103.         SetIgnoreFriendlyFire    (ME,true);
  104.         SetIsShotRadius            (ME,isShotRadius);
  105.         SetEntropyMood            (ME,mood);
  106.         SetCurMood                (ME,mood);
  107.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  108.         SetAttackThrottle        (ME,attackThrottle);
  109.                 
  110.         if (orderTakeOff(takeOffDistance) == true) then
  111.             trans FollowPathState;
  112.         endif;
  113.  
  114. endstate;
  115.  
  116. //------------------------------------------------------------------
  117. //    FollowPathState: follow our path, but keep an eye out for enemies
  118. //------------------------------------------------------------------
  119.  
  120. state FollowPathState;
  121.     code
  122.         if (FindEnemy(fleeRange,FT_DEFAULT)) then
  123.             trans FleeState;
  124.         endif;
  125.  
  126.         if (path <> -1) then
  127.             OrderMoveResumePatrol(path,speed,moveType,true,false);
  128.         else
  129.             OrderMoveLookOut;
  130.         endif;
  131. endstate;
  132.  
  133. //------------------------------------------------------------------
  134. //    FleeState: run away from my target
  135. //------------------------------------------------------------------
  136.  
  137. state FleeState;
  138.     code
  139.         if (LeaveAttackState(stopFleeingRange)) then
  140.             ClearMoveOrder(ME);
  141.             SetTarget(ME,NO_UNIT);
  142.             trans FollowPathState;
  143.         endif;
  144.  
  145.         if (attackSound <> -1) then    
  146.             PlaySoundOnce(attackSound);
  147.         endif;
  148.  
  149.         OrderMoveFlee(GetTarget(ME),600);
  150.  
  151. endstate;
  152.  
  153. //------------------------------------------------------------------
  154. //    DeadState: OK, I kicked the bucket.
  155. //------------------------------------------------------------------
  156.  
  157. state DeadState;
  158.     code
  159.         if (deathSound <> -1) then    
  160.             PlaySoundOnce(deathSound);
  161.         endif;        
  162.  
  163.         orderDie;
  164.  
  165. endstate;
  166.  
  167.  
  168. endfsm.
  169.  
  170.