int turret_data::fire( player &p, const tripoint &target ) { if( !veh || !part ) { return 0; } int shots = 0; p.add_effect( effect_on_roof, 1 ); p.recoil = abs( veh->velocity ) / 100 / 4; auto mode = base()->gun_current_mode(); auto ammo = ammo_current(); long qty = mode->ammo_required(); if( part->info().has_flag( "USE_TANKS" ) ) { mode->ammo_set( ammo, std::min( qty * mode.qty, long( veh->fuel_left( ammo ) ) ) ); } shots = p.fire_gun( target, mode.qty, *mode ); if( part->info().has_flag( "USE_TANKS" ) ) { veh->drain( ammo, qty * shots ); mode->ammo_unset(); } veh->drain( fuel_type_battery, mode->get_gun_ups_drain() * shots ); p.remove_effect( effect_on_roof ); return shots; }
void game::fire(player &p, int tarx, int tary, std::vector<point> &, bool burst) { p.fire_gun(tarx, tary, burst); }