Jump to content
Sign in to follow this  
celery

Mini Realism Mod - Accuracy enhancement

Recommended Posts

Here is a realism mod that can be installed on individual maps via a script. All it does is increase the accuracy of some weapons to a believable level just like in OFP.

Download demo mission here!

The code in the script looks like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;This is the Mini Realism Mod made by Celery.

;It increases the accuracy of the weapons listed

;in _accuracyarray by making the bullet fly exactly

;where the barrel points, eliminating dispersion.

;

;Use and modification is unrestricted, crediting

;of the original author is not necessary but it

;would be a beautiful gesture.

;

;Activated by a "fired" eventhandler.

_unit=_this select 0

_weapon=_this select 1

_accuracyarray=["G36A","G36C","G36K","AK74","M16A2","M4","M4AIM","M4A1","Makarov","M9"]

_bullet=nearestobject [_unit, _this select 4]

?!(_weapon in _accuracyarray):exit

_speed=(speed _bullet)/3.6

_dir=_unit weapondirection _weapon

_vel=[(_dir select 0)*_speed,(_dir select 1)*_speed,(_dir select 2)*_speed]

_bullet setvelocity _vel

_bullet setvectordir _dir

exit

The script will be executed by an eventhandler, in the mission it's like this in the init line of the soldier:

this addeventHandler ["fired", {_this exec "cly_realism.sqs"}]

You can add or remove the weapon classnames as you see fit to include those weapons to have increased accuracy. The speed divided by 3.6 is the formula to make the 3 dimensional velocity match the original speed of the bullet. You can even increase the speed to make bullets faster and deadlier with less drop. I encourage everyone to modify the script, maybe even make it better and more advanced and show how you did it in here.

Share this post


Link to post
Share on other sites

Nice job mate, but especially since the fired eventhandler is running so many times esp in bigger firefightrs, you might want to consider rewriting this quickly to SQF, loading the code into a variable like: CLY_Accuracy

and then changing the eventhandler system to:

{_this call CLY_Accuracy}

replace call with spawn if you intend to use waitUntil or sleep inside ur script.

No need to reload cly_realism.sqs from file every shot fired.

Share this post


Link to post
Share on other sites

Since I'm not at the least skilled in writing sqf (and its performance superiority is not that apparent as discussed in an earlier topic), I will leave the honors to someone else. The script has already been tested in multiplayer and there were no performance differences. It's unprobable that I can bring any enhancements to the mod because I only make scripts to the point where I'm happy with how they work.

Share this post


Link to post
Share on other sites
Since I'm not at the least skilled in writing sqf (and its performance superiority is not that apparent as discussed in an earlier topic), I will leave the honors to someone else. The script has already been tested in multiplayer and there were no performance differences. It's unprobable that I can bring any enhancements to the mod because I only make scripts to the point where I'm happy with how they work.

No Noticeable performance drop doesn't mean we should just throw around with valuable cpu time etc. Especially not when concerning eventhandlers, esp not the fired one smile_o.gif

Here's ur SQF version:

CLY_Accuracy.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//This is the Mini Realism Mod made by Celery.

//It increases the accuracy of the weapons listed

//in _accuracyarray by making the bullet fly exactly

//where the barrel points, eliminating dispersion.

//

//Use and modification is unrestricted, crediting

//of the original author is not necessary but it

//would be a beautiful gesture.

//

//Activated by a "fired" eventhandler.

_unit=_this select 0;

_weapon=_this select 1;

_accuracyarray=["G36A","G36C","G36K","AK74","M16A2","M4","M4AIM","M4A1","Makarov","M9"];

_bullet=nearestobject [_unit, _this select 4];

if(!(_weapon in _accuracyarray))exitwith{};

_speed=(speed _bullet)/3.6;

_dir=_unit weapondirection _weapon;

_vel=[(_dir select 0)*_speed,(_dir select 1)*_speed,(_dir select 2)*_speed];

_bullet setvelocity _vel;

_bullet setvectordir _dir;

in init.sqs or sqf:

CLY_Accuracy = compile preProcessFile "CLY_Accuracy.sqf";

then to enable the eventhandler:

this addeventHandler ["fired", {_this call CLY_Accuracy}]

1 More suggestion btw, as we're speaking optimized scripting;

