Please help with clarification on Peds...
Working on another tiny script (all the tiny scripts!!!) that will make a non lethal stun gun (still lethal/default dmg values in your weapons.meta during missions though).
Working 95% perfect. 1 small problem I'm running into is testing on a ped that is sitting in a chair doesn't seem to be treated as a "Ped" class. I can stun them then they die. If I point the weapon at them until they get out of the chair then they act like a normal Ped and things work.
So initially I thought I needed to intercept their animation but that didn't work. I'm feeling like they might not be a Ped at all until they get up. I'm using a Ped collection/array(?) something like Ped nearbyPeds = World.GetNearbyPeds(pedPlayer.Position, 40f); and if they're not a ped until after they get out of their chair (or whatever sitting animation/scenario they might be in) would it be better to search for entities instead or will that still not catch them?
What could I scan for that wouldn't be overly performance intensive and still capture what I thought would be considered peds (basically any human npc that isnt the player).
The game is probably running some task on the peds when in that state, altering their behavior with different configuration values. Are you saying this issue is occurring for your weapon only?
Animals are also considered peds. I don't know what the .Net method does exactly but I'm sure it works fine. The native function for getting the closest ped doesn't reliably return the closest You can do it more manually, like something like this in C++
Probably, just trying to figure out what that task might be and if theres a way to clear it or make the ped temp invincible until it passes.
During testing, I was using a vector3 based on where the player was pointing (c#) and it works. I was able to get a reading of the base/current health. The interesting thing was it seemed to apply the health bit to the sitting ped but it still wound killing them once the stun animation completed.
Correct, this only affects the stun gun for now.
After some more researching and what not, it seems that peds can be in scenarios and won't be affected by the world.getnearby function. So that looks like something else I need to dig into, that also answers my initial question on why they're not reacting the same (it almost seems that the sitting scenarios have them in a vehicle of sorts and I need a way to make them exit or cancel).
I'm kind of thinking maybe they're part of group scenarios but the pastebin already shows a list of group scenarios so it seems unlikely (mostly due to nothing on the least seeming to match my test location - the tennis court area north of vespucci beach).
1 other side issue I noticed (and may not be an issue at all). I have zeroed out the damage the stun gun does but if the ped is running when getting zapped, they fall and receive fall damage. For the majority, would that be acceptable? Otherwise I would need to look into cancelling that out as well.
Edit: Well it's not technically the vehicle/scenario path I was chasing earlier. A raycast test told me their return type was still Peds. Dug a little deeper and the issue is some of the Peds are static and some function calls won't work on them. So far the only thing I'm reading that breaks static Peds free is to ragdoll them. Which kind of works but any peds in say the Jacuzzi instantly dies. Lots of stuff to poke through but for sure there seems to be the 2 types.