Wednesday at 04:49 PM3 days 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); // DUNNOI'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 movementbut 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.
Thursday at 04:52 AM3 days 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.
Thursday at 09:04 PM2 days 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 Thursday at 10:17 PM2 days by damianegu
Friday at 07:20 AM1 day 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):
Friday at 10:14 AM1 day 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!
Friday at 03:58 PM1 day 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)?
Friday at 08:56 PM1 day 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.