you could pull the _accuracyarray out of ur function and add it to the init.sqs/sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">CLY_accuracyarray=["G36A","G36C","G36K","AK74","M16A2","M4","M4AIM","M4A1","Makarov","M9"];

So in this case you would exchange in ur function the _accuracyarray with CLY_accuracyarray. This way the array gets only initialized once: at mission start/jip join, and not every single time the fire event is called. Win will be minimal, but scripting logic and smart-use of resources would make this method preference biggrin_o.gif

Share this post


Link to post
Share on other sites

The mod is being used in the newest versions of the Gamez-Club league maps by Frantic and I'm thinking of adding it in my deathmatches. I've played a few rounds and it feels almost like OFP again because you actually hit where you aim for once.

It deffo works as it should! thumbs-up.gif

Share this post


Link to post
Share on other sites

just for my information, why dividing bullet speeds by 3.6?

Share this post


Link to post
Share on other sites
just for my information, why dividing bullet speeds by 3.6?

Because that's how the velocity returns to the original value. I don't know the complex 3D math behind it, I just noticed that without dividing the bullet's speed was that much faster than normal.

Share this post


Link to post
Share on other sites

Speed returns km/h and velocity returns m/s. 1m/s=3.6km/h. Theres your complex 3d math tounge2.gif

Cant belive people actually think the ArmA weapons are too inaccurate. I didnt like how you could hit people in 1 shot from 500 meters with M16 in OFP. Much better firefights in ArmA.

Share this post


Link to post
Share on other sites
Cant belive people actually think the ArmA weapons are too inaccurate. I didnt like how you could hit people in 1 shot from 500 meters with M16 in OFP. Much better firefights in ArmA.

Still, as the game is meant to be realistic, the guns should be realistically accurate instead of adding artificial dispersion to them. Inaccuracy can be simulated with shakier hands. Personally I can't believe that anyone has a good time missing someone just because the bullets don't land where there ironsight or reticle suggests.

You should try playing one of the -Gc- CTF maps (v1.06b) and check out how the weapons handle. It's not as easy as in OFP because the sights move a bit, but it feels just as fair.

Share this post


Link to post
Share on other sites

awww... I missed the original purpose of the script, then.

Well, imho, OFP waypoints were easy-to-hit laser-like weapons, with far too much accuracy at range. They felt like paper in your hands, with far too much spray & pray capabilities

But that's what it is : an opinion wink_o.gif

Share this post


Link to post
Share on other sites

Is it really necessary to set the speed? I removed the speed calculation and setting fro the original demo script, and it seems to work just as accurate:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;This is the Mini Realism Mod made by Celery.

;It increases the accuracy of the weapons listed

;in _accuracyarray by making the bullet fly exactly

;where the barrel points, eliminating dispersion.

;

;Use and modification is unrestricted, crediting

;of the original author is not necessary but it

;would be a beautiful gesture.

;

;Activated by a "fired" eventhandler.

_unit=_this select 0

_weapon=_this select 1

_accuracyarray=["G36A","G36C","G36K","AK74","AKS74UN","M16A2","M4","M4AIM","M4A1","M4A1SD","Makarov","MakarovSD","M9","M9SD","M4SPR"]

_bullet=nearestobject [_unit, _this select 4]

?!(_weapon in _accuracyarray):exit

_dir=_unit weapondirection _weapon

_bullet setvectordir _dir

exit

Share this post


Link to post
Share on other sites
Is it really necessary to set the speed? I removed the speed calculation and setting fro the original demo script, and it seems to work just as accurate:

Apparently either velocity or direction can be used to guide the bullet to its target. Velocity did it by itself when I commented the direction change out, but I wasn't sure how it would affect visible tracers. If it really works with just setvectordir, I thank you for the heads up! I will continue using the velocity command myself though, because it also allows changing the speed of the bullet if necessary.

Share this post


Link to post
Share on other sites

Yes,

Regardless of, it's a very interesting find. Lots of things you can do with it. You could increase sniper rifle accuracy by increasing the bullet speed (and thus have less bullet drop). You could also use your idea to balance OPFOR and BLUFOR weapons by adding an equal (slight) random dispersion e.g. for both the M16A2 and the AK74.

Share this post


Link to post
Share on other sites

It just occurred to me that it's possible to make some kind of sight adjusting script from this template by slightly editing the vector of the bullet. That way you could "zero" the sights closer or farther than default. It would take lots of research and testing though, but if someone is up for the challenge, the result may be very interesting!

