Help Neareast part from vehicle

ZaaxHash

Member
Joined
Jun 4, 2019
Messages
20
Solutions
1
Reaction score
2
Is possible get nearest part vehicle from my aim, or get some point collision closer?
 

ZaaxHash

Member
Joined
Jun 4, 2019
Messages
20
Solutions
1
Reaction score
2
I expected get parts of vehicle as hood, trunk, side of car, roof, bump, to check which one my aim is more closest, or other thing like a, get vehicle collision point nearest a screen coords
I hope it's clearer now
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,730
Solutions
2
Reaction score
116
So do you want the XYZ coordinates of the vehicle collison? Or do you want a script that will give you "Car: X Component: X" of what you are aiming at?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,492
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
Code:
:GetBikeWheelOffset
    {
     Example:
       0AB1: call_scm_func @GetBikeWheelPosition 2 bike 0@ componentId 1@ store_to 2@ 3@ 4@
    }
    0006: 2@ = 4
    006A: 2@ *= 1@  // (int)   
    0A97: 1@ = car 0@ struct
    000A: 1@ += 0x5A0   
    005A: 1@ += 2@  // (int)
    0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
    
    0085: 2@ = 1@ // (int)
    000A: 2@ += 0x40
    0A8D: 5@ = read_memory 2@ size 4 virtual_protect 0
    000A: 2@ += 0x4
    0A8D: 6@ = read_memory 2@ size 4 virtual_protect 0
    000A: 2@ += 0x4
    0A8D: 7@ = read_memory 2@ size 4 virtual_protect 0
            
    000A: 1@ += 0x4
    0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
    000A: 1@ += 0x10
    
    0AA5: call_method 0x7EDD60 num_params 3 pop 3 1@ 5@v 2@v
0AB2: ret 3 2@ 3@ 4@



:GetCarWheelOffset
    {
     Example:
       0AB1: call_scm_func @GetCarWheelOffset 2 car 0@ componentId 1@ store_to 2@ 3@ 4@
    }
    0006: 2@ = 4
    006A: 2@ *= 1@  // (int)
    0A97: 1@ = car 0@ struct
    000A: 1@ += 0x648   
    005A: 1@ += 2@  // (int)
    0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
    000A: 1@ += 0x40
    0A8D: 2@ = read_memory 1@ size 4 virtual_protect 0 // x
    000A: 1@ += 0x4
    0A8D: 3@ = read_memory 1@ size 4 virtual_protect 0 // y
    000A: 1@ += 0x4
    0A8D: 4@ = read_memory 1@ size 4 virtual_protect 0 // z
0AB2: ret 3 2@ 3@ 4@


:GetComponentCoordsOfCar
// 0AB1: @GetComponentCoordsOfCar 2 VehicleHandle 0@ ComponentID 7@ _Returned: XYZ 4@ 5@ 6@
IF AND
NOT 1@ < 1
NOT 1@ > 19
THEN
    IF 056E:   car 0@ defined
    THEN
        0A97: 0@ = car 0@ struct
        0A8E: 5@ = 0@ + 0x590 // [byte] The class of transport
        0A8D: 6@ = read_memory 5@ size 4 virtual_protect 0
        IF 6@ == 0 // CAutomobile
        THEN 0AA6: call_method 0x6A2210 struct {CVehicle}0@ num_params 2 pop 0 | {CVector X Y Z}2@v {int::componentId}1@
        END
    END
END
0AB2: ret 3 2@ 3@ 4@
// vehicle 1 - center
// tire 2 - wheel_rf_dummy
// tire 4 - wheel_rb_dummy
// tire 5 - wheel_lf_dummy
// tire 7 - wheel_lb_dummy
// vehicle 8 - near_rf_mirrow
// vehicle 9 - near_door_r_handle
// vehicle 10 - near_lf_mirrow
// vehicle 11 - near_door_l_handle
// vehicle 12 - near_rf_wheel
// vehicle 13 - near_lb_wheel
// vehicle 16 - front_center_between_window_and_hood
// vehicle 17 - back_center_between_window_and_trunk
// vehicle 18 - front_window
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,492
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
Start by finding the car that is closest to your crosshair and save it for reference. This can be done by checking the distance between the crosshair and all nearby cars. Once you have the nearest car, go through all its parts one by one. For each part, calculate how far it is from the crosshair. Compare the distances, and keep track of the part that is the closest to the crosshair. This way, you can identify the specific car part nearest to your crosshair.
 

ZaaxHash

Member
Joined
Jun 4, 2019
Messages
20
Solutions
1
Reaction score
2
So do you want the XYZ coordinates of the vehicle collison? Or do you want a script that will give you "Car: X Component: X" of what you are aiming at?
Yes, I want to get XYZ of collision, I was trying to get the vehicle parts and check the player fov as @Opcode.eXe said finally, but it didn't work out as expected, some vehicles seem to be missing some components.

But I saw an opcode that might help:

Code:
0BFF: process_line_of_sight start 0@ 1@ 2@ end 3@ 4@ 5@ check_solid true car true actor false object true particle false see_through_stuff false ignore_some_objects_for_camera true store_col_point_to 6@ entity_to 7@

So if a player (in this case the first 3 parameters) is aiming at another player (the next 3 parameters) and in the middle there is a vehicle, is it possible with this or another opcode to determine the coordinates or distance to this vehicle?
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,730
Solutions
2
Reaction score
116
Yes, I want to get XYZ of collision, I was trying to get the vehicle parts and check the player fov as @Opcode.eXe said finally, but it didn't work out as expected, some vehicles seem to be missing some components.

But I saw an opcode that might help:

Code:
0BFF: process_line_of_sight start 0@ 1@ 2@ end 3@ 4@ 5@ check_solid true car true actor false object true particle false see_through_stuff false ignore_some_objects_for_camera true store_col_point_to 6@ entity_to 7@

So if a player (in this case the first 3 parameters) is aiming at another player (the next 3 parameters) and in the middle there is a vehicle, is it possible with this or another opcode to determine the coordinates or distance to this vehicle?
Yeah those codes put out by Opcodexe are for general parts defined in a vehicles dff I believe. That opcode you put should work also providing it works the same way 06BD detects obstacles. Here's a script for testing what you want.
Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

THREAD 'CARCOL'

// DUMMY OBJECT
WHILE TRUE
    WAIT 0
    IF
        not model.Available(3000)
    THEN
        model.Load(3000)
    ELSE
        object.Create(0@, 3000, 0.0,0.0,0.0)
        08D2: object 0@ scale_model 1.0
        0382: set_object 0@ collision_detection 0
        BREAK   
    END
END

WHILE TRUE
    WAIT 0
    
    IF
        KEY_DOWN 2
    THEN
        CALL @GET_AIMING_POS 0 1@ 2@ 3@ 4@
        object.PutAt(0@, 1@, 2@, 3@)
        0AD1: "%d %f %f %f" 1 4@ 1@ 2@ 3@
    END
    
END

:GET_AIMING_POS // Ty again Opcodexe
31@ = FALSE       
FOR 4@ = 0.0 TO 250.0 STEP 0.1 // 250.0 = Range limit, Step 0.1 = accuracy, lower number may cause fps drop
    Actor.StorePos($PLAYER_ACTOR, 1@, 2@, 3@)
    0A9F: 5@ = current_thread_pointer
    5@ += 80
    0A8E: 6@ = 5@ + 12 // int
    0AA6: call_method 5327216 11989032 num_params 6 pop 0 6@ 5@ 3@ 2@ 1@ 4@
    IF
        86BD:   not no_obstacles_between 1@ 2@ 3@ and 8@ 9@ 10@ solid 0 car 1 actor 0 object 1 particle 0
    THEN
        31@ = TRUE // CAR DETECTED
        BREAK
    END
