-
-
Notifications
You must be signed in to change notification settings - Fork 124
Add veterancy-based target filtering for weapons and warheads #2008
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
base: develop
Are you sure you want to change the base?
Conversation
Introduced IsVeterancyInThreshold to TechnoExt for checking if a TechnoClass object's veterancy level falls within a specified range. Updated relevant headers and added a corresponding method declaration in WarheadType's ExtData for future use.
Introduces veterancy-based threshold checks for WeaponType and WarheadType, allowing configuration of min/max veterancy for targeting and effect application. Updates relevant methods, serialization, and INI loading to support new AffectsAboveVeterancy, AffectsBelowVeterancy, CanTarget_MinVeterancy, and CanTarget_MaxVeterancy fields.
Added debug logging to IsVeterancyInThreshold for min, max, and veterancy values in TechnoExt. Updated veterancy-related default values in WarheadType and WeaponType headers to use explicit float suffixes for consistency.
Corrected the code to read 'AffectsBelowVeterancy' and 'AffectsAboveVeterancy' into the appropriate variables instead of incorrectly reading them into percent variables.
Extended weapon and warhead targeting logic to include veterancy threshold checks alongside health checks. Updated relevant methods and hooks to ensure that actions such as firing, shrapnel targeting, and damage application now also consider the target's veterancy. Removed debug logging from IsVeterancyInThreshold for cleaner output. Adjusted INI loading to use float literals for veterancy thresholds.
Added documentation for new veterancy-based conditions: `AffectsAboveVeterancy` and `AffectsBelowVeterancy` for warhead detonation, and `CanTarget.MinVeterancy` and `CanTarget.MaxVeterancy` for weapon targeting. Clarified how veterancy values are interpreted and how non-trainable TechnoTypes are handled.
|
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. |
Replaced hardcoded veterancy limits with RulesClass::Instance->VeteranCap in WarheadType and WeaponType target filtering logic. Updated documentation and credits to reflect the addition of veterancy-based target filtering.
Replaced direct assignment of RulesClass::Instance->VeteranCap with a static_cast to float in both WarheadType and WeaponType Body.h files to ensure type consistency.
Replaced Valueable<float> with Nullable<float> for veterancy-related fields in WarheadType and WeaponType headers. This allows these fields to represent unset/null values, improving flexibility in configuration.
Replaced Nullable with Valueable for AffectsAboveVeterancy and CanTarget_MinVeterancy to allow value resolution with VeteranCap. Updated related logic in WarheadTypeExt and WeaponTypeExt to use the new types and ensure correct threshold checks based on game rules.
Replaced hardcoded veterancy cap values with dynamic checks using RulesClass::Instance->VeteranCap in WarheadTypeExt and WeaponTypeExt INI loading. This ensures correct behavior when the veterancy cap is changed from its default value.
Changed veterancy-related variables and function parameters from float to double in WarheadType and WeaponType extensions for improved precision and consistency. Updated related method calls and initializations accordingly.
Corrected the parameter types for IsVeterancyInThreshold to use double instead of float. Fixed the logic for HealthCheck and VeterancyCheck assignments in WarheadTypeExt::ExtData::LoadFromINIFile to properly reflect the intended threshold checks.
Updated documentation to specify that AffectsBelowVeterancy, AffectsAboveVeterancy, CanTarget.MaxVeterancy, and CanTarget.MinVeterancy are of type double, improving clarity for users configuring these values.
Updated documentation for AffectsBelowVeterancy and CanTarget.MaxVeterancy to clarify that these parameters accept floating point values, percents, or absolute values, and to indicate their default behavior. This improves accuracy and consistency in the docs.
Corrected indentation and spacing for configuration examples in Fixed-or-Improved-Logics.md and New-or-Enhanced-Logics.md to improve readability and consistency.
Coronia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's better to put veterancy in an enum, so it can be represented in a clearer way than having to remember what 0.0, 1.0 and 2.0 stand for, and could be reused in the future
docs/Whats-New.md
Outdated
| - [Added Target Filtering Options to AttachEffect System](New-or-Enhanced-Logics.md#attached-effects) (by Flactine) | ||
| - [Customize type selection for IFV](Fixed-or-Improved-Logics.md#customize-type-selection-for-ifv) (by NetsuNegi) | ||
| - [Weapon target filtering by target veterancy](New-or-Enhanced-Logics.md#weapon-targeting-filter) (by Flactine) | ||
| - [Warhead effect filtering by target veterancy](Fixed-or-Improved-Logics.md#customizable-warhead-trigger-conditions) (by Flactine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these 2 lines should be put at the end of this section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks solid overall, but I can't help shake the feeling that the "can target" and "can affect" stuff is getting a bit spaghetti. Could combine it all into single "can target" and "can affect" functions (with subfunctions for the various logics). Though this is not the fault of this specific PR.
CREDITS.md
Outdated
| - add target filtering options to attacheffect system | ||
| - add veterancy-based target filtering for weapons and warheads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization please.
Co-authored-by: Kerbiter <crabiter@vivaldi.net>
Updated the default upper bound for veterancy checks to use VeteranCap + 1.0 instead of VeteranCap, ensuring that the threshold is exclusive and matches documentation. Updated related documentation and developer warnings to reflect this change.
This PR introduces veterancy-based filtering for both weapon targeting and warhead effect application.
1. Weapon target filtering by target veterancy
Weapons can now restrict which targets they are allowed to attack based on the target’s veterancy level.
This affects both weapon firing eligibility and weapon selection logic (except for special cases where weapon selection is fixed by the engine).
New INI options:
0.0= Rookie1.0= Veteran2.0= EliteTargets whose veterancy falls outside the specified range will not be considered valid targets for the weapon.
Units with
Trainable=noare always treated as having Veterancy = 0.0 (Rookie) for the purpose of these checks.2. Warhead effect filtering by target veterancy
Warheads can now conditionally apply their effects based on the target’s veterancy level.
Unlike weapon filtering, this logic does not affect whether a weapon can fire, but instead determines whether the warhead’s effects will be applied after detonation.
New INI options:
Trainable=noare treated as Veterancy = 0.0.本次更新新增了基于目标等级(Veterancy)的筛选逻辑,分别作用于武器攻击判定和弹头效果生效判定。
1. 基于目标等级的武器筛选
武器现在可以根据目标单位的经验等级,决定是否允许对其进行攻击。
该逻辑不仅影响武器能否开火,也会影响武器选择流程(部分引擎强制固定选择的特殊情况除外)。
新增 INI 选项(WeaponType):
经验等级对应关系如下:
0.0= 新兵1.0= 老兵2.0= 精英当目标的经验等级不在该区间内时,武器将不会将其视为可攻击目标。
拥有
Trainable=no的单位会被直接视为 Veterancy = 0.0(新兵) 进行判断。2. 基于目标等级的弹头效果筛选
弹头现在可以根据目标单位的经验等级,决定爆炸后是否对其产生效果。
与武器筛选不同,此逻辑不影响武器是否开火,而是作用于爆炸结算阶段。
新增 INI 选项:
Trainable=no的单位同样被视为 Veterancy = 0.0