
// Special about this level:


// HOW MANY PLAYERS ARE IN THIS SCRIPT (at most 3 at a time !!)
COUNTER numplayers = 3


// -------- define a new player with the following command:
// PLAYER_PED playername = CREATE_PLAYER ( float X  ,  float Y  ,  float Z  )  remap  rotation
// 25 = player sprites

PLAYER_PED player1 = (  127.5 , 135.0 , 255.0 ) 25 90

IF (numplayers > 1)
  PLAYER_PED player2 = ( 105.5 , 172.5 , 255.0 ) 25 90
  //CHAR_DATA player2 = ( 105.5 , 172.5 , 255.0 ) 2 90 DUMMY  // use this for single-player debug
ENDIF
IF (numplayers > 2)
  PLAYER_PED player3 = (  52.5 , 173.5 , 255.0 ) 25 1
  //CHAR_DATA player3 = (  52.5 , 173.5 , 255.0 ) 3 1 DUMMY   // use this for single-player debug
ENDIF


// Some threads, to do checks in the background
THREAD_ID   thr_checkbomb
THREAD_ID   thr_checkallweapons
THREAD_ID   thr_checkremoveweapons
THREAD_ID   thr_checkmostwanted
THREAD_ID   thr_checkvillain
THREAD_ID   thr_checkrandomnum
THREAD_ID   thr_checkaddammo
THREAD_ID   thr_checkbuytank




// villains that hunt a human player down ... activated by triggers !

CHAR_DATA  villain_get_player1
IF (numplayers > 1)
  CHAR_DATA  villain_get_player2
ENDIF
IF (numplayers > 2)
  CHAR_DATA  villain_get_player3
ENDIF


// -------- define a car, parked for the player:
// CAR_DATA  name  =   (  float X  ,  float Y  )  remap   rotation   model

CAR_DATA playercar    // dummy car, checked to see what car a player is driving

CAR_DATA  car_01  =   (  47.5  ,  169.5  )   1   90   BUG
CAR_DATA  car_02  =   (  47.5  ,  170.5  )   2   90   BUG
CAR_DATA  car_03  =   (  47.5  ,  171.5  )   3   90   BUG

CAR_DATA  car_04  =   (  55.5  ,  181.5  )   4   90   BUG
CAR_DATA  car_05  =   (  56.5  ,  181.5  )   5   90   BUG

CAR_DATA  car_06  =   (  84.5  ,  148.5 , 2.0  )   6   180   BOXTRUCK
CAR_DATA  car_07  =   (  86.5  ,  148.5 , 2.0  )   7   180   BOXTRUCK
CAR_DATA  car_08  =   (  88.5  ,  148.5 , 2.0  )   8   180   BOXTRUCK
CAR_DATA  car_09  =   (  90.5  ,  148.5 , 2.0  )   9   180   BOXTRUCK


CAR_DATA  car_11  =   (  135.0  ,  137.0  )  10   90   MORGAN
CAR_DATA  car_12  =   (  135.0  ,  138.5  )  11   90   MORRIS
CAR_DATA  car_13  =   (  135.0  ,  140.0  )  12   90   BUS
CAR_DATA  car_14  =   (  135.0  ,  141.5  )  13   90   RTYPE
CAR_DATA  car_15  =   (  135.0  ,  143.0  )  14   90   SPIDER
CAR_DATA  car_16  =   (  135.0  ,  144.5  )  15   96   RTYPE   // illegal SKYLINE
CAR_DATA  car_17  =   (  135.0  ,  146.0  )  16   90   STYPE
CAR_DATA  car_18  =   (  135.0  ,  147.5  )  17   90   GRAHAM
CAR_DATA  car_19  =   (  135.0  ,  149.0  )  18   90   MONSTER

CAR_DATA  car_21  =   (  135.0  ,  151.5  )  19   90   ALFA
CAR_DATA  car_22  =   (  135.0  ,  153.0  )  20   90   BMW
CAR_DATA  car_23  =   (  135.0  ,  154.5  )  21   90   T2000GT // - illegal type BUG2
CAR_DATA  car_24  =   (  135.0  ,  156.0  )  22   90   RTYPE
CAR_DATA  car_25  =   (  135.0  ,  147.5  )  23   90   STRATOS
CAR_DATA  car_26  =   (  135.0  ,  149.0  )  24   90   FIAT
CAR_DATA  car_27  =   (  135.0  ,  150.5  )  25   90   STYPE
CAR_DATA  car_28  =   (  135.0  ,  152.0  )  26   90   APC
CAR_DATA  car_29  =   (  135.0  ,  153.5  )  27   90   VAN

