Skip to content

Penetration damage on garrisonable structures #1370

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

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

FS-21
Copy link
Contributor

@FS-21 FS-21 commented Aug 30, 2024

  • Warheads can now damage garrisoned infantry at impact.
  • PenetratesGarrison Enables the logic.
    • PenetratesGarrison.RandomTarget specifies if the damage will go at some random garrisoned soldier or if all infantry should be damaged at the same time.
    • PenetratesGarrison.DamageMultiplier can be used to modify the damage applied against the garrisoned infantry. A random percentage value will be picked between the specified range.
    • PenetratesGarrison.CleanSound can be used to specify a sound to play when the structure lost all the garrisoned soldiers with this logic.
    • PenetratesGarrison.Allowed can be set on garrisonable buildings to protect the garrisoned infantry. If used on infantry these units won't affected by this logic.

In rulesmd.ini:

[SOMEWARHEAD]                                 ; WarheadType
PenetratesGarrison=false                      ; boolean
PenetratesGarrison.RandomTarget=true          ; boolean
PenetratesGarrison.DamageMultiplier=1.0,1.0   ; floating point value - single or comma-sep. range (percentages)
PenetratesGarrison.CleanSound=                ; sound entry

[SOMETECHNO]                                  ; TechnoType
PenetratesGarrison.Allowed=false              ; boolean

FS-21 added 3 commits August 20, 2024 13:33
- Warheads can now damage garrisoned infantry at impact.
- `GarrisonPenetration` Enables the logic.
- `GarrisonPenetration.RandomTarget` specifies if the damage will go at some random garrisoned soldier or if all infantry should be damaged at the same time.
- `GarrisonPenetration.DamageMultiplier` can be used to modify the damage applied against the garrisoned infantry. A random percentage value will be picked between the specified range.
- `GarrisonPenetration.CleanSound` can be used to specify a sound to play when the structure lost all the garrisoned soldiers with this logic.
- `ImmuneToGarrisonPenetration` can be set on garrisonable buildings to protect the garrisoned infantry. If used on infantry these units won't affected by this logic.

In `rulesmd.ini`:

[SOMEWARHEAD]                                 ; Warhead
GarrisonPenetration=false                     ; boolean
GarrisonPenetration.RandomTarget=true         ; boolean
GarrisonPenetration.DamageMultiplier=1.0,1.0  ; floating point value - single or comma-sep. range (percentages)
GarrisonPenetration.CleanSound=               ; sound entry

[SOMETECHNO]                                  ; TechnoType
ImmuneToGarrisonPenetration=false             ; boolean
@FS-21 FS-21 closed this Aug 30, 2024
Copy link

github-actions bot commented Aug 30, 2024

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@FS-21 FS-21 reopened this Aug 31, 2024
@FS-21
Copy link
Contributor Author

FS-21 commented Aug 31, 2024

garrison-penetration-01
Reopened because I finally tested it online and is free of desyncs.

@Fryone
Copy link
Contributor

Fryone commented Sep 15, 2024

Isn't it similar to Ares Pass Through? https://ares-developers.github.io/Ares-docs/new/buildings/urbancombattrenches.html
though, Ares did it through projectiles and buildings...

@mevitar
Copy link

mevitar commented Sep 18, 2024

There were some issues with that garrison logic that i do not remember right now, and this feature here might allow for better control over what can get cleared and what not.
If anything, this one is much more intuitive.

Copy link
Contributor

@Coronia Coronia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to change these tags' names into PenetratesGarrison, to keep consistent with the already exists PenetratesBunker tag

damage = MapClass::GetTotalDamage(damage, pWH, pPassenger->Type->Armor, 0);

pPassenger->Health = pPassenger->Health - damage;
pPassenger->Health = pPassenger->Health < 0 ? 0 : pPassenger->Health;
Copy link
Contributor

@Coronia Coronia Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging these 2 lines into 1:

pPassenger->Health = Math::clamp(pPassenger->Health - damage, 0, pPassenger->Type->Strength);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pPassenger->Health = Math::clamp(pPassenger->Health - damage, 0, pPassenger->Type->Strength);

I don't understand the use of pPassenger->Type->Strength here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're now supporting negative damage for PenetrateGarrison, this is for preventing it from gaining more health than its limit. It can be ignored if there're already some other sorts of check elsewhere tho

Copy link
Contributor Author

@FS-21 FS-21 May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean, since I never used that clamp method before:

Example:
Passenger->Health = 50
damage = -25 (healer example)
pPassenger->Type->Strength = 300

Current code:
Passenger->Health = 50 - (-25) = 75;
pPassenger->Health = 75 < 0 ? 0 : 75;

That new line for merging code:
pPassenger->Health = Math::clamp(75, 0, 300);
It does return "pPassenger->Health = 75" ? Just ignorant question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, clamp will return a value that's between minimum and maximum values, which are 0 and 300 in this case

Copy link
Contributor Author

@FS-21 FS-21 May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the right answer of the example is 75, not 300 that is the max health the unit can have :-/

From GarrisonPenetration to PenetratesGarrison
if (pTypeExt->ImmuneToPenetratesGarrison)
return;

damage = MapClass::GetTotalDamage(damage, pWH, pPassenger->Type->Armor, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should consider distance between epicenter as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are infantry gathered together inside a structure, I don't understand the point :-/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's about judging the distance between the warhead's detonation point and the garrisoned building, which is still necessary. Imagine the case when using a neutron bomb with large cellspread on these buildings, it's expected that infantry garrisoned in the edge should take less damage than those in the center

Copy link
Contributor Author

@FS-21 FS-21 May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you can't point at garrisoned infantry directly (maybe if the Techno Attachment is merged into develop, someday?).
If adding that change doesn't affect the current behaviour I'll check how is done in another part of the project and apply the suggested change here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can simply calculate the distance between the warhead's detonation point and the garrisoned building in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how should be done since I see no similar examples in Phobos.
Is this?

int distanceFromCenter = pTarget->DistanceFrom(pPassenger);
damage = MapClass::GetTotalDamage(damage, pWH, pPassenger->Type->Armor, distanceFromCenter);

or:

int distanceFromCenter = pBullet->DistanceFrom(pTarget);
damage = MapClass::GetTotalDamage(damage, pWH, pPassenger->Type->Armor, distanceFromCenter);

or:

int distanceFromCenter = pBullet->DistanceFrom(pPassenger);
damage = MapClass::GetTotalDamage(damage, pWH, pPassenger->Type->Armor, distanceFromCenter);

or none of the above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be the second one

@Starkku Starkku force-pushed the develop branch 2 times, most recently from b429215 to 280b1c8 Compare June 29, 2025 19:13
…es-garrison

# Conflicts:
#	CREDITS.md
#	YRpp
#	src/Ext/TechnoType/Body.cpp
#	src/Ext/WarheadType/Detonate.cpp
@Coronia Coronia force-pushed the feature/penetrates-garrison branch from feba95c to 7809074 Compare July 8, 2025 15:02
@Coronia Coronia added Needs testing ⚙️T1 T1 maintainer review is sufficient labels Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs testing ⚙️T1 T1 maintainer review is sufficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants