Jump to content
View in the app

A better way to browse. Learn more.

RDR2Mods.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] How to find out if you're aiming at an NPC? [C++ Scripting]

Featured Replies

Hey folks,

 

does anyone know how to find out if the player is pointing at an NPC?

I would like the player to do less damage to NPCs (but not creatures), so I would like to lower the weapon damage modifier when pointing at an NPC.

Increasing NPCs health I already tried, but it seems to not have the exact same effect.

 

BR

HJ

Edited by HughJanus
typos, set to "SOLVED"

  • Author

Found some stuff in the nativeDB - here are the methods I needed:

 

 

And here's the code I ended up using:

Player player = PLAYER::PLAYER_ID();
if (PLAYER::IS_PLAYER_TARGETTING_ANYTHING(player) || PLAYER::IS_PLAYER_FREE_AIMING(player))
{
	Ped playertarget;
	if (PLAYER::GET_PLAYER_TARGET_ENTITY(player, &playertarget) || PLAYER::GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(player, &playertarget))
	{
		if (!PED::IS_PED_HUMAN(playertarget)) PLAYER::SET_PLAYER_WEAPON_DAMAGE_MODIFIER(player, 1.0);
	} else PLAYER::SET_PLAYER_WEAPON_DAMAGE_MODIFIER(player, 0.05);
}

 

 

Note: What is the difference between lowering the weapon damage modifier and giving peds more health? - I noticed that, for example, if you shoot someone near the neck and the "bleeding and running" task triggers, the ped usually runs for about 10 seconds then lies down to die. This stays the same even if the peds health is set to something as high as 9000. But if you set the damage modifier, the amount of health drained by blood loss will lower too -> peds will run around bleeding for way more than 10 seconds if your damage multiplier is low.

 

 

 

Edited by HughJanus
typos, removed code which wasnt working properly

On 1/11/2020 at 7:10 AM, HughJanus said:

Note: What is the difference between lowering the weapon damage modifier and giving peds more health? - I noticed that, for example, if you shoot someone near the neck and the "bleeding and running" task triggers, the ped usually runs for about 10 seconds then lies down to die. This stays the same even if the peds health is set to something as high as 9000. But if you set the damage modifier, the amount of health drained by blood loss will lower too -> peds will run around bleeding for way more than 10 seconds if your damage multiplier is low.

 

 

I suppose the difference is quite simple where one deals more/less damage and the other means the ped has more health to begin with which might delay hitting a threshold to trigger specific behavior.

  • Author
5 hours ago, LMS said:

 

I suppose the difference is quite simple where one deals more/less damage and the other means the ped has more health to begin with which might delay hitting a threshold to trigger specific behavior.

 

Yeah, that was my conclusion in the end too.

I first couldnt believe it, because I didnt think that burning or bleeding effects would be affected by player damage modifiers (but more like "do x damage" or "do x% of max_health damage").

Thanks for your continuing input!

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.