home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 2 (DVD) / XENIADVD2.iso / Fragzone / Files / mw4mercseditor.exe / content / ABLScripts / GenericScripts / Generic_AttackList.abl < prev    next >
Encoding:
Text File  |  2002-10-11  |  5.3 KB  |  180 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_AttackList : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_AttackList:
  12. //   This script can be used to attack (or defend) a series of targets
  13. //   contained in a group.  The unit will use a specified tactic
  14. //   on the first living target in the group, and if that unit is
  15. //   destroyed, it will switch to the next one.  When there are no
  16. //   units left in the group, it will go on a rampage, attacking
  17. //   any enemies it can find.
  18.  
  19. //------------------------------------------------------------------
  20.  
  21.  
  22. //------------------------------------------------------------------
  23. //     Constants
  24. //------------------------------------------------------------------
  25.  
  26.     const
  27.         #include_ <content\ABLScripts\mwconst.abi>
  28.  
  29. //------------------------------------------------------------------
  30. //     Types
  31. //------------------------------------------------------------------
  32.  
  33.     type
  34.         #include_ <content\ABLScripts\mwtype.abi>
  35.     
  36.  
  37. //------------------------------------------------------------------
  38. //     Variables
  39. //------------------------------------------------------------------
  40.  
  41.     var
  42.         static integer            rampageAttackRange;        // When all my targets are destroyed, at what range do I start shooting?
  43.  
  44.         static integer            myGroupID;            // The ID of my group ... i.e. this script will
  45.                                                     // call GroupObjectID(groupID)
  46.         static integer            tactic;                // The tactic to use to attack (or defend) my targets
  47.                                                                     
  48.         static integer            piloting;            // Piloting skill
  49.         static integer            gunnery;            // Gunnery skill/chance to hit
  50.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  51.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  52.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  53.                                                     // and other things.  It indicates a general level of combat experience.
  54.         static integer            attackThrottle;        // My attack throttle
  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.         rampageAttackRange    = 1200;
  73.  
  74.         myGroupID            = 0;
  75.         tactic                = TACTIC_PICK_BEST;
  76.  
  77.         takeOffDistance    = 150;
  78.  
  79.         // driver settings
  80.         piloting        = 50;
  81.         gunnery            = 30;
  82.         minDelay        = 1.5;
  83.         maxDelay        = 3.0;
  84.         eliteLevel        = 30;
  85.         attackThrottle    = 80;
  86.         isShotRadius    = 120;
  87.         attackSound        = -1; // no sound
  88.         deathSound        = -1; // no sound
  89.         mood            = NEUTRAL_START;
  90.  
  91. endfunction;
  92.  
  93. //------------------------------------------------------------------
  94. //    StartState: my initial state
  95. //------------------------------------------------------------------
  96.  
  97. state StartState;
  98.  
  99.     code
  100.         SetFiringDelay            (ME,minDelay,maxDelay);
  101.         SetIgnoreFriendlyFire    (ME,true);
  102.         SetIsShotRadius            (ME,isShotRadius);
  103.         SetEntropyMood            (ME,mood);
  104.         SetCurMood                (ME,mood);
  105.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  106.         SetAttackThrottle        (ME,attackThrottle);
  107.                 
  108.         if (orderTakeOff(takeOffDistance) == true) then
  109.             trans AttackFirstLivingTargetState;
  110.         endif;
  111.  
  112. endstate;            
  113.  
  114. //------------------------------------------------------------------
  115. //    AttackFirstLivingTargetState: get the first object in my group, set
  116. //  it as my target, and issue the attack order with my tactic
  117. //------------------------------------------------------------------
  118.  
  119. state AttackFirstLivingTargetState;
  120.  
  121.     var
  122.         ObjectID next_target;
  123.  
  124.     code
  125.         if (GetTarget(ME) == NO_UNIT) then
  126.             next_target = GroupGetFirstObject(GroupObjectID(myGroupID));
  127.  
  128.             if (next_target == NO_UNIT) then
  129.                 trans RampageState;
  130.             endif;
  131.  
  132.             SetTarget(ME,next_target);
  133.         endif;
  134.  
  135.         if (attackSound <> -1) then    
  136.             PlaySoundOnce(attackSound);
  137.         endif;
  138.  
  139.         OrderAttackTactic(tactic,TRUE);
  140.  
  141. endstate;
  142.  
  143. //------------------------------------------------------------------
  144. //    RampageState: no targets remain -- let's kick some ass!
  145. //------------------------------------------------------------------
  146.  
  147. state RampageState;
  148.     code
  149.         if (GetTarget(ME) == NO_UNIT) then
  150.             FindEnemy(rampageAttackRange,FT_DEFAULT);
  151.         endif;
  152.  
  153.         if (GetTarget(ME) <> NO_UNIT) then
  154.             if (attackSound <> -1) then    
  155.                 PlaySoundOnce(attackSound);
  156.             endif;
  157.  
  158.             OrderAttack(TRUE);
  159.         endif;
  160.  
  161. endstate;
  162.  
  163. //------------------------------------------------------------------
  164. //    DeadState: OK, I kicked the bucket.
  165. //------------------------------------------------------------------
  166.  
  167. state DeadState;
  168.     code
  169.         if (deathSound <> -1) then    
  170.             PlaySoundOnce(deathSound);
  171.         endif;        
  172.  
  173.         orderDie;
  174.  
  175. endstate;
  176.  
  177.  
  178. endfsm.
  179.  
  180.