Author Topic: Patch [committed]: fix $Shots for turret-fired weapons  (Read 815 times)

0 Members and 1 Guest are viewing this topic.

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Patch [committed]: fix $Shots for turret-fired weapons
My problem was that when I give a weapon for example $Shots: 2, then it works as expected for primaries with the cycle flag (fires from 2 firepoints per shot), but not for ordinary non-salvo-firing turrets (fires 2 shots from the same firepoint). I got a really simple fix for this, but I think someone familiar with this part of the code should still give it a look since there's a lot of things going on there and I might not have noticed some subtle ways how this could break something.

Code: [Select]
Index: aiturret.cpp
===================================================================
--- aiturret.cpp (revision 7936)
+++ aiturret.cpp (working copy)
@@ -1707,7 +1707,11 @@
  // now do anything else
  else {
  for (int i=0; i < wip->shots; i++)
- {
+ {
+ // Firepoints should cycle normally between shots, so we need to get the position
+ // info separately for each shot
+ ship_get_global_turret_gun_info(&Objects[parent_objnum], turret, turret_pos, turret_fvec, 1, NULL);
+
  weapon_objnum = weapon_create( turret_pos, &turret_orient, turret_weapon_class, parent_objnum, -1, 1);
  weapon_set_tracking_info(weapon_objnum, parent_objnum, turret->turret_enemy_objnum, 1, turret->targeted_subsys);
 
@@ -1762,6 +1766,8 @@
  }
  }
  }
+
+ turret->turret_next_fire_pos++;
  }
 
  // reset any animations if we need to
@@ -2396,8 +2402,6 @@
  turret_set_next_fire_timestamp(valid_weapons[0], wip, ss, parent_aip);
  }
  }
- // moved this here so we increment the fire pos only after we have fired and not during it
- ss->turret_next_fire_pos++;
  }
 
  if(!something_was_ok_to_fire)

EDIT: Committed to trunk in r7981.
« Last Edit: November 13, 2011, 04:31:55 am by zookeeper »