Commit graph

639 commits

Author SHA1 Message Date
Atrik
56107e4e39 Fix formation controller flag reset during patrol
0ace1b44b2 added setting some animation into a controller state,
but formation controllers don't have any animations.
Probably some code intended for individuals has been copied there
by mistake.

This likely caused the visual system to reevaluate the actor somehow
because the animation didn't exist.

Fixes #8817
2026-03-13 12:22:31 +01:00
Dunedan
93ce94655d
Use @stylistic/brace-style for eslint
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace
style for JavaScript code. This plugin was however updated the last time
over 9 years ago and will be incompatible with ESLint v10, as that
[removes `context.getSourceCode()`][1], the plugin relies on.

To keep the eslint config working with ESLint v10, this replaces
`eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule
from `@stylistic/eslint-plugin`, a package we already use.

While `@stylistic/brace-style` doesn't offer an option to format braces
in exactly the same way as before, the "allman" style seems to be the
one closest to the existing code.

[1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members
[2]: https://eslint.style/rules/brace-style
2026-01-12 21:33:52 +01:00
Atrik
d14ee373bf Remove PostMessage for transitions IDLE to IDLE
Co-authored-by: @Vantha

Add 'isIdleConfirmed' flag to distinguish between
entering IDLE state and being confirmed idle.
Only send 'MT_UnitIdleChanged' messages after the
100ms timer elapses while still idle,
preventing spurious notifications for units
that instantaneously enter and leave IDLE.
This prevent the GUI to display a flickering idle count
in most cases, for example.

Refs : #8591
2025-12-18 10:22:27 +01:00
Atrik
b98e7f3b5b Fix formation combat stop command bug
Remove the ResetIdle method that was causing issues with the
'Stop units' command in formation combat

The method was originally added to prevent formation members
from appearing idle during patrol waypoints, but formation
controllers or its members no longer enter idle states
even without it

The ResetIdle method was sending MT_UnitIdleChanged messages
causing formation members to bug when using stop commands

Fixes: #8546
2025-12-18 10:22:27 +01:00
Atrik
06c40946eb Simplify calls for moving units into formation
Co-authored-by: @Vantha

Centralize all calls to move units into formation in UnitAI
Allowing additional checks to be done
before calling members to reform formation

Fixes : #8545

Revised Formation methods and when they do call
on reforming formation

Fixes : #7328

Don't order formation members to go to a point
if the controller is stuck
Instead make the controller jump to the member
who is closest to the destination

Fixes : #8543

Correct 'filter(member)' instead of 'filter(ent)'
in GetClosestMemberToPosition (ex GetClosestMember)

Fixes :	#5120
2025-12-18 10:22:27 +01:00
Ralph Sennhauser
ef007b9e5a
Fix gliding healers when group attack order
In case a healer is currently healing and is part of a selection ordered
to attack the healer gets moved along but the fsm state isn't changed
which leads to healer healing while gliding to the target.

Introduce a WalkToTargetRange function which does transition state in
addition by issuing an order instead.

Fixes: #6134
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-10-07 19:25:21 +02:00
real_tabasco_sauce
18ef4b6a1a Let units attacking low preference units without direction check for high preference units
-During each attack on a low preference target unless player-directed, update the range query and find a new target.
-Adjust behavior for elephants to work better versus infantry.
fixes #1488
2025-09-28 21:28:30 +02:00
Ralph Sennhauser
97a82cbc4a
Enable eslint rule 'no-redeclare'
Enable recommended rule 'no-redeclare' [1] and manually fix violations.

[1] https://eslint.org/docs/latest/rules/no-redeclare

Ref: #8068
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-14 14:53:10 +02:00
Ralph Sennhauser
8b13be3b03
Fix eslint rule 'consistent-return'
Manual fixes needed for:
eslint --no-config-lookup --rule '"consistent-return": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-26 18:54:52 +02:00
Ralph Sennhauser
72be06fd7f
Fix AttackEntityInZone after eslint 'no-shadow'
Fix for 7b4cf11e25

Fixes: #7965
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-22 19:16:28 +02:00
Ralph Sennhauser
7b4cf11e25
Fix eslint rule 'no-shadow'
Manual fixes needed for:
eslint --no-config-lookup --rule '"no-shadow": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-17 09:48:36 +02:00
Ralph Sennhauser
4b3124e364
Fix eslint rule 'prefer-const' in components/unitai
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/simulation/components/UnitAI.js

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-12 08:23:10 +02:00
Ralph Sennhauser
2b67499e05
Fix eslint rule 'no-trailing-spaces'
eslint --no-config-lookup --fix --rule '"no-trailing-spaces": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 17:31:47 +02:00
Ralph Sennhauser
12640ad63e
Fix eslint rule 'brace-on-same-line'
eslint --no-config-lookup --fix --plugin eslint-plugin-brace-rules \
    --rule '"brace-rules/brace-on-same-line": [
                "warn",
                {
                    "FunctionDeclaration": "never",
                    "FunctionExpression": "ignore",
                    "ArrowFunctionExpression": "always",
                    "IfStatement": "never",
                    "TryStatement": "ignore",
                    "CatchClause": "ignore",
                    "DoWhileStatement": "never",
                    "WhileStatement": "never",
                    "ForStatement": "never",
                    "ForInStatement": "never",
                    "ForOfStatement": "never",
                    "SwitchStatement": "never",
                },
                {
                    "allowSingleLine": true,
                }
            ]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 16:16:44 +02:00
Dunedan
8482f25800
Fix a bunch of spelling mistakes
This fixes a bunch of spelling mistakes found in user facing strings.

Fixes #7716
2025-04-11 06:24:32 +02:00
Lancelot de Ferrière
2f7ac026c1 Avoid idle 'flicker' because of regular formation regroups
Since 71a61d5f50, formations regularly regroup. However, units already at their correct offset should remain idle. This doesn't happen as we cannot check if we are at destination.
This exposes that and handles things properly... Unfortunately UnitAI has already left the IDLE state at this point, so we still get counted as no-longer idle for a turn.
To fix this, try and detect that particular situation without triggering infinite loops.
2025-01-02 16:59:13 +01:00
Freagarach
bc85236a38 Fix formation slow-down after stopping.
Introduced in 291f17b3c5.
Reported by @gameboy at
https://wildfiregames.com/forum/topic/107588-problems-with-different-queues-when-marching/.

Differential revision: https://code.wildfiregames.com/D5064
Comment by: @wraitii
This was SVN commit r27777.
2023-07-22 14:04:59 +00:00
Freagarach
c917c39a0d Pull Diplomacy out of cmpPlayer.
Who says only players should be able to conduct diplomacy?
Also separation of concerns, more maintainable files.

Differential revision: https://code.wildfiregames.com/D4921
Comments by: @elexis, @Stan
Refs. #5894

This was SVN commit r27722.
2023-06-19 06:33:33 +00:00
Freagarach
291f17b3c5 Reset speed when stopping.
And use an explicit function for running.

Differential revision: https://code.wildfiregames.com/D4957
Comments by: @Stan
This was SVN commit r27706.
2023-06-15 06:56:41 +00:00
wraitii
298f207e5b Improve AttackEntitiesByPreference by short-circuiting on best possible preference.
Similar trick to D3446 / c87229aa48 - we can short-circuit if we find
units that match our best possible preference.
This is, in particular, almost a 40% wall time improvement on Combat
Demo Huge, but it should apply in a number of more normal cases.

Differential Revision: https://code.wildfiregames.com/D5020
This was SVN commit r27701.
2023-06-14 07:52:30 +00:00
Freagarach
9692a3ec9c Revert af64e565d7.
Introduced #6750, reported by @Langbart, and quite hard to do right.
Fixes #6750

This was SVN commit r27567.
2023-03-06 07:24:47 +00:00
Freagarach
af64e565d7 Autocontinue constructing farms when the first queued for construction is full.
Seen at around minute 20 at
https://wildfiregames.com/forum/topic/15271-0-ad-on-youtube/page/114/#comment-544694.
If not tasked by the user, entities will not autogather. But now they at
least construct the farms.

Differential revision: https://code.wildfiregames.com/D4945
Comments by: @phosit, @Stan
This was SVN commit r27559.
2023-02-24 09:04:10 +00:00
Freagarach
d28145a61a Fix missing animation variant reset after committing resources in UnitAI.
Causing units to not show the gathering animation when close to a
dropsite.
We might want to move this stuff to their respective components.

Differential revision: https://code.wildfiregames.com/D4937
Comments by: @Stan
Fixes #6566

This was SVN commit r27550.
2023-02-17 13:43:06 +00:00
Freagarach
82e2619ece Switch default behavior from capture to attack.
Discussed countless times on the forum.
We try this out this release.

Patch by: @marder
Differential revision: https://code.wildfiregames.com/D4697
Idea accepted by: @asterix, @wowgetoffyourcellphone, @chrstgtr
Comments by: ^ + @Stan
This was SVN commit r27399.
2023-01-09 14:29:06 +00:00
Freagarach
96d33e02e4 Revert 774e8060d9.
Issue found:
https://wildfiregames.com/forum/topic/82754-alpha-26-pre-releaserelease-candidate-build-testing/?do=findComment&comment=513199.
The issue introduced is significantly worse than the stuff it fixed.

This was SVN commit r27034.
2022-08-08 07:14:18 +00:00
Freagarach
d1538f7fbd Fix formation merging issues.
The motion parameters were calculated even without members, which caused
us to try set a undefined passclass.
Also were members added to previously merged twin-formations. Once
merged (i.e. disbanded), they are moved out of world now.

Some cleanups/deduplication whilst at it.

Reported by: @andy5995 at the forums
(https://wildfiregames.com/forum/topic/71578-feedbacks-from-a26-svn-tests/page/8/#comment-505078)
Differential revision: https://code.wildfiregames.com/D4727
Comments by: @Langbart, @marder
Tested by: @Langbart
Fixes #6580

This was SVN commit r26993.
2022-06-30 06:04:05 +00:00
Freagarach
774e8060d9 Make formations respond as one to threats.
Improves their functioning significantly.

Based on a patch by @lyv
Differential revision: https://code.wildfiregames.com/D4666
Reviewed by: @marder
Comments by: @Stan
This was SVN commit r26956.
2022-06-19 06:28:52 +00:00
Freagarach
1af385a6dd Fix attack-walk with formations.
As well as patrolling.
Formations kept moving, finding targets and instructing their members to
attack (thereby resetting their attacking state every time).
We now move into `MEMBER` upon finding a target.

Differential revision: https://code.wildfiregames.com/D4550
Comments by: @Stan
Fixes #6461

This was SVN commit r26741.
2022-04-01 05:46:13 +00:00
Freagarach
dff79a388b Fix obstructed entities being able to drop off resources.
Introduced in 7ba4b1ffc8 by not checking the range anymore.
Reported by @FFFF at
https://wildfiregames.com/forum/topic/72985-stuck-units-delivering-resourses/.

Differential revision: https://code.wildfiregames.com/D4531
Tested by: @Langbart
Fixes #6446

This was SVN commit r26619.
2022-03-11 06:39:25 +00:00
Freagarach
41033d951e Fix stances of healers.
They fled whilst healing and not when idle. That is the other way around
than expected.
Introduced in healing introduction (c56f96040e); #999 specifically made
them flee, but it left quite undefined behaviour.
Reported by @BreakfastBurrito_007 on the forums somewhere.

Differential revision: https://code.wildfiregames.com/D4532
This was SVN commit r26618.
2022-03-11 06:37:03 +00:00
bb
3484a3d483 Move parabolic range computation to rangemanager
Co-proposed By: Freagarach
Reviewed By: Freagarach
Test written By: Stan
Comments By: vladislavbelov, stan, wraitii, Silier
Depricates: D4356

Differential Revision: D3249
This was SVN commit r26392.
2022-02-15 20:31:55 +00:00
Freagarach
8926f5a94c Move the allowed formations from cmpIdentity to cmpUnitAI.
One needs UnitAI to be able to use a formation, so include the spec
therein (to keep information close to where it is used).
Modders can change their templates with the following script:
https://code.wildfiregames.com/P261.

Differential revision: https://code.wildfiregames.com/D4443
Comments by: @Stan
Idea accepted by: @wraitii
Fixes: #6399

This was SVN commit r26235.
2022-01-23 07:23:44 +00:00
Freagarach
f1f744702b Rename "ElevationBonus" and "Delay" to "Origin" and "EffectDelay", respectively.
`ElevationBonus` is vague, as discussions proved. Therefore it is
renamed to `Origin`, which, describes better what the value stands for.
`Delay` is also quite vague, so renamed to `EffectDelay`.

Differential revision: https://code.wildfiregames.com/D2016
Comments by: @bb, @nani, @Nescio, @Silier, @Stan, @wraitii
This was SVN commit r26074.
2021-12-15 07:42:06 +00:00
Freagarach
1dfa8140a9 Fix infinite loop when queuing a gather order after garrison.
There was an infinite loop:
Order.Gather -> MustKill (L497) -> PushOrderFront(Attack) (L526) ->
NotInRange (L410) -> NotAbleToMove, thus finish order (L426/427) ->
Restart from Order.Gather.

We do two things here:
- Assume we don't have vision when garrisoned, which is not a bad
assumption.
- Check the range and if we are not able to move and not in range,
finish the order.

Introduced in: d3c3072c83
Reported by: @Langbart
Differential revision: https://code.wildfiregames.com/D4349
Fixes: #6377
Tested by: @Langbart
Comments by: @Silier, @Stan
This was SVN commit r26044.
2021-12-09 16:35:03 +00:00
Freagarach
65cd29696d Don't stop gathering after starting by autocontinue when in a formation.
FinishOrder called SetWaitingOnController, although the order
(constructing) had pushed another order (gather).
This is done now by telling we finished the order only when really idle.

This seems to boil down to the question: If we issued an order to a
formation, and its members have wandered off (imagine attacking an
entity and our members have finished the initial target but attack
nearby ones) do we want the whole formation to continue attacking or
execute the next order.

Also fixes reforming whilst attacking when an attack order was issued by
the player.

Reported by: @Langbart at https://code.wildfiregames.com/D2175#182343
Differential revision: https://code.wildfiregames.com/D4282
Tested by: @Langbart
This was SVN commit r25947.
2021-10-03 05:59:54 +00:00
Freagarach
9f556c8b5a Check for visibility on finding treasures in UnitAI.
Fixes an infinite loop when the next treasure is outside LOS.

Differential revision: https://code.wildfiregames.com/D4286
Comments by: @Angen, @bb
Fixes: #6329

This was SVN commit r25946.
2021-10-03 05:43:56 +00:00
Freagarach
4597cecd50 Rename misnamed lastGatheredType in ResourceGatherer.
Since it stores not the last gathered, but the last tasked type.
As discussed on IRC
(http://irclogs.wildfiregames.com/%230ad-dev/2021-09-16-QuakeNet-%230ad-dev.log).

Differential revision: https://code.wildfiregames.com/D4277
Reviewed by: @bb
Comments by: @Angen, @Stan, @wraitii
This was SVN commit r25942.
2021-09-24 06:33:53 +00:00
Freagarach
4b1270f841 Implement "Call to the Arms"-button.
This allows a player to task entities to drop off their resources and
subsequently attack-move to a specified location with one button.

Patch by: @JCWasmx86
Icon by: @Stan
Differential revision: https://code.wildfiregames.com/D4149
Fixes: #1364
Comments by: @Langbart
Based on a patch by: @Freagarach (https://code.wildfiregames.com/D1868)
This was SVN commit r25868.
2021-08-28 05:52:37 +00:00
Freagarach
32f3d18a15 Fix walk and fight with formations.
Introduced in c87229aa48, FindWalkAndFightTargets returns after the
first UnitAI finds a target, instead of also querying the rest of the
members.

Differential revision: https://code.wildfiregames.com/D4208
Comments by: @Stan, @wraitii
Fixes: #6260

This was SVN commit r25847.
2021-08-03 16:43:43 +00:00
Freagarach
c48d0c562f Fix fromations gathering treasures.
Introduced in ea96e81098.
The formation ignored the order to collect a treasure, but got into a
individual state (which should not happen).
Subsequent orders may fail due to unimplemented components/functions.

Reported by: @wowgetoffyourcellphone in
https://wildfiregames.com/forum/topic/39973-a25-feedbacks-from-testing/page/15/?tab=comments#comment-444979.

Differential revision: https://code.wildfiregames.com/D4207
Tested by: @wowgetoffyourcellphone
Comments by: @Stan, @wraitii
Fixes: #6266

This was SVN commit r25846.
2021-08-03 16:42:56 +00:00
Angen
8b0d82be33 Reject FormationWalk if entity is not part of formation anymore
Attack orders can be and looks like are pushed in front of formationwalk
order.
That is generally also logic in single entity behaviour.

In case formation gets destroyed and then target dies, attacker is
supposed to stop attacking target immediately.
That essentially leads to getting to old formationwalk command, what was
not issue for packable units until 674cdae166, that introduced
formationcompoennt into the order.

Hovewer abandoning this order without being in formation makes more
sense. Probably this one and FormationLeave should be FORMATIONMEMBER
specific commands and error out in INDIVIDUAL state, but thats too much
refactoring and potential rabbit hole.

Differential revision: D4206
Reviewed by: @wraitii
Accepted by: @asterix
Fixes: #6263

This was SVN commit r25845.
2021-08-02 16:48:00 +00:00
Freagarach
d3e1184191 Check range extra while gathering to prevent animation changes when gathering from dropsite.
Introduced in 3c4a341906.

Reported by: @wowgetoffyourcellphone
Differential revision: https://code.wildfiregames.com/D4198
This was SVN commit r25837.
2021-07-25 18:14:39 +00:00
Freagarach
5fba65e97d Don't lose trade gain when ordering a trader.
Introduced in 8f04d2ee90 due to overeagerly stopping trade when leaving
the trading-state.
Noticed in:
https://wildfiregames.com/forum/topic/41264-alpha-25-pre-releaserelease-candidate-build-testing/page/9/?tab=comments#comment-437888.

Differential revision: https://code.wildfiregames.com/D4197
Comment by: @Stan
This was SVN commit r25835.
2021-07-23 05:24:41 +00:00
Freagarach
8c7d77a610 Fix serialisation crash when patrolling.
6778fc4ea6 introduced waiting at the patrol points, but it was possible
that at such a point an enemy was noticed, thus quiting the "look
around" state, deleting `this.stopSurveying`, which was later `++`-ed.
That lead to an `NaN` property which got serialised. `NaN` serialisation
crashes as of 0e7fafebe1.

Differential revision: https://code.wildfiregames.com/D4177
Reported in:
https://wildfiregames.com/forum/topic/41264-alpha-25-pre-releaserelease-candidate-build-testing/page/4/?tab=comments#comment-435709
Reviewed by: @wraitii
This was SVN commit r25804.
2021-06-17 07:40:24 +00:00
Freagarach
f537fdd87d Look for resources nigh the order when forced.
When tasked to gather, entities looked for resources close to their
current location when the target was invalid (e.g. full).
Now on forced orders the entities will look for resources close to that
order's location, when possible.

Differential revision: https://code.wildfiregames.com/D4146
Fixes: #6085
Reviewed by: @Imarok
Tested by: @Langbart
Comments by: @marder, @Stan, @wraitii
This was SVN commit r25776.
2021-06-12 05:47:06 +00:00
wraitii
70f2ac6788 Fix error on resign with formation
Formation controllers that were about to be destroyed could bug out.
It's plausible this bug would also happen with regular units, but
couldn't reproduce.

Differential Revision: https://code.wildfiregames.com/D4110
This was SVN commit r25730.
2021-06-07 11:38:16 +00:00
wraitii
40cbde1925 Further Pushing tweaks: more customisable, longer ranges.
This overall decreases the deathball effect from units walking to each
other a bit.
- Fix formations - this cleans up a UnitMotion hack for formations,
making it possible to increase pushing ranges without breaking closely
knit formations like testudo.
- Make MINIMAL_PUSHING and the MOVE_EXTENSION configurable, and add a
STATIC_EXTENSION as well.
- Increase the pushing range significantly, making units sparser.

Differential Revision: https://code.wildfiregames.com/D4098
This was SVN commit r25708.
2021-06-06 15:25:52 +00:00
Stan
741d53e3e7 Do not go to the nearest dropsite when full and asked to hunt/slaughter and attack instead. This is fine as long as units don't decay.
Comments by: @wraitii, @Freagarach
Reported by: @FeldFeld
Fixes: #5954
Refs: 6d187f2145
Differential Revision: https://code.wildfiregames.com/D3444
This was SVN commit r25664.
2021-06-04 08:44:15 +00:00
Freagarach
3548feb16a Fix entities receiving double hunt order only attacking.
Caused by: 293cd95ccb.
Noticed by @Asger and @Kate.
Special case hunting.

Differential revision: https://code.wildfiregames.com/D3986
Comment by: @wraitii
This was SVN commit r25509.
2021-05-22 05:27:51 +00:00
Freagarach
9093e7bbe2 TreasureCollecter -> TreasureCollector.
Noticed by @Stan on ea96e81098.

Differential revision: https://code.wildfiregames.com/D3949
This was SVN commit r25461.
2021-05-18 16:51:44 +00:00