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.

Is there a way to make a Ped charge towards the player?

Featured Replies

TASK::TASK_FOLLOW_TO_OFFSET_OF_ENTITY(ped,    
player, // target
0, 0, 0,  // offsets
3.0f, //movespeed
-1,   // timeout
1.0f, // stoprange    
true, // persistFollowing           
false, // dunno
false, // walkonly  
false, false, false); // DUNNO

TASK::TASK_GO_TO_ENTITY(ped,   
player, // target
-1,   // timeout    
1.0f, // stoprange     
3.0f, // movespeed
0,0); // DUNNO

I've noticed that the NPC only rushes towards me if I am actively running, if I am still or walking it will start walking towards me. I am also using

PED::SET_PED_COMBAT_MOVEMENT(ped, 2); // 2 is Offensive movement

but it doesn't seem to make a difference. Most of the times the dude will just start casually walking towards me, resolutely but slowly.

I am trying to program behavior where under some favorable circumstances in combat, like when you are not paying attention to that specific NPC and you are relatively close, it just rushes you with the knife.

Any help will be appreciated.

Did you try the melee natives? I think there are some where you can set a melee target for a ped or even force it to attack another ped via melee.

  • Author
15 hours ago, HughJanus said:

Did you try the melee natives? I think there are some where you can set a melee target for a ped or even force it to attack another ped via melee.

The target I can set, that's not the problem. I am forcing the execution as well, that part works dandy. It's just that the guy won't start charging if I am not running away from him, whilst I want it to be more like a surprise attack, like "oh you are reloading behind some cover and the NPC is close? Get stabbed". This can't work if the guy just starts walking towards me with his knife out.

TASK::TASK_MELEE(ped, player, MISC::GET_HASH_KEY("AR_EXECUTION_FRONT"), 0, 0, 0, 0, 0);

Edited by damianegu

This maybe?

Or you could try tasking the ped with closing the distance (here you can set a speed), then tasking it to attack:

Or you could build a debugging function listing you the tasks a ped receives and then check if the task changes when the ped is transitioning from walking to running towards the player (if it changes, you could try tasking the ped with the second one):

  • Author

TASK_GO_TO_ENTITY Is what I am currently using. It works very similar to TASK_FOLLOW_TO_OFFSET_OF_ENTITY. Imma try SET_ENTITY_VELOCITY, didn't know about this function, thanks!

Sorry, I did not fully read your opening post, it seems^^

Have you tried to not force the ped to go to the player, but just tell it to attack the player via melee (maybe it will try to close the distance by itself)?

  • Author
4 hours ago, HughJanus said:

Sorry, I did not fully read your opening post, it seems^^

Have you tried to not force the ped to go to the player, but just tell it to attack the player via melee (maybe it will try to close the distance by itself)?

Turns out I was doing exactly that, prematurely overwriting TASK_GO_TO_ENTITY with TASK_MELEE. The melee task seems to have an integrated behavior to match PC's speed. TASK_GO_TO_ENTITY works perfectly well and doesn't care about whether PC is stationary or running, it will use the specified movement speed.
When I get the time I will fix the code and post it here. It's a really interesting behavior and it makes NPCs a lot more threatening.

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.