Share this post


Link to post
Share on other sites
Quote[/b] ]Still, as the game is meant to be realistic, the guns should be realistically accurate instead of adding artificial dispersion to them. Inaccuracy can be simulated with shakier hands. Personally I can't believe that anyone has a good time missing someone just because the bullets don't land where there ironsight or reticle suggests.

Im in two minds about this, i generally dont approve of things (that im aware of) that take control from the player, but ive learnt to be accurate with shaky hands in FPS, they would have to be seriously shaky to stop me making a shot. The pseudo-accuracy of arma sometimes feels right to me.

I can understand that for a competitive player it may seem cumbersome but sometimes (although i dont necessarily like it) it adds to the experience for me.

Id go with minimising dispersion rather than removing it, not that i have any knowledge about the stuff you guys do inlove.gif

Share this post


Link to post
Share on other sites

^_^

Thanks for this little thing. Although admittedly I didn't download it to get mah rifles to become -more- accurate, but LESS accurate. Reverse-engineered, you can add quite a lot of dispersion to the AIs guns. Lots of fun. biggrin_o.gif

Thanks for the script!

Regards,

Wolfrug

Share this post


Link to post
Share on other sites

im new to this scripting stuff, to use this script where do I put it?

Share this post


Link to post
Share on other sites
im new to this scripting stuff, to use this script where do I put it?

When you save your mission in the editor, go to My Docs\ArmA Other Profiles\Name\missions\missionname and create or move the script file there. Then write the addeventhandler line in the desired unit's init box and you're set.

Share this post


Link to post
Share on other sites
^_^

Thanks for this little thing. Although admittedly I didn't download it to get mah rifles to become -more- accurate, but LESS accurate. Reverse-engineered, you can add quite a lot of dispersion to the AIs guns. Lots of fun.  biggrin_o.gif

Thanks for the script!

Regards,

Wolfrug

You might as well change the precisionFriendly=;

precisionEnemy=;

values then in your armaprofile file then wink_o.gif

Share this post


Link to post
Share on other sites

@ofpforum

But that only translates to me getting the increased dispersion, not everyone else. smile_o.gif Modding the default settings like that just messes up mission design - however if it's intended in the mission by the mission designer, that changes things quite a lot.

Anyway : thanks for the script once again. The "real" use for it is quite useful as well, of course! biggrin_o.gif

Regards,

Wolfrug

Share this post


Link to post
Share on other sites
But that only translates to me getting the increased dispersion, not everyone else. smile_o.gif

Nope its the other way around, it only affects the AI, while the player remains unaffected by those values.

If you want the change the players accuracy then this script is a good solution. wink_o.gif

(Btw, no missions are messed up when changing those default values, as long as you keep both at the same value then the AI's will still be balanced against eachother, firefights will take a longer and the AI wont snipe you with a PK anymore. BI just messed the default values up.. tounge2.gif )

Share this post


Link to post
Share on other sites

I'm sorry, I was a bit unclear : I mean that only -my- personal experience will be different. If I design a mission where I want the enemies to be less accurate, it won't help if I change my OWN dispersion values, and I'm not going to write in the readme "please change the dispersion values in your cfg to these" either.

Same reason why mission designers can change the skill settings and such. That's what this script can be used for if thusly reverse-engineered. Bring real HD capabilities to the MISSION DESIGNERS, if they want to use it.

I.e., a guerilla mission where the enemies are all civilians with AKs, low skill, and this script which makes their weapons much less accurate to simulate untrained militia. Like Skaven's HD weapons in his excellent pack, except in this case you can define yourself how much dispersion you want!

See now? smile_o.gif

Regards,

Wolfrug

Share this post


Link to post
Share on other sites

Thanks Celery for the code snippet smile_o.gif

And thanks Sickboy for the invaluable coding tip smile_o.gif

Incidentally Celery, I wrote an eventhandler that I wanted applied to everything in the map, and the solution suggested to me was to make a huge trigger that covers everything, set it to Anybody, present, once

and have something like this in the on activation:

{_x addeventhandler ["killed", {[_this select 0, _this select 1] exec "myHandler.sqs"}]} foreach thislist;

correcting for new knowledge from Sickboy wink_o.gif this should give you some ideas about how to apply the eventhandler without using the init field for each unit.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×