Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations related to script tasks #6596

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

lL1l1
Copy link
Contributor

@lL1l1 lL1l1 commented Dec 21, 2024

Description of the proposed changes

  • Annotates ScriptTasks and related code.
    • All task scripts
    • Scry ability (Eye of Rhianne's ability)
      • orders.lua's interaction with scripted abilities like Scry
      • The remote viewing unit class for Scry
  • Whitespace formatting

Testing done on the proposed changes

  • Used cc440f3 to play around with the tasks using the test task while figuring out the behavior.
  • Logging commandmode.lua and UserScriptCommand
  • Looked for and cleared out annotation warnings in the task scripts, RemoteViewing.lua, and XAB3301_script.lua
Clipboard command to view all UnitCommands from RULEUCC command caps
LOG('RULEUCC_Move = ', GetUnitCommandFromCommandCap('RULEUCC_Move'))
LOG('RULEUCC_Stop = ', GetUnitCommandFromCommandCap('RULEUCC_Stop'))
LOG('RULEUCC_Attack = ', GetUnitCommandFromCommandCap('RULEUCC_Attack'))
LOG('RULEUCC_Guard = ', GetUnitCommandFromCommandCap('RULEUCC_Guard'))
LOG('RULEUCC_Patrol = ', GetUnitCommandFromCommandCap('RULEUCC_Patrol'))
LOG('RULEUCC_RetaliateToggle = ', GetUnitCommandFromCommandCap('RULEUCC_RetaliateToggle'))
LOG('RULEUCC_Repair = ', GetUnitCommandFromCommandCap('RULEUCC_Repair'))
LOG('RULEUCC_Capture = ', GetUnitCommandFromCommandCap('RULEUCC_Capture'))
LOG('RULEUCC_Transport = ', GetUnitCommandFromCommandCap('RULEUCC_Transport'))
LOG('RULEUCC_CallTransport = ', GetUnitCommandFromCommandCap('RULEUCC_CallTransport'))
LOG('RULEUCC_Nuke = ', GetUnitCommandFromCommandCap('RULEUCC_Nuke'))
LOG('RULEUCC_Tactical = ', GetUnitCommandFromCommandCap('RULEUCC_Tactical'))
LOG('RULEUCC_Teleport = ', GetUnitCommandFromCommandCap('RULEUCC_Teleport'))
LOG('RULEUCC_Ferry = ', GetUnitCommandFromCommandCap('RULEUCC_Ferry'))
LOG('RULEUCC_SiloBuildTactical = ', GetUnitCommandFromCommandCap('RULEUCC_SiloBuildTactical'))
LOG('RULEUCC_SiloBuildNuke = ', GetUnitCommandFromCommandCap('RULEUCC_SiloBuildNuke'))
LOG('RULEUCC_Sacrifice = ', GetUnitCommandFromCommandCap('RULEUCC_Sacrifice'))
LOG('RULEUCC_Pause = ', GetUnitCommandFromCommandCap('RULEUCC_Pause'))
LOG('RULEUCC_Overcharge = ', GetUnitCommandFromCommandCap('RULEUCC_Overcharge'))
LOG('RULEUCC_Dive = ', GetUnitCommandFromCommandCap('RULEUCC_Dive'))
LOG('RULEUCC_Reclaim = ', GetUnitCommandFromCommandCap('RULEUCC_Reclaim'))
LOG('RULEUCC_SpecialAction = ', GetUnitCommandFromCommandCap('RULEUCC_SpecialAction'))
LOG('RULEUCC_Dock = ', GetUnitCommandFromCommandCap('RULEUCC_Dock'))
LOG('RULEUCC_Script = ', GetUnitCommandFromCommandCap('RULEUCC_Script'))
LOG('RULEUCC_Invalid = ', GetUnitCommandFromCommandCap('RULEUCC_Invalid'))
LOG('RULEUTC_ShieldToggle = ', GetUnitCommandFromCommandCap('RULEUTC_ShieldToggle'))
LOG('RULEUTC_WeaponToggle = ', GetUnitCommandFromCommandCap('RULEUTC_WeaponToggle'))
LOG('RULEUTC_JammingToggle = ', GetUnitCommandFromCommandCap('RULEUTC_JammingToggle'))
LOG('RULEUTC_IntelToggle = ', GetUnitCommandFromCommandCap('RULEUTC_IntelToggle'))
LOG('RULEUTC_ProductionToggle = ', GetUnitCommandFromCommandCap('RULEUTC_ProductionToggle'))
LOG('RULEUTC_StealthToggle = ', GetUnitCommandFromCommandCap('RULEUTC_StealthToggle'))
LOG('RULEUTC_GenericToggle = ', GetUnitCommandFromCommandCap('RULEUTC_GenericToggle'))
LOG('RULEUTC_SpecialToggle = ', GetUnitCommandFromCommandCap('RULEUTC_SpecialToggle'))
LOG('RULEUTC_CloakToggle = ', GetUnitCommandFromCommandCap('RULEUTC_CloakToggle'))

Checklist

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version

@lL1l1 lL1l1 added area: sim Area that is affected by the Simulation of the Game area: ui Anything to do with the User Interface of the Game type: intellisense labels Dec 21, 2024
@lL1l1 lL1l1 added this to the Development I of 2025 milestone Dec 21, 2024
@lL1l1 lL1l1 marked this pull request as ready for review December 21, 2024 02:24
@@ -73,6 +73,7 @@ end
function debug.allocatedsize(obj)
end

--- Returns a cached table of all table allocations tracked between calls of `debug.trackallocations(true)` and `debug.trackallocations(false)`.
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is super interesting!

RULEUCC_Invalid = None
```]]
---@param rule EngineCommandCap
---@return string | "None"
Copy link
Member

Choose a reason for hiding this comment

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

You could turn this into a list of options instead of just a string.

Copy link
Member

@Garanas Garanas left a comment

Choose a reason for hiding this comment

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

Looks like some much-needed documentation on the available tasks. I strongly believe there's still a world to discover here for the FAForever project 😄 !

---| -3 # Abort: "kill all tasks on this thread". Not implemented, usage will cause the unit to be stuck on the command.
---| -4 # Delay: move task to end of this tick's task queue. There is no way to have multiple tasks per tick?
---| 0 # Repeat execution immediately.
---| 1+ # 1+: The task waits the given number of ticks. For example, the value `3` means the task waits for three ticks.
Copy link
Member

Choose a reason for hiding this comment

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

1+? Maybe +1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"1+" means "1 or more". Also are you referring to the 1+ in the type or in the comment? The + symbol in the type doesn't actually do anything with intellisense, it doesn't even show up in the tooltip, so that's why I repeated "1+" in the comment.

@@ -3,12 +3,17 @@ local TASKSTATUS = import("/lua/sim/scripttask.lua").TASKSTATUS
local GiveUnitsToPlayer = import("/lua/simutils.lua").GiveUnitsToPlayer
local SpawnPing = import("/lua/simping.lua").SpawnPing

local transferList = {}
local transferList = {}
Copy link
Member

Choose a reason for hiding this comment

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

There mustn't be global values like this in sim.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

Such tables tend to prevent from garbage collection entities that were already destroyed. Something like this really has to be weak or be defined within some other object like ai brain.

lua/system/utils.lua Outdated Show resolved Hide resolved
self.CommandData = commandData
end,

-- Called by the engine every tick. Function must return a value in TaskStatus
--- Called by the engine in an interval. Function must return a value in TaskStatus
Copy link
Member

Choose a reason for hiding this comment

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

Whether Function must return a value defined in TaskStatus or Function must return a value from TaskStatus.

Copy link
Member

Choose a reason for hiding this comment

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

Or simply Function must return TaskStatus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about "Called by the engine at an interval determined by the returned TaskStatus value"?
The required return value is obvious from the @return and every script task using it, so I omitted it and added info about how the interval is determined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sim Area that is affected by the Simulation of the Game area: ui Anything to do with the User Interface of the Game type: intellisense
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants