Page 1 of 3 123 LastLast
Results 1 to 10 of 27

  Click here to go to the first Developer post in this thread.  

Thread: Mini Realism Mod - Accuracy enhancement

  1. #1

    Exclamation

    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 &#34;fired&#34; eventhandler.

    _unit=_this select 0
    _weapon=_this select 1
    _accuracyarray=&#91;&#34;G36A&#34;,&#34;G36C&#34;, &#34;G36K&#34;,&#34;AK74&#34;,&#34;M16A2&#34;,&#34 ;M4&#34;,&#34;M4AIM&#34;,&#34;M4A1&#34;,&#34;Makar ov&#34;,&#34;M9&#34;&#93;
    _bullet=nearestobject &#91;_unit, _this select 4&#93;
    ?&#33;&#40;_weapon in _accuracyarray&#41;&#58;exit

    _speed=&#40;speed _bullet&#41;/3.6
    _dir=_unit weapondirection _weapon
    _vel=&#91;&#40;_dir select 0&#41;*_speed,&#40;_dir select 1&#41;*_speed,&#40;_dir select 2&#41;*_speed&#93;

    _bullet setvelocity _vel
    _bullet setvectordir _dir

    exit[/QUOTE]

    The script will be executed by an eventhandler, in the mission it&#39;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.




  2. #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.




  3. #3
    First Lieutenant Celery's Avatar
    Join Date
    Apr 9 2003
    Location
    BI Forums
    Posts
    5,084
    Author of the Thread
    Since I&#39;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&#39;s unprobable that I can bring any enhancements to the mod because I only make scripts to the point where I&#39;m happy with how they work.

  4. #4
    Quote Originally Posted by (Celery @ June 12 2007,15:46)
    Since I&#39;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&#39;s unprobable that I can bring any enhancements to the mod because I only make scripts to the point where I&#39;m happy with how they work.
    No Noticeable performance drop doesn&#39;t mean we should just throw around with valuable cpu time etc. Especially not when concerning eventhandlers, esp not the fired one

    Here&#39;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 &#34;fired&#34; eventhandler.

    _unit=_this select 0;
    _weapon=_this select 1;
    _accuracyarray=&#91;&#34;G36A&#34;,&#34;G36C&#34;, &#34;G36K&#34;,&#34;AK74&#34;,&#34;M16A2&#34;,&#34 ;M4&#34;,&#34;M4AIM&#34;,&#34;M4A1&#34;,&#34;Makar ov&#34;,&#34;M9&#34;&#93;;
    _bullet=nearestobject &#91;_unit, _this select 4&#93;;
    if&#40;&#33;&#40;_weapon in _accuracyarray&#41;&#41;exitwith{};

    _speed=&#40;speed _bullet&#41;/3.6;
    _dir=_unit weapondirection _weapon;
    _vel=&#91;&#40;_dir select 0&#41;*_speed,&#40;_dir select 1&#41;*_speed,&#40;_dir select 2&#41;*_speed&#93;;

    _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&#39;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=&#91;&#34;G36A&#34;,&# 34;G36C&#34;,&#34;G36K&#34;,&#34;AK74&#34;,&#34;M1 6A2&#34;,&#34;M4&#34;,&#34;M4AIM&#34;,&#34;M4A1&#3 4;,&#34;Makarov&#34;,&#34;M9&#34;&#93;;[/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




  5. #5
    First Lieutenant Celery's Avatar
    Join Date
    Apr 9 2003
    Location
    BI Forums
    Posts
    5,084
    Author of the Thread
    Thanks for sickboy&#33;

  6. #6
    Lance Corporal
    Join Date
    Jun 10 2007
    Location
    Sauvo, Finland
    Posts
    46
    Nice work Sicboy

  7. #7
    First Lieutenant Celery's Avatar
    Join Date
    Apr 9 2003
    Location
    BI Forums
    Posts
    5,084
    Author of the Thread
    The mod is being used in the newest versions of the Gamez-Club league maps by Frantic and I&#39;m thinking of adding it in my deathmatches. I&#39;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&#33;

  8. #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

  9. #9
    First Lieutenant Celery's Avatar
    Join Date
    Apr 9 2003
    Location
    BI Forums
    Posts
    5,084
    Author of the Thread
    Quote Originally Posted by (whisper @ June 14 2007,17:26)
    just for my information, why dividing bullet speeds by 3.6?
    Because that&#39;s how the velocity returns to the original value. I don&#39;t know the complex 3D math behind it, I just noticed that without dividing the bullet&#39;s speed was that much faster than normal.

  10. #10
    Master Gunnery Sergeant
    Join Date
    Nov 2 2001
    Location
    Sweden
    Posts
    1,260
    Speed returns km/h and velocity returns m/s. 1m/s=3.6km/h. Theres your complex 3d math
    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.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •