{$CLEO .cs}

{
by DK'22
Vol-GTA
}

const   
    //       
    CAR_LIGHT_SIZE = 1.7 //  
    CAR_LIGHT_SIZE_BIKE = 1.0 //    /
    CAR_LIGHT_INTENSITY = 1 //   (0-255)
    CAR_LIGHT_R = 0x64 //R
    CAR_LIGHT_G = 0 // G
    CAR_LIGHT_B = 0 // B
    CAR_LIGHT_OFFSET_FROM_DUMMY_X = 0.3 //     Y  .   1.0     0.0,       ""  
    CAR_LIGHT_OFFSET_FROM_DUMMY_Y = 0.3 //     X  .
    
    //   -      
    shadowRadius = 3.0 //   
    shadowIntensity = 0xFF //   (0-255)
    
    SEARCH_RADIUS = 5000.0 //      0.0 0.0 0.0   /-   
end

wait 250

while true    
    wait 0
    // check if player is available
    if
        not player.Defined(0)
    then
        continue
    end
    // Car Lights
    if
        0AE2: 3@ = random_vehicle_near_point 0.0 0.0 0.0 in_radius SEARCH_RADIUS find_next false pass_wrecked true
    then
        repeat
            0441: 30@ = car 3@ model
            0AB1: call_scm_func @isModelBikeOrQuad num_params 1 model 30@ store_to 21@
            0AB1: call_scm_func @isModelTrailer num_params 1 model 30@ store_to 22@
            if or
                22@ == true
                21@ == true
                0A01: model 30@ car
            then
                0A97: 10@ = car 3@ struct
                0A8E: 30@ = 10@ + 0x584
                0A8D: 30@ = read_memory 30@ size 4 virtual_protect false                
                if
                    08B7: test 30@ bit 2
                then 
                    0A8E: 30@ = 10@ + 0x22    
                    0A8D: 30@ = read_memory 30@ size 2 virtual_protect false    
                    mul(30@, 4)                                                              
                    inc(30@, 0xA9B0C8)                                                                     
                    0A8D: 30@ = read_memory 30@ size 4 virtual_protect false        
                    inc(30@, 0x5C)                                                           
                    0A8D: 30@ = read_memory 30@ size 4 virtual_protect false
                    inc(30@, 0xC)
                    0A8D: 14@ = read_memory 30@ size 4 virtual_protect false
                    inc(30@, 4)                                                           
                    0A8D: 15@ = read_memory 30@ size 4 virtual_protect false
                    inc(30@, 4)                                                         
                    0A8D: 16@ = read_memory 30@ size 4 virtual_protect false
                    if and //      
                        21@ == false
                        22@ == false
                    then    
                        dec(14@, CAR_LIGHT_OFFSET_FROM_DUMMY_X)
                    end
                    dec(15@, CAR_LIGHT_OFFSET_FROM_DUMMY_Y)
                    0407: store_coords_to 11@ 12@ 13@ from_car 3@ with_offset 14@ 15@ 16@
                    if or //    
                        21@ == true
                        22@ == true
                    then    
                        016F: particle 3 rot 0.0 size CAR_LIGHT_SIZE_BIKE CAR_LIGHT_INTENSITY CAR_LIGHT_R CAR_LIGHT_G CAR_LIGHT_B at 11@ 12@ 13@
                    else
                        016F: particle 3 rot 0.0 size CAR_LIGHT_SIZE CAR_LIGHT_INTENSITY CAR_LIGHT_R CAR_LIGHT_G CAR_LIGHT_B at 11@ 12@ 13@
                        mul(14@, -1.0)
                        0407: store_coords_to 11@ 12@ 13@ from_car 3@ with_offset 14@ 15@ 16@                           
                        016F: particle 3 rot 0.0 size CAR_LIGHT_SIZE CAR_LIGHT_INTENSITY CAR_LIGHT_R CAR_LIGHT_G CAR_LIGHT_B at 11@ 12@ 13@
                    end
                end
            end            
        until 8AE2: not 3@ = random_vehicle_near_point 0.0 0.0 0.0 in_radius SEARCH_RADIUS find_next true pass_wrecked true
    end
    // Emergency lights proections
    for 0@ = 0xC3E058 to 0xC3EF58 step 0x3C //   
        0A8E: 8@ = 0@ + 0x38 //   Entity( ),     
        0A8D: 1@ = read_memory 8@ size 4 virtual_protect false 
        0A8D: 28@ = read_memory 0xB74494 size 4 virtual_protect 0 //        
        0A8D: 28@ = read_memory 28@ size 4 virtual_protect 0   
        0A8D: 24@ = read_memory 0xB74494 size 4 virtual_protect false 
        inc(24@, 8) //  -     
        0A8D: 24@ = read_memory 24@ size 4 virtual_protect false   
        mul(24@, 0xA18) 
        005A: 24@ += 28@          
        if and //   Entity - ... 
            002D: 1@ >= 28@ 
            8025: not 1@ > 24@ 
        then 
            0AEB: 7@ = car_struct 1@ handle
            0441: 30@ = car 7@ model
            if or
                0A01: model 30@ car
                30@ == #COPBIKE // HPV1000
            then 
                0A8E: 8@ = 0@ + 0x0 
                0A8D: 21@ = read_memory 8@ size 4 virtual_protect false // X   
                inc(8@, 4) 
                0A8D: 22@ = read_memory 8@ size 4 virtual_protect false // Y   
                inc(8@, 4) 
                0A8D: 23@ = read_memory 8@ size 4 virtual_protect false // Z   
                0A8E: 8@ = 0@ + 0x2C 
                0A8D: 4@ = read_memory 8@ size 1 virtual_protect false // Red   
                inc(8@) 
                0A8D: 15@ = read_memory 8@ size 1 virtual_protect false // Green 
                inc(8@) 
                0A8D: 6@ = read_memory 8@ size 1 virtual_protect false // Blue   
                if 
                    23@ > 0.2 
                then 
                    if 
                        0137: car 7@ model == #COPBIKE // HPV1000 
                    then 
                        if and //       
                            21@ < 0.2 
                            21@ > -0.2 
                        then 
                            continue 
                        end 
                    end 
                    0407: store_coords_to 19@ 10@ 11@ from_car 7@ with_offset 21@ 22@ 23@ //                     
                    016F: add_shadow_type 3 rotation_factor 0.0 shadowRadius shadowIntensity RGB 4@ 15@ 6@ at 19@ 10@ 11@   
                end
            end 
        end 
    end 
end

:isModelBikeOrQuad
if or
    0@ == 462
    0@ == 581
    0@ == 448
    0@ == 522
    0@ == 461
    0@ == 521
    0@ == 523
then
    0AB2: ret 1 true
else if
        0@ == 463
        0@ == 586
        0@ == 468
        0@ == 471
        0@ == 571
    then
        0AB2: ret 1 true
    end
end
0AB2: ret 1 false

:isModelTrailer
if or
    0@ == 435
    0@ == 450
    0@ == 591
    0@ == 584
    0@ == 570
    0@ == 590
    0@ == 569                                                 
then
    0AB2: ret 1 true
end
0AB2: ret 1 false     