Skelt 10 Posted August 12, 2014 (edited) Hello, I am creating a mission which has a specific need to overhaul the way accuracy works. In short, I need to create an aimbot script. I am having some trouble finding a good starting point for the script and hope you guys could share some pseudocode with your thoughts of the best way to implement it. basically I am trying to: while the player is alive or in some main game loop: -gather enemies which are around the player <=100 meters and near the player's cursor. -firedEvent handler (I would think) to essentially re-aim the projectile -- It would be easy to just set the targets health to 1.. but then you could visually miss, and still kill an enemy, which is bad juju. Edit 2: Is there a way to raycast from the player? I have seen some scripts that appear to just turn your character to the enemy.. and that unfortunately is not enough, I need something that truly makes you accurate. ie: call bis_fnc_dirTo //is not enough I would not suggest posting real functional code to this thread and rather keep it more theoretical, with more thorough explanation and working code in private message, just because this type of code can be detrimental to online play in the right hands. If you absolutely must know: It will be an RTS style mission, which should explain to you the reason I need an aim-bot type script Edited August 12, 2014 by Skelt clarity Share this post Link to post Share on other sites
das attorney 858 Posted August 12, 2014 I have seen some scripts that appear to just turn your character to the enemy.. and that unfortunately is not enough, I need something that truly makes you accurate. Ironically, that code is by users registered on these forums. Share this post Link to post Share on other sites
Skelt 10 Posted August 12, 2014 That could be the case, not really sure of the intent of your comment but thanks. Is there a way to detect which selection the player is aiming at or the closest selection? Infantry selections"": The overall damage that determines the damage value of the unit. Unit dies at damage over 0.9. "head_hit": Unit dies at damage over 0.9. "body": Unit dies at damage over 0.9. "hands": Unit doesn't die with damage to this part. "legs": Unit doesn't die with damage to this part. Share this post Link to post Share on other sites
benargee 20 Posted August 12, 2014 (edited) That could be the case, not really sure of the intent of your comment but thanks.Is there a way to detect which selection the player is aiming at or the closest selection? https://community.bistudio.com/wiki/cursorTarget And where did you get that information on body part damage? Edited August 12, 2014 by Benargee Share this post Link to post Share on other sites
Skelt 10 Posted August 12, 2014 The quote came from this old BI thread, it may be deprecated but I don't really see why it would be. It is almost seeming as though I am going to have to delete the projectile spawned when the player fires (if possible), then replace those projectiles with ones that target the nearest selection.. The only problem I see with this, is that taking into account the weapon caliber... spawning a standard round no matter the weapon seems doable, but selecting the correct round for the weapon from the CfgWeapons might take too long and break the script... Share this post Link to post Share on other sites
Beerkan 71 Posted August 12, 2014 The quote came from this old BI thread, it may be deprecated but I don't really see why it would be. It is almost seeming as though I am going to have to delete the projectile spawned when the player fires (if possible), then replace those projectiles with ones that target the nearest selection.. The only problem I see with this, is that taking into account the weapon caliber... spawning a standard round no matter the weapon seems doable, but selecting the correct round for the weapon from the CfgWeapons might take too long and break the script... Or... thinking your logic through, you don't need to spawn a new projectile, you need to delete the original one, and replicate the hit point and damage on the target.(and I hope suggestions offered in this thread, including mine, are helping you to solve your problem, and are not contributing to the development of an aimbot cheat.) Share this post Link to post Share on other sites
Skelt 10 Posted August 12, 2014 Thanks Beerkan, but what if the projectile misses the target? I am going to start with 100% accuracy to enemy units within the players cursor, then from there, create a further algorithm to control hits / misses. I guess there is no point in conceiling the reasoning behind this script as I did with a spoiler in my first post, I am making a mission that uses mechanics similar to an RTS (Real Time Strategy) type game. Which makes it very difficult to aim. I'd like the players cursor to move to, and lock onto enemies within range, and within close proximity to the players cursor, then provide 100% accuracy to the closest selection. ---------- Post added at 06:16 PM ---------- Previous post was at 06:05 PM ---------- It doesn't have to be a elegant solution by any means, any old hack job will do. hmm, so fired event handler > capture the caliber fired > delete it > spawn new projectiles aimed at closest selections > setHit to that selection? ---------- Post added at 06:24 PM ---------- Previous post was at 06:16 PM ---------- Well thinking over cursorTarget; that is going to return an object, and not a selection of the object, so it would seem getting the selection that the projectile is going to hit will have to be in the greater algorithm. Share this post Link to post Share on other sites
Beerkan 71 Posted August 12, 2014 ... I am making a mission that uses mechanics similar to an RTS (Real Time Strategy) type game. Which makes it very difficult to aim. Ahh.. I think I just worked out where you're going with this, so I'll not give the game away. Look forward to seeing your work. Here's some toys to play with. BIS_fnc_inAngleSector lineIntersects Line of sight Enemy-Detection Share this post Link to post Share on other sites
Skelt 10 Posted August 12, 2014 Thanks Beerkan, those are a huge help! I am going to continue to research this before I start. I hope others may also include more implementation theories they may have, what eventHandler, bis functions, specific scripting commands they may use, and when/what they would detect, overall just general logic and or pseudocode. Thanks again, you've been a great help already Beerkan. Share this post Link to post Share on other sites
Jigsor 176 Posted August 13, 2014 I've managed to single out a target depending where weapon is pointing with some help from weaponDirection. You maybe able to use this in combination with fired eventhandler. Filters include side, distance, and degrees right and left of current weapon the return should be the guy the weapon is closest to pointing at. This will check 15 degrees right or left of weapon direction. Lessen the values for tighter range. _Psorted = []; victim = Objnull; _potentialTargets = allunits; { if ((side _x == west) || (player distance _x >= 100)) then { _potentialTargets = _potentialTargets - [_x]; }; } foreach _potentialTargets; _weaponVectorDir = player weaponDirection (currentWeapon player); _wep_dir = (_weaponVectorDir select 0) atan2 (_weaponVectorDir select 1); if (_wep_dir < 0) then {_wep_dir = _wep_dir + 360;}; { _PtargetDir = [player, _potentialTargets select (count _potentialTargets)-1] call BIS_fnc_dirTo; if (_PtargetDir < 0) then {_PtargetDir = _PtargetDir + 360}; if ((_wep_dir - 15 > _PtargetDir) || (_wep_dir + 15 < _PtargetDir)) then { _potentialTargets = _potentialTargets - [_x]; }; } foreach _potentialTargets; if (count _potentialTargets > 0) then { _Psorted = [_potentialTargets,[],{[player, _potentialTargets select (count _potentialTargets)-1] call BIS_fnc_dirTo;},"ASCEND"] call BIS_fnc_sortBy; victim = _Psorted select 0; }; Share this post Link to post Share on other sites