semaphores Posted August 27, 2017 Share Posted August 27, 2017 I want to write a program that causes bullets to send people and cars flying away upon impact. I know how to activate the mod by pressing a button on my keyboard, but I'm not sure how to deal with the in-game physics. I've never worked with a physics engine before, so please understand if I'm not fully getting things right off the bat. Now I've looked at the GTAV NATIVE DB list of functions and came across these two that caught my attention ENTITY::APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS and ENTITY::APPLY_FORCE_TO_ENTITY However, I'm not sure how I'm supposed to call them in my code. Am I supposed to pass a bullet object for the entity parameter? If so, how am I supposed to "retrieve" it (is a bullet object a property that a weapon has?) Thanks guys! Link to comment Share on other sites More sharing options...
Jitnaught Posted September 10, 2017 Share Posted September 10, 2017 You would have to do something like this //check that player is alive and is shooting a weaponif (Game.Player.Character.IsAlive && Game.Player.Character.IsShooting){ Ped[] nearbyPeds = World.GetNearbyPeds(Game.Player.Character, 100f); foreach (Ped p in nearbyPeds) { Yield(); //check if ped has been damaged by the player by his current weapon if (p.HasBeenDamagedBy(Game.Player.Character) && Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_WEAPON, p, (uint)Game.Player.Character.Weapons.Current.Hash, 0)) { //apply force in the direction of the player's camera (which should be in the same direction as the bullet) p.ApplyForce(World.RenderingCamera.Direction); Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, p); Function.Call(Hash.CLEAR_ENTITY_LAST_WEAPON_DAMAGE, p); break; } }} jedijosh920 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now