{
  IF ( INT_GAME_TURN == 0 )
  {
    SET $0                                     0
    DO SET_ATTACK_VARIABLE                     $0
    DO SET_DRUM_TOWER_POS                      136 80
    DO STATE_CONSTRUCT_BUILDING                ON
    DO STATE_FETCH_WOOD                        ON
    SET INT_ATTR_PREF_SPY_TRAINS               0
    SET INT_ATTR_PREF_RELIGIOUS_TRAINS         0
    SET INT_ATTR_PREF_WARRIOR_TRAINS           0
    SET INT_ATTR_PREF_FIREWARRIOR_TRAINS       0
    SET INT_ATTR_PREF_BOAT_HUTS                0
    SET INT_ATTR_PREF_BALLOON_HUTS             0
    SET INT_ATTR_MAX_BUILDINGS_ON_GO           1
    SET INT_ATTR_HOUSE_PERCENTAGE              9
    SET INT_ATTR_SPY_CHECK_FREQUENCY           64
    DO SET_DEFENCE_RADIUS                      7
    SET INT_ATTR_SHAMEN_BLAST                  32
    DO STATE_SPELL_DEFENCE                     138 82 ON
    DO SET_SPELL_ENTRY 0 INT_LIGHTNING INT_M_SPELL_TORNADO_COST 64 6 0
    DO SET_SPELL_ENTRY 1 INT_SWARM INT_M_SPELL_SWARM_COST 64 2 1
    DO SET_SPELL_ENTRY 2 INT_SWAMP INT_M_SPELL_LAND_BRIDGE_COST 64 5 0
    DO SET_SPELL_ENTRY 3 INT_HYPNOTISM INT_M_SPELL_INVISIBILITY_COST 64 4 0
    DO SET_SPELL_ENTRY 4 INT_FIRESTORM INT_M_SPELL_SWAMP_COST 64 9 0
    DO STATE_SHAMAN_GET_WILDS                  ON
    SET INT_ATTR_EXPANSION                     25
    DO STATE_HOUSE_A_PERSON                    ON
    DO STATE_STATE_BRING_NEW_PEOPLE_BACK       ON
    DO STATE_POPULATE_DRUM_TOWER               ON
    SET INT_ATTR_RETREAT_VALUE                 0
    SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT     1
    SET INT_ATTR_RANDOM_BUILD_SIDE             1
    DO STATE_DEFEND                            ON
    DO STATE_DEFEND_BASE                       ON
    SET INT_ATTR_DEFENSE_RAD_INCR              0
    SET INT_ATTR_MAX_DEFENSIVE_ACTIONS         0
    SET INT_ATTR_USE_PREACHER_FOR_DEFENCE      1
    DO STATE_PREACH                            ON
    DO STATE_FIREWARRIOR_DEFEND                ON
    SET INT_ATTR_ATTACK_PERCENTAGE             170
    DO STATE_FETCH_LOST_PEOPLE                 ON
    DO STATE_FETCH_LOST_VEHICLE                ON
    DO STATE_FETCH_FAR_VEHICLE                 ON
    DO STATE_TRAIN_PEOPLE                      OFF
    SET INT_ATTR_PREF_SPY_PEOPLE               8
    SET INT_ATTR_PREF_RELIGIOUS_PEOPLE         16
    SET INT_ATTR_PREF_WARRIOR_PEOPLE           24
    SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE       16
    DO STATE_BUILD_VEHICLE                     ON
    SET INT_ATTR_PEOPLE_PER_BALLOON            10
    SET INT_ATTR_PREF_BALLOON_DRIVERS          4
    DO STATE_AUTO_ATTACK                       ON
    SET INT_ATTR_MAX_ATTACKS                   1
    SET INT_ATTR_AWAY_BRAVE                    0
    SET INT_ATTR_AWAY_WARRIOR                  50
    SET INT_ATTR_AWAY_RELIGIOUS                25
    SET INT_ATTR_AWAY_SPY                      0
    SET INT_ATTR_AWAY_FIREWARRIOR              25
    SET INT_ATTR_AWAY_SHAMAN                   0
    SET INT_ATTR_MAX_TRAIN_AT_ONCE             1
    SET INT_ATTR_GROUP_OPTION                  0
    SET INT_ATTR_SPY_CHECK_FREQUENCY           128
    SET INT_ATTR_SPY_DISCOVER_CHANCE           5
    SET INT_ATTR_ENEMY_SPY_MAX_STAND           128
    DO TARGET_BLUE_SHAMAN
    SET $1                                     0
    SET $2                                     32
    SET $3                                     38
    SET $4                                     0
    SET $5                                     0
    SET $6                                     0
    SET $7                                     0
    SET $8                                     0
    SET $9                                     0
    SET $10                                    0
    SET $11                                    0
    SET $12                                    0
    SET $13                                    0
    SET $14                                    0
    SET $15                                    0
    SET $16                                    0
  }
  ELSE
  {
    SET $17                                    INT_MY_NUM_PEOPLE
    DECREMENT $17 5
    EVERY 256 133
    {
      IF ( INT_MY_NUM_PEOPLE < 80 )
      {
        DO SET_BUCKET_USAGE                      ON
        DO SET_BUCKET_COUNT_FOR_SPELL INT_BLAST                 8
        DO SET_BUCKET_COUNT_FOR_SPELL INT_CONVERT               8
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SWARM                 32
        DO SET_BUCKET_COUNT_FOR_SPELL INT_INVISIBILITY          40
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SHIELD                48
        DO SET_BUCKET_COUNT_FOR_SPELL INT_LAND_BRIDGE           66
        DO SET_BUCKET_COUNT_FOR_SPELL INT_LIGHTNING             64
        DO SET_BUCKET_COUNT_FOR_SPELL INT_HYPNOTISM             70
        DO SET_BUCKET_COUNT_FOR_SPELL INT_TORNADO               72
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SWAMP                 80
        DO SET_BUCKET_COUNT_FOR_SPELL INT_FLATTEN               100
        DO SET_BUCKET_COUNT_FOR_SPELL INT_EARTHQUAKE            140
        DO SET_BUCKET_COUNT_FOR_SPELL INT_EROSION               168
        DO SET_BUCKET_COUNT_FOR_SPELL INT_FIRESTORM             320
        DO SET_BUCKET_COUNT_FOR_SPELL INT_ANGEL_OF_DEATH        408
        DO SET_BUCKET_COUNT_FOR_SPELL INT_VOLCANO               640
      }
      ELSE
      {
        DO SET_BUCKET_USAGE                      ON
        DO SET_BUCKET_COUNT_FOR_SPELL INT_BLAST                 4
        DO SET_BUCKET_COUNT_FOR_SPELL INT_CONVERT               4
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SWARM                 16
        DO SET_BUCKET_COUNT_FOR_SPELL INT_INVISIBILITY          20
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SHIELD                24
        DO SET_BUCKET_COUNT_FOR_SPELL INT_LAND_BRIDGE           33
        DO SET_BUCKET_COUNT_FOR_SPELL INT_LIGHTNING             32
        DO SET_BUCKET_COUNT_FOR_SPELL INT_HYPNOTISM             35
        DO SET_BUCKET_COUNT_FOR_SPELL INT_TORNADO               36
        DO SET_BUCKET_COUNT_FOR_SPELL INT_SWAMP                 40
        DO SET_BUCKET_COUNT_FOR_SPELL INT_FLATTEN               50
        DO SET_BUCKET_COUNT_FOR_SPELL INT_EARTHQUAKE            70
        DO SET_BUCKET_COUNT_FOR_SPELL INT_EROSION               84
        DO SET_BUCKET_COUNT_FOR_SPELL INT_FIRESTORM             180
        DO SET_BUCKET_COUNT_FOR_SPELL INT_ANGEL_OF_DEATH        204
        DO SET_BUCKET_COUNT_FOR_SPELL INT_VOLCANO               320
      }
      ENDIF
    }
    EVERY 256
    {
      DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 20 5 $7
      IF ( $7 > 4 )
      {
        DO CONVERT_AT_MARKER                     20
      }
      ENDIF
    }
    EVERY 2048
    {
      IF ( INT_MY_MANA > INT_M_SPELL_FLATTEN_COST && $2 < 36 )
      {
        DO COUNT_PEOPLE_IN_MARKER BLUE 6 10 $4
        IF ( $4 > 12 && $2 > 29 )
        {
          DO GET_HEIGHT_AT_POS                    $2 $14
          IF ( $14 > 500 )
          {
            DO SPELL_ATTACK INT_FLATTEN $2 0
            DECREMENT $2 1
          }
          ELSE
          {
            INCREMENT $2 1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 2048 200
    {
      IF ( INT_MY_MANA > INT_M_SPELL_FLATTEN_COST && $3 < 42 )
      {
        DO COUNT_PEOPLE_IN_MARKER BLUE 7 8 $5
        IF ( $5 > 12 && $3 > 35 )
        {
          DO GET_HEIGHT_AT_POS                    $3 $15
          IF ( $15 > 500 )
          {
            DO SPELL_ATTACK INT_FLATTEN $3 0
            DECREMENT $3 1
          }
          ELSE
          {
            INCREMENT $3 1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512
    {
      SET $16                                   INT_M_BUILDING_SMALL_HUT
      INCREMENT $16 INT_M_BUILDING_LARGE_HUT
      INCREMENT $16 INT_M_BUILDING_MEDIUM_HUT
      IF ( INT_MY_NUM_PEOPLE > 10 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         2
        SET INT_ATTR_HOUSE_PERCENTAGE            15
      }
      ENDIF
    }
    EVERY 512 10
    {
      IF ( INT_MY_NUM_PEOPLE > 14 && $16 > 1 )
      {
        SET INT_ATTR_PREF_SPY_TRAINS             0
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       1
        SET INT_ATTR_PREF_WARRIOR_TRAINS         1
        SET INT_ATTR_PREF_FIREWARRIOR_TRAINS     0
        SET INT_ATTR_PREF_BOAT_HUTS              0
        SET INT_ATTR_PREF_BALLOON_HUTS           0
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         3
        DO STATE_TRAIN_PEOPLE                    ON
        SET INT_ATTR_HOUSE_PERCENTAGE            25
      }
      ENDIF
    }
    EVERY 512 20
    {
      IF ( INT_MY_NUM_PEOPLE > 25 && INT_M_PERSON_WARRIOR > 4 )
      {
        IF ( $16 > 2 )
        {
          SET INT_ATTR_PREF_SPY_TRAINS            1
          SET INT_ATTR_PREF_RELIGIOUS_TRAINS      1
          SET INT_ATTR_PREF_WARRIOR_TRAINS        1
          SET INT_ATTR_PREF_FIREWARRIOR_TRAINS    0
          SET INT_ATTR_PREF_BOAT_HUTS             0
          SET INT_ATTR_PREF_BALLOON_HUTS          1
          SET INT_ATTR_MAX_BUILDINGS_ON_GO        4
          SET INT_ATTR_HOUSE_PERCENTAGE           40
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 30
    {
      IF ( INT_M_PERSON_WARRIOR > 6 )
      {
        IF ( INT_M_BUILDING_LARGE_HUT > 3 )
        {
          SET INT_ATTR_PREF_FIREWARRIOR_TRAINS    1
          SET INT_ATTR_PREF_WARRIOR_TRAINS        2
          SET INT_ATTR_MAX_BUILDINGS_ON_GO        5
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 1024
    {
      IF ( INT_M_PERSON_SPY > 0 && INT_M_VEHICLE_AIRSHIP > 0 )
      {
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                0
        SET INT_ATTR_AWAY_RELIGIOUS              0
        SET INT_ATTR_AWAY_SPY                    100
        SET INT_ATTR_AWAY_FIREWARRIOR            0
        SET INT_ATTR_AWAY_SHAMAN                 0
        SET INT_ATTR_EMPTY_AT_WAYPOINT           1
        DO ATTACK BLUE 1 ATTACK_BUILDING INT_WARRIOR_TRAIN 10 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_BY_BALLOON 1 15 -1 -1
        SET INT_ATTR_MAX_SPY_ATTACKS             1
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                50
        SET INT_ATTR_AWAY_RELIGIOUS              25
        SET INT_ATTR_AWAY_SPY                    0
        SET INT_ATTR_AWAY_FIREWARRIOR            25
        SET INT_ATTR_AWAY_SHAMAN                 0
      }
      ENDIF
    }
    EVERY 1024 80
    {
      IF ( INT_MY_MANA > INT_M_SPELL_FIRESTORM_COST )
      {
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                50
        SET INT_ATTR_AWAY_RELIGIOUS              25
        SET INT_ATTR_AWAY_SPY                    0
        SET INT_ATTR_AWAY_FIREWARRIOR            25
        SET INT_ATTR_AWAY_SHAMAN                 1
      }
      ELSE
      {
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                50
        SET INT_ATTR_AWAY_RELIGIOUS              25
        SET INT_ATTR_AWAY_SPY                    0
        SET INT_ATTR_AWAY_FIREWARRIOR            25
        SET INT_ATTR_AWAY_SHAMAN                 0
      }
      ENDIF
    }
    EVERY 512 40
    {
      IF ( INT_M_BUILDING_AIRSHIP_HUT > 0 && INT_M_PERSON_WARRIOR > 7 )
      {
        IF ( $17 > INT_BLUE_PEOPLE )
        {
          SET $18                                 INT_MY_NUM_PEOPLE
          DECREMENT $18 INT_BLUE_PEOPLE
          DIVIDE $19 $18 2
          IF ( INT_M_VEHICLE_AIRSHIP > $19 )
          {
            DO ATTACK BLUE $18 ATTACK_BUILDING INT_DRUM_TOWER 10 INT_FIRESTORM INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_BY_BALLOON 0 -1 -1 -1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 50
    {
      DO COUNT_PEOPLE_IN_MARKER BLUE 3 10 $6
      DIVIDE $20 $6 2
      IF ( $6 > 5 && INT_M_VEHICLE_AIRSHIP > $20 )
      {
        DO ATTACK BLUE $6 ATTACK_MARKER 3 70 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_BY_BALLOON 1 -1 -1 -1
      }
      ENDIF
    }
    EVERY 128 120
    {
      IF ( INT_B_BUILDING_TEMPLE > 0 )
      {
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       1
      }
      ENDIF
    }
    EVERY 64 55
    {
      IF ( INT_MY_NUM_PEOPLE < 8 && INT_MY_NUM_KILLED_BY_BLUE > 5 )
      {
        DO GIVE_UP_AND_SULK                      ON
      }
      ENDIF
    }
  }
  ENDIF
}
SCRIPT_END
