{
  IF ( INT_GAME_TURN == 0 )
  {
    SET $0                                     0
    DO SET_ATTACK_VARIABLE                     $0
    DO STATE_STATE_BRING_NEW_PEOPLE_BACK       ON
    DO STATE_SHAMAN_GET_WILDS                  ON
    DO STATE_CONSTRUCT_BUILDING                ON
    DO STATE_FETCH_WOOD                        ON
    DO SET_DRUM_TOWER_POS                      208 128
    SET INT_ATTR_PREF_SPY_TRAINS               0
    SET INT_ATTR_PREF_WARRIOR_TRAINS           0
    SET INT_ATTR_PREF_FIREWARRIOR_TRAINS       0
    SET INT_ATTR_PREF_RELIGIOUS_TRAINS         0
    SET INT_ATTR_PREF_BOAT_HUTS                0
    SET INT_ATTR_PREF_BALLOON_HUTS             0
    SET INT_ATTR_MAX_BUILDINGS_ON_GO           2
    SET INT_ATTR_HOUSE_PERCENTAGE              10
    SET INT_ATTR_EXPANSION                     28
    DO STATE_POPULATE_DRUM_TOWER               ON
    SET INT_ATTR_SHAMEN_BLAST                  128
    DO STATE_SPELL_DEFENCE                     206 128 ON
    DO SET_SPELL_ENTRY 0 INT_LIGHTNING INT_M_SPELL_TORNADO_COST 64 6 0
    SET INT_ATTR_RETREAT_VALUE                 25
    SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT     1
    SET INT_ATTR_RANDOM_BUILD_SIDE             1
    DO SET_DEFENCE_RADIUS                      7
    DO SET_MARKER_ENTRY                        1 17 18 0 5 0 1
    DO SET_MARKER_ENTRY                        2 5 6 0 10 0 3
    DO SET_MARKER_ENTRY                        3 29 30 0 5 0 1
    DO SET_MARKER_ENTRY                        4 31 32 0 10 0 3
    DO SET_MARKER_ENTRY                        5 35 -1 0 4 0 1
    DO SET_MARKER_ENTRY                        6 36 -1 0 4 0 1
    DO SET_MARKER_ENTRY                        7 37 -1 0 4 0 1
    DO SET_MARKER_ENTRY                        8 38 -1 0 4 0 1
    SET INT_ATTR_SPY_DISCOVER_CHANCE           30
    SET INT_ATTR_ENEMY_SPY_MAX_STAND           255
    SET INT_ATTR_MAX_TRAIN_AT_ONCE             7
    SET INT_ATTR_GROUP_OPTION                  0
    DO SET_BASE_MARKER                         34
    DO SET_BASE_RADIUS                         24
    DO STATE_DEFEND                            ON
    DO STATE_DEFEND_BASE                       ON
    SET INT_ATTR_DEFENSE_RAD_INCR              5
    SET INT_ATTR_MAX_DEFENSIVE_ACTIONS         2
    SET INT_ATTR_ATTACK_PERCENTAGE             90
    SET INT_ATTR_USE_PREACHER_FOR_DEFENCE      1
    DO STATE_PREACH                            ON
    DO STATE_TRAIN_PEOPLE                      ON
    SET INT_ATTR_PREF_WARRIOR_PEOPLE           10
    SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE       0
    SET INT_ATTR_PREF_RELIGIOUS_PEOPLE         5
    DO STATE_HOUSE_A_PERSON                    ON
    DO STATE_AUTO_ATTACK                       ON
    SET INT_ATTR_MAX_ATTACKS                   1
    SET INT_ATTR_AWAY_BRAVE                    0
    SET INT_ATTR_AWAY_WARRIOR                  88
    SET INT_ATTR_AWAY_RELIGIOUS                12
    SET INT_ATTR_AWAY_SPY                      0
    SET INT_ATTR_AWAY_FIREWARRIOR              0
    SET INT_ATTR_AWAY_SHAMAN                   1
    DO STATE_FETCH_LOST_PEOPLE                 ON
    DO STATE_FETCH_LOST_VEHICLE                ON
    DO STATE_FETCH_FAR_VEHICLE                 ON
    DO TARGET_FIREWARRIORS
    DO TARGET_BLUE_SHAMAN
    SET $1                                     0
    SET $2                                     0
    SET $3                                     0
    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                                    5
    SET $16                                    5
    SET $17                                    7
    SET $18                                    7
    SET $19                                    0
    SET $20                                    0
    SET $21                                    0
    SET $22                                    1
    SET $23                                    0
    SET $24                                    0
    SET $25                                    0
    SET $26                                    0
    SET $27                                    0
    SET $28                                    0
    SET $29                                    0
    SET $30                                    0
    SET $31                                    0
    SET $32                                    INT_M_SPELL_LAND_BRIDGE_COST
    INCREMENT $32 INT_M_SPELL_LIGHTNING_COST
  }
  ELSE
  {
    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 512 340
    {
      IF ( INT_MY_NUM_PEOPLE > 10 && INT_M_BUILDING_SMALL_HUT > 2 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         2
        SET INT_ATTR_HOUSE_PERCENTAGE            15
        SET INT_ATTR_PREF_SPY_TRAINS             0
        SET INT_ATTR_PREF_WARRIOR_TRAINS         1
        SET INT_ATTR_PREF_FIREWARRIOR_TRAINS     0
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       1
        SET INT_ATTR_PREF_BOAT_HUTS              0
        SET INT_ATTR_PREF_BALLOON_HUTS           0
        SET INT_ATTR_PREF_WARRIOR_PEOPLE         15
        SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE     0
        SET INT_ATTR_PREF_RELIGIOUS_PEOPLE       5
      }
      ENDIF
    }
    EVERY 512 360
    {
      IF ( INT_MY_NUM_PEOPLE > 20 && INT_M_BUILDING_LARGE_HUT > 0 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         4
        SET INT_ATTR_HOUSE_PERCENTAGE            20
        SET INT_ATTR_PREF_WARRIOR_PEOPLE         20
        SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE     0
        SET INT_ATTR_PREF_RELIGIOUS_PEOPLE       10
      }
      ENDIF
    }
    EVERY 512 380
    {
      IF ( INT_MY_NUM_PEOPLE > 45 && INT_M_BUILDING_LARGE_HUT > 2 )
      {
        SET INT_ATTR_HOUSE_PERCENTAGE            15
        SET INT_ATTR_PREF_WARRIOR_PEOPLE         25
        SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE     0
        SET INT_ATTR_PREF_RELIGIOUS_PEOPLE       10
      }
      ENDIF
    }
    EVERY 512 455
    {
      IF ( INT_MY_NUM_PEOPLE > 35 && INT_M_BUILDING_LARGE_HUT > 1 )
      {
        IF ( INT_M_PERSON_RELIGIOUS > 1 && INT_CP_FREE_ENTRIES > 1 )
        {
          IF ( $14 == 0 )
          {
            DO BUILD_DRUM_TOWER                    186 96
            SET $14                                1
          }
          ELSE
          {
            DO PUT_PERSON_IN_DT INT_RELIGIOUS 186 96
            DO PUT_PERSON_IN_DT INT_RELIGIOUS 208 128
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 445
    {
      IF ( INT_M_PERSON_WARRIOR > 6 )
      {
        DO MARKER_ENTRIES                        5 6 7 8
      }
      ENDIF
    }
    EVERY 1024 400
    {
      IF ( $20 == 0 )
      {
        IF ( INT_MY_MANA > $32 && INT_MY_NUM_PEOPLE > 22 )
        {
          IF ( INT_M_PERSON_WARRIOR > 5 )
          {
            DO ATTACK BLUE $16 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 128 INT_LAND_BRIDGE INT_LIGHTNING INT_BLAST ATTACK_NORMAL 0 0 16 -1
            DO MARKER_ENTRIES                      1 -1 -1 -1
            SET $8                                 1
            SET $20                                1
            IF ( $16 < 20 )
            {
              INCREMENT $16 2
            }
            ELSE
            {
              SET $16                               12
            }
            ENDIF
          }
          ENDIF
        }
        ENDIF
      }
      ELSE
      {
        IF ( $20 == 1 )
        {
          DO GET_HEIGHT_AT_POS                    15 $31
          IF ( $31 == 0 )
          {
            SET $20                                0
          }
          ELSE
          {
            SET $20                                2
          }
          ENDIF
        }
        ELSE
        {
          IF ( $20 > 1 )
          {
            IF ( INT_MY_MANA > $32 && INT_MY_NUM_PEOPLE > 32 )
            {
              IF ( INT_M_PERSON_WARRIOR > 5 )
              {
                DO GET_HEIGHT_AT_POS                 28 $21
                IF ( $21 == 0 )
                {
                  DO ATTACK BLUE $16 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 128 INT_LIGHTNING INT_LIGHTNING INT_BLAST ATTACK_NORMAL 0 0 -1 -1
                  IF ( $16 < 20 )
                  {
                    INCREMENT $16 2
                  }
                  ELSE
                  {
                    SET $16                            12
                  }
                  ENDIF
                }
                ELSE
                {
                  DO ATTACK $22 $15 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 999 INT_LIGHTNING INT_LIGHTNING INT_BLAST ATTACK_NORMAL 0 26 -1 -1
                  DO CLEAR_GUARDING_FROM              5 6 7 8
                  DO MARKER_ENTRIES                   3 -1 -1 -1
                  SET $9                              1
                  IF ( $15 < 20 )
                  {
                    INCREMENT $15 2
                  }
                  ELSE
                  {
                    SET $15                            15
                  }
                  ENDIF
                  IF ( $22 == 1 )
                  {
                    SET $22                            0
                  }
                  ELSE
                  {
                    SET $22                            1
                  }
                  ENDIF
                }
                ENDIF
              }
              ENDIF
            }
            ENDIF
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 430
    {
      IF ( $8 == 1 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $10 == 0 )
        {
          DO BUILD_DRUM_TOWER                     152 94
          SET $10                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 152 94
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 330
    {
      IF ( $9 == 1 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $11 == 0 )
        {
          DO BUILD_DRUM_TOWER                     188 180
          SET $11                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 188 180
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 440
    {
      IF ( $8 == 1 && $4 == 0 )
      {
        DO COUNT_PEOPLE_IN_MARKER BLUE 16 6 $6
        IF ( $6 > 3 )
        {
          DO CLEAR_GUARDING_FROM                  1 -1 -1 -1
          DO MARKER_ENTRIES                       2 -1 -1 -1
          SET $4                                  1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 450
    {
      IF ( $9 == 1 && $5 == 0 )
      {
        DO COUNT_PEOPLE_IN_MARKER BLUE 27 6 $7
        IF ( $7 > 3 )
        {
          DO CLEAR_GUARDING_FROM                  3 -1 -1 -1
          DO MARKER_ENTRIES                       4 -1 -1 -1
          SET $5                                  1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 32 13
    {
      IF ( $25 == 0 )
      {
        DO GET_HEAD_TRIGGER_COUNT 120 118 $26
        IF ( $26 == 0 )
        {
          DO TRIGGER_THING                        44
          IF ( INT_YELLOW_PEOPLE > 9 )
          {
            DO DISABLE_USER_INPUTS
            SET $30                                1
            DO CREATE_MSG_INFORMATION              76
            DO SET_MSG_DELETE_ON_OK
            SET $30                                0
            DO ZOOM_TO                             168 176 417
            DO ENABLE_USER_INPUTS
            SET $25                                1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 16 3
    {
      IF ( $28 == 0 )
      {
        DO GET_NUM_ONE_OFF_SPELLS 0 INT_HYPNOTISM $29
        IF ( $29 > 0 )
        {
          IF ( $30 == 0 )
          {
            SET $30                                1
            DO CREATE_MSG_INFORMATION              108
            DO SET_MSG_DELETE_ON_OK
            SET $30                                0
            SET $28                                1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 55
    {
      IF ( INT_MY_NUM_PEOPLE < 8 && INT_MY_NUM_KILLED_BY_BLUE > 5 )
      {
        SET $33                                  INT_M_BUILDING_SMALL_HUT
        INCREMENT $33 INT_M_BUILDING_MEDIUM_HUT
        INCREMENT $33 INT_M_BUILDING_LARGE_HUT
        IF ( $33 == 0 )
        {
          DO GIVE_UP_AND_SULK                     ON
        }
        ENDIF
      }
      ENDIF
    }
  }
  ENDIF
}
SCRIPT_END
