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
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.
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.
Improves pathfinding for the general case (no large entities in a
formation).
Differential revision: https://code.wildfiregames.com/D4605
Comments by: @marder, @Stan, @wraitii
This was SVN commit r26873.
Implement a threshold between "turning" the formation and "rearranging"
it.
Patch By: marder
Based on Patch By: alre
Comments By: Freagarach, Stan, Silier
Glanced good By: Freagarach
Differential Revision: D4294
Forum Topic:
https://wildfiregames.com/forum/topic/44848-proposals-for-formations/#comment-452917
This was SVN commit r26520.
Reduces duplication across components.
Allows to provide specific names and history for formations.
Differential revision: https://code.wildfiregames.com/D4476
Comments by: @bb, @Stan
Fixes#6400
This was SVN commit r26476.
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/D4349Fixes: #6377
Tested by: @Langbart
Comments by: @Silier, @Stan
This was SVN commit r26044.
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.
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.
These don't depend on the simulation and can be useful for e.g. the GUI
(the FSM) or map scripts.
Confer also the vector implementation.
Differential revision: D3863
Comment by: @wraitii (agreed with concept)
This was SVN commit r25288.
Keep responsibilities separated, allow easier modding of attacking
behaviour.
Ideally the BuildingAI attacking routine would be merged in here as
well, but not done for now.
Part of #5810
Differential revision: D3816
Comments by: @smiley, @Stan
This was SVN commit r25235.
Moves the building logic from UnitAI to Builder.
Makes it easier for modders to change building behaviour, e.g. letting
structures build.
Differential revision: D3812
Comment by: @Angen
This was SVN commit r25208.
FindWalkAndFightTargets is used during attack-walk (and a few other
situations) to find new entities to attack. This function can be a bit
slow, taking large chunks of time during battles.
This optimises it by assuming that one of the surrounding unit will
match preferred criteria (which, for most soldiers, are 'Human'), thus
returning the first attackable entity. In the worst case, it should
still be slightly faster than the current code.
Differential Revision: https://code.wildfiregames.com/D3446
This was SVN commit r25102.
Which were autofixable, with slight modifications.
Not done are the slightly more complex changes.
Refs. #5524
Patch by: @Krinkle
Differential revision: D2279
Comments by: @elexis, @Stan
Reviewed by: @wraitii
This was SVN commit r25087.
18b317bc19 (#563) introduced an ANIMAL-state from a separate
AnimalAI-component (introduced in e19146cf25).
This patch merges that separate state and brings the ROAMING and FEEDING
(renamed to LINGERING) under the INDIVIDUAL.IDLE-state.
This enables e.g. city-building mods to have human units that linger and
roam or animals that behave like humans.
The specific values for animals might need tweaking after this.
Differential revision: D2646
Fixes: #1832, #5593
Comments by: @Angen, @Langbart, @Nescio, @Stan, @wraitii
Refs.: #3919
This was SVN commit r24953.
Unit Motion currently checks if the unit is at destination during the
MT_Update_Motion* step, which happens late in the turn (notably, after
Timer.js) and moreover happens while entities are being moved (e.g.
entities with lower IDs have moved already, entities with higher IDs
have yet to do so).
This changes UnitMotion to instead check at turn start, which:
- benefits from in-turn path computations for more fluid movement
- ensure that distance checks aren't done against an entity that has
already moved for the turn.
The latter issue led to units failing to get in range of their target
when chasing them, in some situations.
As a side effect, this means that UnitAI move requests always take one
turn to succeed, so orders should be updated to check for range (or
they'll waste a turn). This is done for garrisoning, other orders were
already doing so.
Also includes a small tweak to avoid units rotating randomly when they
have no movement to accomplish.
Patch by: bb
Reviewed By: wraitii
Refs #5936
Differential Revision: https://code.wildfiregames.com/D3230
This was SVN commit r24797.
Units sometimes ignored targets that entered their LoS. The cause is
d0fc8ff67d: range queries returned units farther away, and those units
might actually be out of range if distance is computed center-to-center,
which both UnitAI and LOS do. This meant that code relying on range
query updates was possibly broken, and indeed units missed things (see
ticket).
This introduces a boolean to switch between pre-d0fc8ff67d behaviour
(entity-as-point, center-to-center range queries) and post-d0fc8ff67d
(entities-as-circumscribing-circle, edge-to-edge range queries).
The former is used for UnitAI (where the new behaviour bugged), auras
(where varying structure sizes made it awkward) and build
restrictions(which simply did not really need it).
Reverts 7f1ee23d88, 050c5401b1 (with the exception of the iber monument
footprint), and the template changes in d0fc8ff67d itself.
It also reduces alertRaiser ranges slightly, this was missed in the
original diff.
#3381 is not reopened as BuildingAI still uses the new range queries.
Reported by: Freagarach
Comments By: Angen
Fixes#5968
Differential Revision: https://code.wildfiregames.com/D3456
This was SVN commit r24776.
Renames helper Entity.js to Position.js and moves to there:
- `EntitiesNearPoint` (from Attacking.js).
- `InterpolatedLocation` (from Attacking.js).
- `TestCollision` (from Attacking.js).
- `PredictTimeToTarget` (from Attack.js).
Also adds a test for the helper.
Differential Revision: D2940
Reviewed By: @wraitii
Comments by: @Stan, @vladislavbelov
This was SVN commit r24128.
- Renames Armour-node to Resistance.
- Support resistance against Capture.
- Puts resistance against effects in separate nodes.
- Some cleaning.
Differential Revision: D2229
Reviewed by: @bb (accepted), @wraitii.
Comments by: @Stan, @Nescio.
This was SVN commit r24001.
This splits the "LOS"-query from the "Attack"-query. The LOS-query is
only enabled for skittish animals for now and entities without cmpAttack
don't try to set up an Attack-query anymore.
Differential Revision: D2824
Reviewed by: @bb.
This was SVN commit r23877.
Formation were reshaping in cases where they should not (such as when
the controller is waiting on members).
This made them look very odd for some orders.
This also cleans up held positions for formations somewhat.
Also:
- ed54ad3486 fixed units not facing correctly after a formation-walk.
The fix is correct, but we can actually make it slightly more
self-contained by moving everything in `leave`. Also clarify comments.
- This fixes some very broken code in 4ca448a686 in
FORMATIONMEMBER.WALKING.MovementUpdate. It never errored because
formation controllers weren't moved out of the world before.
Reviewed By: Angen
Fixes#5443
Differential Revision: https://code.wildfiregames.com/D2763
This was SVN commit r23806.
Formation controllers were not always waiting on their members correctly
because the "finishedOrder" check was being reset in the wrong place.
This happened particularly with queued orders.
This merges the "finishedOrder" and the "InPosition" logic.
Reported by: elexis
Based on a patch by: Freagarach
Tested by: Freagarach
Reviewed By: Angen
Fixes#3274
Differential Revision: https://code.wildfiregames.com/D2702
This was SVN commit r23744.
This lets unitAI FSM states correctly handle target entity renaming by
processing a message when that happens. The default behaviour is to
leave-reenter the state, which re-runs sanity checks and optionally
picks a better behaviour.
UnitMotion is still not made aware of entity renaming, as the
leave-enter makes it irrelevant in practice. It still may be a good idea
to implement that someday.
Fixes the concern raised at de1bb8a766.
Fixes#5584
Comments by: bb, Freagarach
Tested by: Freagarach
Reported by: minohaka, bb, Freagarach, gameboy (error in the original
commit)
Differential Revision: https://code.wildfiregames.com/D2735
This was SVN commit r23742.
Player-testing has revealed QA issues, so reverting these for now.
Differential Revision: https://code.wildfiregames.com/D2773
This was SVN commit r23714.
This addresses two related issues:
- Units visibly garrisoned on gates keep the gate open.
- Units visibly garrisoned on entities keep their pathfinding blocker
flags.
Remove the block-movement flag from visibly garrisoned entities.
Keep a list of entities that cannot move and thus should not count
towards gate-opening logic.
Packing logic is kept separate: it is more related to entities having
'alternate forms' with different capabilities than being currently
incapable of moving.
Based on work by temple
Comments by: Freagarach
Tested by: Nescio
Fixes#2679Fixes#5151
Differential Revision: https://code.wildfiregames.com/D1418
This was SVN commit r23710.
This lets sunit AI FSM states correctly handle target entity renaming by
processing a message when that happens. The default behaviour is to
leave-reenter the state, which re-runs sanity checks and optionally
picks a better behaviour.
UnitMotion is still not made aware of entity renaming, as the
leave-enter makes it irrelevant in practice. It still may be a good idea
to implement that someday.
Fixes the concern raised at de1bb8a766.
Fixes#5584
Comments by: bb, Freagarach
Reported by: minohaka, bb, Freagarach
Differential Revision: https://code.wildfiregames.com/D2735
This was SVN commit r23708.
Do not create range query with no enemies as that triggers warning in
range manager.
This situation occurs when player has no enemies so empty list is
returned.
Fixing CCmpRangeManager: No owners in query for entity 0 warning
refs 38b2e37a61
Differential Revision: https://code.wildfiregames.com/D2601Fixes: #5666
Reviewed by: @Freagarach
This was SVN commit r23467.
After formation member ends walking, he tries to face target point.
However that eliminates rotation set by SetInPosition from formation
component. Partly fixed in 9d0b4db973 with setting correct rotation in
idle state, but one could still notice that there is glitch when unit
does quick turn to target point and then back. However that solution
would be still required if logic in SetInPosition would not be changed
to always set correct rotation. Another alternative would be to unset
unit at position with every walking order but that would have the same
effect and this is just more performance friendly to not splice member
from position every time.
Notice that information from inPosition is currently not used, so that
change in it is not braking anything.
This was SVN commit r23346.
This moves most of what was in the Damage system component to a helper,
and renames that component DelayedDamage.
It also introduces a new global script with all possible attack effects.
Comments Taken From: Freagarach, Stan, bb
Differential Revision: https://code.wildfiregames.com/D2092
This was SVN commit r22754.
945d1ba2e6 broke formation regression tests because there now needs to
be a timer call after the units become idle for behaviour to trigger.
Differential Revision: https://code.wildfiregames.com/D2077
This was SVN commit r22477.
"MoveStarted" messages were sent by UnitMotion when the unit started
moving (sort of) or failed to do so. This was used by formations and
guarding but was not really necessary as this can be done in "enter" or
in a timer.
Differential Revision: https://code.wildfiregames.com/D1885
This was SVN commit r22350.
These functions were placed in UnitMotion, which had nothing to do with
range checks and made them available only to moving entities for no
particular reason.
This patch also adds support for square-square range checks and
shape-shape distance checks.
Modified from a patch by bb on top of work from wraitii.
Differential Revision: https://code.wildfiregames.com/D981
This was SVN commit r22345.
This also moves the actual "moving" code to states instead of orders,
making states more self-contained and removing the change of errors when
cleaning up a state.
Differential Revision: https://code.wildfiregames.com/D1865
This was SVN commit r22313.
This:
- cleans up a code duplication and clarifies the intent.
- reorders things around for clarity
- improves variable names.
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D1840
This was SVN commit r22277.
This changes running speed into a running multiplier (of walk speed).
The advantage is that it simplifies code since you can setup a default
run multiplier at the template level and it'll work for all subsequent
templates, and technologies cannot forget to change it. It makes
specialised unit templates easier to maintain, too.
Formations have a 100 run multiplier which effectively sets their
maximal walking speed at 100
Reviewed By: bb, O2 JS Simulation
Differential Revision: https://code.wildfiregames.com/D438
This was SVN commit r22197.
This should help with simplifying the (un)placeable filtering again.
Reviewed By: fatherbushido
Differential Revision: https://code.wildfiregames.com/D933
This was SVN commit r20241.
This will allow us to use some linters that would otherwise crash on
this non-standard SpiderMonkey feature. Refs #4419.
Special thanks to elexis for thoroughly checking and testing all the
changes!
Reviewed By: leper, elexis
Differential Revision: https://code.wildfiregames.com/D40
This was SVN commit r19191.
This is in turn used by GetEnemies and the new GetAllies and
GetMutualAllies.
Use these in a few places as those are common queries.
Fixes#4161.
Reviewed by: fatherbushido
This was SVN commit r18649.