Skip to content

send customparams to unit scripts on unit creation#7961

Open
efrec wants to merge 19 commits into
beyond-all-reason:masterfrom
efrec:legion/anti-script-hardcoding
Open

send customparams to unit scripts on unit creation#7961
efrec wants to merge 19 commits into
beyond-all-reason:masterfrom
efrec:legion/anti-script-hardcoding

Conversation

@efrec

@efrec efrec commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Work done

Adds generic handling for unitdef and weapondef customparam values to be sent to unit scripts at unit creation.

Adds sweepfire customparams so these properties can go in unitdefs where they are visible as data.

Removed the turret turn speeds gadget. It was marked as unwanted in multiple places. However, turn rates are a prereq to satisfy the GDT ruling that turret turn speeds must compensate for unit speed. I ported that functionality to this code and updated the script headers that use it.

Addresses issue(s)

Legion has many values hardcoded into unit scripts to support some of its unique mechanics. Sweepfire heat rays are the main culprit. These hardcode both the beam duration and reload time in the unit script. We display inaccurate summary statistics for these units in the GUI (namely the Telchine which shows about 2.5x the DPS of a Razorback).

However, many other units in Armada and Cortex do the same without the justification of any unique mechanics. Many units have fixed reload times or restore times which means they cannot be modified through their def files alone.

Some considerations

We are still not scaling these values with XP. The veterancy rework can address this once it is up and running.

Related to #7531.

efrec added 2 commits June 15, 2026 12:08
These have years-old notes to remove them, and here we are today. I'll at least maintain what is not broken. There are also duplicate headers -- entirely, straightforwardly defeating the purpose of a header file. Very frustrating repository to look at or ever think about.
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Integration Test Results

15 tests   - 1   7 ✅  - 1   3s ⏱️ ±0s
 1 suites ±0   8 💤 ±0 
 1 files   ±0   0 ❌ ±0 

Results for commit 92177b9. ± Comparison against base commit 142ee93.

This pull request removes 1 test.
ai_stai_factory_rect.lua

♻️ This comment has been updated with latest results.

Comment thread luarules/gadgets/unit_script_attributes.lua Outdated
local lusEnv = Spring.UnitScript.GetScriptEnv(unitID)
return lusEnv
and function(unitID, funcName, ...)
callLUS(unitID, lusEnv[funcName], ...) -- Hold `env` in a temporary closure.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lus doesn't really need this. it can read customparams on its own

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would need to share the load/conversion code which I'd rather avoid. A common set of callins between COB and LUS seems like a net good, as well.

@efrec

efrec commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Sweepfire stats fetched and calced out in the gui:

image image image

@efrec efrec added the Legion Issue related to Legion label Jun 15, 2026
@efrec efrec marked this pull request as ready for review June 15, 2026 23:51
Comment thread units/ArmBots/T2/armfast.lua Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Legion Issue related to Legion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants