Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: zookeeper on November 27, 2011, 12:23:34 pm

Title: Patch[canceled]: flag to disable turrets when ships are dying
Post by: zookeeper on November 27, 2011, 12:23:34 pm
By default, turrets will keep shooting even when the ship is already in the process of dying which I think doesn't really make much sense, so this patch adds an ai_profiles.tbl flag which prevents that from happening.

Code: [Select]
Index: ai/ai_profiles.cpp
===================================================================
--- ai/ai_profiles.cpp (revision 8049)
+++ ai/ai_profiles.cpp (working copy)
@@ -481,6 +481,7 @@
  }
 
  set_flag(profile, "$no warp camera:", AIPF2_NO_WARP_CAMERA, AIP_FLAG2);
+ set_flag(profile, "$disable turrets on ship death:", AIPF2_DISABLE_TURRETS_ON_SHIP_DEATH, AIP_FLAG2);
 
  // if we've been through once already and are at the same place, force a move
  if ( saved_Mp && (saved_Mp == Mp) )
Index: ai/ai_profiles.h
===================================================================
--- ai/ai_profiles.h (revision 8049)
+++ ai/ai_profiles.h (working copy)
@@ -62,6 +62,7 @@
 #define AIPF2_BEAMS_DAMAGE_WEAPONS (1 << 8)
 #define AIPF2_PLAYER_WEAPON_SCALE_FIX (1 << 9)
 #define AIPF2_NO_WARP_CAMERA (1 << 10)
+#define AIPF2_DISABLE_TURRETS_ON_SHIP_DEATH (1 << 11)
 
 // AI Path types
 #define AI_PATH_MODE_NORMAL 0
Index: ship/shiphit.cpp
===================================================================
--- ship/shiphit.cpp (revision 8049)
+++ ship/shiphit.cpp (working copy)
@@ -1347,6 +1347,20 @@
 
  ship_stop_fire_primary(objp); //mostly for stopping fighter beam looping sounds -Bobboau
 
+ if (The_mission.ai_profile->flags2 & AIPF2_DISABLE_TURRETS_ON_SHIP_DEATH) {
+ // Lock all turrets so they won't keep firing while the ship is dying
+
+ ship_subsys *subsys = GET_FIRST(&sp->subsys_list);
+
+ while ( subsys != END_OF_LIST(&sp->subsys_list) ) {
+ if (subsys->system_info->type == SUBSYSTEM_TURRET) {
+ subsys->weapons.flags |= SW_FLAG_TURRET_LOCK;
+ }
+
+ subsys = GET_NEXT(subsys);
+ }
+ }
+
  sp->flags |= SF_DYING;
  objp->phys_info.flags |= (PF_DEAD_DAMP | PF_REDUCED_DAMP);
  delta_time = (int) (sip->death_roll_base_time);

EDIT: Actually, on second thought, I think this would be even more trivial to script instead. So, if someone else wants to have this feature then great, but I guess I won't need it myself after all. :lol:
Title: Re: Patch: flag to disable turrets when ships are dying
Post by: Spoon on November 27, 2011, 12:31:59 pm
I personally like how turrets these days completely lose their accuracy and fire off in empty space when the ship is going down.
'cept for beams, those just remain spot on, even capable of firing their beams when the ship is almost half way done vaporising in some cases.

In other words, could there be an option to just only disable beam turrets from firing when the ship is going down?
Title: Re: Patch: flag to disable turrets when ships are dying
Post by: zookeeper on November 27, 2011, 12:53:09 pm
I personally like how turrets these days completely lose their accuracy and fire off in empty space when the ship is going down.
'cept for beams, those just remain spot on, even capable of firing their beams when the ship is almost half way done vaporising in some cases.

In other words, could there be an option to just only disable beam turrets from firing when the ship is going down?

Yeah...

Code: [Select]
#Conditional Hooks

$Object type: Ship
$On Death: [

    mn.runSEXP("beam-lock-all !" .. hv.Self.Name .. "!")

]

