From b19ff924b98f832ffca51ad68cb6ac93411093db Mon Sep 17 00:00:00 2001 From: dpwb Date: Tue, 4 Feb 2020 10:11:54 +0000 Subject: [PATCH] Add shot counter to mods and gun (#37693) --- src/ranged.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 98f56da8dd035..e597c735531fc 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -517,7 +517,11 @@ int player::fire_gun( const tripoint &target, int shots, item &gun ) continue; // skip retargeting for launchers } } - + // apply shot counter to gun and its mods. + gun.set_var( "shot_counter", gun.get_var( "shot_counter", 0 ) + curshot ); + for( item *mod : gun.gunmods() ) { + mod->set_var( "shot_counter", mod->get_var( "shot_counter", 0 ) + curshot ); + } // apply delayed recoil recoil += delay; if( is_mech_weapon ) {