Skip to content

Commit

Permalink
simplify jam_mult formula (CleverRaven#76059)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll authored Sep 1, 2024
1 parent 9ba86d3 commit 1870b3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@ ammo_effects define what effect the projectile, that you shoot, would have. List
"count" : 0, // Default amount of ammo contained by a magazine (set this for ammo belts)
"default_ammo": "556", // If specified override the default ammo (optionally set this for ammo belts)
"reload_time" : 100, // How long it takes to load each unit of ammo into the magazine
"mag_jam_mult": 1.25 // Multiplier for gun mechanincal malfunctioning from magazine, mostly when it's damaged; Values lesser than 1 reflect better quality of the magazine, that jam less; bigger than 1 result in gun being more prone to malfunction and jam at lesser damage level; zero mag_jam_mult (and zero gun_jam_mult in a gun) would remove any chance for a gun to malfunction. Only works if gun has any fault from gun_mechanical_simple group presented; Jam chances are described in Character::handle_gun_damage(); at this moment it is roughly: 0.000288% for undamaged magazine, 5% for 1 damage (|\), 24% for 2 damage (|.), 96% for 3 damage (\.), and 250% for 4 damage (XX), then this and gun values are summed up and multiplied by 1.8. Rule of thumb: helical mags should have 3, drum mags should have 2, the rest can be tweaked case by case, but mostly doesn't worth emulating it
"mag_jam_mult": 1.25 // Multiplier for gun mechanincal malfunctioning from magazine, mostly when it's damaged; Values lesser than 1 reflect better quality of the magazine, that jam less; bigger than 1 result in gun being more prone to malfunction and jam at lesser damage level; zero mag_jam_mult (and zero gun_jam_mult in a gun) would remove any chance for a gun to malfunction. Only works if gun has any fault from gun_mechanical_simple group presented; Jam chances are described in Character::handle_gun_damage(); at this moment it is roughly: 0.027% for undamaged magazine, 5% for 1 damage (|\), 24% for 2 damage (|.), 96% for 3 damage (\.), and 250% for 4 damage (XX), then this and gun values are summed up. Rule of thumb: helical mags should have 3, drum mags should have 2, the rest can be tweaked case by case, but mostly doesn't worth emulating it
"linkage" : "ammolink" // If set one linkage (of given type) is dropped for each unit of ammo consumed (set for disintegrating ammo belts)
```

Expand Down Expand Up @@ -4156,7 +4156,7 @@ Guns can be defined like this:
"sight_dispersion": 10, // Inaccuracy of gun derived from the sight mechanism, measured in 100ths of Minutes Of Angle (MOA)
"recoil": 0, // Recoil caused when firing, measured in 100ths of Minutes Of Angle (MOA)
"durability": 8, // Resistance to damage/rusting, also determines misfire chance
"gun_jam_mult": 1.25 // Multiplier for gun mechanincal malfunctioning, mostly when it's damaged; Values lesser than 1 reflect better quality of the gun, that jam less; bigger than 1 result in gun being more prone to malfunction and jam at lesser damage level; zero gun_jam_mult (and zero mag_jam_mult if magazine is presented) would remove any chance for a gun to malfunction. Only apply if gun has any fault from gun_mechanical_simple group presented; Jam chances are described in Character::handle_gun_damage(); at this moment it is roughly: 0.00018% for undamaged gun, 3% for 1 damage (|\), 15% for 2 damage (|.), 45% for 3 damage (\.), and 80% for 4 damage (XX), then this and magazine values are summed up and multiplied by 1.8
"gun_jam_mult": 1.25 // Multiplier for gun mechanincal malfunctioning, mostly when it's damaged; Values lesser than 1 reflect better quality of the gun, that jam less; bigger than 1 result in gun being more prone to malfunction and jam at lesser damage level; zero gun_jam_mult (and zero mag_jam_mult if magazine is presented) would remove any chance for a gun to malfunction. Only apply if gun has any fault from gun_mechanical_simple group presented; Jam chances are described in Character::handle_gun_damage(); at this moment it is roughly: 0.05% for undamaged gun, 3% for 1 damage (|\), 15% for 2 damage (|.), 45% for 3 damage (\.), and 80% for 4 damage (XX), then this and magazine values are summed up
"blackpowder_tolerance": 8,// One in X chance to get clogged up (per shot) when firing blackpowder ammunition (higher is better). Optional, default is 8.
"min_cycle_recoil": 0, // Minimum ammo recoil for gun to be able to fire more than once per attack.
"clip_size": 100, // Maximum amount of ammo that can be loaded
Expand Down
6 changes: 3 additions & 3 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ bool Character::handle_gun_damage( item &it )
int gun_damage = it.damage() / 1000.0;
switch( gun_damage ) {
case 0:
gun_jam_chance = 0.0000018 * firing.gun_jam_mult;
gun_jam_chance = 0.0005 * firing.gun_jam_mult;
break;
case 1:
gun_jam_chance = 0.03 * firing.gun_jam_mult;
Expand All @@ -707,7 +707,7 @@ bool Character::handle_gun_damage( item &it )
mag_damage = it.magazine_current()->damage() / 1000.0;
switch( mag_damage ) {
case 0:
mag_jam_chance = 0.00000288 * it.magazine_current()->type->magazine->mag_jam_mult;
mag_jam_chance = 0.00027 * it.magazine_current()->type->magazine->mag_jam_mult;
break;
case 1:
mag_jam_chance = 0.05 * it.magazine_current()->type->magazine->mag_jam_mult;
Expand All @@ -724,7 +724,7 @@ bool Character::handle_gun_damage( item &it )
}
}

const double jam_chance = ( gun_jam_chance + mag_jam_chance ) * 1.8;
const double jam_chance = gun_jam_chance + mag_jam_chance;

add_msg_debug( debugmode::DF_RANGED,
"Gun jam chance: %s\nMagazine jam chance: %s\nGun damage level: %d\nMagazine damage level: %d\nFail to feed chance: %s",
Expand Down

0 comments on commit 1870b3d

Please sign in to comment.