-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modular curves for weapon attributes during lifetime #6319
base: master
Are you sure you want to change the base?
Modular curves for weapon attributes during lifetime #6319
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curve handling feels like it should be in a function. They're all doing very similar things, it's quite verbose, and highly specific, i.e. something other coders are likely going to want to just skip over and it's only going to get worse over time.
It'd be a heck of a function though to properly encapsulate all the cases, so It's not something I'll ask for in this PR, but it's something we really ought to think about as this system continues to be used.
code/weapon/weapon.h
Outdated
@@ -385,7 +434,7 @@ struct weapon_info | |||
|
|||
float damage; // damage of weapon (for missile, damage within inner radius) | |||
float damage_time; // point in the lifetime of the weapon at which damage starts to attenuate. This applies to non-beam primaries. (DahBlount) | |||
int damage_curve_idx; // damage over time curve | |||
int damage_curve_idx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you couldn't update this one like the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For damage, I would want things like hit angle and target health as inputs, so that needs to go in a separate batch. (I went back and forth on this a lot.)
@BMagnu's been putting together a system to generify modular curves, so we're expecting to integrate these changes into that before it's merged. |
Modular Curve Framework
This branch adds the ability for the modder to specify an arbitrary number of 'modular curves' in weapons.tbl. Each curve has an input (from a list of possible inputs) and an output (from a list of possible outputs), and the name of the curve to be used. Optionally, the curve can also have values for scaling and translation along the X axis. The advantage of these values is that they're random ranges, so the behavior of a curve across different instances of a weapon can be randomized.
This batch of curves deals with attributes changing during the weapon's existence, as opposed to on launch or on hit. In practice, this means mostly cosmetic attributes affecting lasers and lights, with a couple of mechanics-affecting ones as well. I intend to add a weapon velocity multiplier as an output later on, but for now I've left it out -- it will be a bit complicated to set up.
There are a few input-output pairs that overlap with curves already specified in the table. I've folded those hardcoded curves into this system: when they're specified in the table, parsing will convert them into modular curves and add them to the list.
There's a set of considerations to make regarding when to lump curves together into a single set, and when to split them; I lean toward lumping into one set so long as that's possible, which mostly depends on whether the necessary inputs all make sense under all relevant circumstances. There are a few other sets I plan to add to weapons: curves dealing with attributes on launch, ones dealing with attributes on hit, and ones dealing with child spawning. Launch and hit curves will require inputs that wouldn't make sense for this set, and child-spawning curves will have to be defined on a per-child-weapon basis.