Jump to content

Is there a compendium of NPC bones somewhere?


HughJanus
 Share

Recommended Posts

  • 2 weeks later...

Maybe someone can help me if I explain what I'm trying to do: I am iterating through all the NPCs in the players surroundings and trying to check if they got hit in the leg. If they got hit in the leg, I flag the NPC. If an NPC got flagged, I compute a chance of stumbling for this NPC (so if he runs or sprints, there is a chance he stumbles and falls (I do that by setting the NPC to ragdoll and applying a light force to him, so he is pushed forward)).

 

Unfortunately until now I have not figured out how to check if an NPC got hit in the leg.

Link to comment
Share on other sites

It might be easiest to run GET_PED_LAST_DAMAGE_BONE after you shoot a ped and take your own notes. For the bigger parts the results should hopefully be consistent enough. Would be great if you shared the list if you ever get around to creating one!

 

Link to comment
Share on other sites

I might need your help there, bud :)

Because I have tried this already (and I wanted to get the int value shown on screen and not write it in a file), but I failed miserably^^

If you lend me a hand, I would be glad to create the list!

Link to comment
Share on other sites

Its the DrawText method that kills me.

I have something like that:

std::string text = "Last Damaged Bone = ";
int actBone;
if (PED::GET_PED_LAST_DAMAGE_BONE(lastTarget, &actBone))
{
	text += std::to_string(actBone);
	DrawText(0.5, 0.5, text);
}

But the DrawText method (which wants two doubles and a string) is throwing an error - it says it wants a string^^

 

Edit: Wrong info - the DrawText wants two floats and a char* and I couldnt get the str to char*. Just remembered that.

 

Edit 2: I have now googled a bit and have another solution, but I think the text will only get displayed for the split second the player is shooting:

 

if (PED::IS_PED_SHOOTING(playerPed))
{
	Entity playerTarget;
	if (PLAYER::GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(player, &playerTarget))
	{
		int actBone;
		std::string text = "Last Damaged Bone = ";
		if (PED::GET_PED_LAST_DAMAGE_BONE(playerTarget, &actBone))
		{
			text += std::to_string(actBone);
			int n = text.length();
			std::vector<int> temp(n + 1);
			char c[30];
			strcpy(c, text.c_str());
			DrawText(0.5, 0.5, c);
		}
	}
}

 

How would I be able to draw the text for longer? (if this works)

Edited by HughJanus
corrected the code snippet, added information
Link to comment
Share on other sites

Could you also include your DrawText function? I am not sure where you got it from. Before calling _DRAW_TEXT you probably also need to "convert" your string to something the game accepts via _CREATE_VAR_STRING which essentially copies your string data to a game-controlled buffer. That should then show the text. As you have said correctly it will only occur for one frame though, so it would be best to loop this function.

 

 

 

  • Like 1
Link to comment
Share on other sites

Yesterday evening I had half an hour time and did it (i used a fixed character array as a global variable which is shown permanently and I always fill that with the latest bone the playerPed hit).

I will share the code of my solution on the weekend when I have more time.

 

Edit:

so heres the code (you can use it just like that if your project has all of alexander blades SDK stuff included):

void DrawText(float x, float y, char* str)
{
	UI::DRAW_TEXT(GAMEPLAY::CREATE_STRING(10, "LITERAL_STRING", str), x, y);
}

void main()
{
	bool modScriptState{ false };
	constexpr int toggleKey{ VK_F8 };
	int msgTime{ 0 };
	char c[40];
	int act = 99999;
	std::string text = "Last Damaged Bone = ";

	while (true)
	{
		if (IsKeyJustUp(toggleKey))
		{
			modScriptState = !modScriptState;
			msgTime = GetTickCount() + 3000;
		}

		if (modScriptState)
		{
			Player player = PLAYER::PLAYER_ID();
			Ped playerPed = PLAYER::PLAYER_PED_ID();

			if (WEAPON::IS_PED_WEAPON_READY_TO_SHOOT(playerPed))
			{
				strcpy(c, text.c_str());
				DrawText(0.4, 0.4, c);
			}
			else
			{
				if (PED::IS_PED_SHOOTING(playerPed))
				{
					Entity playerTarget;
					if (PLAYER::GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(player, &playerTarget))
					{
						int actBone;
						if (PED::GET_PED_LAST_DAMAGE_BONE(playerTarget, &actBone))
						{
							act = actBone;
							text = "Last Damaged Bone = " + std::to_string(act);
							strcpy(c, text.c_str());
							DrawText(0.4, 0.4, c);
						}
					}
				}
			}
		}
		WAIT(0);
	}
}

void ScriptMain()
{
	srand(GetTickCount());
	main();
}

 

Edited by HughJanus
code added
Link to comment
Share on other sites

