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
CanTargetVeterancy=all     ; List of Affected Veterancy Enumeration (none|rookie|veteran|elite|all)

Targets whose veterancy is not included in the specified enumeration will not be considered valid targets for the weapon.


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
AffectsVeterancy=all        ; List of Affected Veterancy Enumeration (none|rookie|veteran|elite|all)
  • The warhead will only affect targets whose veterancy is explicitly listed in AffectsVeterancy.



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


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

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

新增 INI 选项(WeaponType):

[SOMEWEAPON]             ; 武器类型
CanTargetVeterancy=all     ; List of Affected Veterancy Enumeration (none|rookie|veteran|elite|all)

当目标的等级未被列入指定枚举时,武器将不会将其视为可攻击目标。


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

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

新增 INI 选项:

[SOMEWARHEAD]               ; 弹头类型
AffectsVeterancy=all        ; List of Affected Veterancy Enumeration (none|rookie|veteran|elite|all)
  • 只有等级被列入指定枚举的目标才会受到弹头效果影响

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

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.

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.
@TaranDahl
Copy link
Contributor

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

@Flactine You can make that flag read both the enum (Rookie, Veteran, Elite) and float types simultaneously.
After that, I think this PR can be merged? @Coronia @ZivDero @Metadorius

@TaranDahl
Copy link
Contributor

@Coronia @Metadorius Going to merge this in 24h if no one has further instructions.

@TaranDahl TaranDahl merged commit 490a7df into Phobos-developers:develop Jan 25, 2026
6 checks passed
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.

6 participants