Agreed. Though you should also check if the system you're trying to implement doesn't already exist (which is the case here, since +Target Lead Scaler: does exactly the same thing as this, except it allows more customization).
For my first contribution to the SCP community
Thanks for the patch, however this would change balance fairly significantly - why use harpoons when you've got lead-tracking hornets? :) This would be more useful as a weapon flag that could modify the behaviour of swarm missiles. Having said that, there is the corkscrew flag which effectively gives lead-tracking "swarmers", albeit with slightly different launch characteristics.
If you're keen on joining the SCP, we like bugfixes, some of these would be useful to look at ;)
http://scp.indiegames.us/mantis/view.php?id=2649
http://scp.indiegames.us/mantis/view.php?id=2637
http://scp.indiegames.us/mantis/view.php?id=2605
Actually, this has already been implemented. +Target Lead Scaler: controls whether a missile leads it's targets, lags behind or just uses pure pursuit path.
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;
}
}
// Only lead target if more than one second away. Otherwise can miss target. I think this
// is what's causing Harbingers to miss the super destroyer. -- MK, 4/15/98
if ((old_dot > 0.1f) && (time_to_target > 0.1f)) {
if (wip->wi_flags2 & WIF2_VARIABLE_LEAD_HOMING) {
vm_vec_scale_add2(&target_pos, &hobjp->phys_info.vel, (0.33f * wip->target_lead_scaler * MIN(time_to_target, 6.0f)));
} else if (wip->wi_flags & WIF_LOCKED_HOMING) {
vm_vec_scale_add2(&target_pos, &hobjp->phys_info.vel, MIN(time_to_target, 2.0f));
}
}
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);
}
if ( wp->swarm_index < 0 ) {
// ...
}
else {
// Mastadon: store target_pos back to wp->homing_pos so that the swarm_update_direction(*objp, frametime) code does it's
// magic on the _leaded_ values for the target, not the _actual_ target, since we want the swarm missile to
// actually lead into the target, not vainly aim directly at the ship.
wp->homing_pos = target_pos;
}
I think there's a more general note to be made about the aims of the SCP here - it's a core rule of the project that nothing should ever change retail behavior by default.
Creating a system that would allow modders to make Hornets fly lead pursuit if they wanted is, of course, totally cool. It just shouldn't be on by default.
However, in the unpatched code, the target_lead_scalar is never used again anywhere else in the codebase---I know because I used grep -n 'target_lead_scaler' $(find . -type f) inside the code directory of the project to find all usages of the target_lead_scalar attribute. This would mean that even if a swarm missile supplied this flag it would never actually be leaded towards the target. That's what my patch fixes:Ah, so you mean that your patch makes +Target Lead Scaler: apply to swarm missiles, which it didn't do before? That part is definitely worth implementing, if I understood it right.
QuoteHowever, in the unpatched code, the target_lead_scalar is never used again anywhere else in the codebase---I know because I used grep -n 'target_lead_scaler' $(find . -type f) inside the code directory of the project to find all usages of the target_lead_scalar attribute. This would mean that even if a swarm missile supplied this flag it would never actually be leaded towards the target. That's what my patch fixes:Ah, so you mean that your patch makes +Target Lead Scaler: apply to swarm missiles, which it didn't do before? That part is definitely worth implementing, if I understood it right.
Indeed. I can see mods enjoying the ability to have swarm missiles lead without doing funky corkscrew acrobatics.
AI can't use trebs because the missile has conflicting flags telling AI to:
1.Only use it on cap ships. (more accurately described as never using it against anything fighter or bomber-sized)
2. Only use it on bombers.
Absolutely the table option. You can always just mod the weapons tables for your personal use.
$Swarm: 4
+swarmLeadTarget;
How is this patch applied to the game? Do you need to download a new build?
Patches are for coders only.
As for the patch itself: Command-line flags, especially gratuitous ones like this, will not be included. Ever. We used to have a few of these, and they are nothing but trouble.
*puts his hand up*
Uhh, did I miss something here?
I'm pretty sure we already have lead-tracking swarm missiles - They are called Tornados...
To use the +swarmLeadTarget, just add it below a $Swarm: flag, like so:Why is that needed? I though that it'd be enough to just make +Target lead scaler: work on swarm missiles. I'm asking because somebody may want them to use pure pursuit. This flag, as I understand it, only allows toggling between lead and lag pursuit.Code: [Select]$Swarm: 4
+swarmLeadTarget;
Alright, let's slow down and concretely determine the following:
Does or does not +Target lead scaler work correctly with swarm missiles?
If it is indeed the case that it doesn't, then IMO the correct solution is to fix the code so that it does. +Target lead scaler is an SCP flag, and a relatively recent one, so I think we can implement a bug fix to make it work correctly for all missiles without needing any new table or command line flags.
Alright, let's slow down and concretely determine the following:
Does or does not +Target lead scaler work correctly with swarm missiles?
If it is indeed the case that it doesn't, then IMO the correct solution is to fix the code so that it does. +Target lead scaler is an SCP flag, and a relatively recent one, so I think we can implement a bug fix to make it work correctly for all missiles without needing any new table or command line flags.
I was about to say the same thing.
The SCP doesn't change the behaviour of retail. We can however change the behaviour of SCP additions. Especially if they have a bug, and especially if the bug is recent.
Sorry that you're having a hard time with such a simple patch Mastadon. If I were you, I'd move on to another feature/bug and let the SCP coders decide how we're going to implement your fix. You'll still get the credit and you won't have to worry about changing how it works every 5 minutes. :D
It'd be good to make sure that +target lead scalar works properly with hornets and tornadoes then, overriding default behaviors as necessary.
For instance Diaspora uses tornado flags on a bunch of weapons to give that slight trail jerkiness seen in the show on some weapons. So it'd be nice to have trailing tornadoes for some cases.
As for how to go about incorporating my fix, one solution might be to add a weapons.tbl flag to swarm missiles that we want to have lead their targets. However, I personally would also like to be able to turn on or off swarm missile leading at-will via a command-line switch. So before I go off implementing one or both of these solutions, what would the SCP programmers prefer I do?Well, I think that's the sort of things you'll want to place in ai_profiles or game_settings tables.
Do we really need a flag for this? What exactly will break if the lead scaler setting suddenly works as advertised for Hornets?
This seems like a straightforward fix of an oversight in the lead scaler feature. I'm pretty sure it's a 3.6.13/3.6.14 feature anyway, so we have no obligations of backwards compatibility to make us introduce yet another flag.
Do we really need a flag for this? What exactly will break if the lead scaler setting suddenly works as advertised for Hornets?
This seems like a straightforward fix of an oversight in the lead scaler feature. I'm pretty sure it's a 3.6.13/3.6.14 feature anyway, so we have no obligations of backwards compatibility to make us introduce yet another flag.
Sorry, but even if it doesn't change balance all that much, it's still against FSO policy. It's up to mods if the decide to make Hornets lead their target, and you can enable them to do that by simply fixing +Target Lead Scaler: for swarmers. Something that affects default behavior like that will never get into trunk.
I really don't know why you think you have the authority to tell us all that we're wrong and you're right.
Seriously?
You're going to contradict myself, The_E and Sushi? Even after Sushi flat out stated exactly why? :rolleyes:
I think everyone needs to re-state what they are trying to say. In very clear, concise, explaining it with triple-redundancy terms. 'Cause I think there's a misunderstanding here. Although it might just be me...
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.
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).
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.
Would I be correct to summarize as follows:This is correct.QuoteGeneral 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.
Would I be correct to summarize as follows:This is correct.QuoteGeneral 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.
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 (http://204.12.237.54/websvn/listing.php?repname=fs2open&rev=5502&sc=1) 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 ( 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);
}
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;
}
}
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: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.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 (http://www.hard-light.net/wiki/index.php/Weapons.tbl#.2BTarget_Lead_Scaler:). This is because that flat is unset for cases where the Target Lead Scaler is set t0 1.0:Okay. I see where I glossed over something. I was looking at the heatseeker +Target Lead Scaler: code.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: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).
- 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.More accurately, this code would be executed for every tick of the physics.
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.
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 (http://www.hard-light.net/forums/index.php?topic=78344) :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 (http://www.hard-light.net/wiki/index.php/Portal:Modding) 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 (http://www.hard-light.net/forums/index.php?board=8.0).
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 (http://www.hard-light.net/forums/index.php?topic=78344) :drevil:
Checkout the modding portal (http://www.hard-light.net/wiki/index.php/Portal:Modding) 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 (http://www.hard-light.net/forums/index.php?board=8.0).
Changed the behavior of swarm missiles so they can lead their target.
-- Enabled by setting the "+Target Lead Scaler" flag to a swarm missile.
-snip-