xplosivmufin 0 Posted May 24, 2019 So I'm using this code to create an event in my mission where our PBR driver is shot and killed (this is using the Unsung Mod). I've encountered an issue where the AI keeps missing the target. Is there an easier way to have my driver get shot than this code, if not, what do I need to adjust to actually have my sniper shoot the driver. I think the sniper is trying to aim at the body of the target which isn't visible (I want the sniper to hit the head). The code I used is from Grumpy Old Man, here it is: GOM_fnc_sniperKillTarget = { params ["_sniper","_target",["_debug",true]]; if (_debug) then { systemchat format ["%1 attempting to shoot %2.",typeof _sniper, typeof _target]; }; while {alive _sniper AND alive _target} do { sleep 3; _sniper reveal [_target,4]; _sniper doFire _target; }; if (!alive _sniper AND _debug) exitWith {systemchat "The sniper got killed!"}; {group _sniper forgetTarget _x} forEach (_sniper targets [true,0]); _sniper disableAI "AUTOCOMBAT"; _sniper setBehaviour "AWARE"; _sniper setUnitPos "UP"; _awayPos = _sniper getRelPos [1500,_target getRelDir _sniper]; if (!alive _target AND _debug) then {systemchat format ["The target got eliminated! Moving to grid %1!",mapGridPosition _awayPos]}; _sniper doMove _awayPos; true }; _debug = true; _shoot = [mysniper,myVIP,_debug] spawn GOM_fnc_sniperKillTarget; I used this code because I don't know how to code anything (I've never coded anything in my life), so I had to look for solutions on these forums. I had read on the forum I found this on that you could have the sniper anywhere on the map and shoot, and have the damage set to 1 or something and that would work but I do not know how. Share this post Link to post Share on other sites
pierremgi 4853 Posted May 24, 2019 Oh you know, it's strange to ask a Vietnam veteran to be a good sniper today. They don't have anymore the sharp view they had. Not saying @Grumpy Old Man is too old but... More seriously, is your target moving? what distance? Should be preferable to add a kind of static phase (intermediate waypoint with timeout). On the other hand, sometimes, it can be counter-productive to run this kind of code (reveal/dofire) every 3 seconds. Play with up to 10 or 15 sec value for example. 2 Share this post Link to post Share on other sites
froggyluv 2136 Posted May 25, 2019 Id probably (actually i do) throw a setSKill 1 in there somewheres Share this post Link to post Share on other sites
3l0ckad3 17 Posted May 26, 2019 there are multiple ways of sorting this out, however, it's not really reliable, try this method from Feuerex, he attaches a game logic to a unit, and he gets the game to shoot for him,,,,, and it seems to work well for him, he also has a mission example. I have done it your way in the past but found it unreliable. The best way, and most reliable, 100%, is just to simulate it. Other commands you might want to toy with enableAimPrecision setCustomAimCoef setUnitRecoilCoefficient setSkill Now, with the skill, you could try to adjust his aim shake, because by default they fire in a cone to emulate bullet spread. Aside from that, I have no clue, I had my sniper firing pretty decent at about 2k I think it was, but I didn't like the mixed outcomes. Like I said, the best way is just to simulate it, probably save you on taxing the server as well, not ideal for you I guess, but, it is the only way you'll get the end result you're looking for without bogging down server resources for half the desired outcome. GL Share this post Link to post Share on other sites
x3kj 1247 Posted May 26, 2019 PBR is the little patrol boat right? That means the drivers body is covered on most sides. AI do not target for the head specifically but center torso in many cases. So maybe you can create a fake target and attach it to the soldiers head memory point to get around it. Then let the sniper shoot at the fake target (together with the accuracy buffs from the posts above). Another alternative might be to artifically spawn the bullet only a short distance away from the boat, with a trajectory that intersects with the drivers head. That way you should automatically get all the effects (vfx, sound) compared to when you would do a setkill or similar. Share this post Link to post Share on other sites
xplosivmufin 0 Posted May 27, 2019 OK, thanks to everyone who has suggested fixes, I will try all of these! Share this post Link to post Share on other sites
xplosivmufin 0 Posted May 27, 2019 @x3kj How can I artificially spawn the bullet? I think that would be the best course of action. The actual scene doesn't need to have the actual AI shoot him, but just to seem like it did. So the easiest way to simulate this event would be the best option for me. Share this post Link to post Share on other sites
Alert23 215 Posted May 27, 2019 3 hours ago, xplosivmufin said: @x3kj How can I artificially spawn the bullet? I think that would be the best course of action. The actual scene doesn't need to have the actual AI shoot him, but just to seem like it did. So the easiest way to simulate this event would be the best option for me. I found this: https://www.google.de/amp/s/amp.reddit.com/r/armadev/comments/3u09gf/scripting_in_a_sniper_shot/ _bullet = createVehicle ["SomeKindOfBullet",(_unit modelToWorldVisual [1,0,1]),[],0,"NONE"]; _vector = vectorNormalized ((getPosATL _bullet) vectorFromTo (_unit modelToWorldVisual (_unit selectionPosition "head"))); _bullet setVelocity (_vector vectorMultiply 500) you still have to replace: _unit with the target name and replace: SomeKindOfBullet with the bullet-classname https://community.bistudio.com/wiki/Arma_3_CfgMagazines 1 Share this post Link to post Share on other sites