Commit graph

61 commits

Author SHA1 Message Date
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
phosit
582541ea80 Enable eslint rule 'no-useless-assignment'
Enable rule 'no-useless-assignment' [1] and fix violations.

[1] https://eslint.org/docs/latest/rules/no-useless-assignment
2025-08-01 11:26:40 +02:00
Ralph Sennhauser
0ce889ca6d
Use stylistic for deprecated eslint rules
During the eslint 8 cycle the formatting rules were split out [1],
deprecating the corresponding rules in core.

This replaces all rules that where moved to @stylistic/eslint-plugin [2]
and accounts for the difference in the indenting rule behaviour.

To allow the pre-commit import hack to continue to work with the
stylisitc plugin for a recent nodejs version to be used.

[1] https://eslint.org/blog/2023/10/deprecating-formatting-rules/
[2] https://eslint.style/packages/default

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-10 21:23:23 +02:00
Ralph Sennhauser
8e71be511b
Fix eslint rule 'space-in-parens'
eslint--no-config-lookup --fix --rule '"space-in-parens": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-13 14:29:29 +02:00
Ralph Sennhauser
4c4f787c63
Fix eslint rule 'prefer-const' in components/[A-B]*
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/simulation/components/A* \
    binaries/data/mods/public/simulation/components/B* \

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-11 10:40:23 +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
1da93a6d2f
Fix eslint rule 'object-curly-spacing'
eslint --no-config-lookup --fix --rule '"object-curly-spacing": ["warn", "always"]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 17:17:35 +02:00
Ralph Sennhauser
fd0f7cc270
Fix eslint rule 'comma-spacing'
eslint --no-config-lookup --fix --rule '""comma-spacing: 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 15:12:53 +02:00
Ralph Sennhauser
b6df170303
Fix eslint indent rule
eslint --no-config-lookup --fix --rule 'indent:  ["warn", "tab", { "outerIIFEBody": 0, }]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 09:39:58 +02:00
real_tabasco_sauce
7c95b6700b Add non-random building AI
-lets building arrows target the closest unit by default.
-adds player control of building arrows.
-adds a tooltip to explain how to control arrows.
-Uses "F" for focus fire and concurrently use "F" for force-attack, since "C" is capture.
2024-12-21 22:48:01 +01: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
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
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
b3e3d1f715 Use a map for the weighted list.
Less object creations at addition time, more intuitive handling.

Differential revision: https://code.wildfiregames.com/D3854
Comments by: @Stan, @wraitii
This was SVN commit r25276.
2021-04-16 07:02:58 +00:00
Freagarach
21e866fcf0 Technically seperate Turrets from GarrisonHolder.
While they often look alike, their behaviour is totally different.
This split has some implications:
- There are now separate auras for garrisoning and turrets.
- Entities can now have both turret points and garrison slots,
independent of eachother.

In general previous behaviour is maintained as much as possible.

Differential revision: D3150
Comments by: @Nescio, @wraitii
Tested by: @v32itas
This was SVN commit r25123.
2021-03-26 10:18:30 +00:00
wraitii
93a352ad16 Fix UnitAI range queries - allow queries to ignore sizes - partial revert of d0fc8ff67d
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.
2021-01-23 18:57:46 +00:00
bb
686686f2a4 Make buildingAI's arrowcount more transparent
Reviewed By: Freagarach
Comments By: wraitii, Stan
Differential Revision: D3198
This was SVN commit r24408.
2020-12-17 19:55:22 +00:00
wraitii
3b81fff942 Fix BuildingAI error in FireArrows
Fixes d0fc8ff67d

Differential Revision: https://code.wildfiregames.com/D3159
This was SVN commit r24284.
2020-11-28 14:06:17 +00:00
wraitii
d0fc8ff67d Update range queries to account for entity size.
CCmpRangeManager queries do not take obstruction size into account,
meaning they return fewer entities than they should. This particularly
affects buildings with ranged attacks, gates, and a few other templates.

