Weapon launch curves#6732
Merged
Merged
Conversation
BMagnu
requested changes
May 24, 2025
BMagnu
left a comment
Member
There was a problem hiding this comment.
Small things.
Also, someone more familiar with multi code should take a look here.
| * Set the next fire timestamp for a turret, based on weapon type and ai class | ||
| */ | ||
| void turret_set_next_fire_timestamp(int weapon_num, const weapon_info *wip, ship_subsys *turret, const ai_info *aip) | ||
| void turret_set_next_fire_timestamp(int weapon_num, const weapon_info *wip, ship_subsys *turret, const ai_info *aip, WeaponLaunchCurveData launch_curve_data) |
Member
There was a problem hiding this comment.
This should take a const ref for the curve data
| * Fire a weapon from a turret | ||
| */ | ||
| bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum, const vec3d *orig_firing_pos, const vec3d *orig_firing_vec, const vec3d *predicted_pos = nullptr, float flak_range_override = 100.0f, bool play_sound = true) | ||
| bool turret_fire_weapon(int weapon_num, |
| ADD_FLOAT(ZERO_VALUE); | ||
| } | ||
|
|
||
| ADD_FLOAT(dist_to_target); |
Member
There was a problem hiding this comment.
This is an API change and thus needs to increment the multi version number at some point in this PR.
|
|
||
| void sexp_beam_or_turret_free_one(ship_subsys *turret, bool is_beam, bool free); | ||
| bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum, const vec3d *orig_firing_pos, const vec3d *orig_firing_vec, const vec3d *predicted_pos = nullptr, float flak_range_override = 100.0f, bool play_sound = true); | ||
| bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum, WeaponLaunchCurveData launch_curve_data, const vec3d *orig_firing_pos, const vec3d *orig_firing_vec, const vec3d *predicted_pos = nullptr, float flak_range_override = 100.0f, bool play_sound = true); |
| bool is_spawned = false, | ||
| float fof_cooldown = 0.0f, | ||
| ship_subsys *src_turret = nullptr, | ||
| WeaponLaunchCurveData launch_curve_data = WeaponLaunchCurveData { |
JohnAFernandez
requested changes
May 26, 2025
JohnAFernandez
left a comment
Contributor
There was a problem hiding this comment.
The multi related changes do look safe, but we are going to need to increment the multi version, which is in multi.h. Ping me on discord if you need more detailed instructions.
c341e8a to
70b7f88
Compare
BMagnu
approved these changes
May 26, 2025
JohnAFernandez
approved these changes
May 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a modular curve set that governs the behavior of weapon creation -- things like fire rate and burst shot count.
This is kind of messy, and if anyone has ideas for how to make it less messy I'm all ears, but I think it's just going to have to be this way -- weapon firing behavior is spread over like five different functions in three separate places, not even counting the edge cases. This messiness means that every input for these curves needs to be passed around a lot, so for now I've kept the inputs limited to the ones that I immediately need for my specific use-cases.
Important limitations of these curves at present:
Also, I attempted to add multi support. If I'm understanding correctly I think it will work, but I'm not ultimately very familiar with the multi code at all. Additionally, my method requires adding an extra float to each turret_fired and flak_fired packet, and I have no idea if that's an acceptable cost given that the functions are going to the trouble of squishing ints down into shorts.