Author Topic: Can i ask why this piece of code does this thing?  (Read 78 times)

Offline Cosmitz

  • Zombie Food
  • *
  • Posts: 33
    • View Profile
Can i ask why this piece of code does this thing?
« on: August 13, 2017, 09:06:38 AM »
Code: [Select]
   // get fastest sight that can be used to improve aim further below @ref recoil
    int cost = INT_MAX;
    int limit = 0;
    if( !gun.has_flag( "DISABLE_SIGHTS" ) && effective_dispersion( gun.type->gun->sight_dispersion ) < recoil ) {
        cost  = std::max( std::min( gun.volume() / 250_ml, 8 ), 1 );
        limit = effective_dispersion( gun.type->gun->sight_dispersion );
    }


I'm not big on C, so let's parse this together. If the gun is using stock sights (a gun sight adds the disable sights flag) and at the same time the effective dispersion (perception/eye encumberance) is smaller than your recoil penalty (i assume something like you're not getting shaken up), then how much it costs you per turn to steady, and thus, for how long can you 'aim down' before maxed out, is modified by:

Code: [Select]
        cost  = std::max( std::min( gun.volume() / 250_ml, 8 ), 1 );
So what is that? Basically if your gun is smaller than 8 volume, you aim quicker.

Let's just check the game with 5 weapons of 160 dispersion and default sight dispersion for all of them, and volumes from 10 to 5.

10 = 31 seconds (technically it's somewhere around 516.77 time units since the value shown in the ingame in seconds is divided by 16.67)
9 = 31 seconds
8 = 31 seconds
7 = 27 seconds
6 = 23 seconds
5 = 19 seconds ( 316.73 units )


----------


So it's impossible to create quick-aiming bulky (but not heavy) weapons like bows (unsighted) without making their volume tiny and cheesing the inventory. Would this not be better as a function of volume AND weight? Or just modify it a tad since we assume this was meant for pistols/SMGs or small shotguns/carabines.

LE: Values with 7 of Hand encumberance, so one single tier of penalty because of that, but the progression remains true even then.
« Last Edit: August 13, 2017, 12:39:50 PM by Cosmitz »