Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Valathil on January 09, 2012, 01:56:13 pm

Title: SMALL_ONLY Weapon Turrets (Commited)
Post by: Valathil on January 09, 2012, 01:56:13 pm
Spoon came to me and had the following problem. He has a turret with one weapon for huge ships (WIF_HUGE) and one weapon with WIF2_SMALL_ONLY. Now the ai code checks only that ALL weapons on a turret have WIF2_SMALL_ONLY so what happens that if the turret targets a huge ship both weapons fire. I made a really small patch that checks if the target is a huge ship and if not skips the small only weapon. Any reason why this could cause complications or problems please tell me before i commit this.

Code: [Select]
Index: code/ai/aiturret.cpp
===================================================================
--- code/ai/aiturret.cpp (revision 8155)
+++ code/ai/aiturret.cpp (working copy)
@@ -2084,6 +2084,12 @@
  }
  }
 
+ if ( wip->wi_flags2 & WIF2_SMALL_ONLY ) {
+ if ( (lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
+ continue;
+ }
+ }
+
  if (lep->type == OBJ_SHIP) {
  // Check if we're targeting a protected ship
  if (lep->flags & OF_PROTECTED) {
Title: Re: SMALL_ONLY Weapon Turrets
Post by: The E on January 09, 2012, 02:14:15 pm
I can't see anything that would go wrong there.
Title: Re: SMALL_ONLY Weapon Turrets
Post by: Spoon on January 10, 2012, 12:11:01 pm
All of my tests have shown no problems with this fix  :yes:
Title: Re: SMALL_ONLY Weapon Turrets (Commited)
Post by: Valathil on January 10, 2012, 12:34:21 pm
Commited per revision 8157