Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
gokuta

get closest actor camera pointing at

Recommended Posts

gokuta

this opcode:

0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to [email protected] closest_ped_to [email protected]

gives closest actor. Not exactly what I need. How do I get actor handle, which is closest to me, but in a specific direction where I'm looking at. How to do that... need massive help on this! Any help much appreciated.

 

Most certainly will us plugin-sdk for this. Need to get camera position and camera looking-at position. Also I will need to loop through all peds and check their positions. How do I do it? So... I seriously need some help, no tutorials could be found regarding this.

Edited by gokuta

Share this post


Link to post
Share on other sites
gokuta

alright guys, problem almost solved. Still one problem persists. Alright, so I loop through all the peds and I want to skip player character (that is myself as a player). How do I check whether character is me? For some reason `ped->IsPlayer()` returns TRUE for characters, that are not me as well.

Share this post


Link to post
Share on other sites
gokuta

oh yas yas yaaas, one more question. How do I get camera position and vector, where camera is looking at? Cuz me tried these two `CVector m_vecAimingTargetCoors;` and `CVector m_vecGameCamPos;` but I get nonsensical results. Well, I definitely do not know what parameters meen what. No tutorials available. Anybody knows?

Share this post


Link to post
Share on other sites
gokuta

ahh, yess yes yes... and one more question. So as far as I know (and I know nothing), I should use CCamera class to retrieve camera position. And I should not use CCam class to retrieve camera position. My opinion is based on nothing, because I know nothing. And I find absolutely nothing on the internet. No documentation, nothing at all. Any help? Which class should I use?

Edited by gokuta

Share this post


Link to post
Share on other sites
Jack

You might wanna use these scm commands:

GET_ACTIVE_CAMERA_POINT_AT  //  opcode_068E
IS_CHAR_ON_SCREEN   //  opcode_02CB

 

The next c++ code will kill any NPC visible on screen and close to a player within a radius of 4.0 or less:

auto playa = FindPlayerPed();
for (int i = 0; i < CPools::ms_pPedPool->m_nSize; i++) {
    auto ped = CPools::ms_pPedPool->GetAt(i);
    if (ped && playa) {
        if (ped->m_nPedType > 3) { //    check ePedType  GET_PED_TYPE
            CVector pedPosition = ped->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f));      //  GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS
            CVector playaPosition = playa->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f));  //  GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS
            float radius3D = sqrt(powf(playaPosition.x - pedPosition.x, 2) + powf(playaPosition.y - pedPosition.y, 2) + powf(playaPosition.z - pedPosition.z, 2));
            if (ped->GetIsOnScreen() && radius3D <= 4.0f) {
                ped->m_fHealth = 0.0;
            }
        }
    }
}

Share this post


Link to post
Share on other sites
gokuta

ok, thanks. helped a bit. scm stuff irrelevant. still not clear how do I get camera pos

Edited by gokuta

Share this post


Link to post
Share on other sites
ZAZ
5 hours ago, gokuta said:

still not clear how do I get camera pos

whats your plan?

Share this post


Link to post
Share on other sites
gokuta
1 minute ago, ZAZ said:

whats your plan?

cry. no success yet

Share this post


Link to post
Share on other sites
ZAZ

068D: and 068E: only work for the default camera

068D: get_camera_position_to [email protected] [email protected] [email protected]
068E: get_camera_target_point_to [email protected] [email protected] [email protected]


camera_position is placed ca. 1 or 2 units behind player_actor, depending to the cam adjustment by key V
camera_target_point is placed between camera_position and player_actor

to get a view point anywhere in view direction needs needs to do some calcutions
test the script below to understand
key_press Backspace shows a searchlight in view direction for 2 seconds
it requires to give a target point, which is calculated 30 units infront

{$CLEO .cs}
:AIM_LIGHT_BY_CAMERA
thread 'AIMLIHT'

while true
    wait 0
    if 
        0256:   player $PLAYER_CHAR defined
    then
        if and
            0AB0:   key_pressed 8//----------------------------key = Backspace
            044B:   actor $PLAYER_ACTOR on_foot
            84AD:  not actor $PLAYER_ACTOR in_water
        then            
            068D: get_camera_position_to 1@ 2@ 3@
            068E: get_camera_target_point_to 7@ 8@ 9@  
            0087: 11@ = 7@ // (float) 
            0087: 12@ = 8@ // (float) 
            0087: 13@ = 9@ // (float)            
            0087: 21@ = 7@ // (float) 
            0087: 22@ = 8@ // (float) 
            0087: 23@ = 9@ // (float) 
            0063: 21@ -= 1@ // (float) 
            0063: 22@ -= 2@ // (float) 
            0063: 23@ -= 3@ // (float) 
            0013: 21@ *= 30.0 
            0013: 22@ *= 30.0 
            0013: 23@ *= 30.0             
            005B: 7@ += 21@ // (float) 
            005B: 8@ += 22@ // (float) 
            005B: 9@ += 23@ // (float)                       
            06B1: 31@ = create_searchlight_at 11@ 12@ 13@ radius 0.1 target 7@ 8@ 9@ radius 0.2 
            wait 2000                        
            06B2: destroy_searchlight 31@
        end
    end
end

 

Share this post


Link to post
Share on other sites
gokuta

gosh... I need help with plugin-sdk. I can do all the calculations, no problems. The problem is I have no idead how to GET the frickin' simpliest thing - camera position. I just need camera position, that's all I need. And where it's pointing. These opcodes:

068D: get_camera_position_to [email protected] [email protected] [email protected]
068E: get_camera_target_point_to [email protected] [email protected] [email protected] 

I need these exact things, just in plugin-sdk

 

Edited by gokuta

Share this post


Link to post
Share on other sites
Jack
37 minutes ago, gokuta said:
068D: get_camera_position_to [email protected] [email protected] [email protected]
068E: get_camera_target_point_to [email protected] [email protected] [email protected] 

I need these exact things, just in plugin-sdk

 

 

//   068D: get_camera_position_to [email protected] [email protected] [email protected]
float camX = TheCamera.m_aCams->m_vecSource.x;
float camY = TheCamera.m_aCams->m_vecSource.y;
float camZ = TheCamera.m_aCams->m_vecSource.z;
         
//  068E: get_camera_target_point_to [email protected] [email protected] [email protected]
float camTargetX = camX + TheCamera.m_aCams->m_vecFront.x;
float camTargetY = camY + TheCamera.m_aCams->m_vecFront.y;
float camTargetZ = camZ + TheCamera.m_aCams->m_vecFront.z;

  • Like 1

Share this post


Link to post
Share on other sites
gokuta

yaas! that is basically it. Thanks, Jack, very helpful. to find the appropriate distance basically I need to calculate the magnitude (normalized) of vector cross product

Edited by gokuta

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.