MaRcell Posted March 11, 2020 Share Posted March 11, 2020 I was wondering if there is any way to improve this system of ped / bot, when the bot sees the player he already shoots, and how do I create more bots on the msm team for them to try to kill my player? and like I want them to attack me without me attacking them ped = createPed(106, 2439.27856, -2096.04248 ,13.54688) addEventHandler("onClientPedDamage", getRootElement(), function(attacker) if source == ped then givePedWeapon(ped, 27, 500, true) setPedControlState(source, "fire", true) if attacker then setPedAimTarget(source,getElementPosition(attacker)) end end end ) Link to comment
The_GTA Posted March 11, 2020 Share Posted March 11, 2020 Hello MaRcell, you can improve this script by only firing if the attacker is an enemy player or ped or the vehicle that damaged the ped was controlled by an enemy entity. How about implementing a check for damage of the attack-target aswell? If the attack target has exploded or died then you can make the ped stop firing it's weapon. If you want to implement shooting-on-sight then I recommend client-side (mind trust/security risks of client-side logic) range and line-of-sight checking using "onClientRender" event handler, getDistanceBetweenPoints3D and processLineOfSight functions. Just loop through all the enemy peds, check that they in close proximity of the AI ped, check the line from center of AI ped to the enemy ped. If the processLightOfSight returns the enemy ped as hitElement then the AI ped can start shooting into it's direction. Would also be cool if you continued checking the line of sight to disable shooting if a wall is between shooter and target. The last thing you could improve is a movement navigation system for the peds. But this would be pretty advanced stuff. Link to comment
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