Setup
Unless you need to mod sGunplay scripts, you may want to skip this step. By not specifying sGunplay as a required addon, you can make your mod compatible without a strong dependency to sGunplay, while keeping your modded items still compatible.
Add sGunplay as a dependency by adding it to the requiredAddons
inside your config.cpp
class CfgPatches {
class YourMod {
requiredAddons[] = {
"sGunplay"
};
};
};
Optics
PiP
If your optic has magnification (e.g. 2x, 4x, 6x etc), you should define some additional
attributes
to enable the PiP. These
attributes will have to be added in the config.cpp
class definition of your
optic.
The configurable attributes are:
s_pipRadius
: radius of the lens
0.1 = very small | 0.9 = almost full screen
s_pipMagnification
: intensity of the magnification
0.1 = low magnification | 0.5 = strong magnification
The final lens magnification also depends on the user option of the lens magnification. See user options for more info
s_pipBlur
: blur of the PiP circumference
0.01 = sharp | 0.3 = very blurred
The
s_pipBlur
MUST be a non-zero value or the PiP won't work. If you don't want blur, use small values instead (e.g. 0.001)s_pipChromAber
: chromatic aberration intensity
0.01 = sharp | 0.3 = very blurred
s_pipOffset
: horizontal and vertical offset of the PiP on the screen.
Acceptable values are between -1.0 and 1.0;
You shouldn't need to change these.
s_pipLensOffset
: horizontal and vertical offset of magnification
Acceptable values are between -1.0 and 1.0;
You shouldn't need to change these.
Other parameters
If your optic has a "fullscreen reticle", like the vanilla HuntingOptic, you should
enable the s_isFullscreen
to make the optic behave correctly, and
optionally the s_showEnterMisalignment
to enable a slight misalignment effect
upon entering the optic.
Both are boolean options: they accept true
(1) or false
(0)
s_isFullscreen = 1;
s_showEnterMisalignment = 1;
This is an example configuration of two optics
class cfgVehicles {
class ItemOptics;
class NAME_OF_YOUR_OPTIC : ItemOptics {
s_pipRadius = 0.3;
s_pipMagnification = 0.3;
s_pipBlur = 0.01;
s_pipChromAber = 0.2;
// rest of your config.cpp
};
class NAME_OF_YOUR_SNIPER_OPTIC : ItemOptics {
s_isFullscreen = 1;
s_showEnterMisalignment = 1;
s_pipRadius = 1.0;
s_pipMagnification = 0.2;
s_pipBlur = 0.01;
s_pipChromAber = 0.3;
// rest of your config.cpp
};
};
Recoils
If you have custom weapons which doesn't use custom recoil, but they instead use the recoils of some existing vanilla weapons, you can skip to this step
Before doing anything, it's important to understand how recoil works in sGunplay. Unlike DayZ vanilla, they do not follow predetermined pattern, but they're procedurally generated on many variables:
- Weapon attachments
- Player inventory weight
- Weapon weight
- Player stance (erect, crouched, prone)
- Player movement (standing, walking, jogging)
- Strength soft skill
Also it's important to know that the recoil definition is radically different from vanilla, since
they also behave radically different.
Recoil intensity will "accumulate" if you shoot faster than your ability to control the recoil and
to reset the weapon.
While short burst are manegeable, being accurate with a long spray is not an easy task (especially
at long engagements), but it will become easier once you reach the "apex" of the recoil. At that
point, you'll be able to be more consistent in controlling it.
Let's first understand what recoil really is made of:
The following recoil has been "amplified" for showcasing purposes
Mouse offset
Here we see only the recoil being applied to the mouse, that the player should eventually counter with mouse movements.

Hands offset
Here we see only the "stability", which is the recoil being applied to the hands. More stability means that the gun will stay closer to the center.

Misalignment
Here we see only the misalignment: the recoil causes the front and rear sight to misalign.

Kick
Here we see only the "kick", which is the recoil pushing the weapon into the shoulder.

The final result will be
The recoil has been "amplified" for showcasing purposes.