CAR_DATA  car_31  =   (  99.0  ,  173.0  )  01   0   TAXI
CAR_DATA  car_32  =   ( 100.5  ,  173.0  )  02   0   MERC
CAR_DATA  car_33  =   ( 102.0  ,  173.0  )  03   0   LIMO
CAR_DATA  car_34  =   ( 103.5  ,  173.0  )  04   0   LIMO2
CAR_DATA  car_35  =   ( 105.0  ,  173.0  )  05   0   MIURA
CAR_DATA  car_36  =   ( 106.5  ,  173.0  )  06   0   BUS
CAR_DATA  car_37  =   ( 110.0  ,  173.0  )  07   0   EDSEL
CAR_DATA  car_38  =   ( 111.5  ,  173.0  )  08   0   DART
CAR_DATA  car_39  =   ( 113.0  ,  173.0  )  09   0   BUICK


CAR_DATA  tank1
CAR_DATA  tank2
CAR_DATA  tank3


// -------- define a weapon
// GENERATOR name  =  ( float X , float Y ) rotation  object-type  mindelay  maxdelay  ammo

GENERATOR gen_weapon_pistol         = (  121.5 ,  150.5, 255.0 ) 0 collect_00 3000 3000 15
GENERATOR gen_weapon_machinegun1    = (  62.5 ,  173.5, 255.0 ) 0 collect_01 3000 3000 15
GENERATOR gen_weapon_machinegun2    = (  6.5 ,  6.5, 255.0 ) 0 collect_01 3000 3000 15
GENERATOR gen_weapon_rocketlauncher = (  137.5 , 166.5, 255.0 ) 0 collect_02 3000 3000 5
GENERATOR gen_weapon_electrogun     = (  63.0 , 154.0, 255.0 ) 0 collect_03 3000 3000 15
GENERATOR gen_weapon_molotov        = (  102.5 , 100.5, 255.0 ) 0 collect_04 3000 3000 10
GENERATOR gen_weapon_grenade        = (  75.5 , 162.5, 255.0 ) 0 collect_05 3000 3000 10
GENERATOR gen_weapon_shotgun        = (  59.5 , 141.5, 255.0 ) 0 collect_06 3000 3000 15
GENERATOR gen_weapon_flamethrower   = ( 137.5 ,  125.0, 255.0 ) 0 collect_08 3000 3000 15
GENERATOR gen_weapon_silencedmgun   = ( 88.5 , 163.5, 255.0 ) 0 collect_09 3000 3000 15
GENERATOR gen_weapon_dualpistol     = (  73.5 , 128.5, 255.0 ) 0 collect_10 3000 3000 15
GENERATOR gen_weapon_caroil         = (  86.5 , 176.0, 255.0 ) 0 collect_16 3000 3000 6
GENERATOR gen_weapon_carmine        = (  104.5 , 121.5, 255.0 ) 0 collect_17 3000 3000 4
GENERATOR gen_weapon_carmgun        = (  79.5 , 144.5, 255.0 ) 0 collect_18 3000 3000 15


GENERATOR gen_powerup_health1        = (  122.5 , 164.5, 255.0 ) 0 collect_30 3000 3000
GENERATOR gen_powerup_health2        = (  43.5 , 154.5, 255.0 ) 0 collect_30 3000 3000
GENERATOR gen_powerup_armor1         = (  79.5 , 151.5, 255.0 ) 0 collect_31 3000 3000
GENERATOR gen_powerup_armor2         = (  66.5 , 141.5, 255.0 ) 0 collect_31 3000 3000
GENERATOR gen_powerup_invulnerable   = (  101.5 , 100.5, 255.0 ) 0 collect_34 3000 3000
GENERATOR gen_powerup_ddamage        = (  52.5 , 143.5, 255.0 ) 0 collect_35 3000 3000
GENERATOR gen_powerup_dfire          = (  94.5 , 151.5, 255.0 ) 0 collect_36 3000 3000
GENERATOR gen_powerup_electrify      = (  51.5 , 163.5, 255.0 ) 0 collect_37 3000 3000
GENERATOR gen_powerup_invisible      = (  6.5 , 22.5, 255.0 ) 0 collect_39 3000 3000
GENERATOR gen_powerup_gang           = (  128.5 , 154.5, 255.0 ) 0 collect_40 3000 3000

// weapons on the island:
GENERATOR gen_powerup_health3        = (  114.5 , 116.5, 255.0 ) 0 collect_30 3000 3000
GENERATOR gen_powerup_armor3         = (  112.5 , 116.5, 255.0 ) 0 collect_31 3000 3000
GENERATOR gen_powerup_ddamage2       = (  112.5 , 119.5, 255.0 ) 0 collect_35 3000 3000
GENERATOR gen_powerup_dfire2         = (  114.5 , 119.5, 255.0 ) 0 collect_36 3000 3000

// weapons on buildings:
GENERATOR gen_weapon_rocketlauncher2 = (  81.5 , 129.5, 255.0 ) 0 collect_02 3000 3000 5
GENERATOR gen_weapon_flamethrower2   = (  92.5 , 169.0, 255.0 ) 0 collect_08 3000 3000 15

// sounds at particular places
SOUND sound_1 = ( 86.5 , 135.5 , 255.0 )  INDUSTRIAL_LOW  PLAY_FOREVER


MAP_ZONE right_road_area  = (800, 700 , 100 , 100   ,   500 , 20, 50, 10,  10,  50, 10 )
MAP_ZONE bottom_road_area = (600, 600 , 200 ,  50   ,   330 , 20, 50, 10,  10,  50, 10 )
MAP_ZONE top_road_area    = (600, 600 , 200 ,  50   ,   330 , 20, 50, 10,  10,  50, 10 )
MAP_ZONE park_area        = (700, 100 , 400 ,  50   ,  1000 , 20, 20, 20,  10,  50, 10 )
MAP_ZONE industrial_area  = (200, 200 , 300 ,  20   ,   330 , 50, 20, 10, 100,  50, 50 )
MAP_ZONE residential_area = (300, 100 , 800 ,  50   ,   200 , 50, 20, 10, 100,  50, 50 )


COUNTER  allweapons = 1
COUNTER  iamatweapons1 = 0
COUNTER  iamatweapons2 = 0
COUNTER  iamatweapons3 = 0
COUNTER  invinc1 = 0
COUNTER  count_invinc1
COUNTER  invinc2
COUNTER  count_invinc2
COUNTER  endlessloop = 1
COUNTER  bombloop = 0
COUNTER  bomb_time_delay = 0
COUNTER  random01 = 0
COUNTER  random02 = 0

COUNTER  iamatvillain1 = 0
COUNTER  iamatvillain2 = 0
COUNTER  iamatvillain3 = 0
COUNTER  villain1active = 0
COUNTER  villain2active = 0
COUNTER  villain3active = 0

COUNTER  iamattank1 = 0
COUNTER  iamattank2 = 0
COUNTER  iamattank3 = 0


// The shop where you can buy things for your car:

OBJ_DATA carshop_oil     = ( 49.5 , 124.5 , 2.0 ) 0 CAR_SHOP  OILSLICK_SHOP
OBJ_DATA carshop_mines   = ( 49.5 , 126.5 , 2.0 ) 0 CAR_SHOP  MINES_SHOP
OBJ_DATA carshop_guns    = ( 49.5 , 128.5 , 2.0 ) 0 CAR_SHOP  MACHINEGUN_SHOP
OBJ_DATA carshop_respray = ( 49.5 , 130.5 , 2.0 ) 0 CAR_SHOP  2



sub_buytank:
WHILE (endlessloop = 1)

  IF ((iamattank1 = 0) AND (LOCATE_CHARACTER_ANY_MEANS( player1  , 136.0 , 184.0 , 5.0  , 2.0 , 1.0)))
    IF (CHECK_SCORE_GREATER(player1, 50000))
      // take the money
      ADD_SCORE(player1, -50000)
      // and give him a tank
      tank1 = CREATE_CAR(136.0 , 182.0 , 5.0 ) 11 0 TANK END
    ENDIF
    SET iamattank1 = 1
  ENDIF
  IF (iamattank1 = 1)
    IF (NOT(LOCATE_CHARACTER_ANY_MEANS( player1  , 136.0 , 184.0 , 5.0  , 2.0 , 1.0)))
      SET iamattank1 = 0
    ENDIF
  ENDIF

IF (numplayers > 1)
  IF ((iamattank2 = 0) AND (LOCATE_CHARACTER_ANY_MEANS( player2  , 136.0 , 184.0 , 5.0  , 2.0 , 1.0)))
    IF (CHECK_SCORE_GREATER(player2, 50000))
      // take the money
      ADD_SCORE(player2, -50000)
      // and give him a tank
      tank2 = CREATE_CAR(136.0 , 182.0 , 5.0 ) 11 0 TANK END
    ENDIF
    SET iamattank2 = 1
  ENDIF
  IF (iamattank2 = 1)
    IF (NOT(LOCATE_CHARACTER_ANY_MEANS( player2  , 136.0 , 184.0 , 5.0  , 2.0 , 1.0)))
      SET iamattank2 = 0
    ENDIF
  ENDIF
ENDIF

ENDWHILE
RETURN


