gokuta Posted July 28, 2020 Share Posted July 28, 2020 (edited) 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 July 28, 2020 by gokuta Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 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. Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 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? Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 (edited) 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 July 29, 2020 by gokuta Link to comment Share on other sites More sharing options...
Jack Posted July 29, 2020 Share Posted July 29, 2020 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; } } } } Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 (edited) ok, thanks. helped a bit. scm stuff irrelevant. still not clear how do I get camera pos Edited July 29, 2020 by gokuta Link to comment Share on other sites More sharing options...
ZAZ Posted July 29, 2020 Share Posted July 29, 2020 5 hours ago, gokuta said: still not clear how do I get camera pos whats your plan? CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 1 minute ago, ZAZ said: whats your plan? cry. no success yet Link to comment Share on other sites More sharing options...
ZAZ Posted July 29, 2020 Share Posted July 29, 2020 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 CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 (edited) 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 July 29, 2020 by gokuta Link to comment Share on other sites More sharing options...
Jack Posted July 29, 2020 Share Posted July 29, 2020 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; gokuta 1 Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
gokuta Posted July 29, 2020 Author Share Posted July 29, 2020 (edited) 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 July 29, 2020 by gokuta Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now