@@ -2723,7 +2723,7 @@ int Character::attack_speed( const item &weap ) const
2723
2723
return std::round ( move_cost );
2724
2724
}
2725
2725
2726
- double Character::evaluate_weapon ( const item &maybe_weapon ) const
2726
+ double Character::evaluate_weapon ( const item &maybe_weapon, const bool pretend_have_ammo ) const
2727
2727
{
2728
2728
bool can_use_gun = true ;
2729
2729
bool use_silent = false ;
@@ -2736,11 +2736,27 @@ double Character::evaluate_weapon( const item &maybe_weapon ) const
2736
2736
use_silent = true ;
2737
2737
}
2738
2738
}
2739
- return evaluate_weapon_internal ( maybe_weapon, can_use_gun, use_silent );
2739
+ // ABSOLUTELY disgusting fake gun assembly for character creation
2740
+ int pretend_ammo = 0 ;
2741
+ if ( pretend_have_ammo && maybe_weapon.is_gun () ) {
2742
+ itype_id ammo_id = itype_id::NULL_ID ();
2743
+ if ( maybe_weapon.ammo_default ().is_null () ) {
2744
+ ammo_id = item ( maybe_weapon.magazine_default () ).ammo_default ();
2745
+ } else {
2746
+ ammo_id = maybe_weapon.ammo_default ();
2747
+ }
2748
+ const ammotype &type_of_ammo = item::find_type ( ammo_id )->ammo ->type ;
2749
+ if ( maybe_weapon.magazine_integral () ) {
2750
+ pretend_ammo = maybe_weapon.ammo_capacity ( type_of_ammo );
2751
+ } else {
2752
+ pretend_ammo = item ( maybe_weapon.magazine_default () ).ammo_capacity ( type_of_ammo );
2753
+ }
2754
+ }
2755
+ return evaluate_weapon_internal ( maybe_weapon, can_use_gun, use_silent, pretend_ammo );
2740
2756
}
2741
2757
2742
2758
double Character::evaluate_weapon_internal ( const item &maybe_weapon, bool can_use_gun,
2743
- bool use_silent ) const
2759
+ bool use_silent, const int pretend_ammo ) const
2744
2760
{
2745
2761
if ( is_wielding ( maybe_weapon ) || ( !get_wielded_item () && maybe_weapon.is_null () ) ) {
2746
2762
auto cached_value = cached_info.find ( " weapon_value" );
@@ -2756,8 +2772,9 @@ double Character::evaluate_weapon_internal( const item &maybe_weapon, bool can_u
2756
2772
// This is relatively reasonable, as players can issue commands to NPCs when we do not want them to use ranged weapons.
2757
2773
// Conversely, we cannot directly issue commands when we want NPCs to prioritize ranged weapons.
2758
2774
// Note that the scoring method here is different from the 'weapon_value' used elsewhere.
2759
- double val_gun = allowed ? gun_value ( maybe_weapon, maybe_weapon.shots_remaining ( here,
2760
- this ) ) : 0 ;
2775
+ double val_gun = allowed ? gun_value ( maybe_weapon,
2776
+ std::max ( maybe_weapon.shots_remaining ( here, this ), pretend_ammo )
2777
+ ) : 0 ;
2761
2778
add_msg_debug ( debugmode::DF_NPC_ITEMAI,
2762
2779
" %s %s valued at <color_light_cyan>%1.2f as a ranged weapon to wield</color>." ,
2763
2780
disp_name ( true ), maybe_weapon.type ->get_id ().str (), val_gun );
@@ -2774,39 +2791,6 @@ double Character::evaluate_weapon_internal( const item &maybe_weapon, bool can_u
2774
2791
return val;
2775
2792
}
2776
2793
2777
- double Character::weapon_value ( const item &weap, int ammo ) const
2778
- {
2779
- if ( is_wielding ( weap ) || ( !get_wielded_item () && weap.is_null () ) ) {
2780
- auto cached_value = cached_info.find ( " weapon_value" );
2781
- if ( cached_value != cached_info.end () ) {
2782
- return cached_value->second ;
2783
- }
2784
- }
2785
- double val_gun = gun_value ( weap, ammo );
2786
- val_gun = val_gun /
2787
- 5 .0f ; // This is an emergency patch to get melee and ranged in approximate parity, if you're looking at it in 2025 or later and it's still here... I'm sorry. Kill it with fire. Tear it all down, and rebuild a glorious castle from the ashes.
2788
- add_msg_debug ( debugmode::DF_NPC_ITEMAI,
2789
- " <color_magenta>weapon_value</color>%s %s valued at <color_light_cyan>%1.2f as a ranged weapon</color>." ,
2790
- disp_name ( true ), weap.type ->get_id ().str (), val_gun );
2791
- double val_melee = melee_value ( weap );
2792
- val_melee *=
2793
- val_melee; // Same emergency patch. Same purple prose descriptors, you already saw them above.
2794
- add_msg_debug ( debugmode::DF_NPC_ITEMAI,
2795
- " %s %s valued at <color_light_cyan>%1.2f as a melee weapon</color>." , disp_name ( true ),
2796
- weap.type ->get_id ().str (), val_melee );
2797
- const double more = std::max ( val_gun, val_melee );
2798
- const double less = std::min ( val_gun, val_melee );
2799
-
2800
- // A small bonus for guns you can also use to hit stuff with (bayonets etc.)
2801
- const double my_val = more + ( less / 2.0 );
2802
- add_msg_debug ( debugmode::DF_MELEE, " %s (%ld ammo) sum value: %.1f" , weap.type ->get_id ().str (),
2803
- ammo, my_val );
2804
- if ( is_wielding ( weap ) || ( !get_wielded_item () && weap.is_null () ) ) {
2805
- cached_info.emplace ( " weapon_value" , my_val );
2806
- }
2807
- return my_val;
2808
- }
2809
-
2810
2794
double Character::melee_value ( const item &weap ) const
2811
2795
{
2812
2796
// start with average effective dps against a range of enemies
0 commit comments