END
0@ = 0.0
1@ = 0.0
2@ = 0.0
005B: 0@ += 8@ // (float)
005B: 1@ += 9@ // (float)
005B: 2@ += 10@ // (float)
4@ = 0.0 // RESET THE AIM RADIUS 
0AB2: 4 0@ 1@ 2@ 31@
It's not that accurate however by the sounds of it I don't think it's possible to accurately determine where another player is aiming (atleast not to the same accuracy you can read your own aim). You should be able to replicate this for other players aim with this long lost snippet. Basically you would just loop through distances at set intervals (like in the get_aim_pos code) until it detects car collision (or nothing).
Code:
:get3DXYZInFrontOf{X,Y,Z,ZA,YA,Distance}
{   
   Return:
       PosX-InFrontOf
       PosY-InFrontOf
       PosZ-InFrontOf
      
   Example: 0AB1: call_scm_func @get3DXYZInFrontOf 6 XYZ 1@ 2@ 3@ Z_Angle 4@ Y_Angle 5@  Distance 7.0 Return_XYZ_To 6@ 7@ 8@

}
3@ *= -1.0
02F6: 6@ = sine 3@
006B: 6@ *= 5@
005B: 0@ += 6@
02F7: 6@ = cosine 3@
006B: 6@ *= 5@
005B: 1@ += 6@
02F7: 6@ = cosine 4@
0073: 5@ /= 6@
02F6: 6@ = sine 4@
006B: 5@ *= 6@
005B: 2@ += 5@
0AB2: ret 3 0@ 1@ 2@
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,492
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
I don't think it's possible to accurately determine where another player is aiming
Python:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY

WHILE TRUE
    WAIT 0
    FOR 31@ = 0 TO 1000
        IF
        0B23:  samp is_player_connected 31@
        THEN
            IF
            0B20: samp 29@ = actor_handle_by_samp_player_id 31@
            THEN
                IF
                02CB:   actor 29@ bounding_sphere_visible
                THEN
                    0AC8: 28@ = allocate_memory_size 32
                    0BBE: samp store_player 31@ aim_data 28@
                    0C0C: 27@ = struct 28@ offset 0x1 size 4 // Aimf1X   
                    0C0C: 26@ = struct 28@ offset 0x5 size 4 // Aimf1Y   
                    0C0C: 25@ = struct 28@ offset 0x9 size 4 // Aimf1Z   
                    0C0C: 24@ = struct 28@ offset 0xD size 4  // AimPosX     
                    0C0C: 23@ = struct 28@ offset 0x11 size 4  // AimPosY     
                    0C0C: 22@ = struct 28@ offset 0x15 size 4  // AimPosZ
//                    printf "DATA_READ! %0.1f %0.1f %0.1f | %0.1f %0.1f %0.1f" 1000 24@ 23@ 22@ 27@ 26@ 25@
                    IF AND
                    not 24@ == 0.0
                    not 23@ == 0.0
                    not 22@ == 0.0
                    THEN
                        IF OR
                        82D8:   actor 29@ current_weapon == 38   
                        82D8:   actor 29@ current_weapon == 34
                        THEN
                            25@ += 0.10
                            25@ -= 0.05
                        END

    
    
    
                      
                        0087: 20@ = 27@
                        0087: 19@ = 26@
                        0087: 18@ = 25@
        
                        31@ = 0.0
                        FOR 21@ = 0.0 TO 50.0 STEP 0.5
                            0087: 27@ = 20@
                            0087: 26@ = 19@
                            0087: 25@ = 18@
                            006B: 27@ *= 21@
                            006B: 26@ *= 21@
                            006B: 25@ *= 21@
                            005B: 27@ += 24@
                            005B: 26@ += 23@ 
                            005B: 25@ += 22@
                            
 
                            31@ += 0.01
                            095C: create_smoke_at 27@ 26@ 25@ velocity 0.0 0.0 0.0 RGBA 31@ 0.0 0.0 1.0 size 0.01 last_factor 0.01

                            IF
                            86BD:   are_obstacles_between 27@ 26@ 25@ and 24@ 23@ 22@ solid 1 car 1 actor 0 object 1 particle 0
                            THEN
                                BREAK
                            END
                        END
        


//                        actor.PutAt($PLAYER_ACTOR, 27@, 26@, 25@)
//                        0B55: convert_3D_coords 27@ 26@ 25@ to_screen 1@ 2@
//                        0B55: convert_3D_coords 24@ 23@ 22@ to_screen 3@ 4@
//                        0B69: render draw_box_pos 1@ 2@ size 2 2 color 0xFFFF0000
//                        0B69: render draw_box_pos 3@ 4@ size 4 4 color 0xFF00FF00
        
                        
//                        0B68: render draw_line_point1 1@ 2@ point2 3@ 4@ width 1 color 0xFF0000FF


  

                        
                        
                        
                    END   
                    0AC9: free_allocated_memory 28@     
                END     
            END
        END
    END
    IF
    0AB0: 88
    THEN
        0A92: RESTART "AimingAT.cs"
        004E: STOP THIS CLEO
    END
END
 
  • Like
Reactions: Zin
Top