Author Topic: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug  (Read 11544 times)

0 Members and 1 Guest are viewing this topic.

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
I'ma go with jr2 and say "recap please" ...



Would I be correct to summarize as follows:

Quote
General agreement: Any patch that (significantly) alters retail balance = bad. Afaik Mastadon's original patch falls under this category, and I believe this is what Dragon and NGTM-1R have been talking about.

An SCP addition already exists which should allow fine-tuning of this without breaking retail: +target lead scalar. However as indicated by some experimentation by Qent, that feature doesn't work. At worst, a patch to make this SCP addition work as described might affect the balance of a few mods.




If so:

Congrats to karajorma, for repeatedly failing to explicitly clarify that you're talking about +target lead scalar, and then denying that there was a misunderstanding.

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Perhaps the best way to describe what my patch does would be to simply give an excerpt from my changelog (this will also double as a commit log entry should the SCP coders decide to include this patch):


Changed the behavior of swarm missiles so they can lead their target.
  -- Enabled by adding the new "+swarmLeadTarget" sub-flag to a swarm missile
       (needs to have the $Swarm flag as well).



That's all the patch does.

 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Excuse the backseat coding, but this whole deal has irked me quite a bit and I feel the need to pipe in.

Could you make it so that +target lead scaler works, because that is a more general flag that would benefit more than having to tell everyone that Target Lead Scaler does not work for swarm missiles, if you want them to lead you need to put +swarmLeadTarget instead, which just adds a layer of confusion.

Tying SwarmLeadTarget's behavior into a certain values of Target Lead Scaler would probably be the most "foolproof" way to do this and avoids it looking "hack-ish". While +swarmLeadTarget does the job, it's not..."elegant", and +target lead scaler should probably work anyway. Leaving it as it is doesn't really fix the bug (which was never about swarm missile behavior in the first place, but was entirely with target lead scaler not working (for swarm missiles)).

