Skip to content

Commit 365d9c5

Browse files
authored
gate hull and subsys impacts (#6855)
1 parent 1d5fa5e commit 365d9c5

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

code/ship/shiphit.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void do_subobj_heal_stuff(const object* ship_objp, const object* other_obj, cons
662662
//
663663
//WMC - hull_should_apply armor means that the initial subsystem had no armor, so the hull should apply armor instead.
664664

665-
std::pair<std::optional<ConditionData>, float> do_subobj_hit_stuff(object *ship_objp, const object *other_obj, const vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor, float hit_dot)
665+
std::pair<std::optional<ConditionData>, float> do_subobj_hit_stuff(object *ship_objp, const object *other_obj, const vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor, float hit_dot, bool shield_hit)
666666
{
667667
vec3d g_subobj_pos;
668668
float damage_left, damage_if_hull;
@@ -1003,7 +1003,7 @@ std::pair<std::optional<ConditionData>, float> do_subobj_hit_stuff(object *ship_
10031003
damage_to_apply *= ss_dif_scale;
10041004
}
10051005

1006-
if (j == 0) {
1006+
if (j == 0 && !shield_hit) {
10071007
subsys_impact = ConditionData {
10081008
ImpactCondition(subsystem->armor_type_idx),
10091009
HitType::SUBSYS,
@@ -2503,8 +2503,10 @@ static void ship_do_damage(object *ship_objp, object *other_obj, const vec3d *hi
25032503
if ( (damage > 0.0f) ) {
25042504
bool apply_hull_armor = true;
25052505

2506+
bool shield_hit = quadrant >= 0;
2507+
25062508
// apply damage to subsystems, and get back any remaining damage that needs to go to the hull
2507-
auto damage_pair = do_subobj_hit_stuff(ship_objp, other_obj, hitpos, submodel_num, damage, &apply_hull_armor, hit_dot);
2509+
auto damage_pair = do_subobj_hit_stuff(ship_objp, other_obj, hitpos, submodel_num, damage, &apply_hull_armor, hit_dot, shield_hit);
25082510

25092511
damage = damage_pair.second;
25102512

@@ -2563,13 +2565,15 @@ static void ship_do_damage(object *ship_objp, object *other_obj, const vec3d *hi
25632565
}
25642566
}
25652567

2566-
impact_data[static_cast<std::underlying_type_t<HitType>>(HitType::HULL)] = ConditionData {
2567-
ImpactCondition(shipp->armor_type_idx),
2568-
HitType::HULL,
2569-
damage,
2570-
ship_objp->hull_strength,
2571-
shipp->ship_max_hull_strength,
2572-
};
2568+
if (!shield_hit) {
2569+
impact_data[static_cast<std::underlying_type_t<HitType>>(HitType::HULL)] = ConditionData {
2570+
ImpactCondition(shipp->armor_type_idx),
2571+
HitType::HULL,
2572+
damage,
2573+
ship_objp->hull_strength,
2574+
shipp->ship_max_hull_strength,
2575+
};
2576+
}
25732577

25742578
// multiplayer clients don't do damage
25752579
if (((Game_mode & GM_MULTIPLAYER) && MULTIPLAYER_CLIENT)) {

code/ship/shiphit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ constexpr float DEATHROLL_ROTVEL_CAP = 6.3f; // maximum added deathroll rotve
3535
// function to destroy a subsystem. Called internally and from multiplayer messaging code
3636
extern void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, const vec3d *hitpos, bool no_explosion = false );
3737

38-
std::pair<std::optional<ConditionData>, float> do_subobj_hit_stuff(object *ship_obj, const object *other_obj, const vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor, float hit_dot = 1.f);
38+
std::pair<std::optional<ConditionData>, float> do_subobj_hit_stuff(object *ship_obj, const object *other_obj, const vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor, float hit_dot = 1.f, bool shield_hit = false);
3939

4040
// Goober5000
4141
// (it might be possible to make `target` const, but that would set off another const-cascade)

0 commit comments

Comments
 (0)