sub_addammo:
WHILE (endlessloop = 1)

  IF (LOCATE_CHARACTER_ANY_MEANS( player1  , 122.0 , 163.5 , 4.0  , 2.0 , 1.0))

    IF ( CHECK_CHAR_CURR_WEAPON ( player1 , MACHINE_GUN ) )
      GIVE_WEAPON( player1 , MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , ROCKET_LAUNCHER))
      GIVE_WEAPON( player1 , ROCKET_LAUNCHER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , ELECTRO_GUN))
      GIVE_WEAPON( player1 , ELECTRO_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , SILENCED_MACHINE_GUN))
      GIVE_WEAPON( player1 , SILENCED_MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , FLAME_THROWER))
      GIVE_WEAPON( player1 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , GRENADE))
      GIVE_WEAPON( player1 , GRENADE , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , MOLOTOV))
      GIVE_WEAPON( player1 , MOLOTOV , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , FLAME_THROWER))
      GIVE_WEAPON( player1 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , PISTOL))
      GIVE_WEAPON( player1 , PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , DUAL_PISTOL))
      GIVE_WEAPON( player1 , DUAL_PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player1 , SHOTGUN))
      GIVE_WEAPON( player1 , SHOTGUN , 1)
    ENDIF

  ENDIF


IF (numplayers > 1 )

  IF (LOCATE_CHARACTER_ANY_MEANS( player2  , 122.0 , 163.5 , 4.0  , 2.0 , 1.0))

    IF ( CHECK_CHAR_CURR_WEAPON ( player2 , MACHINE_GUN ) )
      GIVE_WEAPON( player2 , MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , ROCKET_LAUNCHER))
      GIVE_WEAPON( player2 , ROCKET_LAUNCHER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , ELECTRO_GUN))
      GIVE_WEAPON( player2 , ELECTRO_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , SILENCED_MACHINE_GUN))
      GIVE_WEAPON( player2 , SILENCED_MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , FLAME_THROWER))
      GIVE_WEAPON( player2 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , GRENADE))
      GIVE_WEAPON( player2 , GRENADE , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , MOLOTOV))
      GIVE_WEAPON( player2 , MOLOTOV , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , FLAME_THROWER))
      GIVE_WEAPON( player2 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , PISTOL))
      GIVE_WEAPON( player2 , PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , DUAL_PISTOL))
      GIVE_WEAPON( player2 , DUAL_PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player2 , SHOTGUN))
      GIVE_WEAPON( player2 , SHOTGUN , 1)
    ENDIF

  ENDIF

ENDIF

IF (numplayers > 2 )

  IF (LOCATE_CHARACTER_ANY_MEANS( player3  , 122.0 , 163.5 , 4.0  , 2.0 , 1.0))

    IF ( CHECK_CHAR_CURR_WEAPON ( player3 , MACHINE_GUN ) )
      GIVE_WEAPON( player3 , MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , ROCKET_LAUNCHER))
      GIVE_WEAPON( player3 , ROCKET_LAUNCHER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , ELECTRO_GUN))
      GIVE_WEAPON( player3 , ELECTRO_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , SILENCED_MACHINE_GUN))
      GIVE_WEAPON( player3 , SILENCED_MACHINE_GUN , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , FLAME_THROWER))
      GIVE_WEAPON( player3 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , GRENADE))
      GIVE_WEAPON( player3 , GRENADE , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , MOLOTOV))
      GIVE_WEAPON( player3 , MOLOTOV , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , FLAME_THROWER))
      GIVE_WEAPON( player3 , FLAME_THROWER , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , PISTOL))
      GIVE_WEAPON( player3 , PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , DUAL_PISTOL))
      GIVE_WEAPON( player3 , DUAL_PISTOL , 1)
    ENDIF
    IF (CHECK_CHAR_CURR_WEAPON(player3 , SHOTGUN))
      GIVE_WEAPON( player3 , SHOTGUN , 1)
    ENDIF

  ENDIF

ENDIF

ENDWHILE
RETURN



