AMAI Plugins/Job Creation
Warning this section is an advanced part of AMAI and you need to be fluent in jass

Since version 2.41 it is now possible to make your own code segmants for the ai to follow. This will control the ai in a certain way. Maybe you want to make a script that controls the how players use shops. You can either make your own or edit the already inbuilt ones included.

Jobs are basically the equivelent of triggers in warcraft 3 as they run independent of the warcaft script. (In actual fact it only appears to be running independent, of course they are not truly running independent. :D ).This system potentially gives the AMAI engine limitless modability and power. Due to the design of AMAI to simulate triggers, jobs CANNOT USE WAITS/SLEEP commands. Using them could completly mess up the job system.
Part 1 -Creating a Job

Jobs are found in your job directory of the developer edition. Opening up these in notepad/wordpad shows the code and functions inside. The layout of job coding is as follows. This job is in a file called THIS_JOB.eai

    #IFDEF GLOBAL
     unit u = null
     unit m = null
    #ELSE
     function StartJob takes nothing returns nothing
     call DoSomething()
     call TQAddJob(10, THIS_JOB, 0)
     endfunction
    #ENDIF

The first section you can define global variables. This is for organisation so you can relate variables to a section of code to know where they are used and defined. The second section contains all the core scripts of the job. In this example StartJob function is the entry point where the job starts. You are allowed to create other functions in this section and are not limited to this one.
NOTE: call TQAddJob() is an important part of the job system. This call allows the job to repeat. In this case the job will run again in 50 seconds. If you dont call this command then the job will only run once if its set to start.

Part 2 - Linking

Next you have to link the job into AMAI. Jobs are controlled from a jobs.txt file in your main AMAI directory. It is this file that lists all the different jobs and when they are required to run. The job will not be included into AMAI unless its linked into here. Below is the colums and what they mean.

Job ID - Unique id of job that is supposed to be the same as the Job.eai file it will use
Frequency - This depicts the order to run the jobs. Highest number job is run first before the others are checked.
Function Call - The initial function to be called when job is run (in the example above that would be StartJob())
Condition for initial start time - If there is a condition to when the job is allowed the start. If true then the job will start only somewhere between the start times otherwise it will not start automatically. You will have to call the job yourself (see part 3 for info)
minimum start time - The smallest amount of time that must pass before starting
Maximum start time - The largest amount of time that can pass before starting

Part 3 - A lternative Starts

If you do not set your job to start automatically you will have to make it start by placing a command somewhere else in the the amai code. Below are the 3 starting commands for jobs.

    call TQAddJob(time, Job ID,parameter)
    call TQAddUnitJob(time, JOB ID, parameter, unit parameter)
    call TQAddGroupJob(time, JOB ID, parameter, unit parameter, group parameter)

The parameters allows you to pass an integer, unit or group into the jobs starting function. See below code for an example.

    function StartingFunctionJob takes group g, unit u, integer p returns nothing

You have to decide where you want to put this command, most likely in another job. Placing the command in the common.eai or races.eai is possible too but take care where the command is placed.