{$CLEO .cs}
{$USE ini}

0000:
03A4: script_name 'RBLOCK'   

:RBLOCK_01 
wait 100
if
    0AAB:   does_file_exist "cleo\bridgebloxA.ini"
jf @RBLOCK_01
if and
    Player.Defined($PLAYER_CHAR)
    Player.WantedLevel($PLAYER_CHAR) > 2
jf @RBLOCK_01
if and
    $ACTIVE_INTERIOR == 0
    Actor.Driving($PLAYER_ACTOR)
jf @RBLOCK_01
if or
     04A7:   actor $PLAYER_ACTOR driving_boat
     04A9:   actor $PLAYER_ACTOR driving_heli
     04AB:   actor $PLAYER_ACTOR driving_plane
then
jump @RBLOCK_01
end
30@ = 1
0AF0: $rb_num = read_int_from_ini_file "cleo\bridgebloxA.ini" section "RBLOCK" key "N"
if
    $rb_num > 0
jf @RBLOCK_01

:RBLOCK_17
wait 1
22@ = 0.0
0AD3: 28@s = string_format "coord%i" 30@
if and
0AF2: 22@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "x1"
0AF2: 23@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "y1"
0AF2: 24@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "z1"
0AF2: 25@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "x2"
0AF2: 26@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "y2"
0AF2: 27@ = read_float_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "z2"
jf @RBLOCK_END
jump @RBLOCK_19

:RBLOCK_19
0088: $rbx = 22@ //float
005F: $rbx += 25@
$rbx *= 0.5
0088: $rby = 23@ //float
005F: $rby += 26@     
$rby *= 0.5
0088: $rbz = 24@ //float
005F: $rbz += 27@
$rbz *= 0.5
050A: $rbS = distance_between_XYZ 22@ 23@ 24@ and_XYZ 25@ 26@ 27@
0063: 25@ -= 22@  // (float)
0063: 26@ -= 23@  // (float)
0063: 27@ -= 24@  // (float)
0604: get_Z_angle_for_point 25@ 26@ store_to $rba

:RBLOCK_22
if
  0100:  actor $PLAYER_ACTOR in_sphere $rbx $rby $rbz radius 100.0 100.0 100.0 sphere 0 in_car 
jf @RBLOCK_END
if
  0100:  actor $PLAYER_ACTOR in_sphere $rbx $rby $rbz radius 25.0 20.0 50.0 sphere 0 in_car
jf @RBLOCK_30
jump @RBLOCK_END

:RBLOCK_30
wait 0
if and
0AF0: $rb_mode = read_int_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "mode"
0AF0: 0@ = read_int_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "skin"
jf @RBLOCK_32
if
    $rb_mode == 1
jf @RBLOCK_31
gosub @RBLOCK_33
jump @RBLOCK_35

:RBLOCK_31
if
    $rb_mode == 0
jf @RBLOCK_END
if
    Player.WantedLevel($PLAYER_CHAR) > 3
then
    0@ = Player.WantedLevel($PLAYER_CHAR)
end
gosub @RBLOCK_33
jump @RBLOCK_35

:RBLOCK_32
if
    not 0@ > 0
then
008B: 0@ = $CURRENT_TOWN_NUMBER // (int)
end
$rb_mode = 0
jump @RBLOCK_31

:RBLOCK_33
0AD3: 28@s = string_format "custom%i" 0@
if and
0AF0: $rb_car = read_int_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "car"
0AF0: $rb_cop = read_int_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "cop"
0AF0: $rb_gun = read_int_from_ini_file "cleo\bridgebloxA.ini" section 28@s key "gun"    
jf @RBLOCK_END
28@ = 0
0781: get_weapon_with_ID $rb_gun model_to 28@
return         

:RBLOCK_35  
4@ = 0     // number of cars
5@ = 0.0   // barricade length
28@ = 346
//lengths between cars array
7@ = -4.0
8@ = 0.0
9@ = 0.0
10@ = 0.0
11@ = 0.0
$rbN = 0
0@ = 0
0089: 3@ = $rbS   // (float)

:RBLOCK_37
gosub @RBLOCK_rand
0063: 3@ -= 1@  // (float)
if
3@ >= 0.0
jf @RBLOCK_110   
005B: 7@(4@,5f) += 2@ // (float)
4@ += 1     
008A: $rbN = 4@ // (int)        
005B: 5@ += 1@ // (float)
if
4@ >= 5
jf @RBLOCK_37
jump @RBLOCK_110

:RBLOCK_rand
0209: 0@ = random_int_in_ranges 0 2
if
0@ == 1
then
    1@ = 5.0
    2@ = 6.6
else
    1@ = 8.0
    2@ = 8.0
end
return

:RBLOCK_110
//actor side position
Actor.StorePos($PLAYER_ACTOR, 1@, 2@, 3@) 
0063: 1@ -= 22@  // (float)
0063: 2@ -= 23@  // (float)
0604: get_Z_angle_for_point 1@ 2@ store_to 6@
0065: 6@ -= $rba  // (float)
02F6: 6@ = sine 6@ // (float)
if 
    6@ > 0.0 
then $rbf = 1.0
else $rbf = -1.0
end  

:RBLOCK_145
wait 1
Model.Load(1459)
if
    Model.Available(1459)
jf @RBLOCK_145                
if and
    1.0 >= 27@
    27@ >= -1.0
jf @RBLOCK_147
Object.Create($rb12, 1459, 22@, 23@, 24@)
0089: 6@ = $rba //rotation
6@ += 90.0
Object.Angle($rb12) = 6@
$rbf *= 5.0
0400: coords 0@ 1@ 2@ from_object $rb12 with_offset 0.0 $rbf 1.0
02CE: 13@ = ground_z_at 0@ 1@ 2@    
13@ += 0.6
Object.PutAt($rb12, 0@, 1@, 13@)
$rbf /= 5.0

:RBLOCK_147 
//scaling factor
if
    $rbN > 0
jf @RBLOCK_227
0089: 29@ = $rbS   // (float)
0063: 29@ -= 5@  // (float)
0093: 6@ = integer 4@ to_float
6@ += 1.0
0073: 29@ /= 6@ // (float)
$rbf *= -1.0
$rbf += 1.0
$rbf *= 90.0
0059: $rba += $rbf // (float)

:RBLOCK_151
wait 1
Model.Load($rb_car)
Model.Load($rb_cop)
Model.Load(28@)
if and
    Model.Available($rb_car)
    Model.Available($rb_cop)
    Model.Available(28@)
jf @RBLOCK_151

:RBLOCK_163
4@ -= 1
0@ = 0
31@ = 0.0
for 0@ = 0 to 4@
005B: 31@ += 7@(0@,5f) // (float)
005B: 31@ += 29@ // (float)
0077: 31@ /= $rbS // (float)
    for 1@ = 0 to 2
    0087: 3@ = 25@(1@,3f)  // (float)
    006B: 3@ *= 31@  // (float)
    005B: 22@(1@,3f) += 3@ // (float)
    end
Car.Create(12@(0@,5i), $rb_car, 22@, 23@, 24@)  
0089: 6@ = $rba //rotation
if or 
7@(0@,5f) == 6.6
7@(0@,5f) == 2.6
then
    6@ += 87.5
    0397: enable_car 12@(0@,5i) siren 1   
    0657: car 12@(0@,5i) open_door 2  
    7@(0@,5f) = 0.0
else
    6@ += 1.5
    7@(0@,5f) = 2.0                                
end  
Car.Angle(12@(0@,5i)) = 6@
01EC: make_car 12@(0@,5i) very_heavy 1   
end  
                
:RBLOCK_185 
for 0@ = 0 to 4@
0087: 29@ = 7@(0@,5f) // (float)
26@ = -2.0
0407: coords 1@ 2@ 3@ from_car 12@(0@,5i) with_offset 26@ 29@ 0.0
Actor.Create(17@(0@,6i), 6, $rb_cop, 1@, 2@, 3@)
Actor.Angle(17@(0@,6i)) = $rba
0085: 5@ = 0@ // (int)
if
    3 > 4@
    then
005A: 5@ += 4@  // (int)
29@ *= -1
7@(0@,5f) += -1.0
if
    7@(0@,5f) == -1.0
then
0657: car 12@(0@,5i) open_door 3
end  
006B: 26@ *= 7@(0@,5f)  // (float)
0407: coords 1@ 2@ 3@ from_car 12@(0@,5i) with_offset 26@ 29@ 0.0
5@ += 1
Actor.Create(17@(5@,6i), 6, $rb_cop, 1@, 2@, 3@)
    end     
end
jump @RBLOCK_186

:RBLOCK_186 
for 0@ = 0 to 5@
Actor.Health(17@(0@,6i)) = 400
Actor.GiveWeaponAndAmmo(17@(0@,6i), $rb_gun, 9999)
077A: set_actor 17@(0@,6i) acquaintance 4 to_actors_pedtype 0 // see ped.dat
0350: set_actor 17@(0@,6i) maintain_position_when_attacked 1
05E2: AS_actor 17@(0@,6i) kill_actor $PLAYER_ACTOR
end

:RBLOCK_226
Model.Destroy($rb_car)
Model.Destroy($rb_cop)
Model.Destroy(28@)
31@ = 0.0
29@ = 0.0
28@ = 0
1@ = 0.0
2@ = 0.0
3@ = 0.0

:RBLOCK_227
wait 1
if
    00FE: actor $PLAYER_ACTOR sphere 0 in_sphere $rbx $rby $rbz radius 100.0 100.0 50.0
jf @RBLOCK_343
if
    03CA: object $rb12 exists
jf @RBLOCK_337
if
    00FE: actor $PLAYER_ACTOR sphere 0 in_sphere $rbx $rby $rbz radius 45.0 45.0 25.0
jf @RBLOCK_227
0089: 3@ = $rbS   // (float)

:RBLOCK_238
3@ -= 3.5
0392: make_object $rb12 moveable 0
0400: coords 0@ 1@ 2@ from_object $rb12 with_offset 3.5 0.0 0.0
02CE: 29@ = ground_z_at 0@ 1@ 2@
6@ = Object.Angle($rb12)
Object.RemoveReferences($rb12)
if
    3@ >= 0.0
jf @RBLOCK_239
//09CA: set_object 12@ immunities BP 1 FP 0 EP 0 CP 1 MP 1
Object.Create($rb12, 1459, 0@, 1@, 29@)
Object.Angle($rb12) = 6@
jump @RBLOCK_238  

:RBLOCK_239
Model.Destroy(1459)
jump @RBLOCK_337

:RBLOCK_337
wait 1
if
    00FE: actor $PLAYER_ACTOR sphere 0 in_sphere $rbx $rby $rbz radius 100.0 100.0 50.0
jf @RBLOCK_359
if and
    Player.Defined($PLAYER_CHAR)
    Player.WantedLevel($PLAYER_CHAR) > 2
jf @RBLOCK_360
jump @RBLOCK_337

:RBLOCK_343
Object.RemoveReferences($rb12)

:RBLOCK_359
if
    $rbN > 0
jf @RBLOCK_END
for 0@ = 0 to 5@
Actor.DestroyWithFade(17@(0@,6i))
end
jump @RBLOCK_370

:RBLOCK_360
if
    $rbN > 0
jf @RBLOCK_END
for 0@ = 0 to 5@
Actor.RemoveReferences(17@(0@,6i))
077B: clear_actor 17@(0@,6i) acquaintance 4 to_actors_pedtype 0
end
jump @RBLOCK_370

:RBLOCK_370  
for 0@ = 0 to 4@
Car.RemoveReferences(12@(0@,5i))
end 

               
:RBLOCK_END
wait 0
30@ += 1
if 
    001F: 30@ > $rb_num  //int
jf @RBLOCK_17   
jump @RBLOCK_01