Let's see how a recoil is defined in sGunplay, using the AUGRecoil
as example
modded class AUGRecoil {
override void initRecoilParameters() {
handsRanges = {-1.750, 1.750, 2.750, 3.985};
handsAccumSpeed = 0.975;
handsResetSpeed = 0.725;
misalignIntensity = { 1.550, 0.550};
misalignAccumSpeed = 0.925;
misalignResetSpeed = 0.850;
mouseRanges = {-0.215, 0.215, 1.250, 1.750};
mouseTime = 0.150;
kick = 0.045;
kickResetTime = 2.250;
}
}
handsRanges
and mouseRanges
define the the ranges of the horizontal and
vertical of the value that will be generated.
{minimum_horizontal, maximum_horizontal, minimum_vertical, maximum_vertical}
Similarily misalignIntensity
defines the misalign intensity, which is based on the
handsRanges
{horizontal_intensity, vertical_intensity}
kick
describes in metres how much the weapon should "kick" into the shoulder, while
kickResetTime
will define how "fast" the kick will be reset.
Remember that the final recoil will depends on many variables, most importantly on attachments. Many weapons use the same recoil definition, but some of them allow attachments (i.e. buttstocks, handguards, etc.), while some other do not.
The recoil definition SHOULD be made as if your weapon doesn't have any attachments currently attached. For example an M4A1 without buttstock and handguard.
Doing this, will allow other weapons to use the same recoil but with different attachments stats. See the next section for more info.
Attachments stats
Attachments play a major role in the final recoil computation as they could heavily modify the before mentioned values of the recoils (i.e. mouse, stability, misalignment, kick), hence improving (or also worsen) the recoil.
How attachments stats work
All the stats are defined in percentage (0.0 = 0%, 0.69 = 69%, 1.0 = 100%, -0.42 = -42%) and
they're additive, which means that if two attachments are being used, and they reduce
the "kick" respecitevly by 40% and 29%, the final kick reduction will be of 69% (40 + 29 = 69).
So be mindful when choosing the stats.
Define attachments stats
The definition is done through the config.cpp
. The configurable attributes are:
s_recoilControlMouseX
: control of horizontal mouse offsets_recoilControlMouseY
: control of vertical mouse offsets_recoilControlStabilityX
: control of horizontal stabilitys_recoilControlStabilityY
: control of vertical stabilitys_recoilControlMisalignmentX
: control of horizontal misalignments_recoilControlMisalignmentY
: control of vertical misalignments_recoilControlKick
: control of the kick
I highly suggest not to modify the recoil control of the mouse offset, for a mere design reason.
This is an example of stats for Mp5 attachments:
class cfgVehicles {
class Inventory_Base;
class MP5k_StockBttstck : Inventory_Base {
s_recoilControlStabilityX = 0.50;
s_recoilControlStabilityY = 0.50;
s_recoilControlMisalignmentX = 0.00;
s_recoilControlMisalignmentY = 0.25;
s_recoilControlKick = 0.75;
};
class MP5_RailHndgrd : Inventory_Base {
s_recoilControlStabilityX = 0.20;
s_recoilControlStabilityY = 0.20;
s_recoilControlMisalignmentX = 0.50;
s_recoilControlMisalignmentY = 0.50;
};
class MP5_Compensator : Inventory_Base {
s_recoilControlMisalignmentX = 0.45;
s_recoilControlMisalignmentY = 0.05;
};
};
Integrated attachments
Some weapons may not have removable attachments (e.g. M16A1 rifle)
In this case it's possible to add stats for "integrated attachment" directly in your weapon class
class cfgWeapons {
class Rifle_Base;
class M16A2_Base : Rifle_Base {
s_recoilControlStabilityX = 0.65;
s_recoilControlStabilityY = 0.65;
s_recoilControlMisalignmentX = 0.75;
s_recoilControlMisalignmentY = 0.80;
s_recoilControlKick = 0.75;
};
};
So in this example, the M16A1 rifle will have those stats without attachments
A complete example
class cfgVehicles {
class Inventory_Base;
class MyModdedButtstock : Inventory_Base {
s_recoilControlStabilityX = 0.40;
s_recoilControlStabilityY = 0.40;
s_recoilControlMisalignmentX = 0.05;
s_recoilControlMisalignmentY = 0.15;
s_recoilControlKick = 0.60;
};
class MyModdedHandguard : Inventory_Base {
s_recoilControlStabilityX = 0.20;
s_recoilControlStabilityY = 0.20;
s_recoilControlMisalignmentX = 0.55;
s_recoilControlMisalignmentY = 0.45;
};
class MyModdedCompensator : Inventory_Base {
s_recoilControlMisalignmentX = 0.10;
s_recoilControlMisalignmentY = 0.05;
};
};
class cfgWeapons {
class Rifle_Base;
class MyModdedWeapon : Rifle_Base {
s_recoilControlStabilityX = 0.05;
s_recoilControlStabilityY = 0.05;
s_recoilControlMisalignmentX = 0.05;
s_recoilControlMisalignmentY = 0.05;
s_recoilControlKick = 0.05;
};
};
So using a MyModdedWeapon
with MyModdedButtstock
,
MyModdedHandguard
and MyModdedCompensator
as attachments, will
result in a final recoil control of:
stability control horizontal | stability control vertical | misalignment control horizontal | misalignment control vertical | kick control | |
---|---|---|---|---|---|
MyModdedButtstock | 0.40 | 0.40 | 0.05 | 0.15 | 0.60 |
MyModdedHandguard | 0.20 | 0.20 | 0.55 | 0.45 | 0.00 |
MyModdedCompensator | 0.00 | 0.00 | 0.10 | 0.05 | 0.00 |
MyModdedWeapon (integrated attachment stats) | 0.05 | 0.05 | 0.05 | 0.05 | 0.05 |
final result | 0.65 | 0.65 | 0.75 | 0.70 | 0.65 |