Commit graph

196 commits

Author SHA1 Message Date
Vantha
0168ad9cbe Support setting multiply and add to 0 in techs
Previously (only) setting `multiply` and/or `add` to zero in a tech
modification caused warnings saying the format wasn't recognised.
With this patch, those cases are now handled as one would expect.
2026-02-20 21:26:19 +01:00
Atrik
065ecdbdf8 Implement level class sorting for formations
Add support for multi-level priority sorting of entity classes
in formations.

fixes #7547

Change formation template's default sorting order
using multi-level sorting.

fixes #6873
2026-01-23 17:20:11 +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
wowgetoffyourcellphone
3592814aa8 Gendered Civilians
Adds a randomly male and female Civilian unit which replaces the old "Female Citizen" for each civ.
New actors, new portraits, some new body textures, but the same stats as the old Female Citizen.
Updates maps, technologies, skirmish templates, et al. including the Tutorials.

Co-Authored By: Itms
Reviewed By: Vantha
2025-09-02 10:23:44 +02: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
Stan
dc04f3f432
Fix autofixable eslint warnings for eqeqeq
Ref: #7812
Pull Request: #8129
2025-06-26 11:03:19 +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
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
f3ac9e9669
Fix eslint rule 'default-case'
Manual fixes needed for:
eslint --no-config-lookup --rule '"default-case": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-28 19:24:50 +02:00
Ralph Sennhauser
4e5cdc87b9
Fix eslint rule 'spaced-comment'
Manual fixes needed for:
eslint --no-config-lookup --rule '"spaced-comment": ["warn", "always"]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-17 12:08:47 +02:00
Ralph Sennhauser
40f1340e60
Fix eslint rule 'space-before-function-paren'
eslint --no-config-lookup --fix --rule '"space-before-function-paren": ["warn", "never"]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-13 15:21:57 +02:00
Ralph Sennhauser
0791504491
Fix eslint rule 'prefer-const' in globalscripts
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/globalscripts

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-06 14:16:42 +02:00
Ralph Sennhauser
bc5f42d4a4
Fix eslint rule 'no-else-return'
Use ternary expressions instead.

eslint--no-config-lookup --fix --rule '"no-else-return": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-04 22:34:54 +02:00
Ralph Sennhauser
3916fab66f
Fix eslint rule 'no-undef-init'
Manual fix needed, remove all assignments to undefined and rely on the
default state.

eslint --no-config-lookup --rule '""no-undef-init: 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-04 20:34:40 +02:00
Ralph Sennhauser
08a5f4405f
Fix eslint rule 'no-empty'
Manual fix needed, using 'noop' comment to silence warnings and convert
for loop to a probably more readable while loop.

eslint --no-config-lookup --rule '"no-empty": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-04 20:05:02 +02:00
Ralph Sennhauser
dc6544a6c4
Fix eslint rule 'operator-assignment'
eslint --no-config-lookup --fix --rule '"operator-assignment": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 19:02:10 +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
ddba1ceabd
Fix eslint rule 'no-extra-semi'
eslint --no-config-lookup --fix --rule '"no-extra-semi": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 11:18:16 +02:00
Ralph Sennhauser
24c47c81c7
Fix eslint rule 'no-multi-spaces'
eslint --no-config-lookup --fix --rule '"no-multi-spaces": ["warn", { "ignoreEOLComments": true, }]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 10:50:50 +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
Dunedan
f58dc9b485
Remove unnecessary executable bits
This removes the executable bits from files which aren't supposed to
have them.

Also removes shebangs for files which aren't supposed to be executable.
2024-08-26 07:46:34 +02:00
wraitii
cce7d02036 Bugfix & optimisations to ApplyModifiers
This functions is amongst the most called in JS, so it's important to
make it speedy.

- Bugfix: if 'originalValue' is falsy, the result was never cached. This
in particular affected the minRange of archers, which is 0. It's a large
optimisation on combatDemoHuge, but the effect elsewhere is less likely
to be noticeable.
- Don't go through the helper to get the player Entity ID, in this case
it's slower.
- Concat is slower than Flat() in this case according to my profiling.
- Some micro-optimisation by strict equality.

Differential Revision: https://code.wildfiregames.com/D5012
This was SVN commit r27696.
2023-06-14 07:27:06 +00:00
Freagarach
9bb9ff8b16 Add Requirements helper.
Allows more flexibility in e.g. the Identity requirements and unifies
the checking of requirements.
One can use the script at https://code.wildfiregames.com/P265 to fix
templates.

Differential revision: https://code.wildfiregames.com/D4514
Comments by: @elexis, @Stan
Fixes #6421

This was SVN commit r27245.
2022-11-24 11:20:11 +00:00
marder
a80ce526b7 [Fix] Patch globalscripts technology template helper after 8d80a2186e and the ProductionQueue split
Patch by @s0600204.

This lets all technologies show up correctly in-game and in the
structure tree again.

accepted by: @marder @Freagarach
Fixes: #6587

Differential Revision: https://code.wildfiregames.com/D4755
This was SVN commit r27042.
2022-08-10 21:49:15 +00:00
bb
2af020bab1 Generalize fromInitAttributes loop
Add deepCompare function to utilities to easy and reliably compare js
variables.

Comments By: Langbart, Stan, asterix
Differential Revision: D4521
This was SVN commit r26583.
2022-03-06 21:01:36 +00:00
Freagarach
3994105946 Fix checkrefs after ea72437739.
Noticed by checkrefs by @Stan.

Differential revision: https://code.wildfiregames.com/D4480
Reviewed by: @Stan
This was SVN commit r26317.
2022-02-08 05:55:01 +00:00
Freagarach
eaff28c448 Store possible formations for a civ in XML instead of the JSON.
The JSON was purely GUI at first, but has gotten some simulation content
over time. Not all of that was necessary/correct to do.
When the formations were added (58836c624a) there was only a generic
player.xml
(https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/simulation/templates/special/;11735)
and differentiation was added only later.
The formations in the XML is more logical and allows inheritance.

Differential revision: https://code.wildfiregames.com/D4466
Idea approved by: @wowgetoffyourcellphone
This was SVN commit r26299.
2022-02-05 06:39:53 +00:00
Freagarach
ea72437739 Move GenericName, History and Icon from the civ-JSON to cmpIdentity.
Since the players/civs already have cmpIdentity, use it.
This forces civs to have corresponding XML in the `special/players/`
folder.

Also moves the files from `special/player/` to `special/players/`
consistent with other folders. And moves the generic `player.xml` one
level up.

Differential revision: https://code.wildfiregames.com/D4473
Help and comments by: @Stan, @wraitii
This was SVN commit r26298.
2022-02-05 06:24:45 +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
0c4f59d0a7 Split tasks from ProductionQueue.
The task of the production queue should first and foremost be that; a
queue for production items.
Hence, the specifics of training/researching are delegated to specific
components.

As a side effect, this improves the test coverage and fixes:
- Resource not refunding when hitting the entity limit. Introduced in
b8758c8941.
- Autoqueue changing when unable to spawn. Introduced in 956b3f96db.

Modders can change their templates using
https://code.wildfiregames.com/P256.

Differential revision: https://code.wildfiregames.com/D4333
Fixes: #6363
Comments by: @Silier
Refs. #6364

This was SVN commit r26000.
2021-11-16 07:08:39 +00:00
bb
acc780bcbb Add accelerations in unit movement.
This helps preventing arrow dodging.

Differential Revision: D3200
Reviewed By: Freagarach
Comments By: wraitii, vladislav, Palaxin, Stan
refs: #5106

This was SVN commit r25953.
2021-10-09 21:31:11 +00:00
s0600204
184ed2fb55 Apply modifiers from civ/team bonus auras in Reference Suite
The Reference Suite (Structure Tree, Civ Info, Viewer) wasn't taking
into
account civilization- or team-bonus auras when calculating entity stats.

This wasn't really a problem (for Vanilla 0AD) prior to a18d97b047, as
civ-bonus auras don't exist in Vanilla 0AD, and our team-bonus auras
didn't
apply to the owning civ before that change. Now they do, the Suite needs
to
take them into consideration.


Differential Revision: https://code.wildfiregames.com/D4093
This was SVN commit r25751.
2021-06-08 23:35:44 +00:00
Freagarach
9450cfcbda Move custom JS data structures to globalscripts.
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.
2021-04-18 08:31:30 +00:00
Freagarach
b74ab54cf7 Fix translation of damage types.
Broken in d28a91b83d.
Due to not checking for `template_helpers` in the game's files.

Patch by: @nwtour
Differential revision: https://code.wildfiregames.com/D3850
This was SVN commit r25265.
2021-04-15 05:47:54 +00:00
Freagarach
e2f4ce0649 Add Upkeep component.
Adds a new component effectively handling negative resource trickles.
Prevents resources from going negative and provides an effect for not
being able to pay.
The effect chosen for 0 A.D. is having the entity not being
controllable.

Not used in the public mod itself, but it is in quite some mods.

Based on an idea of @Nescio
Differential revision: D1323
Comments by: @Angen, (@smiley,) @Stan
This was SVN commit r25191.
2021-04-04 06:52:20 +00:00
wraitii
e5b971c2bf Allow modifiers without "affects" list.
This allows modifiers without "affects", or with empty "affects" lists,
to do something.
This makes it possible to force a modifier on an entity without classes
(e.g. trees) or with unknown classes.

Accepted By: asterix
Differential Revision: https://code.wildfiregames.com/D3761
This was SVN commit r25157.
2021-03-29 08:10:08 +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
Freagarach
ea96e81098 Split treasures from ResourceSupply.
Removes some hardcoding and allows for easier modding of treasures.

Refs.: #5888
Differential revision: D3303
Comments by: @Imarok, @Nescio, @Stan, @wraitii
This was SVN commit r24989.
2021-03-03 07:47:38 +00:00
Freagarach
0e6cf11d86 Resupport more garrisoned slots per entity.
Basically removed in 3521c8f51e, now brought back :) (But split from the
population space.)