This is, unfortunately, a slight performance decrease.

Discovered following Angen's comment [[
https://code.wildfiregames.com/D2738#116269 | here ]].

Comments by: Angen
Reviewed By: bb
Refs #3381 (not marking it down as 'fixes' and I'm not entirely sure it
was the only moving part here).

Differential Revision: https://code.wildfiregames.com/D2759
This was SVN commit r24217.
2020-11-19 14:07:24 +00:00
Freagarach
215c503e30 Move the ability to hold a turret to a separate file.
The logic concerning visible garrison points (i.e. turrets) is moved
from `GarrisonHolder` to a separate file.
This is logical because garrisoned != turreted, so this allows for
turrets that cannot be garrisoned (refs. D1958).
Also references #3488.

Differential Revision: D2367
Reviewed by: @wraitii
This was SVN commit r23856.
2020-07-20 10:51:14 +00:00
Stan
423b3cbcaa Allow specific garrison points to receive only specific units, for instance catapults on ships, or having both visible garrison points for fortresses and garrisonning elephants.
Reviewed by: @Freagarach,
Comments by: @elexis, @Angen
Fixes #3488

This was SVN commit r23630.
2020-05-07 15:03:18 +00:00
wraitii
16b452cf91 Generalise Attack effects. All attacks, including death damage and splash, can deal any number of attack effects (damaging, capture, giving status effects.)
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.
2019-08-22 18:00:33 +00:00
bb
c72d2b6dc0 Allow attack and attack_impact sounds for multiple attacks
Add "melee", "ranged" etc. to the template tag name,
Allow and use specific sounds for slaughter,
Rearrange the templates a bit, and so add missing sounds.


Reviewed By: fatherbushido
Differential Revision: https://code.wildfiregames.com/D757
This was SVN commit r20367.
2017-10-28 16:52:37 +00:00
fatherbushido
11f90549c7 Add missing roundings for garrisoned arrows tooltips. Reviewed by elexis.
Differential Revision: https://code.wildfiregames.com/D470
This was SVN commit r19551.
2017-05-10 13:04:35 +00:00
elexis
08fbf223f6 Unify random integer and float helper functions of GUI, Simulation and AI.
Patch By: bb
Differential Revision: D121
Refs: #4326

Removes the Random.js simulation helper and randomFloat function of the
random map scripts library.
Adds randomIntInclusive and randomIntExclusive to make the calls more
readable and fix and prevent off-by-one mistakes.
Adds randBool and use it in an AI occurance. It will be used in many
places by the random map scripts.
Use the pickRandom function introduced in 3c56638e8b in more applicable
occurances.
Replace remaining occurances of Math.random() with the new functions to
easily test completeness.

Cleanup of the random map script functions will come in a separate
commit.

This was SVN commit r19270.
2017-03-03 21:13:10 +00:00
leper
fe8d096364 Add GetPlayersByDiplomacy to cmpPlayer.
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.
2016-08-27 15:28:02 +00:00
elexis
ebfd214a19 Return Infinity instead of undefined in BuildingAI.GetMaxArrowCount. Refs #3196, #3846 and 82fa9d8f5b.
Notice the previous check `if (count > this.GetMaxArrowCount())`
implicitly relied on
numerical comparisons returning false if one of the two arguments is
undefined.

This was SVN commit r17944.
2016-03-24 13:25:47 +00:00
sanderd17
82fa9d8f5b Fix counting issue with previous commit
This was SVN commit r17939.
2016-03-23 10:01:27 +00:00
sanderd17
63d276b73b Fix counting of arrows in buildings: don't remove entities twice from the garrisonholder. Fixes #3846
This was SVN commit r17938.
2016-03-23 09:04:02 +00:00
Itms
d84ad7799a Limit arrows on certain buildings and ships. Patch by sanderd17, fixes #3196.
Balancing by elexis, reverts fcf7344537 in favor of the new total arrow
limit.