#End
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: Goober5000 on November 28, 2011, 11:16:31 am
Yes, this can be done (and has been done before) with sexps.  Just beam-lock or turret-lock any ships you don't want to fire while they're blowing up.  We don't need a flag for this.
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: zookeeper on November 28, 2011, 11:38:15 am
I kinda agree. When a scripted workaround is this simple, it's probably better to avoid an engine-side addition. At least it didn't take all too long to write. ;)
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: Spoon on November 28, 2011, 02:31:19 pm
Yes, this can be done (and has been done before) with sexps.  Just beam-lock or turret-lock any ships you don't want to fire while they're blowing up.  We don't need a flag for this.
But if you want to do this for a whole campaign, you'll have to beam/turret lock eveerrrry damn capital ship in every mission.
Your argument here is: "We don't need an easy available option because we already have a painfully time consuming hard way available to do this."  :blah:
What's the harm in having an extra ai_profile.tbl flag available to modders? I for one would gladly use this for beam locking capital ship turrets. But I sure as hell won't manually do it for 20+ missions.
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: The E on November 28, 2011, 02:34:40 pm
Hang on. I think what would be better would be to introduce a sort of meta-argument like "<all ships>" or something.
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: Qent on November 28, 2011, 03:00:55 pm
But if you want to do this for a whole campaign, you'll have to beam/turret lock eveerrrry damn capital ship in every mission.

Code: [Select]
#Conditional Hooks

$Object type: Ship
$On Death: [

    mn.runSEXP("beam-lock-all !" .. hv.Self.Name .. "!")

]

#End
Doesn't this do that?
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: zookeeper on November 28, 2011, 03:43:53 pm
Doesn't this do that?

Yes, just shoving that piece of code into whatever-sct.tbm should cause all beams on all ships get locked the moment they begin to blow up.

I agree that doing it via mission events would be very annoying when you'd have to do it in every mission (I don't think you'd need to do it on a ship by ship basis), but a simple script like this shouldn't be a problem unless I'm missing something.
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: Dragon on November 28, 2011, 05:05:51 pm
Hang on. I think what would be better would be to introduce a sort of meta-argument like "<all ships>" or something.
A million times this.
SCP needs at least a couple of meta-arguments for things such as <all friendly>, <all ships>, <all [class]> and such. This would make when-argument much easier to use for large amount of ships.
Title: Re: Patch[if someone else wants it]: flag to disable turrets when ships are dying
Post by: Spoon on November 29, 2011, 11:07:46 am
Doesn't this do that?

Yes, just shoving that piece of code into whatever-sct.tbm should cause all beams on all ships get locked the moment they begin to blow up.

I agree that doing it via mission events would be very annoying when you'd have to do it in every mission (I don't think you'd need to do it on a ship by ship basis), but a simple script like this shouldn't be a problem unless I'm missing something.
I'm scripting inept but that sounds easy enough.

Hang on. I think what would be better would be to introduce a sort of meta-argument like "<all ships>" or something.
A million times this.
SCP needs at least a couple of meta-arguments for things such as <all friendly>, <all ships>, <all [class]> and such. This would make when-argument much easier to use for large amount of ships.
I wouldnt mind seeing this at all
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: SypheDMar on November 29, 2011, 02:00:55 pm
Hang on. I think what would be better would be to introduce a sort of meta-argument like "<all ships>" or something.
A million times this.
SCP needs at least a couple of meta-arguments for things such as <all friendly>, <all ships>, <all [class]> and such. This would make when-argument much easier to use for large amount of ships.
Indeed.  :yes:
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: karajorma on November 29, 2011, 06:01:12 pm
You guy do realise that would basically involve manually changing every single SEXP that can take a ship as an argument, right?
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: The E on November 29, 2011, 06:05:08 pm
Does it? I thought we could do it in the argument-evaluation stage, take the meta argument and expand it before firing off the actual event...

But then, I haven't looked too deeply into the argument code...
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: karajorma on November 29, 2011, 07:59:32 pm
Hmmmmm. I suppose doing it that way might work. It would mean you could only use <all ships> in the argument list and not as an argument to the SEXP itself. I was assuming you mean making it possible for the SEXPs to take the meta-argument the same way many of them currently take arguments like <any wingman> or <any hostile>.

Doing it to the argument list might not be that hard.


One problem would be deciding if <all ships> means "all ships in the mission file" or "all ships currently in the mission" as many SEXPs have different actions for ships not in the mission.
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: Goober5000 on November 30, 2011, 12:17:53 am
Not to mention the fiasco with ships in wings...
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: FUBAR-BDHR on November 30, 2011, 03:28:14 am
You guy do realise that would basically involve manually changing every single SEXP that can take a ship as an argument, right?

You do realize that I did this over 2 years ago and it's still waiting code review.
Title: Re: Patch[canceled]: flag to disable turrets when ships are dying
Post by: karajorma on November 30, 2011, 04:05:16 am
No, this is quite different from what you did. What they're talking about is having this.

when-argument
-any-of
--<all ships>
-etc