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

  1. // @1 = color to do AI for, @2 = color of enemy, @3 = value for @1Action variable
  2. macro killer_ai_enemy 3
  3. {
  4.     // these events setup the @1Action variable
  5.  
  6.     // before attacking @2 make sure @2 is in the game and is not an ally
  7.     if @1SetAttack@2 testvar IsColorInGame @2 > 0 and IsAlly @1 @2 = 0 then
  8.         setvar @1Action 1,
  9.         trigger @1Attack@2,
  10.         trigger @1StartTimeOut
  11.  
  12.     // these events do the actual attack orders
  13.  
  14.     if @1Attack@2 testvar @1Action = @3 then
  15.         order @1sarge1 follow @2sarge1 inmode attack,
  16.         order @1 group 1 follow @1sarge1 inmode defend,
  17.         order @1 group 2 follow @2sarge1 inmode attack,
  18.         order @1 group 3 follow @2sarge1 inmode attack,
  19.         order @1 group 4 follow @2sarge1 inmode attack,
  20.         order @1 group 5 follow @2sarge1 inmode attack,
  21. }
  22.  
  23. // @1 = color of army to do AI for, @2-@4 = other colors
  24. macro killer_ai_macro 4
  25. {
  26.     // This variable holds the current action for @1
  27.     // 0 means no action, 1 means attack @2, 2 means attack @3, 3 means attack @4,
  28.     // 4 means follow black flag
  29.     variable @1Action 0
  30.  
  31.     if startup1 then
  32.         triggerdelay 1000 @1ChooseNewAction,
  33.         triggerdelay 2000 @1RegularOrders
  34.  
  35.     if @1ChooseNewAction then
  36.         setvar @1Action 0,
  37.         trigger @1ChooseAction
  38.  
  39.     // if @1 has no current action then pick a random action
  40.     // keep doing this until an action is set
  41.     if @1ChooseAction testvar @1Action = 0 and hasitem @1sarge1 blackflag1 = 1 then
  42.         trigger @1PickRandomAction,
  43.         triggerdelay 1000 @1ChooseAction
  44.  
  45.     if @1ChooseAction testvar @1Action = 0 and hasitem @1sarge1 blackflag1 = 0 then
  46.         trigger @1FollowBlackFlag
  47.  
  48.     if @1PickRandomAction then random
  49.         trigger @1SetAttack@2,
  50.         trigger @1SetAttack@3,
  51.         trigger @1SetAttack@4
  52.  
  53.     expand killer_ai_enemy ( @1 @2 1 )
  54.     expand killer_ai_enemy ( @1 @3 2 )
  55.     expand killer_ai_enemy ( @1 @4 3 )
  56.  
  57.  
  58.     if @1FollowBlackFlag then
  59.         setvar @1Action 4,
  60.         trigger @1StartTimeOut,
  61.         order @1sarge1 follow blackflag1 inmode attack,
  62.         order @1 group 1 follow @1sarge1 inmode defend,
  63.         order @1 group 2 follow blackflag1 inmode attack,
  64.         order @1 group 3 follow blackflag1 inmode attack,
  65.         order @1 group 4 follow blackflag1 inmode attack,
  66.         order @1 group 5 follow blackflag1 inmode attack
  67.  
  68.     // these events choose new actions if a sarge is killed
  69.  
  70.     if killed sarge by @1 then
  71.         triggerdelay 5000 @1ChooseNewAction
  72.  
  73.     if killed @1sarge1 then
  74.         triggerdelay 5000 @1ChooseNewAction
  75.  
  76.     if pickedup blackflag1 by @1sarge1 then
  77.         triggerdelay 100 @1ChooseNewAction
  78.  
  79.     // these are the standing order regardless of what mode sarge is in
  80.         
  81.     if @1RegularOrders then
  82.         order @1 group 7 goto @1base inmode defend,
  83.         triggerdelay 5000 @1RegularOrders
  84.  
  85.     // timeout code - if mode has not changed for a while then change it
  86.  
  87.     variable @1TimeOutVar 0
  88.     variable @1LastTimeOutVar 1
  89.  
  90.     if @1StartTimeOut then
  91.         addvar @1TimeOutVar 1,
  92.         triggerdelay 120000 @1CheckTimeOut
  93.  
  94.     if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
  95.         trigger @1ChooseNewAction
  96.  
  97.     if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
  98.         addvar @1LastTimeOutVar 1
  99. }
  100.  
  101.