{
  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 DELAY_MAIN_DRUM_TOWER
    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         0
    SET INT_ATTR_PREF_BOAT_HUTS                0
    SET INT_ATTR_PREF_BALLOON_HUTS             0
    SET INT_ATTR_MAX_BUILDINGS_ON_GO           4
    SET INT_ATTR_HOUSE_PERCENTAGE              9
    SET INT_ATTR_EXPANSION                     38
    DO STATE_POPULATE_DRUM_TOWER               ON
    SET INT_ATTR_SPY_DISCOVER_CHANCE           30
    SET INT_ATTR_ENEMY_SPY_MAX_STAND           255
    DO SET_BASE_MARKER                         33
    DO SET_BASE_RADIUS                         25
    DO CONVERT_AT_MARKER                       19
    SET INT_ATTR_SHAMEN_BLAST                  128
    DO STATE_SPELL_DEFENCE                     140 184 ON
    DO SET_SPELL_ENTRY 0 INT_LIGHTNING INT_M_SPELL_TORNADO_COST 128 6 0
    DO SET_SPELL_ENTRY 1 INT_SWARM INT_M_SPELL_SWARM_COST 128 2 0
    SET INT_ATTR_RETREAT_VALUE                 25
    SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT     1
    SET INT_ATTR_RANDOM_BUILD_SIDE             1
    SET INT_ATTR_MAX_TRAIN_AT_ONCE             5
    SET INT_ATTR_GROUP_OPTION                  0
    DO STATE_DEFEND                            ON
    DO STATE_DEFEND_BASE                       ON
    SET INT_ATTR_DEFENSE_RAD_INCR              2
    SET INT_ATTR_MAX_DEFENSIVE_ACTIONS         2
    SET INT_ATTR_ATTACK_PERCENTAGE             75
    SET INT_ATTR_USE_PREACHER_FOR_DEFENCE      1
    DO STATE_PREACH                            ON
    DO STATE_TRAIN_PEOPLE                      ON
    SET INT_ATTR_PREF_WARRIOR_PEOPLE           40
    SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE       0
    SET INT_ATTR_PREF_RELIGIOUS_PEOPLE         15
    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                  80
    SET INT_ATTR_AWAY_RELIGIOUS                30
    SET INT_ATTR_AWAY_SPY                      0
    SET INT_ATTR_AWAY_FIREWARRIOR              0
    SET INT_ATTR_AWAY_SHAMAN                   0
    DO STATE_FETCH_LOST_PEOPLE                 ON
    DO STATE_FETCH_LOST_VEHICLE                ON
    DO STATE_FETCH_FAR_VEHICLE                 ON
    DO SET_MARKER_ENTRY                        1 9 10 0 3 0 0
    DO SET_MARKER_ENTRY                        2 11 12 0 3 0 0
    DO SET_MARKER_ENTRY                        3 21 22 0 3 0 0
    DO SET_MARKER_ENTRY                        4 23 -1 0 3 0 0
    DO SET_MARKER_ENTRY                        5 24 -1 0 3 0 0
    DO SET_MARKER_ENTRY                        6 42 -1 0 1 0 0
    DO ONLY_STAND_AT_MARKERS
    DO MARKER_ENTRIES                          6 -1 -1 -1
    DO CREATE_MSG_NARRATIVE                    75
    DO SET_MSG_AUTO_OPEN_DLG
    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                                    0
    SET $16                                    0
    SET $17                                    0
    SET $18                                    0
    SET $19                                    0
  }
  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 8
    {
      IF ( INT_GAME_TURN > 5 )
      {
        IF ( $19 == 0 )
        {
          SET $19                                 1
          DO FLYBY_CREATE_NEW
          DO FLYBY_ALLOW_INTERRUPT                ON
          DO FLYBY_SET_EVENT_POS                  120 118 1 40
          DO FLYBY_SET_EVENT_POS                  154 216 42 50
          DO FLYBY_SET_EVENT_POS                  212 116 93 60
          DO FLYBY_SET_EVENT_POS                  114 52 154 30
          DO FLYBY_SET_EVENT_POS                  58 52 185 30
          DO FLYBY_SET_EVENT_ANGLE                1258 20 30
          DO FLYBY_SET_EVENT_ANGLE                1497 35 25
          DO FLYBY_SET_EVENT_ANGLE                913 65 37
          DO FLYBY_SET_EVENT_ANGLE                1332 133 40
          DO FLYBY_SET_EVENT_ANGLE                1452 174 35
          DO FLYBY_SET_EVENT_ANGLE                1900 210 25
          DO FLYBY_SET_EVENT_ZOOM                 60 25 20
          DO FLYBY_SET_EVENT_ZOOM                 30 50 35
          DO FLYBY_SET_EVENT_ZOOM                 -70 90 50
          DO FLYBY_SET_EVENT_ZOOM                 -30 150 30
          DO FLYBY_SET_EVENT_ZOOM                 0 195 35
          DO FLYBY_SET_END_TARGET                 58 52 1900 0
          DO FLYBY_START
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 256
    {
      IF ( INT_MY_MANA > INT_M_SPELL_SWARM_COST )
      {
        IF ( $17 < 2 )
        {
          DO COUNT_PEOPLE_IN_MARKER BLUE 20 3 $11
          IF ( $11 > 1 )
          {
            DO SPELL_ATTACK INT_SWARM 20 0
            INCREMENT $17 1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 20
    {
      IF ( INT_M_PERSON_WARRIOR > 6 )
      {
        DO MARKER_ENTRIES                        1 2 -1 -1
      }
      ENDIF
    }
    EVERY 512 40
    {
      IF ( INT_MY_NUM_PEOPLE > 9 && INT_M_BUILDING_SMALL_HUT > 2 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         4
        SET INT_ATTR_HOUSE_PERCENTAGE            18
        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       10
      }
      ENDIF
    }
    EVERY 512 60
    {
      IF ( INT_MY_NUM_PEOPLE > 20 && INT_M_BUILDING_LARGE_HUT > 0 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         3
        SET INT_ATTR_HOUSE_PERCENTAGE            25
        SET INT_ATTR_PREF_WARRIOR_PEOPLE         20
        SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE     0
        SET INT_ATTR_PREF_RELIGIOUS_PEOPLE       12
      }
      ENDIF
    }
    EVERY 128 100
    {
      IF ( INT_B_BUILDING_WARRIOR_TRAIN > 0 )
      {
        SET INT_ATTR_PREF_WARRIOR_TRAINS         1
      }
      ENDIF
    }
    EVERY 64 23
    {
      IF ( INT_B_BUILDING_TEMPLE > 0 )
      {
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       1
      }
      ENDIF
    }
    EVERY 2048
    {
      DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 13 7 $9
      IF ( $9 > 4 )
      {
        DO CONVERT_AT_MARKER                     13
      }
      ENDIF
    }
    EVERY 1024 33
    {
      DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 41 7 $9
      IF ( $9 > 4 )
      {
        DO CONVERT_AT_MARKER                     13
      }
      ENDIF
    }
    EVERY 512 180
    {
      IF ( $1 == 0 )
      {
        IF ( INT_M_PERSON_WARRIOR > 4 && INT_M_PERSON_RELIGIOUS > 2 )
        {
          SET INT_ATTR_AWAY_SHAMAN                0
          DO SET_ATTACK_VARIABLE                  $0
          DO ATTACK BLUE 4 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 20 INT_SWARM INT_LIGHTNING INT_SWARM ATTACK_NORMAL 0 7 -1 -1
          SET INT_ATTR_AWAY_SHAMAN                1
          SET $1                                  1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 200
    {
      IF ( $1 == 1 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $1                                  2
        }
        ELSE
        {
          SET $1                                  0
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 1024 220
    {
      IF ( INT_B_BUILDING_WARRIOR_TRAIN > 0 && $1 == 2 )
      {
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         4
        DO STATE_HOUSE_A_PERSON                  ON
        SET INT_ATTR_HOUSE_PERCENTAGE            30
        SET INT_ATTR_AWAY_SHAMAN                 0
        DO SET_ATTACK_VARIABLE                   $0
        DO ATTACK BLUE 5 ATTACK_BUILDING INT_WARRIOR_TRAIN 20 INT_SWARM INT_LIGHTNING INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 2 -1 -1
        SET INT_ATTR_AWAY_SHAMAN                 1
        SET $1                                   3
      }
      ENDIF
    }
    EVERY 512 240
    {
      IF ( $1 == 3 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $1                                  4
        }
        ELSE
        {
          SET $1                                  2
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 512 260
    {
      IF ( INT_MY_MANA > INT_M_SPELL_LIGHTNING_COST )
      {
        SET INT_ATTR_AWAY_SHAMAN                 1
      }
      ENDIF
    }
    EVERY 512 280
    {
      SET $20                                   INT_MY_NUM_PEOPLE
      DECREMENT $20 INT_BLUE_PEOPLE
      IF ( $20 > 0 )
      {
        DO STATE_SHAMAN_GET_WILDS                OFF
      }
      ELSE
      {
        DO STATE_SHAMAN_GET_WILDS                ON
      }
      ENDIF
    }
    EVERY 2048 320
    {
      IF ( INT_M_PERSON_WARRIOR > 10 && $1 == 4 )
      {
        DO GET_HEIGHT_AT_POS                     15 $10
        IF ( $10 > 0 )
        {
          SET INT_ATTR_AWAY_BRAVE                 0
          SET INT_ATTR_AWAY_WARRIOR               90
          SET INT_ATTR_AWAY_RELIGIOUS             10
          SET INT_ATTR_AWAY_SPY                   0
          SET INT_ATTR_AWAY_FIREWARRIOR           0
          SET INT_ATTR_AWAY_SHAMAN                1
          DO SET_ATTACK_VARIABLE                  $0
          DO ATTACK BLUE 5 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 999 INT_SWARM INT_LIGHTNING INT_BLAST ATTACK_NORMAL 0 7 -1 -1
          SET $1                                  5
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 350
    {
      IF ( $1 == 5 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $1                                  6
        }
        ELSE
        {
          SET $1                                  4
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 1024 390
    {
      IF ( INT_M_PERSON_WARRIOR > 11 && $1 == 6 )
      {
        DO GET_HEIGHT_AT_POS                     15 $10
        IF ( $10 > 0 )
        {
          SET INT_ATTR_AWAY_BRAVE                 0
          SET INT_ATTR_AWAY_WARRIOR               90
          SET INT_ATTR_AWAY_RELIGIOUS             10
          SET INT_ATTR_AWAY_SPY                   0
          SET INT_ATTR_AWAY_FIREWARRIOR           0
          SET INT_ATTR_AWAY_SHAMAN                1
          DO SET_ATTACK_VARIABLE                  $0
          DO ATTACK BLUE 6 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 999 INT_SWARM INT_LIGHTNING INT_BLAST ATTACK_NORMAL 0 40 -1 -1
          SET $1                                  7
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 350
    {
      IF ( $1 == 7 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $1                                  8
        }
        ELSE
        {
          SET $1                                  6
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 512 10
    {
      IF ( INT_M_PERSON_RELIGIOUS > 3 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $12 == 0 )
        {
          DO BUILD_DRUM_TOWER                     140 184
          SET $12                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 140 184
          DO MARKER_ENTRIES                       5 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 30
    {
      IF ( INT_M_PERSON_RELIGIOUS > 3 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $13 == 0 )
        {
          DO BUILD_DRUM_TOWER                     110 176
          SET $13                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 120 176
          DO MARKER_ENTRIES                       4 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 50
    {
      IF ( INT_M_PERSON_RELIGIOUS > 3 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $14 == 0 )
        {
          DO BUILD_DRUM_TOWER                     82 164
          SET $14                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 82 164
          DO MARKER_ENTRIES                       3 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 70
    {
      IF ( INT_M_PERSON_RELIGIOUS > 3 && INT_CP_FREE_ENTRIES > 1 )
      {
        IF ( $15 == 0 )
        {
          DO BUILD_DRUM_TOWER                     38 162
          SET $15                                 1
        }
        ELSE
        {
          DO PUT_PERSON_IN_DT INT_RELIGIOUS 38 162
          DO MARKER_ENTRIES                       2 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 2048
    {
      DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 13 4 $8
      IF ( $8 > 4 )
      {
      }
      ENDIF
      DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 14 4 $7
      IF ( $7 > 4 )
      {
      }
      ENDIF
    }
    EVERY 64 55
    {
      IF ( INT_MY_NUM_PEOPLE < 8 && INT_MY_NUM_KILLED_BY_BLUE > 5 )
      {
        SET $21                                  INT_M_BUILDING_SMALL_HUT
        INCREMENT $21 INT_M_BUILDING_MEDIUM_HUT
        INCREMENT $21 INT_M_BUILDING_LARGE_HUT
        IF ( $21 == 0 )
        {
          DO GIVE_UP_AND_SULK                     ON
          IF ( $18 == 0 )
          {
            DO TRIGGER_THING                       44
            DO REMOVE_HEAD_AT_POS                  120 118
            DO TRIGGER_THING                       44
            SET $18                                1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
  }
  ENDIF
}
SCRIPT_END
