Jump to content

How do status effects of NPCs work (limping, bleeding, etc.)? [C++ Scripting]


HughJanus
 Share

Recommended Posts

Hey dear RDR 2 community,

 

introduction:

over the weekend I set up a development environment for RDR 2 and have played around with C++ scripts (asi) a bit.

When I was studying years ago, I learned programming in Java and scripting in Python, so I am not completely new to coding.

I managed to make NPCs take more bullets by playing around with their health values, but have not come very far in what I actually wanted to do.

 

goal:

my goal is to make NPC behavior more dynamic and also realistic. If I shoot NPCs in the legs, they shouldnt be able to sprint for cover (just as an example).

I have yet to find out how to trigger a certain behavior (e.g. limping, lying on the floor, bleeding, etc.).

In GTA 5 there was a "writhe mode" -> NPCs which had a certain amount of health entered that state in which they squirmed on the ground and could be killed by 1 shot.

It seems that in RDR 2 it is the same thing. I dont want that. I want them, for example, to go down and still be able to take some bullets (so e.g. if I shoot their legs multiple times, so they have to go down, their friends should still be able to help them).

 

problem:

I would like to know how to trigger certain states (wounded, limping, etc.) and how I can circumvent the "writhe mode" (but still have NPCs play that animation, but without dying after taking 1 hit).

 

Is this knowledge already available?

I would really love to get into modding RDR 2! 🙂

Any help is much appreciated.

 

BR

HJ

 

Edited by HughJanus
  • Like 1
Link to comment
Share on other sites

I would assume it is easiest to override the movement clipset for the peds to achieve a limping effect (it worked reasonably well for V), but I am not sure what has been discovered in that area. As for writhe, perhaps try to use and then make them invincible? Not sure if that works or if the dying is hardcoded afterwards, but might be worth a shot.

 

Link to comment
Share on other sites

Thanks for the response!

I have already tried setting their entity_health to something as high as 5000, but unfortunately they still died with one shot.

I will try invincibility on the weekend, thanks!

 

As for overriding the movement clipset: I have searched the native database already for a lot of keywords (like "limp", "injured", "wound", etc.) but to no avail.

Where would I find those movement sets (do they have names like "set_movement_for_ped(int movementID, ped pedID)")? Or does it mean that they have not been discovered, if I havent found them by those words?

Link to comment
Share on other sites

That is the name for V more or less (SET_PED_MOVEMENT_CLIPSET), so it probably got renamed/reworked a bit in RDR2. I don't know if such a native has been discovered already unfortunately.

Link to comment
Share on other sites

Ah, I see. I found SET_PED_COMBAT_MOVEMENT in the nativeDB and I suppose the movement IDs will be known as soon as we have a working version of OpenIV?

Thanks for all your help!

 

Edit: I now tried the following

Player player = PLAYER::PLAYER_ID();
Ped playerPed = PLAYER::PLAYER_PED_ID();
const int x = 1024;
Ped peds[x];
int count = worldGetAllPeds(peds, x);

for (int i = 0; i < count; i++)
{
	if (peds[i] != playerPed)
	{
    	if (PED::IS_PED_HUMAN(peds[i]) && (PED::GET_PED_MAX_HEALTH(peds[i]) != pedhealth))
		{
			PED::SET_PED_MAX_HEALTH(peds[i], pedhealth);
			ENTITY::SET_ENTITY_HEALTH(peds[i], pedhealth, 0);
		}
		if (AI::IS_PED_IN_WRITHE(peds[i])) ENTITY::SET_ENTITY_INVINCIBLE(peds[i], true);
	}
}

I inserted the first "if" to check if any of this is working - and it does (peds can take more bullets).

But unfortuanely writhers still die (from bleeding out or one shot).

I guess I'll have to wait until the movement IDs get figured out and then override the usual behavior when peds are hit in certain bones.

Edited by HughJanus
new information
Link to comment
Share on other sites

7 hours ago, HughJanus said:

Ah, I see. I found SET_PED_COMBAT_MOVEMENT in the nativeDB and I suppose the movement IDs will be known as soon as we have a working version of OpenIV?

 

If it is the same as GTA V, SET_PED_COMBAT_MOVEMENT doesn't have anything to do with animations and instead determines how much the ped moves around while in combat.  If you set this to 0, for example, they will generally stand still while shooting.  I think setting it to 1 or 2 increases the amount that they'll move, flank, etc.

Link to comment
Share on other sites

On 1/10/2020 at 9:24 PM, HughJanus said:

Thank you.

Is there any database for GTA V from which we could draw the SET_PED_MOVEMENT_CLIPSET method idea and some values for clipsets?

I think googling for the native is probably the easiest to find some GTA V snippets for it.

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...