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_Reinforcement.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.1 KB  |  208 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_Reinforcement : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_Reinforcement:
  12. //   Shuts down, waits until a trigger, powers up, moves to a specific
  13. //   point (if specified) and attacks anything that comes near
  14.  
  15. //------------------------------------------------------------------
  16.  
  17.  
  18.  
  19. //------------------------------------------------------------------
  20. //     Constants
  21. //------------------------------------------------------------------
  22.  
  23.     const
  24.         #include_ <content\ABLScripts\mwconst.abi>
  25.  
  26. //------------------------------------------------------------------
  27. //     Types
  28. //------------------------------------------------------------------
  29.  
  30.     type
  31.         #include_ <content\ABLScripts\mwtype.abi>
  32.     
  33.  
  34. //------------------------------------------------------------------
  35. //     Variables
  36. //------------------------------------------------------------------
  37.  
  38.     var
  39.     static integer            attackRange1;        // At what range do I start shooting (as I'm moving to the point)?
  40.     static integer            attackRange2;        // At what range do I start shooting (as a reinforcement)?
  41.     static integer            withdrawRange;        // At what range do I stop shooting (as a reinforcement)?
  42.  
  43.     static integer            triggerID;            // The index of my global trigger
  44.     static LocPoint            destination;        // The destination to move to when ready
  45.                                                                 
  46.     static integer            piloting;            // Piloting skill
  47.     static integer            gunnery;            // Gunnery skill/chance to hit
  48.     static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  49.     static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  50.     static integer             speed;                // What speed so I move at?
  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.     static integer            findTypes;            // What kind of enemies to look for
  55.  
  56.      static integer            isshotradius;        // How far away from me will I detect an enemy shot?
  57.  
  58.     static integer             attackSound;        // The attack sound I play when I first attack
  59.     static integer             deathSound;            // The sound I play when I die
  60.  
  61.     static integer            mood;                // My default mood.
  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.         attackRange1    = 500;
  73.         attackRange2    = 500;
  74.         withdrawRange    = attackRange2 * 3 / 2;
  75.         triggerID        = 1;
  76.         destination[0]    = -1;
  77.         destination[1]    = -1;
  78.         destination[2]    = -1;
  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.         speed            = 600;
  89.         isshotradius    = 80;
  90.         attackSound        = -1; // no sound
  91.         deathSound        = -1; // no sound
  92.         mood            = NEUTRAL_START;
  93.         findTypes        = FT_DEFAULT;
  94.  
  95. endfunction;
  96.  
  97. //------------------------------------------------------------------
  98. //    StartState: my initial state
  99. //------------------------------------------------------------------
  100.  
  101. state StartState;
  102.  
  103.     code
  104.         SetFiringDelay            (ME,minDelay,maxDelay);
  105.         SetIgnoreFriendlyFire    (ME,true);
  106.         SetIsShotRadius            (ME,isshotradius);
  107.         SetEntropyMood            (ME,mood);
  108.         SetCurMood                (ME,mood);
  109.         SetSkillLevel            (ME,piloting,gunnery,elitelevel);
  110.         SetAttackThrottle        (ME,attackThrottle);
  111.                 
  112.         trans ShutdownAndWaitState;
  113.  
  114. endstate;        
  115.  
  116. //------------------------------------------------------------------
  117. //    ShutdownAndWaitState: shut down and wait for the trigger to be set, then go
  118. //------------------------------------------------------------------
  119.  
  120. state ShutdownAndWaitState;
  121.     code
  122.         Shutdown(ME);
  123.  
  124.         if (GetGlobalTrigger(triggerID)) then
  125.             if (orderTakeOff(takeOffDistance) == true) then
  126.                 Startup(ME);
  127.  
  128.                 if ((destination[0] == -1) and (destination[1] == -1) and (destination[2] == -1)) then
  129.                     trans AttackState;
  130.                 endif;
  131.  
  132.                 trans MoveToPointState;
  133.             endif;
  134.         endif;
  135.  
  136. endstate;
  137.  
  138. //------------------------------------------------------------------
  139. //    MoveToPointState: go to the destination, and attack when we get there
  140. //------------------------------------------------------------------
  141.  
  142. state MoveToPointState;
  143.     code
  144.         if (OrderMoveToLocPoint(destination,speed,true,true)) then
  145.             orderstopattacking;
  146.             SetTarget(ME,NO_UNIT);
  147.             trans WaitAtPointState;
  148.         else
  149.             if (FindEnemy(attackRange1,findTypes)) then
  150.  
  151.                 if (attackSound <> -1) then    
  152.                     PlaySoundOnce(attackSound);
  153.                 endif;
  154.  
  155.                 OrderAttack(false);
  156.             endif;
  157.         endif;
  158. endstate;
  159.  
  160. //------------------------------------------------------------------
  161. //    WaitAtPointState: I got to the point; let's look around
  162. //------------------------------------------------------------------
  163.  
  164. state WaitAtPointState;
  165.     code
  166.         if (FindEnemy(attackRange2,findTypes)) then
  167.             trans AttackState;
  168.         endif;
  169. endstate;
  170.  
  171. //------------------------------------------------------------------
  172. //    AttackState: let's find someone and hurt them
  173. //------------------------------------------------------------------
  174.  
  175. state AttackState;
  176.     code
  177.         if (LeaveAttackState(withdrawRange)) then
  178.             OrderStopAttacking;
  179.             SetTarget(ME,NO_UNIT);
  180.             trans MoveToPointState;
  181.         endif;
  182.  
  183.         if (attackSound <> -1) then    
  184.             PlaySoundOnce(attackSound);
  185.         endif;
  186.  
  187.         OrderAttack(TRUE);
  188.  
  189. endstate;
  190.  
  191. //------------------------------------------------------------------
  192. //    DeadState: OK, I kicked the bucket.
  193. //------------------------------------------------------------------
  194.  
  195. state DeadState;
  196.   code
  197.         if (deathSound <> -1) then    
  198.             PlaySoundOnce(deathSound);
  199.         endif;        
  200.  
  201.         orderDie;
  202.  
  203. endstate;
  204.  
  205.  
  206. endfsm.
  207.  
  208.