{
  IF ( INT_GAME_TURN == 0 )
  {
    DO SET_REINCARNATION                       OFF
    DO DELAY_MAIN_DRUM_TOWER
    SET $0                                     0
    SET $1                                     0
    DO SET_ATTACK_VARIABLE                     $0
    DO DISABLE_USER_INPUTS
    DO STATE_STATE_BRING_NEW_PEOPLE_BACK       ON
    DO STATE_TRAIN_PEOPLE                      ON
    DO STATE_SHAMAN_GET_WILDS                  OFF
    DO STATE_CONSTRUCT_BUILDING                ON
    DO STATE_FETCH_WOOD                        ON
    DO STATE_SEND_GHOSTS                       OFF
    DO STATE_FETCH_LOST_PEOPLE                 ON
    DO STATE_FETCH_FAR_VEHICLE                 OFF
    DO STATE_FETCH_LOST_VEHICLE                OFF
    SET INT_ATTR_PREF_BOAT_DRIVERS             0
    SET INT_ATTR_SHAMEN_BLAST                  128
    SET INT_ATTR_MAX_TRAIN_AT_ONCE             1
    SET INT_ATTR_GROUP_OPTION                  0
    SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT     1
    DO SET_DEFENCE_RADIUS                      7
    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           1
    SET INT_ATTR_HOUSE_PERCENTAGE              3
    SET INT_ATTR_EXPANSION                     12
    DO STATE_DEFEND                            OFF
    DO STATE_DEFEND_BASE                       ON
    SET INT_ATTR_DEFENSE_RAD_INCR              2
    SET INT_ATTR_MAX_DEFENSIVE_ACTIONS         0
    SET INT_ATTR_ATTACK_PERCENTAGE             45
    DO STATE_SPELL_DEFENCE                     8 28 ON
    DO SET_SPELL_ENTRY 0 INT_BLAST INT_M_SPELL_BLAST_COST 512 6 0
    DO SET_SPELL_ENTRY 1 INT_BLAST INT_M_SPELL_BLAST_COST 512 6 1
    DO STATE_HOUSE_A_PERSON                    ON
    DO STATE_AUTO_ATTACK                       ON
    SET INT_ATTR_MAX_ATTACKS                   1
    SET INT_ATTR_AWAY_BRAVE                    100
    SET INT_ATTR_AWAY_WARRIOR                  34
    SET INT_ATTR_AWAY_RELIGIOUS                0
    SET INT_ATTR_AWAY_SPY                      0
    SET INT_ATTR_AWAY_FIREWARRIOR              0
    SET INT_ATTR_AWAY_SHAMAN                   0
    SET INT_ATTR_RETREAT_VALUE                 50
    SET INT_ATTR_SPY_DISCOVER_CHANCE           30
    SET INT_ATTR_ENEMY_SPY_MAX_STAND           255
    DO TURN_PUSH                               OFF
    DO SET_MARKER_ENTRY                        0 0 -1 0 1 0 0
    DO SET_MARKER_ENTRY                        1 7 -1 0 1 0 0
    DO SET_MARKER_ENTRY                        2 1 -1 1 0 0 0
    DO ONLY_STAND_AT_MARKERS
    DO MARKER_ENTRIES                          2 -1 -1 -1
    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                                    1
    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
    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                                    0
    SET $33                                    0
    SET $34                                    0
    SET $35                                    0
    SET $36                                    0
    SET $37                                    0
    SET $38                                    0
    SET $39                                    0
    SET $40                                    0
    SET $41                                    0
    SET $42                                    0
    SET $43                                    0
    SET $44                                    0
    SET $45                                    0
    SET $46                                    0
    SET $47                                    0
    SET $48                                    0
    SET $49                                    0
    SET $50                                    0
    SET $51                                    0
    SET $52                                    0
    SET $53                                    0
    SET $54                                    0
    SET $55                                    0
    SET $56                                    0
    SET $57                                    0
    SET $58                                    0
    SET $59                                    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 64 13
    {
      IF ( $4 == 0 )
      {
        DO PARTIAL_BUILDING_COUNT
        IF ( INT_M_BUILDING_SMALL_HUT > 0 )
        {
          DO STATE_CONSTRUCT_BUILDING             OFF
          SET INT_ATTR_MAX_BUILDINGS_ON_GO        0
          SET INT_ATTR_HOUSE_PERCENTAGE           0
          SET $4                                  1
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 2
    {
      DO GET_SPELLS_CAST RED INT_BLAST $19
      IF ( $19 > 1 )
      {
        DO STATE_SPELL_DEFENCE                   90 202 OFF
        DO SET_SPELL_ENTRY 0 0 INT_M_SPELL_BLAST_COST 512 6 0
        DO SET_SPELL_ENTRY 1 0 INT_M_SPELL_BLAST_COST 512 6 1
      }
      ENDIF
    }
    EVERY 128
    {
      IF ( INT_M_PERSON_WARRIOR < 1 )
      {
        DO TRAIN_PEOPLE_NOW 1 INT_WARRIOR
        SET $5                                   0
      }
      ELSE
      {
        SET $5                                   1
      }
      ENDIF
    }
    EVERY 128 15
    {
      IF ( $2 < 3 )
      {
        IF ( INT_B_PERSON_WARRIOR > 0 && INT_B_PERSON_WARRIOR < 4 )
        {
          SET INT_ATTR_AWAY_BRAVE                 34
        }
        ELSE
        {
          IF ( INT_B_PERSON_WARRIOR > 3 && INT_B_PERSON_WARRIOR < 13 )
          {
            SET INT_ATTR_AWAY_BRAVE                67
          }
          ELSE
          {
            IF ( INT_B_PERSON_WARRIOR > 12 )
            {
              SET INT_ATTR_AWAY_BRAVE               100
            }
            ENDIF
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 256 55
    {
      IF ( $50 > 0 )
      {
        IF ( INT_M_PERSON_WARRIOR > 2 )
        {
          IF ( INT_B_PERSON_WARRIOR > 0 )
          {
            IF ( $2 == 0 )
            {
              DO COUNT_PEOPLE_IN_MARKER BLUE 3 7 $8
              IF ( $8 > 0 )
              {
                DO ATTACK BLUE 3 ATTACK_MARKER 3 999 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 -1 -1 0
                SET $2                               1
                DO CREATE_MSG_INFORMATION            140
              }
              ENDIF
            }
            ELSE
            {
              IF ( $2 == 1 )
              {
                IF ( $0 != 0 )
                {
                  IF ( $0 > 50 )
                  {
                    SET $2                             2
                  }
                  ELSE
                  {
                    SET $2                             0
                  }
                  ENDIF
                }
                ENDIF
              }
              ELSE
              {
                IF ( $2 == 2 )
                {
                  DO COUNT_PEOPLE_IN_MARKER BLUE 3 7 $8
                  IF ( $8 > 0 )
                  {
                    DO ATTACK BLUE 3 ATTACK_MARKER 3 999 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 -1 -1 0
                    SET $2                             3
                  }
                  ENDIF
                }
                ELSE
                {
                  IF ( $2 == 3 )
                  {
                    IF ( $0 != 0 )
                    {
                      IF ( $0 > 50 )
                      {
                        SET $2                           4
                      }
                      ELSE
                      {
                        SET $2                           2
                      }
                      ENDIF
                    }
                    ENDIF
                  }
                  ENDIF
                }
                ENDIF
              }
              ENDIF
            }
            ENDIF
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 256 175
    {
      IF ( $3 == 0 && $50 == 1 )
      {
        IF ( INT_M_PERSON_WARRIOR == 0 )
        {
          MULTIPLY $53 INT_MY_NUM_PEOPLE 2
          IF ( INT_BLUE_PEOPLE > $53 )
          {
            SET INT_ATTR_AWAY_BRAVE                100
            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               1
            DO ATTACK BLUE INT_MY_NUM_PEOPLE ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 999 INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 -1 -1 0
            SET $3                                 1
          }
          ENDIF
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 512 473
    {
      DO MARKER_ENTRIES                         0 -1 -1 -1
    }
    EVERY 8
    {
      IF ( INT_GAME_TURN > 70 )
      {
        IF ( $57 == 0 )
        {
          DO CREATE_MSG_INFORMATION               78
          DO SET_MSG_AUTO_OPEN_DLG
          DO SET_MSG_DELETE_ON_OK
          DO ENABLE_USER_INPUTS
          SET $57                                 1
          DO FLYBY_CREATE_NEW
          DO FLYBY_ALLOW_INTERRUPT                ON
          DO FLYBY_SET_EVENT_POS                  8 28 4 80
          DO FLYBY_SET_EVENT_POS                  2 28 81 44
          DO FLYBY_SET_EVENT_POS                  252 254 126 45
          DO FLYBY_SET_EVENT_POS                  12 238 181 30
          DO FLYBY_SET_EVENT_POS                  20 216 221 45
          DO FLYBY_SET_EVENT_ANGLE                0 5 35
          DO FLYBY_SET_EVENT_ANGLE                1072 46 40
          DO FLYBY_SET_EVENT_ANGLE                681 87 45
          DO FLYBY_SET_EVENT_ANGLE                744 134 35
          DO FLYBY_SET_EVENT_ANGLE                54 170 48
          DO FLYBY_SET_EVENT_ANGLE                1438 219 45
          DO FLYBY_SET_EVENT_ZOOM                 -100 10 35
          DO FLYBY_SET_EVENT_ZOOM                 10 67 25
          DO FLYBY_SET_EVENT_ZOOM                 80 165 36
          DO FLYBY_SET_EVENT_ZOOM                 0 202 63
          DO FLYBY_SET_EVENT_TOOLTIP              12 26 1 60 71
          DO FLYBY_SET_EVENT_TOOLTIP              2 250 1 132 60
          DO FLYBY_SET_EVENT_TOOLTIP              18 246 0 193 60
          DO FLYBY_SET_END_TARGET                 20 216 1438 0
          DO FLYBY_START
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 17
    {
      IF ( $29 == 0 && $30 == 0 )
      {
        SET $60                                  INT_B_BUILDING_SMALL_HUT
        INCREMENT $60 INT_B_BUILDING_MEDIUM_HUT
        INCREMENT $60 INT_B_BUILDING_LARGE_HUT
        IF ( $60 > 3 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               84
          SET $30                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 23
    {
      IF ( $29 == 0 && $32 == 0 )
      {
        DO PARTIAL_BUILDING_COUNT
        SET $60                                  INT_B_BUILDING_SMALL_HUT
        DO PARTIAL_BUILDING_COUNT
        INCREMENT $60 INT_B_BUILDING_MEDIUM_HUT
        DO PARTIAL_BUILDING_COUNT
        INCREMENT $60 INT_B_BUILDING_LARGE_HUT
        DO GET_HEAD_TRIGGER_COUNT 18 246 $35
        IF ( $35 < 3 && $60 < 4 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               85
          SET $32                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 35
    {
      IF ( $29 == 0 && $32 == 0 )
      {
        DO PARTIAL_BUILDING_COUNT
        SET $60                                  INT_B_BUILDING_SMALL_HUT
        DO PARTIAL_BUILDING_COUNT
        INCREMENT $60 INT_B_BUILDING_MEDIUM_HUT
        DO PARTIAL_BUILDING_COUNT
        INCREMENT $60 INT_B_BUILDING_LARGE_HUT
        DO GET_HEAD_TRIGGER_COUNT 2 250 $36
        IF ( $36 < 1 && $60 < 4 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               85
          SET $32                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 3
    {
      IF ( $29 == 0 && $38 == 0 )
      {
        DO GET_HEAD_TRIGGER_COUNT 18 246 $33
        IF ( $33 < 4 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               83
          SET $38                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 16 1
    {
      IF ( $29 == 0 && $43 == 0 )
      {
        DO GET_NUM_ONE_OFF_SPELLS 0 INT_LAND_BRIDGE $42
        IF ( $42 > 0 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               82
          SET $43                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 7
    {
      IF ( $29 == 0 && $37 == 0 )
      {
        DO GET_HEAD_TRIGGER_COUNT 2 250 $34
        IF ( $34 < 1 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               86
          DO TRIGGER_THING                        41
          DO GET_SPELLS_CAST BLUE INT_LAND_BRIDGE $54
          SET $37                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 32 3
    {
      DO GET_HEIGHT_AT_POS                      35 $21
      DO GET_HEIGHT_AT_POS                      36 $22
      DO GET_HEIGHT_AT_POS                      37 $23
      DO GET_HEIGHT_AT_POS                      38 $24
      DO GET_HEIGHT_AT_POS                      39 $25
      DO GET_HEIGHT_AT_POS                      40 $26
      SET $52                                   $21
      INCREMENT $52 $22
      INCREMENT $52 $23
      INCREMENT $52 $24
      INCREMENT $52 $25
      INCREMENT $52 $26
      IF ( $52 > 0 )
      {
        DO GET_HEIGHT_AT_POS                     25 $45
        DO GET_HEIGHT_AT_POS                     26 $46
        DO GET_HEIGHT_AT_POS                     27 $47
        DO GET_HEIGHT_AT_POS                     28 $48
        DO GET_HEIGHT_AT_POS                     29 $49
        SET $50                                  $45
        INCREMENT $50 $46
        INCREMENT $50 $47
        INCREMENT $50 $48
        INCREMENT $50 $49
        IF ( $50 > 0 )
        {
          DO REMOVE_HEAD_AT_POS                   2 222
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 13
    {
      IF ( $29 == 0 && $39 == 0 )
      {
        IF ( INT_B_BUILDING_WARRIOR_TRAIN > 0 )
        {
          SET $29                                 1
          DO CREATE_MSG_INFORMATION               87
          SET $39                                 1
          SET $29                                 0
        }
        ENDIF
      }
      ENDIF
    }
    EVERY 64 55
    {
      IF ( INT_MY_NUM_PEOPLE < 8 && INT_MY_NUM_KILLED_BY_BLUE > 5 )
      {
        DO DEFEND_SHAMEN                         INT_MY_NUM_PEOPLE
      }
      ENDIF
    }
  }
  ENDIF
}
SCRIPT_END