sub_checkbomb:
WHILE (endlessloop = 1)

  // check if someone enters the explosion-trigger
  IF (bombloop = 0)
    IF ( LOCATE_CHARACTER_ANY_MEANS( player1  , 127.5 , 133.0 , 3.0  , 1.0 , 1.0) )
      SET bombloop = 1
      SET bomb_time_delay = 0
    ENDIF
    IF ( (numplayers > 1) AND (LOCATE_CHARACTER_ANY_MEANS( player2  , 127.5 , 133.0 , 3.0  , 1.0 , 1.0)))
      SET bombloop = 1
      SET bomb_time_delay = 0
    ENDIF
    IF ( (numplayers > 2) AND (LOCATE_CHARACTER_ANY_MEANS( player3  , 127.5 , 133.0 , 3.0  , 1.0 , 1.0)))
      SET bombloop = 1
      SET bomb_time_delay = 0
    ENDIF
  ENDIF


  // create the explosions, the counter creates some time delay.
  IF (bombloop > 0)
    ++ bomb_time_delay
  ENDIF

  IF ( bomb_time_delay > 1 )
    SET bomb_time_delay = 0

    IF (bombloop=1)
        EXPLODE_SMALL  (  126.5  ,  133.0 ,  2.0  )
        EXPLODE_SMALL  (  128.5  ,  133.0 ,  2.0  )
    ENDIF
    IF (bombloop=2)
        EXPLODE_SMALL  (  125.5  ,  133.0 ,  2.0  )
        EXPLODE_SMALL  (  129.5  ,  133.0 ,  2.0  )
    ENDIF
    IF (bombloop=3)
        EXPLODE_SMALL  (  124.5  ,  133.0 ,  2.0  )
        EXPLODE_SMALL  (  130.5  ,  133.0 ,  2.0  )
    ENDIF
    IF (bombloop=4)
        EXPLODE_SMALL  (  123.5  ,  133.0 ,  2.0  )
        EXPLODE_SMALL  (  131.5  ,  133.0 ,  2.0  )
    ENDIF
    IF (bombloop=5)
        EXPLODE_SMALL  (  122.5  ,  133.0 ,  2.0  )
        EXPLODE_SMALL  (  132.5  ,  133.0 ,  2.0  )
    ENDIF

    ++ bombloop

    // end of the loop
    IF (bombloop > 5 )
      SET bombloop = 0
    ENDIF
  ENDIF
    
ENDWHILE
RETURN



// At this strange place, you got a 2 in 3 chance to get a full load of
// weaponry; and a 1 in 3 chance to be blown to bits !! Do you feel lucky
// today, punk?

sub_allweapons:
WHILE (endlessloop = 1)

  IF (LOCATE_CHARACTER_ANY_MEANS( player1  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0))

    // only do this, if you've only just entered the block!!
    IF (iamatweapons1 = 0)

      // change the status into occupied
      SET iamatweapons1 = 1

      // and, be generous and give the lucky one a lot of guns
        
      IF (random02 = 0)
        // bad luck - you lose all you got, including your LIFE !!
        EXPLODE_LARGE  (  83.5  ,  157.5 ,  2.0  )

      ELSE

        // lucky bastard, you get free weapons !!

        GIVE_WEAPON ( player1, ROCKET_LAUNCHER, 15 )
        GIVE_WEAPON ( player1, MOLOTOV, 30 )
        GIVE_WEAPON ( player1, GRENADE, 30 )
        GIVE_WEAPON ( player1, FLAME_THROWER, 30 )
        GIVE_WEAPON ( player1, SILENCED_MACHINE_GUN, 100 )
        GIVE_WEAPON ( player1, ELECTRO_GUN, 100 )
        GIVE_WEAPON ( player1, MACHINE_GUN, 100 )
        //GIVE_WEAPON ( player1, CAR_MACHINE_GUN, 30 )
        //GIVE_WEAPON ( player1, CAR_MINE, 10 )
      ENDIF

    ENDIF
  ENDIF

  IF (NOT(LOCATE_CHARACTER_ANY_MEANS( player1  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0)))
    SET iamatweapons1 = 0
  ENDIF

IF (numplayers > 1)   // then, check if player 2 is near this block
  IF (LOCATE_CHARACTER_ANY_MEANS( player2  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0))

    // only do this, if you've only just entered the block!!
    IF (iamatweapons2 = 0)

      // change the status into occupied
      SET iamatweapons2 = 1

      IF (random02 = 0)
        // bad luck - you lose all you got, including your LIFE !!
        EXPLODE_LARGE  (  83.5  ,  157.5 ,  2.0  )

      ELSE
        // lucky bastard, you get free weapons !!

        GIVE_WEAPON ( player2, ROCKET_LAUNCHER, 15 )
        GIVE_WEAPON ( player2, MOLOTOV, 30 )
        GIVE_WEAPON ( player2, GRENADE, 30 )
        GIVE_WEAPON ( player2, FLAME_THROWER, 30 )
        GIVE_WEAPON ( player2, SILENCED_MACHINE_GUN, 100 )
        GIVE_WEAPON ( player2, ELECTRO_GUN, 100 )
        GIVE_WEAPON ( player2, MACHINE_GUN, 100 )
      ENDIF

    ENDIF
  ENDIF

  IF (NOT(LOCATE_CHARACTER_ANY_MEANS( player2  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0)))
    SET iamatweapons2 = 0
  ENDIF
ENDIF

