Skip to content

Commit df02798

Browse files
authored
Allow shockwave orientations to be relative to their parents (#6919)
* initial setup * various orientations
1 parent 85b37e0 commit df02798

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

code/ship/ship.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13408,7 +13408,7 @@ int ship_fire_primary(object * obj, int force, bool rollback_shot)
1340813408
vm_vec_normalized_dir(&firing_vec, &predicted_target_pos, &obj->pos);
1340913409
}
1341013410

13411-
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, nullptr, nullptr);
13411+
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, &obj->orient.vec.uvec, &obj->orient.vec.rvec);
1341213412
} else if (std_convergence_flagged || (auto_convergence_flagged && (aip->target_objnum != -1))) {
1341313413
// std & auto convergence
1341413414
vec3d target_vec, firing_vec, convergence_offset;
@@ -13435,12 +13435,12 @@ int ship_fire_primary(object * obj, int force, bool rollback_shot)
1343513435
vm_vec_normalized_dir(&firing_vec, &target_vec, &firing_pos);
1343613436

1343713437
// set orientation
13438-
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, nullptr, nullptr);
13438+
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, &obj->orient.vec.uvec, &obj->orient.vec.rvec);
1343913439
} else if (sip->flags[Ship::Info_Flags::Gun_convergence]) {
1344013440
// model file defined convergence
1344113441
vec3d firing_vec;
1344213442
vm_vec_unrotate(&firing_vec, &pm->gun_banks[bank_to_fire].norm[pt], &obj->orient);
13443-
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, nullptr, nullptr);
13443+
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, &obj->orient.vec.uvec, &obj->orient.vec.rvec);
1344413444
}
1344513445

1344613446
if (winfo_p->wi_flags[Weapon::Info_Flags::Apply_Recoil]){ // Function to add recoil functionality - DahBlount
@@ -14281,7 +14281,7 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1428114281
{
1428214282
vec3d firing_vec;
1428314283
vm_vec_unrotate(&firing_vec, &pm->missile_banks[bank].norm[pnt_index-1], &obj->orient);
14284-
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, nullptr, nullptr);
14284+
vm_vector_2_matrix_norm(&firing_orient, &firing_vec, &obj->orient.vec.uvec, &obj->orient.vec.rvec);
1428514285
}
1428614286

1428714287
// create the weapon -- for multiplayer, the net_signature is assigned inside

code/weapon/shockwave.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ int shockwave_create(int parent_objnum, const vec3d* pos, const shockwave_create
173173

174174
orient = vmd_identity_matrix;
175175
vm_angles_2_matrix(&orient, &sw->rot_angles);
176+
if (sci->rot_parent_relative) {
177+
orient = orient * Objects[parent_objnum].orient;
178+
}
179+
176180
flagset<Object::Object_Flags> tmp_flags;
177181
objnum = obj_create( OBJ_SHOCKWAVE, real_parent, i, &orient, &sw->pos, sw->outer_radius, tmp_flags + Object::Object_Flags::Renders, false );
178182

code/weapon/shockwave.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef struct shockwave_create_info {
8383
int radius_curve_idx; // curve for shockwave radius over time
8484
angles rot_angles;
8585
bool rot_defined; // if the modder specified rot_angles
86+
bool rot_parent_relative = false;
8687
bool damage_overridden; // did this have shockwave damage specifically set or not
8788

8889
int damage_type_idx;

code/weapon/weapons.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ void parse_shockwave_info(shockwave_create_info *sci, const char *pre_char)
618618
sci->rot_defined = true;
619619
}
620620

621+
sprintf(buf, "%sShockwave Rotation Is Relative To Parent:", pre_char);
622+
if(optional_string(buf.c_str())) {
623+
stuff_boolean(&sci->rot_parent_relative);
624+
}
625+
621626
sprintf(buf, "%sShockwave Model:", pre_char);
622627
if(optional_string(buf.c_str())) {
623628
stuff_string(sci->pof_name, F_NAME, MAX_FILENAME_LEN);
@@ -7265,7 +7270,7 @@ void spawn_child_weapons(object *objp, int spawn_index_override)
72657270
// fire the beam
72667271
beam_fire(&fire_info);
72677272
} else {
7268-
vm_vector_2_matrix_norm(&orient, &tvec, nullptr, nullptr);
7273+
vm_vector_2_matrix_norm(&orient, &tvec, &objp->orient.vec.uvec, &objp->orient.vec.rvec);
72697274
weapon_objnum = weapon_create(&pos, &orient, child_id, parent_num, -1, wp->weapon_flags[Weapon::Weapon_Flags::Locked_when_fired], true);
72707275

72717276
//if the child inherits parent target, do it only if the parent weapon was locked to begin with

0 commit comments

Comments
 (0)