Differential revision: D2056
Comments by: @Angen, @Nescio, @Stan, @wraitii
This was SVN commit r24960.
2021-02-28 10:02:03 +00:00
Freagarach
f1de414a6d Fix sound not played when being attacked by non-capture attacks.
Wrong assumptions on reviewing 2627714c07 and 7f7a3edfae made it such
that non-capture attacks did not play a being-attacked sound anymore.
We only want a different sound when being captured.

Differential revision: D3408
Tested by: @Stan
This was SVN commit r24694.
2021-01-19 07:22:27 +00:00
wraitii
c7fac7ee88 Small fixes for status effects
Fixes the default name.
Remove comment that was invalid after 876b035336.
Deepfreeze data.

Reviewed By: Freagarach
Differential Revision: https://code.wildfiregames.com/D3306
This was SVN commit r24532.
2021-01-10 09:54:12 +00:00
Freagarach
7f7a3edfae Get attack effects from JSON.
Reads attack effects from JSON files to allow easier introduction (one
still needs to modify other components).

Differential revision: D2661
Comments by: @Angen, @bb, @Stan, @wraitii
This was SVN commit r24500.
2021-01-02 07:09:08 +00:00
s0600204
ababc796b4 Remove unneeded bonus info from {civ}.json files
This commit removes two things from the `{civ}.json files, for the
following
reasons:

1. The team-bonus information, as the only thing that was reading it
(the
   `civinfo` page) no longer does so.

2. Information about civ-bonuses that have been implemented via a single
   auto-researchable technology, as the `civinfo` page is now capable of
   displaying information from technology files and, in fact, now does
so.

This was SVN commit r24494.
2021-01-01 05:58:34 +00:00
s0600204
ad6263a5a6 Remove entity information from {civ}.json files
As of 190d6e7cf5, the `civinfo` page no longer reads information about
Heroes and Special Structures/Technologies from the `{civ}.json` files,
but
from relevant templates.

Nothing else uses the entity/tech descriptive information contained in
the
`{civ}.json` files, so we can safely remove it.

Note: The Team and Civilisation Bonus information contained within the
      `{civ}.json` files are not touched in this commit.

This was SVN commit r24493.
2021-01-01 02:58:21 +00:00
wraitii
59d0885d68 Allow picking a default formation for walk (and walk-like) orders.
This allows choosing a "default formation", which is activated
automatically for units given walk orders (and attack-walk etc.).
Conversely, units in formation that are given a gather/build/... order
are taken out of formation and given the order individually.
The default formation can be selected by right-clicking on any formation
icon.

This leverages formations for walking, where they are quite efficient
(in fact, perhaps too efficient), while circumventing issues with
various orders.

Choosing the "null formation" as the default formation de-activates the
behaviour entirely, and plays out exactly like SVN.

This makes it possible to queue a formation-order then a
noformation-order (i.e. walk then repair), though the behaviour isn't
very flexible.

For modders, it should be relatively easy to change the setup for each
order, and/or to force deactivating/activating formations in general.

Tested by: Freagarach, Angen
Refs #3479, #1791.
Makes #3478 mostly invalid.

Differential Revision: https://code.wildfiregames.com/D2764
This was SVN commit r24480.
2020-12-31 10:04:58 +00:00
Freagarach
a79a47effe Allow to limit unit count per match.
This allows to limit the number of times a specific template can be
constructed/trained/created during a match.

Part of:
https://wildfiregames.com/forum/index.php?/topic/27214-borg-expansion-pack-mod-implementation-in-0ad-alpha-24-release/
Refs.
https://wildfiregames.com/forum/topic/24682-champions-and-civilisations-balance-mod-for-a23/

Differential revision: D2411
Reviewed by: @wraitii
Comments by: @Angen, @Stan
This was SVN commit r24468.
2020-12-29 11:00:54 +00:00
wraitii
9fc6c3c897 Correctly serialize/deserialize user-defined JS objects.
Generalize component/AI serialization system to any user-defined JS
object. This includes Vector2D/3D, fixing an old issue.
As with components/AI, JS Objects may implement a Serialize/Deserialize
function to store custom data instead of the default, which attemps to
serialize all enumerable properties.

Fixes #4698

Differential Revision: https://code.wildfiregames.com/D2746
This was SVN commit r24462.
2020-12-27 17:18:13 +00:00
Freagarach
7f77cf2f3e Move PopulationBonus from cmpCost to new cmpPopulation.
Since PopBonus is not a cost.

Patch by: @lonehawk
Differential Revision: D2948
Comments by: @Angen, @Nescio, @wraitii
Closes #4081

This was SVN commit r24394.
2020-12-14 18:17:59 +00:00
Stan
bf85e4ac38 Allow boolean and u16 modifications for C++
Allow boolean modifications JavaScript
Allow territory influence weight, and root, to be changed via tech.


Differential Revision: https://code.wildfiregames.com/D3069
This was SVN commit r24373.
2020-12-11 14:07:48 +00:00
s0600204
f230988e0e Add globalscript helper function for Auras
Similar to those for templates and technologies.

This was SVN commit r24290.
2020-11-29 04:44:38 +00:00