IF (numplayers > 2)   // then, check if player 2 is near this block
  IF (LOCATE_CHARACTER_ANY_MEANS( player3  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0))

    // only do this, if you've only just entered the block!!
    IF (iamatweapons3 = 0)

      // change the status into occupied
      SET iamatweapons3 = 1

      IF (random02 = 0)
        // bad luck - you lose all you got, including your LIFE !!
        EXPLODE_LARGE  (  83.5  ,  157.5 ,  2.0  )

      ELSE

        // lucky bastard, you get free weapons !!

        GIVE_WEAPON ( player3, ROCKET_LAUNCHER, 15 )
        GIVE_WEAPON ( player3, MOLOTOV, 30 )
        GIVE_WEAPON ( player3, GRENADE, 30 )
        GIVE_WEAPON ( player3, FLAME_THROWER, 30 )
        GIVE_WEAPON ( player3, SILENCED_MACHINE_GUN, 100 )
        GIVE_WEAPON ( player3, ELECTRO_GUN, 100 )
        GIVE_WEAPON ( player3, MACHINE_GUN, 100 )
      ENDIF

    ENDIF
  ENDIF

  IF (NOT(LOCATE_CHARACTER_ANY_MEANS( player2  , 83.5 , 157.5 , 2.0  , 2.0 , 1.0)))
    SET iamatweapons2 = 0
  ENDIF
ENDIF
ENDWHILE
RETURN


