Skip to content

Conversation

@Flactine
Copy link
Contributor

@Flactine Flactine commented Dec 17, 2025

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:

[SOMEWEAPON]             ; WeaponType
CanTarget.MinVeterancy=0.0   ; float, default 0.0
CanTarget.MaxVeterancy=   ; float, default to [General] -> VeteranCap
  • 0.0 = Rookie
  • 1.0 = Veteran
  • 2.0 = Elite

Targets whose veterancy falls outside the specified range will not be considered valid targets for the weapon.

Units with Trainable=no are 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:

[SOMEWARHEAD]               ; WarheadType
AffectsAboveVeterancy=0.0   ; float, default 0.0
AffectsBelowVeterancy=   ; float, default to [General] -> VeteranCap
  • The warhead will only affect targets whose veterancy lies within the specified range.
  • If the target has zero health remaining, this check is bypassed (consistent with existing health-based warhead conditions).
  • Units with Trainable=no are treated as Veterancy = 0.0.



本次更新新增了基于目标等级(Veterancy)的筛选逻辑,分别作用于武器攻击判定弹头效果生效判定


1. 基于目标等级的武器筛选

武器现在可以根据目标单位的经验等级,决定是否允许对其进行攻击。
该逻辑不仅影响武器能否开火,也会影响武器选择流程(部分引擎强制固定选择的特殊情况除外)。

新增 INI 选项(WeaponType):

[SOMEWEAPON]             ; WeaponType
CanTarget.MinVeterancy=0.0   ; 浮点数,默认 0.0
CanTarget.MaxVeterancy=   ; 浮点数,默认 [General] -> VeteranCap

经验等级对应关系如下:

  • 0.0 = 新兵
  • 1.0 = 老兵
  • 2.0 = 精英

当目标的经验等级不在该区间内时,武器将不会将其视为可攻击目标。

拥有 Trainable=no 的单位会被直接视为 Veterancy = 0.0(新兵) 进行判断。


2. 基于目标等级的弹头效果筛选

弹头现在可以根据目标单位的经验等级,决定爆炸后是否对其产生效果。
与武器筛选不同,此逻辑不影响武器是否开火,而是作用于爆炸结算阶段。

新增 INI 选项:

[SOMEWARHEAD]               ; WarheadType
AffectsBelowVeterancy=0.0   ; 浮点数,默认 0.0
AffectsAboveVeterancy=   ; 浮点数,默认 [General] -> VeteranCap
  • 只有经验等级位于指定区间内的目标才会受到弹头效果影响
  • 当目标生命值为 0 时,该检查会被跳过(与现有生命值条件保持一致)
  • Trainable=no 的单位同样被视为 Veterancy = 0.0

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.
@github-actions
Copy link

github-actions bot commented Dec 17, 2025

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.
@Flactine Flactine requested a review from TaranDahl December 17, 2025 15:23
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.
@TaranDahl TaranDahl added ❓New feature ⚙️T1 T1 maintainer review is sufficient Tested labels Dec 18, 2025
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.

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

- [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)
Copy link
Contributor

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

Copy link
Contributor

@ZivDero ZivDero left a 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
Comment on lines 660 to 661
- add target filtering options to attacheffect system
- add veterancy-based target filtering for weapons and warheads
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalization please.

Flactine and others added 4 commits December 18, 2025 23:47
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❓New feature ⚙️T1 T1 maintainer review is sufficient Tested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants