{
  IF ( INT_GAME_TURN == 0 )
  {
    SET $0                                     0
    DO SET_ATTACK_VARIABLE                     $0
    DO DELAY_MAIN_DRUM_TOWER
    DO STATE_STATE_BRING_NEW_PEOPLE_BACK       ON
    DO STATE_SHAMAN_GET_WILDS                  ON
    DO STATE_CONSTRUCT_BUILDING                ON
    DO SET_DRUM_TOWER_POS                      74 72
    DO STATE_FETCH_WOOD                        ON
    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                1
    SET INT_ATTR_PREF_BALLOON_HUTS             0
    DO EXTRA_WOOD_COLLECTION                   ON
    DO SET_WOOD_COLLECTION_RADII               5 40 0 0
    DO GIVE_ONE_SHOT INT_VOLCANO YELLOW
    DO STATE_BUILD_VEHICLE                     ON
    SET INT_ATTR_PEOPLE_PER_BOAT               8
    DO STATE_FETCH_LOST_PEOPLE                 ON
    DO STATE_FETCH_LOST_VEHICLE                ON
    DO STATE_FETCH_FAR_VEHICLE                 ON
    SET INT_ATTR_SPY_DISCOVER_CHANCE           30
    SET INT_ATTR_ENEMY_SPY_MAX_STAND           255
    SET INT_ATTR_MAX_BUILDINGS_ON_GO           2
    SET INT_ATTR_HOUSE_PERCENTAGE              10
    SET INT_ATTR_EXPANSION                     20
    DO STATE_POPULATE_DRUM_TOWER               ON
    DO STATE_HOUSE_A_PERSON                    ON
    DO STATE_DEFEND                            ON
    DO STATE_FIREWARRIOR_DEFEND                ON
    DO STATE_DEFEND_BASE                       ON
    SET INT_ATTR_DEFENSE_RAD_INCR              10
    SET INT_ATTR_MAX_DEFENSIVE_ACTIONS         2
    SET INT_ATTR_ATTACK_PERCENTAGE             160
    SET INT_ATTR_USE_PREACHER_FOR_DEFENCE      1
    DO STATE_PREACH                            ON
    DO STATE_TRAIN_PEOPLE                      ON
    SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE       20
    SET INT_ATTR_PREF_WARRIOR_PEOPLE           15
    SET INT_ATTR_PREF_RELIGIOUS_PEOPLE         15
    SET INT_ATTR_PREF_BOAT_DRIVERS             10
    DO SET_MARKER_ENTRY                        1 6 7 0 5 0 0
    DO SET_MARKER_ENTRY                        2 13 -1 0 5 5 0
    SET INT_ATTR_SHAMEN_BLAST                  128
    DO STATE_SPELL_DEFENCE                     74 72 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 1
    SET INT_ATTR_RETREAT_VALUE                 25
    SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT     1
    SET INT_ATTR_RANDOM_BUILD_SIDE             0
    SET INT_ATTR_MAX_TRAIN_AT_ONCE             4
    SET INT_ATTR_GROUP_OPTION                  0
    DO CONVERT_AT_MARKER                       4
    DO STATE_AUTO_ATTACK                       ON
    SET INT_ATTR_MAX_ATTACKS                   2
    SET INT_ATTR_AWAY_BRAVE                    0
    SET INT_ATTR_AWAY_WARRIOR                  100
    SET INT_ATTR_AWAY_RELIGIOUS                0
    SET INT_ATTR_AWAY_SPY                      0
    SET INT_ATTR_AWAY_FIREWARRIOR              0
    SET INT_ATTR_AWAY_SHAMAN                   0
    DO CREATE_MSG_NARRATIVE                    54
    DO SET_MSG_AUTO_OPEN_DLG
    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
    SET $20                                    0
    SET $21                                    0
    SET $22                                    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                  248 179 5 50
          DO FLYBY_SET_EVENT_POS                  178 68 58 50
          DO FLYBY_SET_EVENT_ANGLE                184 1 20
          DO FLYBY_SET_EVENT_ANGLE                904 35 25
          DO FLYBY_SET_EVENT_ANGLE                1230 65 20
          DO FLYBY_SET_EVENT_ANGLE                1750 88 20
          DO FLYBY_SET_EVENT_ZOOM                 -70 4 25
          DO FLYBY_SET_EVENT_ZOOM                 20 40 19
          DO FLYBY_SET_EVENT_ZOOM                 -100 60 20
          DO FLYBY_SET_EVENT_ZOOM                 0 85 20
          DO FLYBY_SET_END_TARGET                 178 68 1750 0
          DO FLYBY_START
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512
    {
      IF ( $10 < 3 && INT_CP_FREE_ENTRIES > 1 )
      {
        DO PRAY_AT_HEAD                          1 16
        INCREMENT $10 1
        SET $9                                   1
      }
      ENDIF
    }
    EVERY 512 455
    {
      IF ( INT_CP_FREE_ENTRIES > 2 )
      {
        DO GET_HEIGHT_AT_POS                     15 $13
        IF ( $13 > 0 )
        {
          IF ( $12 == 0 )
          {
            DO BUILD_DRUM_TOWER                    110 158
            SET $12                                1
          }
          ELSE
          {
            IF ( INT_M_PERSON_RELIGIOUS > 0 )
            {
              DO PUT_PERSON_IN_DT INT_RELIGIOUS 110 158
            }
            ENDIF
            IF ( INT_M_PERSON_WARRIOR > 5 && INT_M_PERSON_FIREWARRIOR > 8 )
            {
              DO MARKER_ENTRIES                     2 -1 -1 -1
            }
            ENDIF
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 50
    {
      IF ( $9 == 1 )
      {
        IF ( INT_M_PERSON_WARRIOR > 2 && $2 == 0 )
        {
          DO SET_ATTACK_VARIABLE                  $0
          SET INT_ATTR_DONT_USE_BOATS             1
          DO ATTACK BLUE 2 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 9 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 0 -1 -1
          SET INT_ATTR_DONT_USE_BOATS             0
          SET $2                                  1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 70
    {
      IF ( $2 == 1 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $2                                  2
          SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE    30
          SET INT_ATTR_PREF_WARRIOR_PEOPLE        35
          SET INT_ATTR_PREF_RELIGIOUS_PEOPLE      15
        }
        ELSE
        {
          SET $2                                  0
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 512 140
    {
      IF ( INT_M_PERSON_WARRIOR > 4 && $2 == 2 )
      {
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                44
        SET INT_ATTR_AWAY_RELIGIOUS              12
        SET INT_ATTR_AWAY_SPY                    0
        SET INT_ATTR_AWAY_FIREWARRIOR            44
        SET INT_ATTR_AWAY_SHAMAN                 0
        IF ( INT_M_VEHICLE_BOAT > 3 )
        {
          DO SET_ATTACK_VARIABLE                  $0
          DO ATTACK BLUE 9 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 25 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_BY_BOAT 1 1 -1 -1
          SET $2                                  3
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 210
    {
      IF ( $2 == 3 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $2                                  4
        }
        ELSE
        {
          SET $2                                  2
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 512 280
    {
      IF ( $2 == 4 && INT_M_PERSON_WARRIOR > 16 )
      {
        IF ( INT_M_VEHICLE_BOAT > 5 )
        {
          DO SET_ATTACK_VARIABLE                  $0
          SET INT_ATTR_DONT_USE_BOATS             1
          DO ATTACK BLUE 10 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 50 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 0 -1 -1
          SET INT_ATTR_DONT_USE_BOATS             0
          SET $2                                  5
          INCREMENT $4 1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 350
    {
      IF ( $2 == 5 && $0 != 0 )
      {
        IF ( $0 > 50 )
        {
          SET $2                                  6
        }
        ELSE
        {
          SET $2                                  4
        }
        ENDIF
        SET $0                                   0
      }
      ENDIF
    }
    EVERY 1024 420
    {
      IF ( INT_M_PERSON_FIREWARRIOR > 4 && INT_M_VEHICLE_BOAT > 0 )
      {
        DO VEHICLE_PATROL 5 9 10 11 12 BOAT_TYPE
      }
      ENDIF
    }
    EVERY 64
    {
      IF ( $4 > 0 )
      {
        DO COUNT_PEOPLE_IN_MARKER RED 0 8 $3
        IF ( $3 > 2 )
        {
          DO ATTACK BLUE 15 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 50 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_BY_BOAT 0 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 256
    {
      IF ( INT_M_BUILDING_BOAT_HUT > 0 )
      {
        SET INT_ATTR_PREF_WARRIOR_TRAINS         1
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       0
        SET INT_ATTR_PREF_FIREWARRIOR_TRAINS     1
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         4
        SET INT_ATTR_HOUSE_PERCENTAGE            20
      }
      ENDIF
    }
    EVERY 512 99
    {
      SET $20                                   INT_M_BUILDING_MEDIUM_HUT
      INCREMENT $20 INT_M_BUILDING_SMALL_HUT
      INCREMENT $20 INT_M_BUILDING_LARGE_HUT
      IF ( INT_M_BUILDING_WARRIOR_TRAIN > 0 && $20 > 1 )
      {
        SET INT_ATTR_PREF_WARRIOR_TRAINS         1
        SET INT_ATTR_PREF_RELIGIOUS_TRAINS       1
        SET INT_ATTR_PREF_FIREWARRIOR_TRAINS     1
        SET INT_ATTR_MAX_BUILDINGS_ON_GO         4
        SET INT_ATTR_HOUSE_PERCENTAGE            30
      }
      ENDIF
    }
    EVERY 256 100
    {
      SET $20                                   INT_M_BUILDING_MEDIUM_HUT
      INCREMENT $20 INT_M_BUILDING_SMALL_HUT
      INCREMENT $20 INT_M_BUILDING_LARGE_HUT
      IF ( $20 > 3 )
      {
        SET INT_ATTR_HOUSE_PERCENTAGE            40
        IF ( INT_CP_FREE_ENTRIES > 2 )
        {
          IF ( $7 == 0 )
          {
            DO BUILD_DRUM_TOWER                    114 112
            INCREMENT $7 1
          }
          ELSE
          {
            DO PREACH_AT_MARKER                    6
          }
          ENDIF
        }
        ENDIF
        IF ( INT_CP_FREE_ENTRIES > 2 )
        {
          IF ( $8 == 0 )
          {
            DO BUILD_DRUM_TOWER                    96 126
            INCREMENT $8 1
          }
          ELSE
          {
            DO PREACH_AT_MARKER                    7
          }
          ENDIF
        }
        ENDIF
        IF ( INT_CP_FREE_ENTRIES > 2 )
        {
          IF ( $6 == 0 )
          {
            DO BUILD_DRUM_TOWER                    68 126
            INCREMENT $6 1
          }
          ELSE
          {
            DO PREACH_AT_MARKER                    8
          }
          ENDIF
        }
        ENDIF
        IF ( $7 > 0 && $8 > 0 )
        {
          DO MARKER_ENTRIES                       1 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 2048 11
    {
      IF ( $9 > 0 )
      {
        DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 5 4 $5
        IF ( $5 > 3 )
        {
          DO CONVERT_AT_MARKER                    5
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 44
    {
      DO COUNT_PEOPLE_IN_MARKER BLUE 3 3 $16
      IF ( $16 > 2 && INT_M_VEHICLE_BOAT > 2 )
      {
        SET INT_ATTR_AWAY_BRAVE                  0
        SET INT_ATTR_AWAY_WARRIOR                0
        SET INT_ATTR_AWAY_RELIGIOUS              0
        SET INT_ATTR_AWAY_SPY                    0
        SET INT_ATTR_AWAY_FIREWARRIOR            100
        SET INT_ATTR_AWAY_SHAMAN                 1
        DO ATTACK BLUE 4 ATTACK_MARKER 3 99 INT_LIGHTNING INT_BLAST INT_BLAST ATTACK_BY_BOAT 1 -1 -1 -1
      }
      ENDIF
    }
    EVERY 64 55
    {
      DO GET_HEAD_TRIGGER_COUNT 104 230 $17
      IF ( $17 > 0 )
      {
        DO COUNT_PEOPLE_IN_MARKER BLUE 17 3 $18
        IF ( $18 > 2 )
        {
          SET INT_ATTR_AWAY_BRAVE                 0
          SET INT_ATTR_AWAY_WARRIOR               50
          SET INT_ATTR_AWAY_RELIGIOUS             0
          SET INT_ATTR_AWAY_SPY                   0
          SET INT_ATTR_AWAY_FIREWARRIOR           50
          SET INT_ATTR_AWAY_SHAMAN                1
          DO ATTACK BLUE $18 ATTACK_MARKER 17 99 INT_LIGHTNING INT_BLAST INT_BLAST ATTACK_NORMAL 0 -1 -1 -1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 2048 770
    {
      IF ( INT_BLUE_PEOPLE > 38 && INT_GAME_TURN > 5000 )
      {
        DO I_HAVE_ONE_SHOT SPELL_TYPE INT_VOLCANO $14
        IF ( $14 > 0 && INT_M_VEHICLE_BOAT > 2 )
        {
          IF ( $21 < 5 )
          {
            SET INT_ATTR_AWAY_BRAVE                0
            SET INT_ATTR_AWAY_WARRIOR              0
            SET INT_ATTR_AWAY_RELIGIOUS            5
            SET INT_ATTR_AWAY_SPY                  0
            SET INT_ATTR_AWAY_FIREWARRIOR          95
            SET INT_ATTR_AWAY_SHAMAN               1
            DO DEFEND_SHAMEN                       4
            SET INT_ATTR_DONT_USE_BOATS            0
            DO ATTACK BLUE 4 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 99 INT_VOLCANO INT_TORNADO INT_NO_SPECIFIC_SPELL ATTACK_BY_BOAT 0 1 -1 -1
            SET INT_ATTR_DONT_USE_BOATS            0
            SET INT_ATTR_AWAY_BRAVE                0
            SET INT_ATTR_AWAY_WARRIOR              44
            SET INT_ATTR_AWAY_RELIGIOUS            12
            SET INT_ATTR_AWAY_SPY                  0
            SET INT_ATTR_AWAY_FIREWARRIOR          44
            SET INT_ATTR_AWAY_SHAMAN               0
          }
          ELSE
          {
            SET INT_ATTR_AWAY_BRAVE                0
            SET INT_ATTR_AWAY_WARRIOR              0
            SET INT_ATTR_AWAY_RELIGIOUS            5
            SET INT_ATTR_AWAY_SPY                  0
            SET INT_ATTR_AWAY_FIREWARRIOR          95
            SET INT_ATTR_AWAY_SHAMAN               1
            DO DEFEND_SHAMEN                       4
            SET INT_ATTR_DONT_USE_BOATS            1
            DO ATTACK BLUE 6 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 99 INT_VOLCANO INT_TORNADO INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 0 -1 -1
            SET INT_ATTR_DONT_USE_BOATS            0
            SET INT_ATTR_AWAY_BRAVE                0
            SET INT_ATTR_AWAY_WARRIOR              44
            SET INT_ATTR_AWAY_RELIGIOUS            12
            SET INT_ATTR_AWAY_SPY                  0
            SET INT_ATTR_AWAY_FIREWARRIOR          44
            SET INT_ATTR_AWAY_SHAMAN               0
          }
          ENDIF
        }
        ENDIF
      }
      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 )
      {
        SET $22                                  INT_M_BUILDING_SMALL_HUT
        INCREMENT $22 INT_M_BUILDING_MEDIUM_HUT
        INCREMENT $22 INT_M_BUILDING_LARGE_HUT
        IF ( $22 == 0 )
        {
          DO GIVE_UP_AND_SULK                     ON
        }
        ENDIF
      }
      ENDIF
    }
  }
  ENDIF
}
SCRIPT_END