Unless I have read wrong and your flag doesn't cause swarm missiles to lead, but allows the use of target lead scaler to make them lead, in which case you don't even need that "flag", target lead scaler should always work.
(´・ω・`)
=============================================================

 

Offline Sushi

  • Art Critic
  • 211
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Excuse the backseat coding, but this whole deal has irked me quite a bit and I feel the need to pipe in.

Could you make it so that +target lead scaler works, because that is a more general flag that would benefit more than having to tell everyone that Target Lead Scaler does not work for swarm missiles, if you want them to lead you need to put +swarmLeadTarget instead, which just adds a layer of confusion.

Tying SwarmLeadTarget's behavior into a certain values of Target Lead Scaler would probably be the most "foolproof" way to do this and avoids it looking "hack-ish". While +swarmLeadTarget does the job, it's not..."elegant", and +target lead scaler should probably work anyway. Leaving it as it is doesn't really fix the bug (which was never about swarm missile behavior in the first place, but was entirely with target lead scaler not working (for swarm missiles)).

Unless I have read wrong and your flag doesn't cause swarm missiles to lead, but allows the use of target lead scaler to make them lead, in which case you don't even need that "flag", target lead scaler should always work.

+1. This is what I was trying to say earlier.

 

Offline Iss Mneur

  • 210
  • TODO:
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Would I be correct to summarize as follows:

Quote
General agreement: Any patch that (significantly) alters retail balance = bad. Afaik Mastadon's original patch falls under this category, and I believe this is what Dragon and NGTM-1R have been talking about.

An SCP addition already exists which should allow fine-tuning of this without breaking retail: +target lead scalar. However as indicated by some experimentation by Qent, that feature doesn't work. At worst, a patch to make this SCP addition work as described might affect the balance of a few mods.
This is correct.

Mastadon's original patch (that is no longer attached to any of his posts as far as I can tell) would have broken retail balance because it would have "fixed" every swarm missile.

The current patch in the OP just fixes +target lead scalar:+target lead scalar: is a SCP addition added (it was added in revision 5502 by Wanderer) for 3.6.12.  That is, compatibility of retail is not affected by the currently proposed solution.  Compatibility of any mods that were built against 3.6.11 and newer may be affected if this flag is used on swarm missiles.  However that is assuming that anyone actually uses this flag on swarm missiles because if they had they would have noticed that is has no effect at all.  There is no mantis ticket on this bug (closed or otherwise); there is no (public) post that talks about this weapon flag (except for this thread).

The above combined with the fact that SCP does not guarantee compatibility of any SCP feature regardless of its release status (though we are less likely to break something that has seen an official release, like this feature has) means that the simple fix of just making the existing flag +target lead scalar: work with a swarm missile is the correct fix.

I have to agree with Droid803, the current alternative patch proposed by Mastadon that adds +swarmLeadTarget is of no value to SCP because the feature is attempting to work around a problem that doesn't actually exist and just adds resource and support requirements that are not necessary.
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Would I be correct to summarize as follows:

Quote
General agreement: Any patch that (significantly) alters retail balance = bad. Afaik Mastadon's original patch falls under this category, and I believe this is what Dragon and NGTM-1R have been talking about.

An SCP addition already exists which should allow fine-tuning of this without breaking retail: +target lead scalar. However as indicated by some experimentation by Qent, that feature doesn't work. At worst, a patch to make this SCP addition work as described might affect the balance of a few mods.
This is correct.

Mastadon's original patch (that is no longer attached to any of his posts as far as I can tell) would have broken retail balance because it would have "fixed" every swarm missile.

The current patch in the OP just fixes +target lead scalar:+target lead scalar: is a SCP addition added (it was added in revision 5502 by Wanderer) for 3.6.12.  That is, compatibility of retail is not affected by the currently proposed solution.  Compatibility of any mods that were built against 3.6.11 and newer may be affected if this flag is used on swarm missiles.  However that is assuming that anyone actually uses this flag on swarm missiles because if they had they would have noticed that is has no effect at all.  There is no mantis ticket on this bug (closed or otherwise); there is no (public) post that talks about this weapon flag (except for this thread).

The above combined with the fact that SCP does not guarantee compatibility of any SCP feature regardless of its release status (though we are less likely to break something that has seen an official release, like this feature has) means that the simple fix of just making the existing flag +target lead scalar: work with a swarm missile is the correct fix.

I have to agree with Droid803, the current alternative patch proposed by Mastadon that adds +swarmLeadTarget is of no value to SCP because the feature is attempting to work around a problem that doesn't actually exist and just adds resource and support requirements that are not necessary.


If I am understanding you correctly, you are stating that when +Target Lead Scaler is set to a non-zero value, the missile is supposed to lead to it's intended target, correct?

If this understanding is correct, then +Target lead Scaler does not work for swarm missiles because after the "lead" value is calculated for a missile, a check is made at the end of weapon_home() to see if a missile is a swarm missile:

Code: [Select]
if ( wp->swarm_index < 0 ) {
ai_turn_towards_vector(&target_pos, obj, frame_time, wip->turn_time, NULL, NULL, 0.0f, 0, NULL);
vel = vm_vec_mag(&obj->phys_info.desired_vel);

vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.vec.fvec, vel);
}



Patching the code to check for whether the WIF2_VARIABLE_LEAD_HOMING flag is set for a swarm missile wouldn't work if a mod creator wanted to have swarm missiles have a lead scaler of 1.0, which is documented as default value for all aspect missiles. This is because that flat is unset for cases where the Target Lead Scaler is set t0 1.0:

Code: [Select]
if (optional_string("+Target Lead Scaler:"))
{
stuff_float(&wip->target_lead_scaler);
if (wip->target_lead_scaler == 1.0f)
wip->wi_flags2 &= ~WIF2_VARIABLE_LEAD_HOMING;
else {
wip->wi_flags2 |= WIF2_VARIABLE_LEAD_HOMING;
wi_flags2 |= WIF2_VARIABLE_LEAD_HOMING;
}
}


The only three options that come to mind to enable swarm missiles to properly lead their targets w/o breaking the cardinal rule are:
  • Don't turn off the WIF2_VARIABLE_LEAD_HOMING flag for missiles with a default target lead scaler and store the new homing position to wp->homing_pos when the WIF2_VARIABLE_LEAD_HOMING flag is set.
  • Add a special flag for swarm missiles to indicate that the mod designer wants them to lead in cases where the target lead scaler is set and store the new homing position to wp->homing_pos when that special flag is set.
  • Add a tag such as +swarmerLeadTarget and store the new homing position to wp->homing_pos when that flag is set.

While the first solution would probably work, doing so will increase the missile lead calculation time for all missiles by for instruction cycles (a multiplication operation costs two instruction cycles if I remember correctly and there are two multiplication operations executed...see below:


While four cycles might not sound like much, this code is executed up to every millisecond, so it adds up quickly. The second option should also work, and sounds like the best of the three options the more I think about it.


If you believe that the problem that I am describing with swarm missiles doesn't exist, I would encourage you to download the two attached files and run them with the latest and greatest version of FSO (I'm using 3.6.14 RC6). The first one modifies the stats for the swarm missiles so as to make the bug very easy to see. The second file is a test mission that starts you off with being able to fire swarm missiles at a freighter's 3 o-clock position. If the swarm missiles were leading their target at all, they would be roughly turning towards the ships target lead indicator. Instead, however, they behave like FS1-style missiles and turn directly towards the ship (that is, enter pure pursuit mode).

[attachment deleted by a ninja]

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Bear in mind that swarm missiles flying pure pursuit is not a bug, it's intended behavior. It's an important part of the difference between the Hornet and Tornado.

The real bug here seems to be that Target Lead Scaler doesn't work. That is not intended behavior.


 

Offline Iss Mneur

  • 210
  • TODO:
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
If I am understanding you correctly, you are stating that when +Target Lead Scaler is set to a non-zero value, the missile is supposed to lead to it's intended target, correct?
Correct.

If this understanding is correct, then +Target lead Scaler does not work for swarm missiles because after the "lead" value is calculated for a missile, a check is made at the end of weapon_home() to see if a missile is a swarm missile:

Code: [Select]
if ( wp->swarm_index < 0 ) {
ai_turn_towards_vector(&target_pos, obj, frame_time, wip->turn_time, NULL, NULL, 0.0f, 0, NULL);
vel = vm_vec_mag(&obj->phys_info.desired_vel);

vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.vec.fvec, vel);
}
Correct.  This is what your patch in the OP changes, making swarm missiles also lead by the lead factor.  Yes, I understand now that this would in change retail because of what I was looking at the heatseeker parsing code.

Patching the code to check for whether the WIF2_VARIABLE_LEAD_HOMING flag is set for a swarm missile wouldn't work if a mod creator wanted to have swarm missiles have a lead scaler of 1.0, which is documented as default value for all aspect missiles. This is because that flat is unset for cases where the Target Lead Scaler is set t0 1.0:

Code: [Select]
if (optional_string("+Target Lead Scaler:"))
{
stuff_float(&wip->target_lead_scaler);
if (wip->target_lead_scaler == 1.0f)
wip->wi_flags2 &= ~WIF2_VARIABLE_LEAD_HOMING;
else {
wip->wi_flags2 |= WIF2_VARIABLE_LEAD_HOMING;
wi_flags2 |= WIF2_VARIABLE_LEAD_HOMING;
}
}
Okay. I see where I glossed over something.  I was looking at the heatseeker  +Target Lead Scaler: code.

The only three options that come to mind to enable swarm missiles to properly lead their targets w/o breaking the cardinal rule are:
  • Don't turn off the WIF2_VARIABLE_LEAD_HOMING flag for missiles with a default target lead scaler and store the new homing position to wp->homing_pos when the WIF2_VARIABLE_LEAD_HOMING flag is set.
  • Add a special flag for swarm missiles to indicate that the mod designer wants them to lead in cases where the target lead scaler is set and store the new homing position to wp->homing_pos when that special flag is set.
  • Add a tag such as +swarmerLeadTarget and store the new homing position to wp->homing_pos when that flag is set.

While the first solution would probably work, doing so will increase the missile lead calculation time for all missiles by for instruction cycles (a multiplication operation costs two instruction cycles if I remember correctly and there are two multiplication operations executed...see below:
Yes, solution 1 would be the best solution because it doesn't add more weirdness for modders (solution 3) and for coders (solution 2 and 3).

While four cycles might not sound like much, this code is executed up to every millisecond, so it adds up quickly. The second option should also work, and sounds like the best of the three options the more I think about it.
More accurately, this code would be executed for every tick of the physics.

However, I don't understand how using solution 1 would affect every missile.

It would only affect missiles that use +Target Lead Scaler:, which is an optional flag. I just checked, Mediavps does not use the flag.  BP WIHR1 uses it for the "Dart" missile, but the Dart is a Corkscrew missile which is already an expensive missile from a computation standpoint. In addition, the dart is a heatseeker with a +Target Lead Scaler: of 1.0 so it is already using the more expensive path.

So, to reiterate what I stated in my post yesterday, considering how long this feature has been in the engine and you being the first to notice, we should just fix the bug using solution 1 and call it a day (yes, this is not quite the same position as what I had yesterday because of the oversight noted above), because nobody is using the feature and expecting default behaviour.
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Bear in mind that swarm missiles flying pure pursuit is not a bug, it's intended behavior. It's an important part of the difference between the Hornet and Tornado.

The real bug here seems to be that Target Lead Scaler doesn't work. That is not intended behavior.

It is becoming more and more clear that my issues with swarm missiles are not that :v: introduced a bug when they added target leading to missile tracking to FS2, but rather that I don't agree with their decision to make it so you have to get an aspect lock on a target to fire a group of missiles that chase their target as if they were heat seekers rather than chase the target like all other aspect missiles do.

I'm going to go ahead and implement the solution Iss Mneur suggested and be done with this (I could have never imagined that a one-liner "fix" could evoke so much controversy!), but for my reference, how should I go about making a mod available so that everyone else can benefit from having swarm missiles that at least have half a chance of hitting their target (and you as well)?
« Last Edit: June 02, 2012, 03:16:55 pm by Mastadon »

 

Offline Iss Mneur

  • 210
  • TODO:
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
I'm going to go ahead and implement the solution Iss Mneur suggested and be done with this (I could have never imagined that a one-liner "fix" could evoke so much controversy!),
:D its only just beginning  :drevil:

but for my reference, how should I go about making a mod available so that everyone else can benefit from having swarm missiles that at least have half a chance of hitting their target (and you as well)?
Checkout the modding portal on the wiki.  Though basically, create a weapon .tbm to make the changes to the swarm weapon spec's, write a mod.ini, put everything into its own mod directory, zip it up, and release it in Freespace Modding.
« Last Edit: June 02, 2012, 03:57:00 pm by Iss Mneur »
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
I'm going to go ahead and implement the solution Iss Mneur suggested and be done with this (I could have never imagined that a one-liner "fix" could evoke so much controversy!),
:D its only just beginning  :drevil:

Fun.

Checkout the modding portal on the wiki.  Though basically, create a weapon .tbm to make the changes to the swarm weapon spec's, write a mod.ini, put everything into its own mod directory, zip it up, and release it in Freespace Modding.

Will do. Thanks Iss Mneur!

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
I've finished writing the patch so that swarmers can lead if the mod author adds the +Target Lead Scaler flag to a swarm missile. Below is a commit log entry should the SCP community wish to commit it:


Changed the behavior of swarm missiles so they can lead their target.
  -- Enabled by setting the "+Target Lead Scaler" flag to a swarm missile.


I've also attached the patch along with two tbm files that set +Target Lead Scaler to 1.1 for every swarm missile. In my limited testing, this leads the swarm missiles just enough so that they are effective against heavy fighters on up through cruisers but not so much that they can reliably hit a fast moving target, like a Mara or a Manticore.



EDIT: You actually need to have +Target Lead Scaler set to 2.0 for swarm missiles to reliably hit moving heavy fighters on up through cruisers. I also tried these modifications out on the Silent Threat Reborn campaign. One thing I noticed in my playthrough is that some of the missions are harder to complete because an enemy's swarm missiles will actually reliably hit a moving target. This appears to happen on the mission where you have to protect the Einstein escape pods and on the Exodus mission. I guess that's one reason why the cardinal rule is in place.

In any event, I'll release the mods I created that cause swarmers to lead their target if / when the +Target Lead Scaler bug is patched so as to not put undue presssure on the SCP coders to apply a patch that might not be ready.

[attachment deleted by a ninja]
« Last Edit: June 03, 2012, 06:24:22 pm by Mastadon »

 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Yay! Thanks! This r awesome, now I can more deadlier make missile.
(´・ω・`)
=============================================================

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
Looks great. Glad to see it done and cleared up. :)

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
-snip-


Uploaded the files to my DropBox public folder so you can download it here when the attachments get nuked, until Mastadon releases this as a mod.

 

Offline Mastadon

  • Contributes SCP patches and doesn't afraid of anything
  • 26
Re: Patch for the "My entire bank of swarm missiles missed a moving freighter" bug
:bump:

Out of curiosity, was a decision ever reached on this patch?