Skip to content
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

Forcing specific weapon by range #1407

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Coronia
Copy link
Contributor

@Coronia Coronia commented Oct 17, 2024

  • ForceWeapon.InRange forces specified a list of weapons to be used once the target is within their Range. The first weapon in the listed order satisfied will be selected.
    • ForceWeapon.InRange.Overrides overrides the range when decides which weapon to use. Value from position matching the position from ForceWeapon.InRange is used if found, or the weapon's own Range if not found or set to a value below 0. Specifically, if a position has ForceWeapon.InRange set to -1 and ForceWeapon.InRange.Overrides set to a positive value, it'll use default weapon selection logic once satisfied.
    • If ForceWeapon.InRange.ApplyRangeModifiers is set to true, any applicable weapon range modifiers from the firer are applied to the decision range.

In rulesmd.ini:

[SOMETECHNO]                                    ; TechnoType
ForceWeapon.InRange=                            ; list of integer. 0 for primary weapon, 1 for secondary weapon, -1 to disable
ForceWeapon.InRange.Overrides=                  ; list of floating point value
ForceWeapon.InRange.ApplyRangeModifiers=false   ; boolean

An example:

[SOMETECHNO]
ForceWeapon.InRange=0,1,0,-1,1
ForceWeapon.InRange.Overrides=1,2,3,4,0

when the target distance is less than 1: use primary.
when the target distance is between 1 and 2: use secondary.
when the target distance is between 2 and 3: use primary.
when the target distance is between 3 and 4: use default weapon selection rule.
when the target distance is between 4 and secondary's range: use secondary.
when the target distance is greater than secondary's range: use default weapon selection rule.

This pattern can natually support WeaponX as well.

Copy link

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.

@Coronia Coronia force-pushed the force-weapon branch 7 times, most recently from a1455aa to 7b847ce Compare October 20, 2024 04:35
@Coronia Coronia force-pushed the force-weapon branch 2 times, most recently from 51e9811 to cc29999 Compare November 6, 2024 18:08
@Aephiex
Copy link
Contributor

Aephiex commented Nov 26, 2024

This is very useful. Now we can make a unit who has a ranged attack mode as a primary weapon and a melee attack mode as a secondary weapon, and it switches to melee attack when enemies are in range of the melee weapon.

Does it also take into consideration if the forced weapon can actually target the enemy or not? Such as if I have a unit called Space Marine, the primary weapon is a gauss gannon vs. air and land, the secondary weapon is a chainsaw vs. land at close range and is extremely high DPS, in this case is he forced to use his chainsaw vs. air units at close range and fail to do so and stuck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants