HughJanus 244 Posted January 10, 2020 Share Posted January 10, 2020 (edited) 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 January 11, 2020 by HughJanus typos, set to "SOLVED" Quote Link to comment Share on other sites More sharing options...
HughJanus 244 Posted January 11, 2020 Author Share Posted January 11, 2020 (edited) 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 January 11, 2020 by HughJanus typos, removed code which wasnt working properly 1 Quote Link to comment Share on other sites More sharing options...
LMS 674 Posted January 13, 2020 Share Posted January 13, 2020 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. Quote Link to comment Share on other sites More sharing options...
HughJanus 244 Posted January 13, 2020 Author Share Posted January 13, 2020 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.