@@ -1554,9 +1554,10 @@ void turret_set_next_fire_timestamp(int weapon_num, const weapon_info *wip, ship
15541554{
15551555 Assert (weapon_num < MAX_SHIP_WEAPONS);
15561556 float wait = 1000 .0f ;
1557- // should subtract 1 from firepoints to match behavior of wip->burst_shots
1558- int burst_shots = (wip->burst_flags [Weapon::Burst_Flags::Num_firepoints_burst_shots] ? turret->system_info ->turret_num_firing_points - 1 : wip->burst_shots );
1559- burst_shots = fl2i (i2fl (burst_shots) * wip->weapon_launch_curves .get_output (weapon_info::WeaponLaunchCurveOutputs::BURST_SHOTS_MULT, launch_curve_data));
1557+ // we have to add 1 to wip->burst_shots so that the multiplier behaves as expected, then remove 1 from burst_shots to match the zero-indexed burst_counter
1558+ int base_burst_shots = (wip->burst_flags [Weapon::Burst_Flags::Num_firepoints_burst_shots] ? turret->system_info ->turret_num_firing_points : wip->burst_shots + 1 );
1559+ float burst_shots_mult = wip->weapon_launch_curves .get_output (weapon_info::WeaponLaunchCurveOutputs::BURST_SHOTS_MULT, launch_curve_data);
1560+ int burst_shots = MAX (fl2i (i2fl (base_burst_shots) * burst_shots_mult) - 1 , 0 );
15601561
15611562 if (burst_shots > turret->weapons .burst_counter [weapon_num]) {
15621563 wait *= wip->burst_delay ;
@@ -1888,7 +1889,8 @@ bool turret_fire_weapon(int weapon_num,
18881889 }
18891890 // now do anything else
18901891 else {
1891- int shots = fl2i (i2fl (wip->shots ) * wip->weapon_launch_curves .get_output (weapon_info::WeaponLaunchCurveOutputs::SHOTS_MULT, launch_curve_data));
1892+ float shots_mult = wip->weapon_launch_curves .get_output (weapon_info::WeaponLaunchCurveOutputs::SHOTS_MULT, launch_curve_data);
1893+ int shots = fl2i (i2fl (wip->shots ) * shots_mult);
18921894 for (int i = 0 ; i < shots; i++) {
18931895 if (!in_lab && turret->system_info ->flags [Model::Subsystem_Flags::Turret_use_ammo]) {
18941896 int bank_to_fire, num_slots = turret->system_info ->turret_num_firing_points ;
@@ -2052,9 +2054,9 @@ bool turret_fire_weapon(int weapon_num,
20522054 subsys_index = ship_get_subsys_index (turret);
20532055 Assert ( subsys_index != -1 );
20542056 if (wip->wi_flags [Weapon::Info_Flags::Flak]){
2055- send_flak_fired_packet ( parent_objnum, subsys_index, weapon_objnum, flak_range, launch_curve_data.distance_to_target );
2057+ send_flak_fired_packet ( parent_objnum, subsys_index, weapon_objnum, flak_range, launch_curve_data.distance_to_target , launch_curve_data. target_radius );
20562058 } else {
2057- send_turret_fired_packet ( parent_objnum, subsys_index, weapon_objnum, launch_curve_data.distance_to_target );
2059+ send_turret_fired_packet ( parent_objnum, subsys_index, weapon_objnum, launch_curve_data.distance_to_target , launch_curve_data. target_radius );
20582060 }
20592061 }
20602062
@@ -2127,6 +2129,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
21272129 auto launch_curve_data = WeaponLaunchCurveData {
21282130 tsi->turret ->system_info ->turret_num_firing_points ,
21292131 0 .f ,
2132+ 0 .f ,
21302133 };
21312134
21322135 // create weapon and homing info
@@ -2181,7 +2184,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
21812184
21822185 subsys_index = ship_get_subsys_index (tsi->turret );
21832186 Assert ( subsys_index != -1 );
2184- send_turret_fired_packet ( tsi->parent_objnum , subsys_index, weapon_objnum, 0 .f );
2187+ send_turret_fired_packet ( tsi->parent_objnum , subsys_index, weapon_objnum, 0 .f , 0 . f );
21852188 }
21862189 }
21872190}
@@ -2328,15 +2331,19 @@ void ai_turret_execute_behavior(const ship *shipp, ship_subsys *ss)
23282331
23292332 // Don't try to fire beyond weapon_limit_range
23302333 // WMC moved the range check to within the loop, but we can still calculate the enemy distance here
2334+ float base_dist_to_enemy = 0 .0f ;
23312335 float dist_to_enemy = 0 .0f ;
23322336 if (lep) {
2333- if (The_mission. ai_profile -> flags [AI::Profile_Flags::Turrets_ignore_target_radius]) {
2334- dist_to_enemy = MAX ( 0 . 0f , vm_vec_normalized_dir (&v2e, &predicted_enemy_pos, &global_gun_pos)) ;
2335- } else {
2336- dist_to_enemy = MAX ( 0 . 0f , vm_vec_normalized_dir (&v2e, &predicted_enemy_pos, &global_gun_pos) - lep->radius ) ;
2337+ base_dist_to_enemy = vm_vec_normalized_dir (&v2e, &predicted_enemy_pos, &global_gun_pos);
2338+ dist_to_enemy = base_dist_to_enemy ;
2339+ if (!The_mission. ai_profile -> flags [AI::Profile_Flags::Turrets_ignore_target_radius]) {
2340+ dist_to_enemy -= lep->radius ;
23372341 }
2342+ base_dist_to_enemy = MAX (0 .0f , base_dist_to_enemy);
2343+ dist_to_enemy = MAX (0 .0f , dist_to_enemy);
23382344 } else if (in_lab) {
2339- dist_to_enemy = 500 .0f ;
2345+ base_dist_to_enemy = 500 .0f ;
2346+ dist_to_enemy = base_dist_to_enemy;
23402347 vm_vec_normalized_dir (&v2e, &predicted_enemy_pos, &global_gun_pos);
23412348 }
23422349
@@ -2349,10 +2356,17 @@ void ai_turret_execute_behavior(const ship *shipp, ship_subsys *ss)
23492356
23502357 float turret_barrel_length = -1 .0f ;
23512358
2359+ float target_radius = 0 .f ;
2360+
2361+ if (lep != nullptr ) {
2362+ target_radius = lep->radius ;
2363+ }
2364+
23522365 // grab the data for the launch curve inputs
23532366 auto launch_curve_data = WeaponLaunchCurveData {
23542367 ss->system_info ->turret_num_firing_points ,
2355- dist_to_enemy,
2368+ base_dist_to_enemy,
2369+ target_radius,
23562370 };
23572371
23582372 // WMC - go through all valid weapons. Fire spawns if there are any.
0 commit comments