home *** CD-ROM | disk | FTP | other *** search
/ Eigen PC: CD-ROM 37 / EPC_47.BIN / toyspace / data1.cab / Required_Files / rules / koth_ai.txt < prev    next >
Text File  |  1999-10-08  |  4KB  |  123 lines

  1.  
  2. // these macros get expanded on the host if the @1 army is AI controlled
  3.  
  4.  
  5. // @1 = color of army to do AI for, @2 = enemy color,
  6. // @3 = this colors owner number, @4 = enemy colors owner numbers
  7. // @5 = action number for attcking this enemy
  8. macro koth_enemy_ai 5
  9. {
  10.     if @1TakeHill testvar hillowner = @4 then
  11.         setvar @1Action @5,
  12.         order @1sarge1 follow @2sarge1 inmode attack,
  13.         order @1 group 1 follow @1sarge1 inmode defend,
  14.         order @1 group 2 follow @2sarge1 inmode attack,
  15.         order @1 group 3 follow @2sarge1 inmode attack,
  16.         order @1 group 4 follow @2sarge1 inmode attack,
  17.         order @1 group 5 follow @2sarge1 inmode attack,
  18.         trigger @1StartTimeOut
  19. }
  20.  
  21. // @1 = color of army to do AI for, @2-@4 = other colors,
  22. // @5 = this colors owner number, @6-8 = other colors owner numbers
  23. macro koth_ai_macro 8
  24. {
  25.     // This variable holds the current action for @1
  26.     // 0 means no action, 1 means goto hill, 2 means get powerups, 3 means defend hill,
  27.     // 4 means attack @2 sarge, 5 means attack @3 sarge, 6 means attack @4 sarge
  28.     variable @1Action 0
  29.  
  30.     expand koth_enemy_ai ( @1 @2 @5 @6 4 )
  31.     expand koth_enemy_ai ( @1 @3 @5 @7 5 )
  32.     expand koth_enemy_ai ( @1 @4 @5 @8 6 )
  33.  
  34.     if startup1 then
  35.         triggerdelay 1000 @1ChooseNewAction,
  36.         triggerdelay 2000 @1RegularOrders
  37.  
  38.     if @1ChooseNewAction then
  39.         setvar @1Action 0,
  40.         trigger @1CheckIfOnHill,
  41.         trigger @1CheckIfHillEmpty,
  42.         trigger @1ChoseAction
  43.  
  44.     // if it's time to choose a new action but we are currently owning the hill then
  45.     // we should always stay on the hill
  46.  
  47.     if @1CheckIfOnHill testvar @1Action = 0 and hillowner = @5 then
  48.         trigger @1DefendHill
  49.         
  50.     // if it's time to choose a new action and the hill is not owned then head straight for it
  51.  
  52.     if @1CheckIfHillEmpty testvar @1Action = 0 and hillowner = 0 then
  53.         trigger @1GotoHill
  54.         
  55.     // if @1 has no current action then pick an action
  56.     // ideally we would base this on how well armed we are
  57.     if @1ChooseAction testvar @1Action = 0 then random
  58.         trigger @1TakeHill,
  59.         trigger @1GetPowerUps
  60.  
  61.     // these events setup the @1Action variable and do the actions
  62.  
  63.     if @1GotoHill then
  64.         setvar @1Action 1,
  65.         order @1sarge1 goto @1hill inmode attack,
  66.         order @1 group 1 follow @1sarge1 inmode defend,
  67.         order @1 group 2 goto @1hill inmode attack,
  68.         order @1 group 3 goto @1hill inmode attack,
  69.         order @1 group 4 goto @1hill inmode attack,
  70.         order @1 group 5 goto @1hill inmode attack,
  71.         trigger @1StartTimeOut
  72.  
  73.     if @1GetPowerUps then
  74.         setvar @1Action 2,
  75.         order @1sarge1 goto @1hill inmode attack,
  76.         order @1 group 1 follow @1sarge1 inmode defend,
  77.         order @1 group 2 goto @1hill inmode attack,
  78.         order @1 group 3 goto @1hill inmode attack,
  79.         order @1 group 4 goto @1hill inmode attack,
  80.         order @1 group 5 goto @1hill inmode attack,
  81.         trigger @1StartTimeOut
  82.  
  83.     if @1DefendHill then
  84.         setvar @1Action 3,
  85.         order @1sarge1 goto @1hill inmode attack,
  86.         order @1 group 1 follow @1sarge1 inmode defend,
  87.         order @1 group 2 goto @1hill inmode defend,
  88.         order @1 group 3 goto @1hill inmode defend,
  89.         order @1 group 4 goto @1hill inmode defend,
  90.         order @1 group 5 goto @1hill inmode defend,
  91.         trigger @1StartTimeOut
  92.  
  93.     // these events chose a new action if we get on the hill
  94.  
  95.     if hillOwnerChanged then
  96.         trigger @1ChooseNewAction
  97.  
  98.     // these events choose new actions if a sarge is killed
  99.  
  100.     if killed @1sarge1 then
  101.         triggerdelay 5000 @1GetPowerups
  102.  
  103.     // these are the standing order regardless of what mode sarge is in
  104.         
  105.     if @1RegularOrders then
  106.         order @1 group 7 goto @1base inmode defend,
  107.         triggerdelay 5000 @1RegularOrders
  108.  
  109.     // timeout code - if mode has not changed for a while then change it
  110.  
  111.     variable @1TimeOutVar 0
  112.     variable @1LastTimeOutVar 1
  113.  
  114.     if @1StartTimeOut then
  115.         addvar @1TimeOutVar 1,
  116.         triggerdelay 120000 @1CheckTimeOut
  117.  
  118.     if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
  119.         trigger @1ChooseNewAction
  120.  
  121.     if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
  122.         addvar @1LastTimeOutVar 1
  123. }