@@ -575,8 +575,8 @@ item &item::ammo_set( const itype_id &ammo, int qty )
575
575
qty = ammo_capacity ( ammo_type );
576
576
577
577
// else try to add a magazine using default ammo count property if set
578
- } else if ( !magazine_default ().is_null () ) {
579
- item mag ( magazine_default () );
578
+ } else if ( !magazine_default ( true ).is_null () ) {
579
+ item mag ( magazine_default ( true ) );
580
580
if ( mag.type ->magazine ->count > 0 ) {
581
581
qty = mag.type ->magazine ->count ;
582
582
} else {
@@ -9600,6 +9600,24 @@ skill_id item::melee_skill() const
9600
9600
return res;
9601
9601
}
9602
9602
9603
+
9604
+ int item::min_cycle_recoil () const
9605
+ {
9606
+ if ( !is_gun () ) {
9607
+ return 0 ;
9608
+ }
9609
+ int to_cycle = type->gun ->min_cycle_recoil ;
9610
+ // This should only be used for one mod or it'll mess things up
9611
+ // TODO: maybe generalize this so you can have mods for hot loads or whatever
9612
+ for ( const item *mod : gunmods () ) {
9613
+ // this value defaults to -1
9614
+ if ( mod->type ->gunmod ->overwrite_min_cycle_recoil > 0 ) {
9615
+ to_cycle = mod->type ->gunmod ->overwrite_min_cycle_recoil ;
9616
+ }
9617
+ }
9618
+ return to_cycle;
9619
+ }
9620
+
9603
9621
int item::gun_dispersion ( bool with_ammo, bool with_scaling ) const
9604
9622
{
9605
9623
if ( !is_gun () ) {
@@ -10117,8 +10135,20 @@ bool item::uses_magazine() const
10117
10135
return contents.has_pocket_type ( item_pocket::pocket_type::MAGAZINE_WELL );
10118
10136
}
10119
10137
10120
- itype_id item::magazine_default ( bool /* conversion */ ) const
10138
+ itype_id item::magazine_default ( bool conversion ) const
10121
10139
{
10140
+ // consider modded ammo types
10141
+ if ( conversion && !ammo_types ().empty () ) {
10142
+ const itype_id ammo = ammo_default ();
10143
+ for ( const itype_id mag : contents.magazine_compatible () ) {
10144
+ auto mag_types = mag->magazine ->type ;
10145
+ if ( mag_types.find ( ammo->ammo ->type ) != mag_types.end () ) {
10146
+ return mag;
10147
+ }
10148
+ }
10149
+ }
10150
+
10151
+ // otherwise return the default
10122
10152
return contents.magazine_default ();
10123
10153
}
10124
10154
0 commit comments