diff --git a/.luadefs/eaw-functions-emmyluadoc.lua b/.luadefs/eaw-functions-emmyluadoc.lua new file mode 100644 index 0000000..d117559 --- /dev/null +++ b/.luadefs/eaw-functions-emmyluadoc.lua @@ -0,0 +1,1127 @@ +-- ------------------------------------------------------------------ +-- ------------------------------------------------------------------ +-- _____ _ _ _ _ +-- | ___| (_) | | | | | | +-- | |__ _ __ ___ _ __ _ _ __ ___ __ _| |_ | | | | __ _ _ __ +-- | __| '_ ` _ \| '_ \| | '__/ _ \ / _` | __| | |/\| |/ _` | '__| +-- | |__| | | | | | |_) | | | | __/ | (_| | |_ \ /\ / (_| | | +-- \____/_| |_| |_| .__/|_|_| \___| \__,_|\__| \/ \/ \__,_|_| +-- | | +-- |_| +-- _____ _ ______ +-- | ___| | | | _ \ +-- | |__ _ __ ___ _ __ ___ _ _| | _ _ __ _| | | |___ ___ +-- | __| '_ ` _ \| '_ ` _ \| | | | | | | | |/ _` | | | / _ \ / __| +-- | |__| | | | | | | | | | | |_| | |___| |_| | (_| | |/ / (_) | (__ +-- \____/_| |_| |_|_| |_| |_|\__, \_____/\__,_|\__,_|___/ \___/ \___| +-- __/ | +-- |___/ +-- ------------------------------------------------------------------ +-- ------------------------------------------------------------------ +---@diagnostic disable +-- ------------------------------------------------------------------ +-- Finders as sorted by SGMG documentation +-- ------------------------------------------------------------------ +---@public +---Finds the game object that currently attacks the given game object and deals the highest damage. +---@param gameObject GameObject|TaskForce +---@return GameObject +function FindDeadlyEnemy(gameObject) end + +---@public +---@param faction_name string The name of the faction +---@return PlayerObject|nil +---Returns the PlayerObject matching the given faction name +function Find_Player(faction_name) end + +---@public +---@param type_name string The type name +---@return GameObjectType|nil +---Returns the GameObjectType matching the given type name +function Find_Object_Type(type_name) end + +---@public +---Literally finds all objects of this type. That may include projectiles or other unexpected objects. Categories can be piped together (e.g. `"Frigate | Capital"`) +---Filters by owner if filter is a `PlayerObject` or by `CategoryMask` if filter is a `string` +---@overload fun(propertyOrPlayer:string|PlayerObject) +---@overload fun(propertyOrPlayer:string, playerOrCategory:PlayerObject) +---@overload fun(propertyOrPlayer:PlayerObject, playerOrCategory:string) +---@param propertyOrPlayer string|PlayerObject A property flag if used with a single parameter or with a player wrapper as second parameter +---@param playerOrCategory PlayerObject|string|nil A player wrapper if the first parameter is a property flag, otherwise a category mask +---@return table +function Find_All_Objects_Of_Type(propertyOrPlayer, playerOrCategory) end + +---@public +--- Returns the first object of the given type. Possibly finds objects in reverse spawn order. +---@param typeName string A type name as specified in the XML code +---@return GameObject|nil +function Find_First_Object(typeName) end + +---@public +---@param hint string The hint +---@return GameObject|nil +---Returns the GameObject with the given hint. Hints can be set in the map editor. +function Find_Hint(hint) end + +---@public +---@param hint string The object hint as set in the map editor. +---@return GameObject[] +function Find_All_Objects_With_Hint(hint) end + +---@public +--- Returns the nearest object that has the given properties. May return nil. The two argument version takes as second parameter an object type name. The four argument version takes as second parameter a property flag string. The `isFriendly`parameter filters for friendlies or enemies, respectively. +---@overload fun(gameObject:GameObject|TaskForce, typeNameOrProperty:string) +---@overload fun(gameObject:GameObject|TaskForce, player:PlayerObject, isFriendly:boolean) +---@overload fun(gameObject:GameObject|TaskForce, typeNameOrProperty:string, player:PlayerObject, isFriendly:boolean) +---@param gameObject GameObject|TaskForce +---@param typeNameOrProperty string +---@param player PlayerObject +---@param isFriendly boolean +---@return GameObject +function Find_Nearest(gameObject, typeNameOrProperty, player, isFriendly) end + +---@public +---@param gameObject GameObject|TaskForce +---@param spaceFieldType string Can be "Asteroid", "Nebula" or "Ion_Storm". +---@return GameObject +function Find_Nearest_Space_Field(gameObject, spaceFieldType) end + +---@public +--- Returns position and combined threat of units (from the unit list) in range of the position. +---@param unitList table +---@param distance number +---@return Position +function Find_Best_Local_Threat_Center(unitList, distance) end + +---@public +---@param gameObject GameObject +---@param player PlayerObject +---@return Position +function Get_Most_Defended_Position(gameObject, player) end + +---@public +---Returns a position outside the range of the object that is given as first parameter. +---@param enemyObject GameObject The object whose weapon range is considered +---@param gameObject GameObject|TaskForce The object or task force looking to flee outside the range of the first object. +---@return Position +function Project_By_Unit_Range(enemyObject, gameObject) end + +---@public +--- GC only. Only for AI players. Returns a list of planet objects. +---@param player PlayerObject +---@param startingPlanet PlanetObject +---@param destinationPlanet PlanetObject +---@return PlanetObject[] +function Find_Path(player, startingPlanet, destinationPlanet) end + +---@type table|fun(planetName:string):PlanetObject +---@public +---Can be called directly with a planet name or can be indexed to call the function `Get_All_Planets`. +---@param planetName string +---@return PlanetObject +FindPlanet = {} +---@public +--- Returns all planets in the current GC game. +---@return PlanetObject[] +function FindPlanet.Get_All_Planets() end + +-- ------------------------------------------------------------------ +-- ------------------------ Spawn Functions ------------------------ +-- ------------------------------------------------------------------ + +---@public +---Spawns a unit and returns a table containing only the unit. Respects collision. If something blocks the spawn, the unit will be spawned as close as possible to the given position. +---@param unit_type GameObjectType The type of the unit +---@param location PlanetObject|GameObject|Position The location the unit is supposed to spawn at +---@param owner PlayerObject The owner of the unit +---@return GameObject[] +function Spawn_Unit(unit_type, location, owner) end + +---@public +---Spawns a unit with Hyperspace/landing Transport animation. +---@param object_type GameObjectType The GameObjectType of the unit to spawn +---@param location PlanetObject|GameObject|Position|nil The location the unit is supposed to spawn at. If nil, adds unit to reinforcement pool +---@param allow_ai_usage boolean Determines whether the AI is allowed to control the unit +---@param ignore_reinforcement_rules boolean Ignores reinforcement rules when set to true +---@return CommandBlock +---Returns a CommandBlock with a table containing the spawned unit +function Reinforce_Unit(object_type, location, player, allow_ai_usage, + ignore_reinforcement_rules) +end + +---@public +--- Spawns an object without regard for collision. +---@param object_type GameObjectType|string Object type or type xml name +---@param position Position A game object is also possible but can cause script crashes +---@param player PlayerObject +---@return GameObject The spawned object +function Create_Generic_Object(object_type, position, player) end + +---@public +--- Spawns a unit from the reinforcement pool without hyperspace animation while respecting collision. Returns a list containing the spawned object. If the required unit is not in the reinforcement pool, it does nothing. The unit faces toward the center of the map. +---@param object_type GameObjectType +---@param position Position|GameObject +---@param player PlayerObject +---@return GameObject[] +function Spawn_From_Reinforcement_Pool(object_type, position, player) end + +---@public +--- Space only. Spawns a ground to space weapon for the given player and returns it. Can be fired using `Fire_Special_Weapon` but is not available to the player. +---@param type_name string +---@param player PlayerObject +---@return GameObject The spawned weapon +function Spawn_Special_Weapon(type_name, player) end + +-- ----------------------------------------------------------- +-- ------------------------ Game time ------------------------ +-- ----------------------------------------------------------- + +--- Returns game time of the current game mode in seconds if called. Can be indexed for additional functions. +--- +---@type fun():number +---@public +---@return number +GetCurrentTime = {} + +---@public +--- The current frame +---@return number +function GetCurrentTime.Frame() end + +---@public +---@return number +function GetCurrentTime.Galactic_Time() end + +-- --------------------------------------------------------------- +-- ------------------------ Randomization ------------------------ +-- --------------------------------------------------------------- + +--- Returns a random integer between the given integers when called (uses game time as seed). +--- Can be indexed to access further functions. +--- +---@type fun(lower:number, upper:number):number +---@public +---@param lower number +---@param upper number +---@return number +GameRandom = {} + +---@public +--- Returns a random float between the given bounds or between zero and one if no bounds are given. +---@overload fun():number +---@param lower number +---@param upper number +---@return number +function GameRandom.Get_Float(lower, upper) end + +---@public +--- Returns a random integer within the given bounds (uses real time or some other game independent value as seed). +---@param lower number +---@param upper number +---@return number +function GameRandom.Free_Random(lower, upper) end + +-- ----------------------------------------------------------------------- +-- ------------------------ Camera and Cinematics ------------------------ +-- ----------------------------------------------------------------------- + +---@public +--- Teleports all units of the given player capable of retreating into retreat position and starts the retreat. +--- The actual hyperspace jump is executed only after the given delay. This neither starts a countdown nor does it end the battle. +---@param playerID number +---@param delay number +function Start_Cinematic_Space_Retreat(playerID, delay) end + +---@public +--- Ends the automatic cinematic camera. +function End_Cinematic_Mode() end + +---@public +--- Starts the automatic cinematic camera. +function Start_Cinematic_Mode() end + +---@public +--- Used in campaign openings to have a cinematic space scene when a ground map is loaded. +---@param on boolean +function Set_Cinematic_Environment(on) end + +---@public +--- Used in campaign openings to have a cinematic space scene when a ground map is loaded. +---@param object GameObject +function Promote_To_Space_Cinematic_Layer(object) end + +---@public +---@param type_name string +---@param player_id number +---@param transport_pos GameObject|Position +---@param zangle number +---@param phase_mode number Landing = 1, Unloading = 2, Leaving = 3 +---@param anim_delta number +---@param idle_time number +---@param persist number +---@param hint any Unknown +---@return GameObject The spawned transport +function Create_Cinematic_Transport(type_name, player_id, transport_pos, zangle, + phase_mode, anim_delta, idle_time, persist, + hint) +end + +---@public +--- Zooms the cinematic camera in or out. +---@param transition_time number The time that the transition to the zoomed state takes +---@param magnification number Greater than 1 zooms out, less than 1 zooms in +function Cinematic_Zoom(transition_time, magnification) end + +---@public +--- Transition from the cinematic camera back to the tactical view. +---@param time number +function Transition_To_Tactical_Camera(time) end + +---@public +--- Transition the camera position to a new position. The position new is determined as an offset from some reference position. +---@param position GameObject|Position A reference position for the coordinate parameters +---@param transition_time number +---@param x_offset number Offset from the given position in x direction, or the distance to the given position depending on the following parameter +---@param y_offset number Offset from the given position in y direction, or pitch depending on the following parameter +---@param z_offset number Offset from the given position in y direction, or yaw depending on the following parameter +---@param euler_angles number Sets the previous parameters to cartesian coordinates (0), or spherical coordinates (1) +---@param attach_object GameObject|number A game object to attach the camera to. The camera will move with the object. Set to 0 to use no object +---@param use_object_orientation number Sets orientation of the used coordinate system to default (0) as seen in the map editor or to the orientation of the given object +---@param cinematic_animation number Play the given objects cinematic animation (1) or not (0) +function Transition_Cinematic_Camera_Key(position, transition_time, x_offset, + y_offset, z_offset, euler_angles, + attach_object, use_object_orientation, + cinematic_animation) +end + +---@public +--- Set the camera position. The position is determined as an offset from some reference position. +---@param position GameObject|Position A reference position for the coordinate parameters +---@param x_offset number Offset from the given position in x direction, or the distance to the given position depending on the following parameter +---@param y_offset number Offset from the given position in y direction, or pitch depending on the following parameter +---@param z_offset number Offset from the given position in y direction, or yaw depending on the following parameter +---@param euler_angles number Sets the previous parameters to cartesian coordinates (0), or spherical coordinates (1) +---@param attach_object GameObject|number A game object to attach the camera to. The camera will move with the object. Set to 0 to use no object +---@param use_object_orientation number Sets orientation of the used coordinate system to default (0) as seen in the map editor or to the orientation of the given object +---@param cinematic_animation number Play the given objects cinematic animation (1) or not (0) +function Set_Cinematic_Camera_Key(position, x_offset, y_offset, z_offset, + euler_angles, attach_object, + use_object_orientation, cinematic_animation) +end + +---@public +--- Transition the camera target to a new position. The new position is determined as an offset from some reference position. +---@param position GameObject|Position A reference position for the coordinate parameters +---@param transition_time number +---@param x_offset number Offset from the given position in x direction, or the distance to the given position depending on the following parameter +---@param y_offset number Offset from the given position in y direction, or pitch depending on the following parameter +---@param z_offset number Offset from the given position in y direction, or yaw depending on the following parameter +---@param euler_angles number Sets the previous parameters to cartesian coordinates (0), or spherical coordinates (1) +---@param attach_object GameObject|number A game object to attach the camera to. The camera will move with the object. Set to 0 to use no object +---@param use_object_orientation number Sets orientation of the used coordinate system to default (0) as seen in the map editor or to the orientation of the given object +---@param cinematic_animation number Play the given objects cinematic animation (1) or not (0) +function Transition_Cinematic_Target_Key(position, transition_time, x_offset, + y_offset, z_offset, euler_angles, + attach_object, use_object_orientation, + cinematic_animation) +end + +---@public +--- Set the camera target. The target position is determined as an offset from some reference position. +---@param position GameObject|Position A reference position for the coordinate parameters +---@param x_offset number Offset from the given position in x direction, or the distance to the given position depending on the following parameter +---@param y_offset number Offset from the given position in y direction, or pitch depending on the following parameter +---@param z_offset number Offset from the given position in y direction, or yaw depending on the following parameter +---@param euler_angles number Sets the previous parameters to cartesian coordinates (0), or spherical coordinates (1) +---@param attach_object GameObject|number A game object to attach the camera to. The camera will move with the object. Set to 0 to use no object +---@param use_object_orientation number Sets orientation of the used coordinate system to default (0) as seen in the map editor or to the orientation of the given object +---@param cinematic_animation number Play the given objects cinematic animation (1) or not (0) +--- Set a target position for the camera to point at. If W is given, the camera will follow its movements. Without W the parameters R and S(?) won't work. If R is 1, the function uses W's coordinate system. +function Set_Cinematic_Target_Key(position, x_offset, y_offset, z_offset, + euler_angles, attach_object, + use_object_orientation, cinematic_animation) +end + +---@public +--- End the cinematic camera and enable the command bar again. +function End_Cinematic_Camera() end + +---@public +--- Start the cinematic camera disabling the command bar. +---@param unknown boolean Default is true +function Start_Cinematic_Camera(unknown) end + +---@public +--- Point the camera to the given position. Can be used during camera sequences but only affects the tactical camera. +---@param position GameObject|Position +function Point_Camera_At(position) end + +---@public +--- Rotate the camera to the given angle. Takes the shortest direction. Can be used during camera sequences, but +--- only affects the tactical camera. +---@param z_angle number The angle around the z axis giving the new orientation +---@param transition_time number The duration of the transition +function Rotate_Camera_To(z_angle, transition_time) end + +---@public +--- Rotates the camera around the z axis by the given amount of degrees. The sign of the angle determines the direction of the rotation. The rotation takes the given amount of time. +---@param z_angle number +---@param transition_time number +function Rotate_Camera_By(z_angle, transition_time) end + +---@public +--- Zoom in the tactical camera either immediately or with a short transition. +---@param zoom number Float between 0 (zoomed in) and 1 (zoomed out) +---@param immediate number Set the zoom immediately (1) or use a short transition (0) +function Zoom_Camera(zoom, immediate) end + +---@public +--- Function and parameters unknown. +function Camera_To_Follow(...) end + +---@public +--- Scroll the tactical camera to the given position. +---@param position GameObject|Position +function Scroll_Camera_To(position) end + +---@public +--- Fade screen into blackness. +---@param time number +function Fade_Screen_Out(time) end + +---@public +--- Fade screen back in from blackness +---@param time number +function Fade_Screen_In(time) end + +---@public +--- Turn off blackness from fade +function Fade_Off() end + +---@public +--- Make screen black immediately +function Fade_On() end + +---@public +--- Move black bars at the top and bottom out of the screen +---@param time number +function Letter_Box_Out(time) end + +---@public +--- Move black bars at the top and bottom into the screen +---@param time number +function Letter_Box_In(time) end + +---@public +--- Get rid of black bars immediately +function Letter_Box_Off() end + +---@public +--- Show black bars immediately +function Letter_Box_On() end + +---@public +--- Hides and disables all units not marked by In_End_Cinematic. Ignores space stations and structures. +function Do_End_Cinematic_Cleanup() end + +---@public +--- Pause/unpause weather audio. +---@param pause boolean +function Weather_Audio_Pause(pause) end + +---@public +---@param allow boolean +function Allow_Localized_SFX(allow) end + +---@type SFXManagerClass +SFXManager = {} + +---@public +---@param allow boolean +function SFXManager.Allow_Ambient_VO(allow) end + +---@public +---@param allow boolean +function SFXManager.Allow_Enemy_Sighted_VO(allow) end + +---@public +---@param allow boolean +function SFXManager.Allow_HUD_VO(allow) end + +---@public +--- Spelling mistake! +---@param allow boolean +function SFXManager.Allow_Unit_Reponse_VO(allow) end + +---@public +---@param allow boolean +function SFXManager.Allow_Localized_SFXEvents(allow) end + +---@public +--- Removes screen texts +function Remove_All_Text() end + +---@public +function Stop_All_Speech() end + +---@public +function Resume_Mode_Based_Music() end + +---@public +function Stop_All_Music() end + +---@public +--- Plays a music event defined in MusicEvents.xml +---@param music_event string +function Play_Music(music_event) end + +---@public +function Stop_Bink_Movie() end + +---@public +--- Plays a movie defined in Movies.xml +---@param movie_name string +function Play_Bink_Movie(movie_name) end + +---@public +---@param environment number Integer +function Set_New_Environment(environment) end + +---@public +--- Turn on weather effects +function Force_Weather() end + +---@public +---@param enable boolean +function Enable_Distance_Fog(enable) end + +---@public +---@param enable boolean +function Enable_Fog(enable) end + +---@public +--- Plays a lightning effect between the given positions for a time. +---@param effect string +---@param position1 Position|GameObject +---@param position2 Position|GameObject +---@return CommandBlock +function Play_Lightning_Effect(effect, position1, position2) end + +-- ------------------------------------------------------------------------- +-- ------------------------ Miscellaneous Functions ------------------------ +-- ------------------------------------------------------------------------- + +--- Used to run event handlers like `Default_Space_Conflict_Begin`. Returns an event handler function to be called or nil. +--- +---@type function|table +---@public +---@return function|nil +GetEvent = {} + +---@public +--- Returns a list with parameters for the function call returned by GetEvent() +---@return table +function GetEvent.Params() end + +---@public +--- Clear out any thread events +function GetEvent.Reset() end + +---@public +--- Returns the call stacks for all threads of this lua script. +---@return string +function DumpCallStack() end + +---@public +--- Seems to be equivalent to Thread.Get_Current_ID() +---@return number The current thread ID, an integer +function GetThreadID() end + +---@public +--- Prints to _LogFile.txt. Contains a spelling mistake. +---@param out_string string +function _OuputDebug(out_string) end + +---@public +--- Trigger a message popup window +---@param out_string string +function _MessagePopup(out_string) end + +---@public +--- Print to the given file. +---@param file_name string Just a filename, no path +---@param out_string string +function _CustomScriptMessage(file_name, out_string) end + +---@public +--- Prints to the AILog if it is enabled +---@param out_string string +function _ScriptMessage(out_string) end + +---@public +--- Sets a flag for the engine to terminate the script. The script will not be killed immediately, only after the next yield. +function _ScriptExit() end + +---@public +---@param string1 string +---@param string2 string +---@return boolean +function StringCompare(string1, string2) end + +---@public +--- Is this a multiplayer game? +---@return boolean +function Is_Multiplayer_Mode() end + +---@public +--- Returns "Land", "Space" or "Galactic" +---@return string +function Get_Game_Mode() end + +---@public +--- True for GC games +---@return boolean +function Is_Campaign_Game() end + +---@public +--- (Un)Lock all player controls +---@param lock number Integer to denote true(1) or false(0) +function Lock_Controls(lock) end + +---@public +--- Disable or enable all AIs +---@param suspend number Integer to denote true(1) or false(0) +function Suspend_AI(suspend) end + +---@public +--- Stops fast forward +function Cancel_Fast_Forward() end + +---@public +--- In tactical missions when reward parameter 9 of LINK_TACTICAL is set to 2, this will trigger the arrival of the attacking fleet. Should be called before the player is given control. +function Resume_Hyperspace_In() end + +---@public +--- Displays the text entry as a droid advisor hint +---@param text_string string Text identifier from dat file +function Game_Message(text_string) end + +---@public +--- For info_section == true the objective is added under the heading "Battle Information", otherwise it is added under the heading "Mission Objectives" +---@param text_string string Text identifier from dat file +---@param info_section boolean Add objective as "Battle Information" or as "Mission Objective" +function Add_Objective(text_string, info_section) end + +---@public +---@param identifier string +function Remove_Planet_Highlight(identifier) end + +---@public +---@param planet GameObject +---@param identifier string +function Add_Planet_Highlight(planet, identifier) end + +---@public +--- Removes the radar blip identified by the given string. +---@param identifier string +function Remove_Radar_Blip(identifier) end + +---@public +--- Add a radar blip on the given object with an identifier for removal. +---@param game_object GameObject +---@param identifier string +function Add_Radar_Blip(game_object, identifier) end + +---@public +---@param object GameObject +---@param hide number +---@param sub_object_name string +function Hide_Sub_Object(object, hide, sub_object_name) end + +---@public +---@param object GameObject +---@param hide number +function Hide_Object(object, hide) end + +---@public +--- Assembles the passed objects into a fleet and returns the fleet object. +---@param object_list GameObject[] +---@return GameObject +function Assemble_Fleet(object_list) end + +---@public +---@param position GameObject|Position +---@return boolean +function Is_Point_In_Asteroid_Field(position) end + +---@public +---@param position GameObject|Position +---@return boolean +function Is_Point_In_Ion_Storm(position) end + +---@public +---@param position GameObject|Position +---@return boolean +function Is_Point_In_Nebula(position) end + +---@public +--- Only valid in land mode. +---@overload fun(position1, position2):boolean +---@param position1 position +---@param position2 position +---@param player PlayerObject +---@param unknown boolean +---@return boolean +function Are_On_Opposite_Sides_Of_Shield(position1, position2, player, unknown) end + +---@public +--- Triggers the retry dialog that allows the player to restart the mission or quit. +function Activate_Retry_Dialog() end + +---@public +---@param planet PlanetObject +---@param level number +---@return CommandBlock +function WaitForStarbase(planet, level) end + +---@public +---@param planet PlanetObject +---@param level number +---@return CommandBlock +function WaitForGroundbase(planet, level) end + +---@public +---@param planet PlanetObject +---@return GameObjectType +function GetNextGroundbaseType(planet) end + +---@public +---@param planet PlanetObject +---@return GameObjectType +function GetNextStarbaseType(planet) end + +-- ---------------------------------------------------------------- +-- ------------------------ Multithreading ------------------------ +-- ---------------------------------------------------------------- + +---@public +--- Starts the given function in a new thread on the next frame with the given parameter and returns the thread ID (an integer). If the parameter is a table, its contents will be copied into a new list which is given to the function, the keys of the original table will be lost. +---@param function_name string +---@param parameter any +---@return number Thread ID +function Create_Thread(function_name, parameter) end + +Thread = {} + +---@public +--- Starts the given function in a new thread on the next frame with the given parameter and returns the thread ID (an integer). If the parameter is a table, its contents will be copied into a new list which is given to the function, the keys of the original table will be lost. +---@param function_name string +---@param parameter any +---@return number Thread ID +function Thread.Create(function_name, parameter) end + +---@public +--- Stops the thread with the given ID +---@param thread_id number +function Thread.Kill(thread_id) end + +---@public +function Thread.Kill_All() end + +---@public +---@param thread_id number +function Thread.Is_Thread_Active(thread_id) end + +---@public +--- Returns the name of the main function ("main" or the function name passed to Create_Thread). +---@param thread_id number +function Thread.Get_Name(thread_id) end + +---@public +--- Returns the ID of the current thread. +function Thread.Get_Current_ID() end + +-- -------------------------------------------------------- +-- ------------------------ Values ------------------------ +-- -------------------------------------------------------- + +GlobalValue = {} + +---@public +--- Get the value for the given name. +---@param name string +---@return any +function GlobalValue.Get(name) end + +---@public +--- Set a value for the given name. This value is accessible for all lua scripts and can be any variable type except userdata or thread. Can theoretically still be used to access userdata from other scripts, however the game throws an error in that case. +---@param name string +---@param value any +function GlobalValue.Set(name, value) end + +--- Get the value set for the given name. Can be indexed for further functions. +--- +---@type fun(name:string):any +---@public +---@param name string +---@return any +ThreadValue = {} + +---@public +--- Get the value set for the given name. +---@param name string +---@return any +function ThreadValue.Get(name) end + +---@public +--- Set a value for the given identifier. This value is specific to a thread as defined by Create_Thread. +---@param name string +---@param value any +function ThreadValue.Set(name, value) end + +---@public +--- Sets value for the given name to nil. +---@param name string +function ThreadValue.Reset(name) end + +-- ------------------------------------------------------------ +-- ------------------------ Fog of War ------------------------ +-- ------------------------------------------------------------ + +FogOfWar = {} + +---@public +--- Reveals the entire map for a player. Can be undone using the return value. +---@param player PlayerObject +---@return FowRevealClass +function FogOfWar.Reveal_All(player) end + +---@public +--- Reveals FoW in a radius aroung the given position for a player. The return value can be used to undo the reveal. +---@param player PlayerObject +---@param position Position +---@param radius number +---@return FowRevealClass +function FogOfWar.Reveal(player, position, radius) end + +---@public +--- Reveals FoW in a radius aroung the given position for a player for about 5 seconds. +---@param player PlayerObject +---@param position Position +---@param radius number +function FogOfWar.Temporary_Reveal(player, position, radius) end + +---@public +---@param disable boolean +function FogOfWar.Disable_Rendering(disable) end + +---@class FowRevealClass +local FowRevealClass = {} + +---@public +--- Undo a reveal. +function FowRevealClass.Undo_Reveal() end + +-- --------------------------------------------------------------------- +-- ------------------------ Story functionality ------------------------ +-- --------------------------------------------------------------------- + +---@public +--- Trigger a STORY_AI_NOTIFICATION event with the given identifier. +---@overload fun(identifier:string) +---@param identifier string +---@param unknownArgument GameObject +function Story_Event(identifier, unknownArgument) end + +---@public +--- Checks if corresponding reward type TRIGGER_AI has fired. +---@param player PlayerObject +---@param identifier string +---@param gameObject GameObject|nil +---@param bool boolean +---@return boolean +function Check_Story_Flag(player, identifier, gameObject, bool) end + +---@public +--- Returns the story file as StoryPlotWrapper object. The parameter is case sensitive. +---@param file_name string +---@return StoryPlotWrapper +function Get_Story_Plot(file_name) end + +---@class StoryPlotWrapper +local StoryPlotWrapper = {} + +---@public +--- Finds an Xml event from the plot and returns it. +---@param event_name string +---@return StoryEventWrapper +function StoryPlotWrapper.Get_Event(event_name) end + +---@public +--- Suspends the plot. +function StoryPlotWrapper.Suspend() end + +---@public +--- Activates the plot +function StoryPlotWrapper.Activate() end + +---@public +--- Resets all events of the plot. +function StoryPlotWrapper.Reset() end + +---@class StoryEventWrapper +local StoryEventWrapper = {} + +---@public +--- Sets the event's reward type. +---@param reward_type string +function StoryEventWrapper.Set_Reward_Type(reward_type) end + +---@public +--- Sets a reward parameter. The index starts counting at zero which corresponds to . +---@param parameter_index number +---@param value any +function StoryEventWrapper.Set_Reward_Parameter(parameter_index, value) end + +---@public +--- Sets an event parameter. The index starts counting at zero which corresponds to . +---@param parameter_index number +---@param value any +function StoryEventWrapper.Set_Event_Parameter(parameter_index, value) end + +---@public +--- Sets the dialog file. +---@param dialog_file_name string +function StoryEventWrapper.Set_Dialog(dialog_file_name) end + +---@public +function StoryEventWrapper.Clear_Dialog_Text() end + +---@public +--- The text will be formatted with any additional parameters given. +---@param text_identifier string +function StoryEventWrapper.Add_Dialog_Text(text_identifier, ...) end + +-- ---------------------------------------------------------------------- +-- ------------------------ AI related functions ------------------------ +-- ---------------------------------------------------------------------- + +---@class MarkupBlockStatus + +---@public +--- For tactical battle. Evaluates the perception at GC level. +---@param perception string +---@return number +function Evaluate_In_Galactic_Context(perception) end + +---@public +---@param player PlayerObject +---@param path PlanetObject[] +---@param number number +---@param unknown MarkupBlockStatus +---@return MarkupBlockStatus +function Apply_Markup(player, path, number, unknown) end + +---@public +---@param player PlayerObject +function Purge_Goals(player) end + +---@public +---@param player PlayerObject +---@param goal string +---@param target GameObject|PlanetObject +---@param desire_bonus number +---@param unknown number Possibly goal cycles? +---@return CommandBlock +function GiveDesireBonus(player, goal, target, desire_bonus, unknown) end + +---@public +--- Evaluates a perception and returns the result. Player and target are needed if and only if the perception uses Variable_Self and Variable_Target, respectively. +---@overload fun(perception:string):number +---@overload fun(perception:string, player:PlayerObject):number +---@param perception string +---@param player PlayerObject +---@param target GameObject|PlayerObject|AITarget +---@return number +function EvaluatePerception(perception, player, target) end + +---@public +--- Deprecated but may still work as intended +---@param player PlayerObject +---@param target GameObject|PlanetObject +---@param taskforce TaskForce +---@return GameObject|PlanetObject +function _FindStageArea(player, target, taskforce) end + +---@public +--- Deprecated but may still work as intended +---@param player PlayerObject +---@return any +function _ProduceObject(player, type, target) end + +--- Find a target for a taskforce. Tries to find the one that the perception returns the highest value on. +--- +---@type fun(taskforce:TaskForce, perception:string, goal_application_flag:string, probability:number, range:number):GameObject|PlanetObject|AITarget +---@public +---@overload fun(taskforce:TaskForce, perception:string, goal_application_flag:string, probability:number):GameObject|PlanetObject|AITarget +---@param taskforce TaskForce +---@param perception string +---@param goal_application_flag string +---@param probability number +---@param range number +---@return GameObject|PlanetObject|AITarget +FindTarget = {} + +---@public +--- Find a target for an aiplayer. Tries to find the one that the perception returns the highest value on. +---@overload fun(player:PlayerObject, perception:string, goal_application:string, reachability:string, probability:number):GameObject|PlanetObject|AITarget +---@overload fun(player:PlayerObject, perception:string, goal_application:string, reachability:string, probability:number, target:PlanetObject|GameObject|AITarget):GameObject|PlanetObject|AITarget +---@param player PlayerObject +---@param perception string +---@param goal_application string +---@param reachability string +---@param probability number +---@param target PlanetObject|GameObject|AITarget +---@param range number +---@return PlanetObject|GameObject +function FindTarget.Reachable_Target(player, perception, goal_application, + reachability, probability, target, range) +end + +---@public +---@param taskforce TaskForce +---@param list GameObject[]|PlanetObject[] +---@param perception string +---@return GameObject|PlanetObject +function FindTarget.Best_Of(taskforce, list, perception) end + +FreeStore = {} + +---@public +---@param game_object GameObject +---@return boolean +function FreeStore.Is_Object_On_Free_Store(game_object) end + +---@public +---@return number +function FreeStore.Get_Object_Count() end + +---@public +---@param game_object GameObject +---@return boolean +function FreeStore.Is_Unit_Safe(game_object) end + +---@public +---@param game_object GameObject +---@return boolean +function FreeStore.Is_Unit_In_Transit(game_object) end + +---@public +---@param game_object GameObject +---@param planet PlanetObject +function FreeStore.Move_Object(game_object, planet) end + +---@public +---@param s string The otput message as string. +---Prints a message into a message box. +---**WARNING**: Appears to be non-functional! +function _MessagePopup(s) end + +---@public +---@param s string The otput message as string. +---Prints a message to the `AILog.txt` if the command `aiff script` has been used in the ingame console. +function _ScriptMessage(s) end + +---@public +---@param s string The otput message as string. +---Prints a debug message directly to the `LogFile.txt`. Usually used as Error Log. +function _OuputDebug(s) end + +---@public +---@return string +---Dumps the current call stack of the LUA environment to a string. +function DumpCallStack() end + +-- ---------------------------------------------------------------------- +-- ------------------------ GUI related functions ----------------------- +-- ---------------------------------------------------------------------- + +---@public +---@param component string The name of the UI Component. +---@param is_visible boolean Whether the UI Component is visible. +---Sets the UI Component as visible / not visible. +function GUI_Component_Visibility(component, is_visible) end + +---@public +---@param component string The name of the UI Component. +---@param is_enabled boolean Whether the UI Component is enabled. +---Sets the UI Component as enabled / disabled. +function GUI_Component_Enable(component, is_enabled) end + +---@public +---@param component string The name of the UI Component. +---@param text string The Text ID or raw text to display. +---Sets the Text ID or raw text for the UI Component. +function GUI_Component_Text(component, text) end + +---@public +---@param component string The name of the UI Component. +---@param animation string The animation name. +---@param index integer The frame to begin at. +---@param loop boolean Whether to loop the animation. +---Plays the named animation for the UI Component. +function GUI_Component_Play_Anim(component, animation, index, loop) end + +---@public +---@param component string The name of the UI Component. +---Stops any animation for the UI Component. +function GUI_Component_Shop_Anim(component) end + +---@public +---@param component string The name of the UI Component. +---@param red number The red component. +---@param green number The green component. +---@param blue number The blue component. +---@param alpha number The alpha component. +---Sets the UI Component color. +function GUI_Component_Color(component, red, green, blue, alpha) end + +---@public +---@param component string The name of the UI Component. +---@param is_on boolean Whether the blinking should stay on. +---@param blink_off boolean Whether the blinking should stay off. +---@param restart boolean Whether to restart the blinking. +---Sets the UI Component blinking state. +function GUI_Component_Blink(component, is_on, blink_off, restart) end + +---@public +---@param component string The name of the UI Component. +---@param is_perpetual boolean Whether the flashing lasts until stopped. +---@param duration number The duration to flash in seconds. +---@param count integer The number of times to flash. +---Sets the UI Component flashing state. +function GUI_Component_Flash(component, is_perpetual, duration, count) end + +---@public +---@param component string The name of the UI Component. +---Stops flashing the UI Component. +function GUI_Component_Stop_Flash(component) end + +---@public +---@param component string The name of the UI Component. +---@param red number The red component. +---@param green number The green component. +---@param blue number The blue component. +---@param alpha number The alpha component. +---Sets the text color of the UI Component. +function GUI_Text_Color(component, red, green, blue, alpha) end + +---@public +---@param component string The name of the UI Component. +---@param icon string The name of the icon to display. +---@param red number The red component. +---@param green number The green component. +---@param blue number The blue component. +---@param alpha number The alpha component. +---Displays the icon in the UI Component. +function GUI_Button_Icon(component, icon, red, green, blue, alpha) end diff --git a/.luadefs/eaw-pglib-pgdebug-emmyluadoc.lua b/.luadefs/eaw-pglib-pgdebug-emmyluadoc.lua new file mode 100644 index 0000000..4777579 --- /dev/null +++ b/.luadefs/eaw-pglib-pgdebug-emmyluadoc.lua @@ -0,0 +1,60 @@ +-- ------------------------------------------------------------------ +-- ------------------------------------------------------------------ +-- _____ _ _ _ _ +-- | ___| (_) | | | | | | +-- | |__ _ __ ___ _ __ _ _ __ ___ __ _| |_ | | | | __ _ _ __ +-- | __| '_ ` _ \| '_ \| | '__/ _ \ / _` | __| | |/\| |/ _` | '__| +-- | |__| | | | | | |_) | | | | __/ | (_| | |_ \ /\ / (_| | | +-- \____/_| |_| |_| .__/|_|_| \___| \__,_|\__| \/ \/ \__,_|_| +-- | | +-- |_| +-- _____ _ ______ +-- | ___| | | | _ \ +-- | |__ _ __ ___ _ __ ___ _ _| | _ _ __ _| | | |___ ___ +-- | __| '_ ` _ \| '_ ` _ \| | | | | | | | |/ _` | | | / _ \ / __| +-- | |__| | | | | | | | | | | |_| | |___| |_| | (_| | |/ / (_) | (__ +-- \____/_| |_| |_|_| |_| |_|\__, \_____/\__,_|\__,_|___/ \___/ \___| +-- __/ | +-- |___/ +-- ------------------------------------------------------------------ +-- ------------------------------------------------------------------ +---@diagnostic disable +---Opens a message box that contains the handled event and its parameters as multi-line formatted string. +---**WARNING:** Appears to be non-functional. +---@param event any TODO: This is most likely be the same Event type as used in gamescoring.lua +---@param params table +function DebugEventAlert(event, params) end + +---@vararg string +---Opens a message box that contains the formatted input string provided as a vararg. +---The vararg should be a string with _n_ formatting placeholders, and _n_ elements that will be handled via `string.format(unpack(arg))`. +---**WARNING:** Appears to be non-functional! +function MessageBox(...) end + +---@vararg string +---Prints a debug message to the `AILog.txt` that contains the formatted input string provided as a vararg if the command `aiff script` has been used in the ingame console. +---The vararg should be a string with _n_ formatting placeholders, and _n_ elements that will be handled via `string.format(unpack(arg))`. +function ScriptMessage(...) end + +---@vararg string +---Prints a debug message to the `AILog.txt` that contains the formatted input string provided as a vararg if the command `aiff script` has been used in the ingame console. +---The vararg should be a string with _n_ formatting placeholders, and _n_ elements that will be handled via `string.format(unpack(arg))`. +function DebugMessage(...) end + +---@vararg string +---Prints a debug message that contains the formatted input string provided as a vararg directly to the `LogFile.txt`. Usually used as Error Log. +---The vararg should be a string with _n_ formatting placeholders, and _n_ elements that will be handled via `string.format(unpack(arg))`. +---@see string#format +---@see unpack +function OutputDebug(...) end + +---@vararg string +---Prints an error log to `LogFile.txt` and `AILog.txt` including the contains the formatted input string provided as a vararg and a stack trace. +---The vararg should be a string with _n_ formatting placeholders, and _n_ elements that will be handled via `string.format(unpack(arg))`. +---@see string#format +---@see unpack +function ScriptError(...) end + +---@param unit_table GameObjectWrapper[] +---Unpacks a table and prints its content to the `AILog.txt` if the command `aiff script` has been used in the ingame console. +function DebugPrintTable(unit_table) end diff --git a/.luadefs/eaw-types-emmyluadoc.lua b/.luadefs/eaw-types-emmyluadoc.lua new file mode 100644 index 0000000..6bf07da --- /dev/null +++ b/.luadefs/eaw-types-emmyluadoc.lua @@ -0,0 +1,998 @@ +-- ================================================================== +-- ================================================================== +-- _____ _ _ _ _ +-- | ___| (_) | | | | | | +-- | |__ _ __ ___ _ __ _ _ __ ___ __ _| |_ | | | | __ _ _ __ +-- | __| '_ ` _ \| '_ \| | '__/ _ \ / _` | __| | |/\| |/ _` | '__| +-- | |__| | | | | | |_) | | | | __/ | (_| | |_ \ /\ / (_| | | +-- \____/_| |_| |_| .__/|_|_| \___| \__,_|\__| \/ \/ \__,_|_| +-- | | +-- |_| +-- _____ _ ______ +-- | ___| | | | _ \ +-- | |__ _ __ ___ _ __ ___ _ _| | _ _ __ _| | | |___ ___ +-- | __| '_ ` _ \| '_ ` _ \| | | | | | | | |/ _` | | | / _ \ / __| +-- | |__| | | | | | | | | | | |_| | |___| |_| | (_| | |/ / (_) | (__ +-- \____/_| |_| |_|_| |_| |_|\__, \_____/\__,_|\__,_|___/ \___/ \___| +-- __/ | +-- |___/ +-- ================================================================== +-- ================================================================== +---@diagnostic disable +---@class TaskForce +local TaskForce = {} +---@public +---@param targetingPrioritySetName string The name of the Targeting Priority Set as defined in the XML. +---@param categoryMask string The Category Mask of the units contained within the TaskForce to attach the Targeting Priority Set to. +---Attaches a given Targeting Priority Set to all units in the TaskForce that match the given Category Mask. +function TaskForce.Set_Targeting_Priorities(targetingPrioritySetName, + categoryMask) +end + +---@public +---@return GameObject[] The units contained within the Task Force. +---Returns all units that are part of the task force. WARNING: The units may not be valid. +function TaskForce.Get_Unit_Table() end + +---@public +---@return number The amount of units in the TaskForce's unit table. +---Returns the number of units in a task force. +function TaskForce.Get_Force_Count() end + +---@public +---@param target GameObject The object to get the distance to. +---@return number The distance to the given game object. +function TaskForce.Get_Distance(target) end + +---@public +---@overload fun() +---@overload fun(stage:PlanetObject) +---@param stage PlanetObject The planet to produce the taskforce on. +---@param unknownArgument boolean TODO: Find out what this does. +---Produces a task force. +function TaskForce.Produce_Force(stage, unknownArgument) end + +---@public +---@param target GameObject The target to attack. +---Orders the task force to attack a given target. +function TaskForce.Attack_Target(target) end + +---@public +---@param target GameObject The target to attack. +---@param unknownArgument number TODO: Find out what this does. +---@param shouldPathThroughObstacle boolean Should the task force ignore space obstacles. +---Orders the task force to attack a given target. +function TaskForce.Attack_Target(target, unknownArgument, + shouldPathThroughObstacle) +end + +---@public +---@param target GameObject The target to guard. +---Orders the task force to guard a given target. +function TaskForce.Guard_Target(target) end + +---@public +---@param target GameObject The target to reinforce (usually a position). +-----Orders the task force to reinforce (at) a given target. +function TaskForce.Reinforce(target) end + +---@public +---@param target GameObject The target to move to (usually a position). +-----Orders the task force to move to a given target. +function TaskForce.Move_To(target) end + +---@public +---@param gameObject GameObject The object to release. +---Releases a given unit from the task force. +function TaskForce.Release_Unit(gameObject) end + +---@public +---@param abilityName string The ability to (de-)activate. +---@param shouldActivate boolean Activates the ability if true, deactivates if false. +---Activates or deactivates a given ability. +function TaskForce.Activate_Ability(abilityName, shouldActivate) end + +---@public +---@return (PlanetObject|Position) The task force's staging area. +---Returns the task force's staging area. +function TaskForce.Get_Stage() end + +---@public +---Lands the task force's units +function TaskForce.Land_Units() end + +---@public +---Launches the task force's units into orbit. +function TaskForce.Launch_Units() end + +---@public +---@return boolean Returns true if the invasion succeeded, false if the invasion failed. +---Invades a planet. +function TaskForce.Invade() end + +---@public +---@param isRemovable boolean +---Adjusts whether the Goal the task force is associated with can be removed before it's been achieved. +function TaskForce.Set_As_Goal_System_Removable(isRemovable) end + +---@class GameObject +---A wrapper around a single instance of a generic GameObjectType +local GameObject = {} +---@public +---@return GameObjectType +---Gets the type of the current game object wrapper. +function GameObject.Get_Type() end + +---@public +---@param propertyFlag string A string representation of 1..n properties. +---@return boolean +---Tests if a GameObject has 1..n flags of the bitfield defined in GameObjectPropertiesType.xml set. Valid inputs are single items `"Turret"` or many `"Turret | InBase"`. +function GameObject.Has_Property(propertyFlag) end + +---@public +---@return PlayerObject The PlayerObject owning the GameObject +---Returns the owner of the game object. +function GameObject.Get_Owner() end + +---@public +---@return Position +---Returns the current position of the object in the world. +function GameObject.Get_Position() end + +---@public +---@param categoryMask string The category mask to test for. Can be a single mask, or a combination: "CAPITAL" or "CAPITAL | SPACE_HERO" +---@return boolean +---Tests whether a given game object has a given category mask assigned to it. +function GameObject.Is_Category(categoryMask) end + +---@public +---@return (GameObject|nil) +---Returns a game object if the unit has an attack target, nil else. +function GameObject.Get_Attack_Target() end + +---@public +---@param abilityName string The ability to (de-)activate. +---@param shouldActivate boolean Activates the ability if true, deactivates if false. +---Activates or deactivates a given ability. +function GameObject.Activate_Ability(abilityName, shouldActivate) end + +---@public +---@return boolean +---Tests whether a unit has active orders. +function GameObject.Has_Active_Orders() end + +---@public +---@return number +---Returns a number between 0 and 1 representing the current percentage of hull points left. +function GameObject.Get_Hull() end + +---@public +---@return number +---Returns a number between 0 and 1 representing the current percentage of shield points left. +function GameObject.Get_Shield() end + +---@public +---@param target GameObject|Position +---@return number +function GameObject.Get_Distance(target) end + +---@public +---@overload fun(target:Position|GameObject|PlanetObject):CommandBlock +---@param unit_list GameObject[] +---@param target Position|GameObject|PlanetObject +---@return CommandBlock +---Orders the GameObject to move to the given target. Returns a CommandBlock is marked as finished when the GameObject has arrived at target +function GameObject.Move_To(unit_list, target) end + +---@public +---Despawns the GameObject +function GameObject.Despawn() end + +---@public +---@param new_owner PlayerObject The PlayerObject the ownership will be transferred to +---Transfers ownership of a GameObject over to another Player +function GameObject.Change_Owner(new_owner) end + +---@public +---@param behavior_id int The ID of the behavior +---@param enable boolean Enables the behavior if set to true. Disables it if it's false. +---Enables or disables a behavior defined in the XML entry of the GameObject +function GameObject.Enable_Behavior(behavior_id, enable) end + +---@public +---@return GameObject Returns the parent object of the given GameObject. In galactic conquest this will return either a planet, a company or a container. In tactical mode it returns the squadron for single fighters. +function GameObject.Get_Parent_Object() end + +---@public +---@return PlanetObject +---Returns the Planet the GameObject is located on. Can be nil if the GameObject is in Hyperspace +function GameObject.Get_Planet_Location() end + +---@public +---@param hidden boolean Determines whether the GameObject is visible or invisible +---Makes the GameObject visible or invisible +function GameObject.Hide(hidden) end + +---@public +---@param animation_name string The name of the animation +---@param should_repeat boolean Determines whether the animation gets repeated +---@param animation_index number The index of the animation, e.g. `3` to play `deploy_03.ala` +---Plays an animation on a GameObject. The animation must be present in the 3D model +function GameObject.Play_Animation(animation_name, should_repeat, + animation_index) +end + +---@public +---@param abilityName string +---@return boolean +function GameObject.Is_Ability_Autofire(abilityName) end + +---@public +---@param sfxEventName string +function GameObject.Play_SFX_Event(sfxEventName) end + +---@public +---@return boolean +function GameObject.Is_Transport() end + +---@public +---@param planet PlanetObject +---@return boolean +function GameObject.Can_Land_On_Planet(planet) end + +---@public +function GameObject.Get_Game_Scoring_Type() end + +---@public +---@param abilityName string +---@return boolean +function GameObject.Is_Ability_Ready(abilityName) end + +---@public +---@param position Position|GameObject +function GameObject.Divert(position) end + +---@public +---@return boolean +function GameObject.Is_On_Diversion() end + +---@public +---@return GameObject[] +function GameObject.Get_Garrisoned_Units() end + +---@public +---@param target GameObject +---@return boolean +function GameObject.Should_Switch_Weapons(target) end + +---@public +---@param allow_spawn boolean +function GameObject.Set_Garrison_Spawn(allow_spawn) end + +---@public +---@param disable boolean +function GameObject.Disable_Capture(disable) end + +---@public +---@overload fun(damageAmount:number) +---@param damageAmount number +---@param hardpoint string +function GameObject.Take_Damage(damageAmount, hardpoint) end + +---@public +---@overload fun(callbackFunction:function, range:number) +---@param callbackFunction fun(obj:GameObject, trigger:GameObject) +---@param range number +---@param player PlayerObject +function GameObject.Event_Object_In_Range(callbackFunction, range, player) end + +---@public +---@param callbackFunction function +function GameObject.Cancel_Event_Object_In_Range(callbackFunction) end + +---@public +--- The returned command block will never finish, even if the move is done and there is no target to be attacked. +---@overload fun(target:GameObject):CommandBlock +---@param unit_list GameObject[] +---@param target GameObject|Position +---@return CommandBlock +function GameObject.Attack_Move(unit_list, target) end + +---@public +---@overload fun(target:GameObject):CommandBlock +---@param unit_list GameObject[] +---@param target GameObject +---@return CommandBlock +function GameObject.Attack_Target(unit_list, target) end + +---@public +---@overload fun(target:GameObject):CommandBlock +---@param unit_list GameObject[] +---@param target GameObject|Position +---@return CommandBlock +function GameObject.Guard_Target(unit_list, target) end + +---@public +--- Returns true if the unit can currently move (is false e.g. during hyperspace in) +---@return boolean +function GameObject.Can_Move() end + +---@public +--- Stops the unit. +function GameObject.Stop() end + +---@public +--- Movability on or off +---@param suspend boolean +function GameObject.Suspend_Locomotor(suspend) end + +---@public +--- Activates targeted ability +---@param ability_name string +---@param turn_on GameObject|Position|boolean A target to turn on targeted abilities or a boolean. +function GameObject.Activate_Ability(ability_name, turn_on) end + +---@public +--- Finishes ability cooldowns +function GameObject.Reset_Ability_Counter() end + +---@public +---@param ability_name string +---@param autofire boolean +function GameObject.Set_Single_Ability_Autofire(ability_name, autofire) end + +---@public +---@param autofire boolean +function GameObject.Set_All_Abilities_Autofire(autofire) end + +---@public +---@param ability_name string +---@return boolean +function GameObject.Is_Ability_Active(ability_name) end + +---@public +---@param ability_name string +---@return boolean +function GameObject.Has_Ability(ability_name) end + +---@public +---@param ability_name string +---@param optional number +function GameObject.Force_Ability_Recharge(ability_name, optional) end + +---@public +---@param ability_name string +function GameObject.Cancel_Ability(ability_name) end + +---@public +---@return boolean +function GameObject.Are_Engines_Online() end + +---@public +---@param speed number +function GameObject.Override_Max_Speed(speed) end + +---@public +--- Makes the unit hyperspace into battle with a delay by the given number of frames. +---@param delay number The number of frames before the hyperspace animation is started +function GameObject.Cinematic_Hyperspace_In(delay) end + +---@public +--- Makes unit leave into hyperspace. Will be removed from galactic level as well if the optional parameter is not set to false. +---@param remove_from_campaign boolean Default is true +function GameObject.Hyperspace_Away(remove_from_campaign) end + +---@public +function GameObject.Cancel_Hyperspace() end + +---@public +--- Allow or prevent AI usage. In tactical battles this crashes the game if the unit has no active AI! When the faction's AI changes, the unit is AI usable again. +---@param prevent boolean +function GameObject.Prevent_AI_Usage(prevent) end + +---@public +--- Shall object be displayed in Cinematic? +---@param keep_visible boolean +function GameObject.In_End_Cinematic(keep_visible) end + +---@public +---@param target Position|GameObject +function GameObject.Teleport(target) end + +---@public +--- Teleport object make it face the same way as the target +---@param target GameObject +function GameObject.Teleport_And_Face(target) end + +---@public +---@param target Position|GameObject +function GameObject.Face_Immediate(target) end + +---@public +---@param target Position|GameObject +function GameObject.Turn_To_Face(target) end + +---@public +--- Prevent automatically firing at targets in range +---@param prevent boolean +function GameObject.Prevent_Opportunity_Fire(prevent) end + +---@public +--- Completely prevent a unit from firing +---@param prevent boolean +function GameObject.Prevent_All_Fire(prevent) end + +---@public +--- Stops the unit from taking any damage +---@param invulnerable boolean +function GameObject.Make_Invulnerable(invulnerable) end + +---@public +---@param check boolean +function GameObject.Set_Check_Contested_Space(check) end + +---@public +function GameObject.Lock_Current_Orders() end + +---@public +function GameObject.Unlock_Current_Orders() end + +---@public +---@return boolean +function GameObject.Is_In_Asteroid_Field() end + +---@public +---@return boolean +function GameObject.Is_In_Ion_Storm() end + +---@public +---@return boolean +function GameObject.Is_In_Nebula() end + +---@public +---@param enable boolean +function GameObject.Enable_Dynamic_LOD(enable) end + +---@public +--- Only for fleets with land units in orbit over an enemy planet (is used in FoC campaign but doesn't seem to work) +function GameObject.Invade() end + +---@public +---@param unknown boolean +function GameObject.Set_In_Limbo(unknown) end + +---@public +--- Returns a list of the projectile types the unit uses +---@return GameObjectType[] +function GameObject.Get_All_Projectile_Types() end + +---@public +---@return boolean +function GameObject.Is_Selectable() end + +---@public +--- Sets a unit to be selectable or not selectable by the player +---@param selectable boolean +function GameObject.Set_Selectable(selectable) end + +---@public +--- Returns the projectile type the unit is currently using +---@return GameObjectType +function GameObject.Get_Current_Projectile_Type() end + +---@public +---@param target GameObject +---@return boolean +function GameObject.Is_Good_Against(target) end + +---@public +---@return boolean +function GameObject.Is_In_Garrison() end + +---@public +--- Returns true if the object contains any garrisoned units +---@return boolean +function GameObject.Has_Garrison() end + +---@public +--- Eject all garrisoned units +function GameObject.Eject_Garrison() end + +---@public +--- Make a garrisoned unit leave its garrison +function GameObject.Leave_Garrison() end + +---@public +---@return boolean +function GameObject.Can_Garrison_Fire() end + +---@public +--- Can the unit be garrisoned in the given object? +---@param target GameObject +---@return boolean +function GameObject.Can_Garrison(target) end + +---@public +--- Garrison the unit in the given object +---@param target GameObject +function GameObject.Garrison(target) end + +---@public +function GameObject.Play_Cinematic_Engine_Flyby() end + +---@public +---@overload fun(event_name:string) +---@param event_name string +---@param optional number +function GameObject.Stop_SFX_Event(event_name, optional) end + +---@public +---@overload fun(type:string|GameObjectType) +---@param type string|GameObjectType +---@param optional string +---@return GameObject +function GameObject.Attach_Particle_Effect(type, optional) end + +---@public +---@return boolean +function GameObject.Has_Attack_Target() end + +---@public +---@param emitter string +---@param show boolean +function GameObject.Show_Emitter(emitter, show) end + +---@public +--- Put a small arrow highlight on top of the object +---@overload fun(highlight:boolean) +---@param highlight boolean +---@param optional number Seems to change the distance of the arrow to the object +function GameObject.Highlight_Small(highlight, optional) end + +---@public +--- Put an arrow highlight on top of the object +---@overload fun(highlight:boolean) +---@param highlight boolean +---@param optional number Seems to change the distance of the arrow to the object +function GameObject.Highlight(highlight, optional) end + +---@public +---@param target AITarget +---@return CommandBlock +function GameObject.Explore_Area(target) end + +---@public +--- Check if a space battle should be initiated, e.g. after spawning a fleet at an enemy planet (only works on fleets and planets) +function GameObject.Force_Test_Space_Conflict() end + +---@public +--- Keep a unit from dying (it can still be damaged) +---@param cannot_be_killed boolean +function GameObject.Set_Cannot_Be_Killed(cannot_be_killed) end + +---@public +--- Returns the hint set for this object in the map editor or nil. +---@return string|nil +function GameObject.Get_Hint() end + +---@public +--- Fire death star in tactical mode +function GameObject.Fire_Tactical_Superweapon() end + +---@public +--- Test if death star is ready to fire +---@return boolean +function GameObject.Is_Tactical_Superweapon_Ready() end + +---@public +---@param bone_name string +---@return Position +function GameObject.Get_Bone_Position(bone_name) end + +---@public +---@param lock boolean +function GameObject.Lock_Build_Pad_Contents(lock) end + +---@public +--- Only used on fleets +---@param number number +function GameObject.Destroy_Contained_Objects(number) end + +---@public +--- Only used on fleets +---@param object_type GameObjectType +---@return boolean +function GameObject.Contains_Object_Type(object_type) end + +---@public +--- Only used on fleets +---@return number +function GameObject.Get_Contained_Object_Count() end + +---@public +--- (tactical only) +---@param game_object GameObject +---@return number +function GameObject.Get_AI_Power_Vs_Unit(game_object) end + +---@public +--- Use in tactical. This kills the corresponding GC object +function GameObject.Mark_Parent_Mode_Object_For_Death() end + +---@public +---@param number number +function GameObject.Set_Importance(number) end + +---@public +function GameObject.Service_Wrapper() end + +---@public +--- Possibly only for build pad contents +function GameObject.Sell() end + +---@public +--- Use on build pads or MDUs +---@return GameObject +function GameObject.Get_Build_Pad_Contents() end + +---@public +--- Only for fleets +---@return GameObject[] +function GameObject.Get_Contained_Heroes() end + +---@public +--- Only for fleets +---@return boolean +function GameObject.Contains_Hero() end + +---@public +--- Use on spawned special weapon or on space station with special weapon +---@param target GameObject +---@param user PlayerObject +function GameObject.Fire_Special_Weapon(target, user) end + +---@public +---@return number +function GameObject.Get_Rate_Of_Damage_Taken() end + +---@public +--- Expected time til death based on damage taken. +---@return number +function GameObject.Get_Time_Till_Dead() end + +---@public +---@param number number +function GameObject.Set_Targeting_Stickiness_Time_Threshold(number) end + +---@public +---@param targeting_priority_set string +function GameObject.Set_Targeting_Priorities(targeting_priority_set) end + +---@public +--- Obeject needs UNIT_AI behavior +---@param prefer boolean +function GameObject.Set_Prefer_Ground_Over_Space(prefer) end + +---@public +--- Normalized with respect to unit's total energy +---@return number Float between 0 and 1 +function GameObject.Get_Energy() end + +---@public +--- Normalized with respect to unit's total health +---@return number Float between 0 and 1 +function GameObject.Get_Health() end + +---@public +function GameObject.Release() end + +---@public +--- Use on buildpads and MDUs. Takes a UC type +---@param type string|GameObjectType +---@param optional boolean +function GameObject.Build(type, optional) end + +---@class Position +---Represents a position in the world. +local Position = {} + +---@class GameObjectType +---A generic GameObjectType that represents a C++ GameObjectTypeClass +local GameObjectType = {} +---@public +---@return string +---Retrieves the XML name of a GameObjectType +function GameObjectType.Get_Name() end + +---@public +---@return boolean +function GameObjectType.Is_Hero() end + +---@public +---@return number +function GameObjectType.Get_Build_Cost() end + +---@public +--- Returns the AI_Combat_Power +---@return number +function GameObjectType.Get_Combat_Rating() end + +---@public +--- Returns required tech level +---@return number +function GameObjectType.Get_Tech_Level() end + +---@public +--- Returns level of a starbase type +---@return number +function GameObjectType.Get_Base_Level() end + +---@public +---@param player PlayerObject +---@return boolean +function GameObjectType.Is_Affiliated_With(player) end + +---@public +---@param player PlayerObject +---@return boolean +function GameObjectType.Is_Build_Locked(player) end + +---@public +---@param player PlayerObject +---@return boolean +function GameObjectType.Is_Obsolete(player) end + +---@public +---@return number +function GameObjectType.Get_Tactical_Build_Cost() end + +---@public +---@return number +function GameObjectType.Get_Score_Cost_Credits() end + +---@public +---@return number +function GameObjectType.Get_Max_Range() end + +---@public +---@return number +function GameObjectType.Get_Min_Range() end + +---@public +---@return number +function GameObjectType.Get_Bribe_Cost() end + +---@public +--- This only makes sense for projectile types though it can be used for others as well. +---@return boolean +function GameObjectType.Is_Affected_By_Missile_Shield() end + +---@public +--- This only makes sense for projectile types though it can be used for others as well. +---@return boolean +function GameObjectType.Is_Affected_By_Laser_Defense() end + +---@class GameObjectWrapper +---A generic wrapper around a GameObject +local GameObjectWrapper = {} +---@public +---Returns `true` if the contained game object is valid. +---@return boolean +function GameObjectWrapper.Is_Valid() end + +---@class PlayerObject +---A wrapper around a player (AI or human) taking control of a faction. +local PlayerObject = {} +---@public +---@return boolean +---Tests whether a PlayerObject is human. +function PlayerObject.Is_Human() end + +---@public +---@param playerObject PlayerObject +---@return boolean +---Tests whether a player object is an enemy of another player object. +function PlayerObject.Is_Enemy(playerObject) end + +---@public +---@param amount number +function PlayerObject.Give_Money(amount) end + +---@public +---@return number +function PlayerObject.Get_ID() end + +---@public +---@param playerObject PlayerObject +---@return boolean +function PlayerObject.Is_Ally(playerObject) end + +---@public +--- Enables Advisor Hints +---@param mode string Is "space" or "ground" +---@param enable boolean +function PlayerObject.Enable_Advisor_Hints(mode, enable) end + +---@public +--- Returns an enemy player (may only ever returns Rebel or Empire, in any case there is not much point using it outside the base EaW though it might be related to the Primary Enemy tag) +---@return PlayerObject +function PlayerObject.Get_Enemy() end + +---@public +--- Forces player to select object +---@param object GameObject +function PlayerObject.Select_Object(object) end + +---@public +--- Activates the AI for the player +function PlayerObject.Enable_As_Actor() end + +---@public +--- Enables retreat event. Returns false if player is not able to retreat. +---@return boolean +function PlayerObject.Retreat() end + +---@public +--- returns the displayed faction name +---@return string +function PlayerObject.Get_Name() end + +---@public +--- Returns xml faction name +---@return string +function PlayerObject.Get_Faction_Name() end + +---@public +---@return number +function PlayerObject.Get_Tech_Level() end + +---@public +function PlayerObject.Give_Random_Sliceable_Tech() end + +---@public +--- Gets reset with any game mode changes, in particular at the end of every tactical battle! +---@param player PlayerObject +function PlayerObject.Make_Ally(player) end + +---@public +--- Gets reset with any game mode changes, in particular at the end of every tactical battle! +---@param player PlayerObject +function PlayerObject.Make_Enemy(player) end + +---@public +--- Returns the player's space station in space tactical +---@return GameObject +function PlayerObject.Get_Space_Station() end + +---@public +--- Team ID in skirmish +---@return number +function PlayerObject.Get_Team() end + +---@public +--- Clan ID in skirmish +---@return number +function PlayerObject.Get_Clan_ID() end + +---@public +--- Removes the orbital bombardment. Countdown for usage will continue and not be reset if the bombardment is re-enabled. +---@param remove boolean +function PlayerObject.Remove_Orbital_Bombardment(remove) end + +---@public +--- Disable the bombardment. The countdown for usage will continue. +---@param disable boolean +function PlayerObject.Disable_Orbital_Bombardment(disable) end + +---@public +---@param set boolean +function PlayerObject.Set_Sabotage_Tutorial(set) end + +---@public +---@param set boolean +function PlayerObject.Set_Black_Market_Tutorial(set) end + +---@public +---@return string Returns "Easy", "Normal" or "Hard" +function PlayerObject.Get_Difficulty() end + +---@public +--- The parameter logic is reversed here. The bombing run is disabled if false is passed. +---@param enable boolean +function PlayerObject.Disable_Bombing_Run(enable) end + +---@public +---@param object_type GameObjectType +function PlayerObject.Unlock_Tech(object_type) end + +---@public +function PlayerObject.Get_GameSpy_Stats_Player_ID() end + +---@public +---@return number +function PlayerObject.Get_Credits() end + +---@public +--- For AI player (with galactic AI) only. Releases credits for spending in tactical mode. +---@param amount number +function PlayerObject.Release_Credits_For_Tactical(amount) end + +---@public +---@param level number +function PlayerObject.Set_Tech_Level(level) end + +---@class PlanetObject +local PlanetObject = {} +---@public +---@return boolean +function PlanetObject.Get_Is_Planet_AI_Usable() end + +---@public +---@return boolean +function PlanetObject.Is_Corrupted() end + +---@public +--- Check if a space battle should be initiated, e.g. after spawning a fleet at an enemy planet (only works on fleets and planets) +function PlanetObject.Force_Test_Space_Conflict() end + +---@public +---@return boolean +function PlanetObject.Is_Planet_Destroyed() end + +---@public +--- Returns the indigenous unit type of that planet affiliated with the given player +---@return GameObjectType +function PlanetObject.Get_Affiliated_Indigenous_Type(player) end + +---@public +---@return GameObjectType +function PlanetObject.Get_Next_Starbase_Type() end + +---@public +---@return PlayerObject +function PlanetObject.Get_Final_Blow_Player() end + +---@public +---@return number +function PlanetObject.Get_Starbase_Level() end + +---@class GameScoringType +local GameScoringType = {} +---@public +---@return number +function GameScoringType.Get_Score_Cost_Credits() end + +---@public +---@return number +function GameScoringType.Get_Combat_Rating() end + +---@public +---@return number +function GameScoringType.Get_Build_Cost() end + +---@class CommandBlock +local CommandBlock = {} + +---@public +---@return table +---Returns the result of the CommandBlock +function CommandBlock.Result() end + +---@public +---@return boolean +---Returns a boolean indicating whether the CommandBlock has finished its command +function CommandBlock.IsFinished() end + +---@class AITarget +local AITarget = {} +---@public +--- Returns corresponding game object if there is one (e.g. a targeted unit or planet). +---@return GameObject +function AITarget.Get_Game_Object() end + +---@public +---@param position Position +---@return number +function AITarget.Get_Distance(position) end + +-- return TaskForce, GameObject, Position, GameObjectType, GameObjectWrapper, PlayerObject, PlanetObject, GameScoringType, CommandBlock diff --git a/.luadefs/foc_engine.lua b/.luadefs/foc_engine.lua deleted file mode 100644 index bc8cb74..0000000 --- a/.luadefs/foc_engine.lua +++ /dev/null @@ -1,152 +0,0 @@ ----@meta ----@diagnostic disable: missing-fields --- Empire at War / Forces of Corruption engine API stubs. --- This file is never executed — the Lua Language Server reads it as definitions only. - --- ================================================== --- Engine Object Types --- ================================================== - ----A player in the game (C++ PlayerWrapper userdata). ----@class PlayerWrapper ----@field Get_Name fun(): string ----@field Get_ID fun(): integer ----@field Get_Faction fun(): string ----@field Get_Credits fun(): number ----@field Is_Valid fun(): boolean ----@field Is_Human fun(): boolean ----@field Is_Ally fun(other: PlayerWrapper): boolean ----@field Is_Enemy fun(other: PlayerWrapper): boolean ----@field Select_Object fun(other: GameObjectWrapper) - ----A game object instance (C++ GameObjectWrapper userdata). ----@class GameObjectWrapper ----@field Get_Type fun(): GameObjectTypeWrapper ----@field Get_Owner fun(): PlayerWrapper ----@field Get_Final_Blow_Player fun(): PlayerWrapper ----@field Get_Game_Scoring_Type fun(): GameObjectTypeWrapper ----@field Is_Valid fun(): boolean ----@field Is_Pool_Safe fun(): boolean ----@field Service_Wrapper fun() - ----A game object type definition (C++ GameObjectTypeWrapper userdata). ----@class GameObjectTypeWrapper ----@field Get_Name fun(): string ----@field Is_Valid fun(): boolean - --- ================================================== --- Script Object --- ================================================== - ----The engine-injected script context object. ----@class ScriptObject ----@field Debug_Should_Issue_Event_Alert fun(): boolean - ----Engine-injected script context. Set by the engine before the script runs. ----@type ScriptObject -Script = {} - ----Engine-injected object context. Set by the engine before the script runs. ----@type GameObjectWrapper -Object = {} - --- ================================================== --- GlobalValue / ThreadValue --- (callable table: GlobalValue("key") to get, GlobalValue.Set("key", val) to set) --- ================================================== - ----@class ValueStore ----@field Set fun(key: string, value: any) ----@operator call(string): any - ----Persistent global value store shared across scripts. ----@type ValueStore -GlobalValue = {} - ----Per-thread value store. ----@type ValueStore -ThreadValue = {} - --- ================================================== --- Engine Global Functions --- ================================================== - ----Pumps services for the script. -function Pump_Service() end - ----Compares two strings for equality (case-insensitive in FoC). ----@param a string ----@param b string ----@return boolean -function StringCompare(a, b) end - ----Finds a player by name (e.g. "local", "empire", "rebel"). ----@param name string ----@return PlayerWrapper -function Find_Player(name) end - ----Returns the current game time in seconds. ----@return number -function GetCurrentTime() end - ----Returns the ID of the current thread, or -1 if not in a thread. ----@return integer -function GetThreadID() end - ----Returns the next pending event function, or nil if the queue is empty. ----@return (fun(...): any) | nil -function GetEvent() end - ----Exits the current script. -function _ScriptExit() end - ----Pops up a message box (internal engine call). ----@param message string -function _MessagePopup(message) end - ----Sends a message to the script log (internal engine call). ----@param message string -function _ScriptMessage(message) end - ----Sends a message to the debug output (internal engine call — note: typo in original source). ----@param message string -function _OuputDebug(message) end - ----Dumps the current Lua call stack as a string. ----@return string -function DumpCallStack() end - ----Sets the visibility of the named component. ----@param component string ----@param isVisible boolean -function GUI_Component_Visibility(component, isVisible) end - ----Sets the text for the named component. ----@param component string ----@param text string -function GUI_Component_Text(component, text) end - ----Sets the text color for the named component. ----@param component string ----@param r number ----@param g number ----@param b number ----@param a number -function GUI_Text_Color(component, r, g, b, a) end - ----Sets the icon for the named component. ----@param component string ----@param icon string ----@param r number ----@param g number ----@param b number ----@param a number -function GUI_Button_Icon(component, icon, r, g, b, a) end - ----Finds all objects matching the criteria. ----@param a any ----@param b any ----@param c any ----@param d any ----@return GameObjectWrapper[] -function Find_All_Objects_Of_Type(a, b, c, d) end diff --git a/Data/Scripts/Miscellaneous/GameManager/GUIManager.lua b/Data/Scripts/Miscellaneous/GameManager/GUIManager.lua index 2d0e779..f637838 100644 --- a/Data/Scripts/Miscellaneous/GameManager/GUIManager.lua +++ b/Data/Scripts/Miscellaneous/GameManager/GUIManager.lua @@ -86,6 +86,7 @@ function GUIManager:Service() ServiceGameTime(self.TacticalGame) ServiceTeamCredits(self.SkirmishGame) --ServiceUnitDisplay(self.SkirmishGame, self.ShowTeamId) + ServiceScreenText(self.SkirmishGame) end ---Services Game Time display. @@ -169,11 +170,16 @@ function ServiceUnitDisplay(skirmishGame, teamId) return end + local localPlayer = Find_Player("local") + + if not localPlayer then + return + end + local function DisplayTeamUnit(unit, uiComponent) end - local localPlayer = Find_Player("local") local players = skirmishGame:GetPlayersOnTeam(teamId) ---@type table Units Table by name with alive count. local units = {} @@ -192,3 +198,6 @@ function ServiceUnitDisplay(skirmishGame, teamId) end end end + +function ServiceScreenText(skirmishGame) +end diff --git a/Data/Scripts/Miscellaneous/GameManager/SkirmishGameClass.lua b/Data/Scripts/Miscellaneous/GameManager/SkirmishGameClass.lua index 0d12352..45bfb7d 100644 --- a/Data/Scripts/Miscellaneous/GameManager/SkirmishGameClass.lua +++ b/Data/Scripts/Miscellaneous/GameManager/SkirmishGameClass.lua @@ -24,6 +24,7 @@ function SkirmishGameClass:New(gameMode) local function FindSpectators() ---@type SpectatorStruct[] local spectators = {} + ---@type string local spectatorMarker = nil if StringCompare(gameMode, "Space") then @@ -57,6 +58,10 @@ function SkirmishGameClass:New(gameMode) local function GetLocalSpectator() local localPlayer = Find_Player("local") + if not localPlayer then + return false + end + return self:GetSpectator(localPlayer.Get_ID()) ~= nil end diff --git a/Data/Scripts/Miscellaneous/GameScoring.lua b/Data/Scripts/Miscellaneous/GameScoring.lua index 7662479..23cd7e2 100755 --- a/Data/Scripts/Miscellaneous/GameScoring.lua +++ b/Data/Scripts/Miscellaneous/GameScoring.lua @@ -13,7 +13,7 @@ require("GameManager/SkirmishGameClass") local DebugCounter = 0 ---Debugging service rate. -local ServiceDebugRate = 10 +local ServiceDebugRate = 5 ---The Local Player FoC PlayerWrapper object. local LocalPlayer = nil