Good to see it's working now! Looking forward to your findings 🙂 I think for most of the bigger bones it will be quite simple but for others, such as the fingers, it could be trickier so I'd recommend starting with the more obvious ones.

Link to comment
Share on other sites

At first I went to analyze the leg bones, but the results are weird.

Here are the IDs I noted when shooting those zones:

  • bottom: 6884, 56200
  • thighs: 65478
  • knees: 6884, 55120
  • lower legs: 43312
  • ankles: 55120
  • feet: 33646, 34606, 45454

I dont really know what to think of this, but it made the thing I wanted work. I check if the last hit bone is any of those and then mark the NPC and make them stumble. It works if I shoot their leg or foot anywhere.

Edited by HughJanus
typos
Link to comment
Share on other sites

Thanks for the research! That also confirms that they use different ids than on GTA V unfortunately. I had a closer look based on your findings and could map a few bones (mix of peds and horses it seems) and find more ids, although some names appear multiple times with different values.

 

SKEL_ROOT: 0

SKEL_R_Thigh: 6884

reins: 7434

FACIAL_R_LipCorner: 10509

SKEL_R_Finger41: 11300

FACIAL_L_LipCorner: 31911

SKEL_Neck1: 14284

SKEL_Neck2: 14285

SKEL_Neck3: 14286

SKEL_Neck4: 14287

SKEL_Neck5: 14288

SKEL_Spine1: 14411

SKEL_Spine2: 14412

SKEL_Spine3: 14413

SKEL_Spine4: 14414

SKEL_Spine5: 14415

SKEL_R_Finger12: 16749

SKEL_L_Finger32: 16765

SKEL_R_Finger32: 16781

SKEL_L_Finger32: 16829

SKEL_Head: 21030

SKEL_SADDLE: 29245

SKEL_R_SATCHELROOT: 34484

SKEL_L_Finger41: 35876

SKEL_L_Finger12: 41325

SKEL_L_Finger12: 41326

SKEL_L_Finger12: 41405

SKEL_L_Finger32: 41341

SKEL_L_Finger32: 41357

SKEL_R_Calf: 43312

SKEL_L_Forearm: 53675

PH_bridle_attach_L: 53945

PH_L_LipAttach: 53945

PH_bridle_attach_R: 53951

PH_R_LipAttach: 53951

SKEL_R_Forearm: 54187

SKEL_L_CALF: 55120

PH_SaddleHorn: 62111

PH_bridle_wagon_L: 64311

PH_bridle_wagon_R: 64413

SKEL_L_Thigh: 65478

 

Confirmed Horse:

SKEL_ROOT: 0

SKEL_Neck2: 14285

SCALE_Pelvis: 19060

SCALE_Spine1: 38711

SCALE_Spine3: 38713

SPR_L_Saddlebag: 47850

SPR_R_Saddlebag: 50064

SPR_C_BedRoll: 53074

  • Like 1
Link to comment
Share on other sites

How did you manage to pinpoint the IDs to certain bones when the IDs come up multiple times with different names?

What I also noticed is that the ID you got for the head (21030) I get when I shoot a dead body (no matter where) - maybe it returns the last damaged bone before death for me?

Link to comment
Share on other sites

There are from some of the data files, but unfortunately are incomplete. I am not sure why there are multiple IDs for the same names, could be horse/ped again or something entirely unrelated. What happens when you shoot them in the leg until they die? Will it also return head afterwards?

Link to comment
Share on other sites

  • 1 month later...

I need some help.

I have been trying to apply force to certain bones, but they seem to vary for each NPC.

 

For example I tried to apply a force push to the right forearm (= 54187), when an NPC is down.

The sheriff in Valentine does work, but other NPC might be pushed in the left forearm, some even in the thigh,..

How can I make sure that I push every NPC in the right forearm - can I work with bone names somehow like this:

GET_ENTITY_BONE_INDEX_BY_NAME(Ped, "SKEL_R_Forearm");

 

Or does it need another name?

 

 

Edit: I just tried it with the bone names, but the result is the same. The Sheriff in Valentine keeps moving his arms, other NPCs mostly dont. Is that a known problem? How can it be solved?

Edited by HughJanus
Link to comment
Share on other sites

I wonder if some peds just do not have these bones (or use different names). It's hard to say without the models. Can you get valid positions for the forearm bone on the other peds?

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...
  • 3 months later...
On 2/3/2021 at 8:47 PM, atMee said:

SKEL_Neck0
SKEL_R_Hand
SKEL_L_Clavicle
SKEL_L_Hand
SKEL_L_Foot
SKEL_R_Clavicle
SKEL_Pelvis

 

Do you by any chance know the ID of SKEL_R_Foot?

Or maybe even better, have a list of all the bones? :D

Link to comment
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.

 Share

×
×
  • Create New...