Jump to content

Photo
- - - - -

Mini Realism Mod - Accuracy enhancement


  • Please log in to reply
26 replies to this topic
Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 12 June 2007 - 12:57 #1

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[/QUOTE]

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.





sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

  • Joined: 11-May 2005

Posted 12 June 2007 - 13:35 #2

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.





Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 12 June 2007 - 13:46 #3

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.

sickboy
sickboy

    Colonel

  • Members
  • 9947 posts

  • Joined: 11-May 2005

Posted 12 June 2007 - 14:14 #4

[quote name='(Celery @ June 12 2007,15:46)']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.[/QUOTE]
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 Posted Image

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;[/QUOTE]

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"];[/QUOTE]

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 Posted Image





Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 12 June 2007 - 14:23 #5

Thanks for Posted Image sickboy! Posted Image

JukkaN
JukkaN

    Lance Corporal

  • Members
  • 46 posts

  • Joined: 10-June 2007

Posted 12 June 2007 - 20:18 #6

Nice work Sicboy Posted Image

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 13 June 2007 - 22:50 #7

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! Posted Image

whisper
whisper

    Chief Warrant Officer

  • Members
  • 3478 posts

  • Joined: 16-July 2001

Posted 14 June 2007 - 14:26 #8

just for my information, why dividing bullet speeds by 3.6?
Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 14 June 2007 - 17:10 #9

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.

InqWiper
InqWiper

    Master Gunnery Sergeant

  • Members
  • 1260 posts

  • Joined: 02-November 2001

Posted 14 June 2007 - 21:07 #10

Speed returns km/h and velocity returns m/s. 1m/s=3.6km/h. Theres your complex 3d math Posted Image
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.
"Cibit, come in my number two." - Terox

Want someone to JIP into your squad? Choose your words carefully.

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 15 June 2007 - 12:35 #11

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.

whisper
whisper

    Chief Warrant Officer

  • Members
  • 3478 posts

  • Joined: 16-July 2001

Posted 15 June 2007 - 12:53 #12

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 Posted Image




Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

hitmanff
hitmanff

    Master Sergeant

  • Members
  • 651 posts

  • Joined: 09-October 2002

Posted 15 June 2007 - 17:56 #13

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[/QUOTE]
Bellum pacis pater

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 15 June 2007 - 18:05 #14

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.





hitmanff
hitmanff

    Master Sergeant

  • Members
  • 651 posts

  • Joined: 09-October 2002

Posted 15 June 2007 - 18:23 #15

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.
Bellum pacis pater

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 15 June 2007 - 21:45 #16

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!





xmongx
xmongx

    Staff Sergeant

  • Members
  • 232 posts

  • Joined: 02-February 2007

Posted 15 June 2007 - 21:49 #17

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 Posted Image

Wolfrug
Wolfrug

    First Sergeant

  • Members
  • 825 posts

  • Joined: 25-July 2001

Posted 16 June 2007 - 08:49 #18

^_^

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. Posted Image

Thanks for the script!

Regards,
Wolfrug

Julian
Julian

    Corporal

  • Members
  • 66 posts

  • Joined: 04-April 2004

Posted 17 June 2007 - 17:04 #19

im new to this scripting stuff, to use this script where do I put it?
Posted Image{187th}Ufz.Günter Posted Image
www.187thMgdiv.com
A Red Orchestra Clan

Thread Starter
celery
celery

    First Lieutenant

  • Members
  • 5084 posts

  • Joined: 09-April 2003

Posted 17 June 2007 - 17:44 #20

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.