sub_removeweapons:
WHILE (endlessloop = 1)

  // A trigger which removes weapons of a particular player ... each trigger
  // is specific to one player ! Be careful, since you may remove your
  // own weapons if you activate the wrong trigger !! The triggers are
  // located in the leftmost mid building.

  // on the roof
  IF ( LOCATE_CHARACTER_ANY_MEANS( player1  , 56.5 , 144.5 , 3.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player1 )
  ENDIF
  // on the other roof closeby
  IF ((numplayers > 1) AND ( LOCATE_CHARACTER_ANY_MEANS( player1  , 48.5 , 144.5 , 3.0  , 2.0 , 1.0)))
    REMOVE_WEAPONS( player2 )
  ENDIF
  // in the "hall" closeby
  IF ((numplayers > 2) AND ( LOCATE_CHARACTER_ANY_MEANS( player1  , 52.5 , 138.5 , 2.0  , 2.0 , 1.0)))
    REMOVE_WEAPONS( player3 )
  ENDIF

IF ( numplayers > 1 )
  IF ( LOCATE_CHARACTER_ANY_MEANS( player2  , 56.5 , 144.5 , 3.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player1 )
  ENDIF
  IF ( LOCATE_CHARACTER_ANY_MEANS( player2  , 48.5 , 144.5 , 3.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player2 )
  ENDIF
  IF ((numplayers > 1) AND ( LOCATE_CHARACTER_ANY_MEANS( player2  , 52.5 , 138.5 , 2.0  , 2.0 , 1.0)))
    REMOVE_WEAPONS( player3 )
  ENDIF
ENDIF

IF ( numplayers > 2 )
  IF ( LOCATE_CHARACTER_ANY_MEANS( player3  , 56.5 , 144.5 , 3.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player1 )
  ENDIF
  IF ( LOCATE_CHARACTER_ANY_MEANS( player3  , 48.5 , 144.5 , 3.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player2 )
  ENDIF
  IF ( LOCATE_CHARACTER_ANY_MEANS( player3  , 52.5 , 138.5 , 2.0  , 2.0 , 1.0))
    REMOVE_WEAPONS( player3 )
  ENDIF
ENDIF

ENDWHILE
RETURN


//
// WARNING
// Use of level 6 police
// may make the game go out of sync,
// it is nice nevertheless
// but I dont use it for the final version.

sub_mostwanted:
WHILE (endlessloop = 1)

  // If you enter one location, you get haunted by police level 6 instantly !!
  // But you are also set to invincible, so don't worry, at least for 1 minute ! !!

  IF ( (LOCATE_CHARACTER_ANY_MEANS( player1  , 122.0 , 163.5 , 4.0  , 2.0 , 1.0))
  AND ( invinc1 = 0 ) )
    ALTER_WANTED_LEVEL ( player1, 6 )
    SET_CHAR_INVINCIBLE ( player1, ON )
    SET invinc1 = 1
    SET count_invinc1 = 0
  ENDIF

  IF ( invinc1 = 1 )
    ++ count_invinc1
  ENDIF
  
  IF ((invinc1 = 1) AND (count_invinc1 > 60))   // after 60 seconds ??
    SET count_invinc1 = 0
    SET invinc1 = 0          // i.e., do this only once in the entire game !!
    SET_CHAR_INVINCIBLE ( player1, OFF )
    //GIVE_WEAPON ( player1, ROCKET_LAUNCHER, 15 )
  ENDIF

IF (numplayers > 1)
  IF ( (LOCATE_CHARACTER_ANY_MEANS( player2  , 122.0 , 163.5 , 4.0  , 2.0 , 1.0))
  AND ( invinc2 = 0 ) )
    ALTER_WANTED_LEVEL ( player2, 6 )
    SET_CHAR_INVINCIBLE ( player2, ON )
    SET invinc2 = 1
    SET count_invinc2 = 0
  ENDIF

  IF ( invinc2 = 1 )
    ++ count_invinc2
  ENDIF
  
  IF ((invinc2 = 1) AND (count_invinc2 > 200))   // after about 60 seconds ??
    SET count_invinc2 = 0
    SET invinc2 = 0          // i.e., do this only once in the entire game !!
    SET_CHAR_INVINCIBLE ( player2, OFF )
    //GIVE_WEAPON ( player1, ROCKET_LAUNCHER, 15 )
  ENDIF

ENDIF

ENDWHILE
RETURN


sub_villain:
WHILE (endlessloop = 1)

  IF (HAS_CHARACTER_DIED(villain_get_player1))
    SET villain1active = 0
  ENDIF
  IF ((numplayers > 1) AND (HAS_CHARACTER_DIED(villain_get_player2)))
    SET villain2active = 0
  ENDIF
  IF ((numplayers > 2) AND (HAS_CHARACTER_DIED(villain_get_player3)))
    SET villain3active = 0
  ENDIF

  // activate a villain to hunt down another player, around the position
  // from where they are activated !!

  IF ( (LOCATE_CHARACTER_ANY_MEANS( player1  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0) )
  AND ( iamatvillain1 = 0 ) )

    SET iamatvillain1 = 1
    // player 1: create villains to get 2 and 3

    IF ((numplayers > 1) AND (villain2active = 0))
      SET villain2active = 1
      villain_get_player2 = CREATE_CHAR ( 133.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player2 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player2, KILL_CHAR_ANY_MEANS , player2 )
    ENDIF

    IF ((numplayers > 2) AND (villain3active = 0))
      SET villain3active = 1
      villain_get_player3 = CREATE_CHAR ( 131.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player3 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player3, KILL_CHAR_ANY_MEANS , player3 )
    ENDIF
  ENDIF

  IF (iamatvillain1 = 1)
    IF (NOT( LOCATE_CHARACTER_ANY_MEANS( player1  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0)))
      SET iamatvillain1 = 0          // show that you've left the area
    ENDIF
  ENDIF


IF ( numplayers > 1 )
  
  IF ( ( LOCATE_CHARACTER_ANY_MEANS( player2  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0) )
  AND ( iamatvillain2 = 0 ) )

    SET iamatvillain2 = 1
    // player 1: create villains to get 2 and 3

    IF (HAS_CHARACTER_DIED(villain_get_player1))
      villain_get_player1 = CREATE_CHAR ( 133.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player1 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player1, KILL_CHAR_ANY_MEANS , player1 )
    ENDIF

    IF ((numplayers > 2) AND (HAS_CHARACTER_DIED(villain_get_player3)))
      villain_get_player3 = CREATE_CHAR ( 133.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player3 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player3, KILL_CHAR_ANY_MEANS , player3 )
    ENDIF
  ENDIF

  IF (iamatvillain2 = 1)
    IF (NOT( LOCATE_CHARACTER_ANY_MEANS( player2  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0)))
      SET iamatvillain2 = 0          // show that you've left the area
    ENDIF
  ENDIF

ENDIF

IF ( numplayers > 2 )
  
  IF ( (LOCATE_CHARACTER_ANY_MEANS( player3  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0) )
  AND ( iamatvillain3 = 0 ) )

    SET iamatvillain3 = 1
    // player 1: create villains to get 2 and 3

    IF (HAS_CHARACTER_DIED(villain_get_player1))
      villain_get_player1 = CREATE_CHAR ( 133.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player1 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player1, KILL_CHAR_ANY_MEANS , player1 )
    ENDIF

    IF (HAS_CHARACTER_DIED(villain_get_player2))
      villain_get_player2 = CREATE_CHAR ( 133.0 , 144.0 , 2.0 ) 25 0 mugger END
      GIVE_WEAPON ( villain_get_player2 , SILENCED_MACHINE_GUN , 99 )
      SET_CHAR_OBJECTIVE ( villain_get_player2, KILL_CHAR_ANY_MEANS , player2 )
    ENDIF
  ENDIF

  IF (iamatvillain3 = 1)
    IF (NOT( LOCATE_CHARACTER_ANY_MEANS( player3  , 132.0 , 144.0 , 2.0  , 2.0 , 1.0)))
      SET iamatvillain3 = 0          // show that you've left the area
    ENDIF
  ENDIF

ENDIF

  
ENDWHILE
RETURN


sub_randomnum:
WHILE_EXEC ( endlessloop = 1 )
  // keep track of "random" numbers
  // Note the use of WHILE_EXEC - then the counts go MUCH faster, and the
  // numbers are really more randomlike !!

  // switch the random01 between 0 and 1 each turn - this effectively
  // creates a random number !
  IF ( random01 = 0 )
    SET random01 = 1
  ELSE
    SET random01 = 0
    //GIVE_WEAPON ( player1 , PISTOL, 1 )      // use for "speed" of the counter
  ENDIF

  // another one, yielding a random number between 0 and 2
  IF (random02 >= 2)
    SET random02 = 0
  ELSE
    ++ random02
  ENDIF
ENDWHILE
RETURN



LEVELSTART


  // On one of the pavewalk bridges over the main road, check if someone
  // is on top of it; then trigger bombs one the road below.

  thr_checkbomb = CREATE_THREAD sub_checkbomb:


  // check if someone enters the "get all weapons or die" trigger, detected
  // every time someone enters the area !! Note, you got 50% chance of getting
  // the weapons, and 50% chance to trigger a bomb !!

  thr_checkallweapons = CREATE_THREAD sub_allweapons:


  // A trigger which removes weapons of a particular player ... each triggers
  // works for a different player ! Be careful, since you may remove your
  // own weapons if you are at the wrong place !!

  thr_checkremoveweapons = CREATE_THREAD sub_removeweapons:


  // If you enter one location, you get haunted by police level 6 instantly !!
  // But you are also set to invincible, so don't worry, at least for 1 minute ! !!
  //                       
  // I've disabled this, since the game always goes out of sync after
  // the soldiers go away !!
  //
  //thr_checkmostwanted = CREATE_THREAD sub_mostwanted:


  // activate a villain.
  thr_checkvillain = CREATE_THREAD sub_villain:


  // keep track of "random" numbers
  thr_checkrandomnum = CREATE_THREAD sub_randomnum:


  // keep track of the trigger that slows all the others down
  thr_checkaddammo = CREATE_THREAD sub_addammo:


  // keep track of the trigger that creates a tankie !
  thr_checkbuytank = CREATE_THREAD sub_buytank:



  // max number of heads in this level (<= 6) Really cool, at level 6 you
  // are persued by special forces !! But then the game gets out of sync,
  // hence, go up to 4 (5 is a nuisance)
  DECLARE_POLICELEVEL ( 4 )

  // order the generator to switch on and start generating weapons:

  SWITCH_GENERATOR   ( gen_weapon_pistol  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_machinegun1  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_machinegun2  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_rocketlauncher  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_electrogun  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_molotov  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_grenade  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_shotgun  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_flamethrower  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_silencedmgun  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_dualpistol  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_caroil  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_carmine  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_carmgun  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_health1  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_health2  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_health3  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_armor1  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_armor2  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_invulnerable  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_ddamage  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_dfire  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_electrify  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_invisible  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_gang  , ON  ) 

  SWITCH_GENERATOR   ( gen_powerup_health3  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_armor3  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_ddamage2  , ON  ) 
  SWITCH_GENERATOR   ( gen_powerup_dfire2  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_rocketlauncher2  , ON  ) 
  SWITCH_GENERATOR   ( gen_weapon_flamethrower2  , ON  )

  // add weapons to some cars
  GIVE_WEAPON( car_36, CAR_OIL, 25 )
  GIVE_WEAPON( car_15, CAR_MACHINE_GUN, 15 )
  GIVE_WEAPON( car_25, CAR_MINE, 10 )
  GIVE_WEAPON( car_32, CAR_MACHINE_GUN, 15 )
  GIVE_WEAPON( car_21, CAR_OIL, 25 )

  // Give alarms to some cars
  GIVE_CAR_ALARM( car_01 )
  GIVE_CAR_ALARM( car_03 )
  GIVE_CAR_ALARM( car_08 )
  GIVE_CAR_ALARM( car_11 )
  GIVE_CAR_ALARM( car_15 )
  GIVE_CAR_ALARM( car_19 )
  GIVE_CAR_ALARM( car_24 )
  GIVE_CAR_ALARM( car_26 )
  GIVE_CAR_ALARM( car_29 )
  GIVE_CAR_ALARM( car_32 )
  GIVE_CAR_ALARM( car_37 )
  GIVE_CAR_ALARM( car_38 )

  // set the directions of the dishes on the TV vans
  SET_DIR_OF_TV_VANS ( 100.0 , 100.0 )

  // start with lots of money ... only useful when editing and trying out
  // your nasty triggers...
  ADD_SCORE(player1, 50100)

  // player 1 belongs to gang 1
  //SET_GANG_INFO ( gng1, 15, PISTOL, MACHINE_GUN, MOLOTOV, 3,
  //                  10.0, 10.0, 2.0, 0, BUG, 1 )
  //ADD_CHAR_TO_GANG ( player1, gng1 )

  // The following needs to be checked all the time:

WHILE (endlessloop = 1)

   DO_NOWT

ENDWHILE

LEVELEND
