Skip to content

Commit e8bb54c

Browse files
authored
Add "Move End Position by target velocity" (#6760)
* add "Move End Position by target velocity" * Enable the functionality for slashbeams as well
1 parent 6115a34 commit e8bb54c

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

code/weapon/beam.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,9 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots, int burst_seed, floa
24712471
if(b->weapon_info_index < 0){
24722472
return;
24732473
}
2474-
bwi = &Weapon_info[b->weapon_info_index].b_info;
2474+
2475+
auto& wi = Weapon_info[b->weapon_info_index];
2476+
bwi = &wi.b_info;
24752477

24762478
// stuff num shots even though its only used for antifighter beam weapons
24772479
b->binfo.shot_count = (ubyte)num_shots;
@@ -2519,6 +2521,11 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots, int burst_seed, floa
25192521
vm_vec_sub(&b->binfo.dir_a, &pos1, &turret_point);
25202522
vm_vec_normalize(&b->binfo.dir_a);
25212523

2524+
if (b->target && wi.beam_curves.has_curve(weapon_info::BeamCurveOutputs::END_POSITION_BY_VELOCITY)) {
2525+
float velocity_mult = wi.beam_curves.get_output(weapon_info::BeamCurveOutputs::END_POSITION_BY_VELOCITY, *b, &b->modular_curves_instance);
2526+
pos2 += b->target->phys_info.vel * velocity_mult;
2527+
}
2528+
25222529
// point 2
25232530
vm_vec_sub(&b->binfo.dir_b, &pos2, &turret_point);
25242531
vm_vec_normalize(&b->binfo.dir_b);
@@ -2643,6 +2650,11 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots, int burst_seed, floa
26432650
per_burst_rot_axis = b->target->pos;
26442651
if (bwi->t5info.burst_rot_axis == Type5BeamRotAxis::CENTER)
26452652
burst_rot_axis = b->target->pos;
2653+
2654+
if (wi.beam_curves.has_curve(weapon_info::BeamCurveOutputs::END_POSITION_BY_VELOCITY)) {
2655+
float velocity_mult = wi.beam_curves.get_output(weapon_info::BeamCurveOutputs::END_POSITION_BY_VELOCITY, *b, &b->modular_curves_instance);
2656+
pos2 += b->target->phys_info.vel * velocity_mult;
2657+
}
26462658

26472659
} else { // No usable target
26482660
vec3d center = vm_vec_new(0.f, 0.f, 0.f);

code/weapon/weapon.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ typedef struct type5_beam_info {
225225
float continuous_rot; // radians per sec rotation over beam lifetime
226226
int rot_curve_idx;
227227
Type5BeamRotAxis continuous_rot_axis; // axis around which do continuous rotation
228-
SCP_vector<float> burst_rot_pattern; // radians to rotate for each beam in a burst, will also make spawned and ssb beams fire
228+
SCP_vector<float> burst_rot_pattern; // radians to rotate for each beam in a burst, will also make spawned and ssb beams fire
229229
// this many beams simultaneously with the defined rotations
230230
Type5BeamRotAxis burst_rot_axis; // axis around which to do burst rotation
231231
float per_burst_rot; // radians to rotate for each burst, or each shot if no burst
@@ -256,7 +256,7 @@ typedef struct beam_weapon_info {
256256
float beam_initial_width; // what percentage of total beam width the beam has initially
257257
float beam_grow_factor; // what percentage of total beam lifetime when the beam starts growing
258258
float beam_grow_pct; // what percent/second the beam grows at
259-
beam_weapon_section_info sections[MAX_BEAM_SECTIONS]; // info on the visible sections of the beam
259+
beam_weapon_section_info sections[MAX_BEAM_SECTIONS]; // info on the visible sections of the beam
260260
float range; // how far it will shoot-Bobboau
261261
float damage_threshold; // point at wich damage will start being atenuated from 0.0 to 1.0
262262
float beam_width; // width of the beam (for certain collision checks)
@@ -833,6 +833,7 @@ struct weapon_info
833833
GLOW_RADIUS_MULT,
834834
GLOW_ALPHA_MULT,
835835
GLOW_ANIM_STATE,
836+
END_POSITION_BY_VELOCITY,
836837

837838
NUM_VALUES
838839
};
@@ -846,6 +847,7 @@ struct weapon_info
846847
std::pair {"Muzzle Glow Radius Mult", BeamCurveOutputs::GLOW_RADIUS_MULT},
847848
std::pair {"Muzzle Glow Alpha Mult", BeamCurveOutputs::GLOW_ALPHA_MULT},
848849
std::pair {"Muzzle Glow Anim State", BeamCurveOutputs::GLOW_ANIM_STATE},
850+
std::pair {"Move End Position by Target Velocity", BeamCurveOutputs::END_POSITION_BY_VELOCITY}
849851
},
850852
std::pair {"Beam Lifetime", modular_curves_math_input<
851853
modular_curves_math_input<
@@ -861,6 +863,7 @@ struct weapon_info
861863
modular_curves_submember_input<&beam::life_left>,
862864
ModularCurvesMathOperators::subtraction
863865
>{}},
866+
std::pair {"Beam Total Life", modular_curves_submember_input<&beam::life_total>{}},
864867
std::pair {"Warmup Lifetime", modular_curves_functional_input<beam_get_warmup_lifetime_pct>{}},
865868
std::pair {"Warmdown Lifetime", modular_curves_functional_input<beam_get_warmdown_lifetime_pct>{}},
866869
std::pair {"Warmdown Age", modular_curves_functional_input<beam_get_warmdown_age>{}},

0 commit comments

Comments
 (0)