This was SVN commit r17882.
2016-03-13 17:02:18 +00:00
elexis
b68654b52d Inlining this is not possible due to the closure.
This was SVN commit r17785.
2016-02-22 17:23:46 +00:00
elexis
94ccb153a6 BuildingAI style fixes, refs #3763.
Remove a duplicate targetUnits-, some useless length-checks and unneeded
comments.

This was SVN commit r17783.
2016-02-22 16:44:57 +00:00
leper
e4834e8a0d Some JS component cleanup.
This was SVN commit r17301.
2015-11-28 08:27:38 +00:00
leper
870237cce4 Do not create range queries in case we aren't at war with anyone. Fixes #3382.
This was SVN commit r16957.
2015-08-30 02:49:49 +00:00
sanderd17
604538a63a Fix issue with preferences in BuildingAI. Refs #1731
This was SVN commit r16580.
2015-04-26 08:21:43 +00:00
sanderd17
4d1dee171e Explicitely add the UnitAI target to the BuildingAI target list to circumvent the range mismatch. Refs #1731
This was SVN commit r16577.
2015-04-25 12:54:34 +00:00
sanderd17
8712ad835c Fix buildingAI in case of modifications (techs, auras, ownership changes, ...) + clean up the code a bit
This was SVN commit r16472.
2015-03-30 09:25:20 +00:00
Itms
1564a10120 Move back the computation of most of the visibilities from JS to engine, to improve performance.
Also fix the remaining TODO left by #958, as a use case of the scripted
Visibility component.

Refs #2913, #958.

This was SVN commit r16248.
2015-01-30 15:28:06 +00:00
Itms
f7e591c9f2 Hide changes to buildings in the fog-of-war.
To achieve this, mirage entities are created per player, to replace the
real entities when these ones fall into the fog-of-war. These mirage
entities are created on-the-fly, and destroyed when they get back in
sight.
This depends heavily on the VisibilityChanged message added in
2174eaaeee.

As a temporary adjustment, territories do not explore the map anymore
when their borders change. See #2709.

Fixes #599

This was SVN commit r15612.
2014-08-04 22:49:19 +00:00
leper
a96a333b47 Small cleanup.
This was SVN commit r14274.
2013-12-03 01:01:12 +00:00
sanderd17
f3968c0d4c fix some flaws in the preferred classes. Patch by Jammus, Fixes #1985
This was SVN commit r14011.
2013-10-16 19:08:01 +00:00
sanderd17
5f5eedc513 Rename technology related files, methods and messages so their names represent the shared data flow between technologies and auras (and maybe future components). Implement the C++ part of auras through these generalised files. Fixes #2154
This was SVN commit r14001.
2013-10-15 10:05:08 +00:00
sanderd17
87753bf3fd forgot to commit extra change for 508cc0d4c7
This was SVN commit r13824.
2013-09-11 18:59:51 +00:00
sanderd17
508cc0d4c7 Add preferred classes to BuildingAI. Patch by jammus. Fixes #1985
This was SVN commit r13823.
2013-09-11 17:50:49 +00:00
sanderd17
fe0ec1c720 fix coding style for buildingAI. Refs #2010
This was SVN commit r13671.
2013-08-16 12:17:18 +00:00
sanderd17
fd2245c53c Improved building AI. Refs #2010
This was SVN commit r13670.
2013-08-16 11:17:36 +00:00
alpha123
8c74df2acd Give an elevation advantage to ranged units. Patch by sanderd17. Fix #1960.
This was SVN commit r13626.
2013-08-03 19:20:20 +00:00
quantumstate
5caddcdd20 Make technology code cleaner with helper functions. Refs #1692.
This was SVN commit r13056.
2013-01-08 00:00:21 +00:00
leper
18b532a195 Remove current targets when changing ownership. Fixes #1794.
This was SVN commit r13014.
2012-12-23 20:03:00 +00:00
leper
a0e13d9625 Fix tests. BuildingAI now handles DiplomacyChanged messages.
This was SVN commit r12812.
2012-11-02 17:20:32 +00:00