### Dawn of War Scar: Setup Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet details functions for game setup in Dawn of War Scar. It includes a general 'Group_Setup' and a specific 'Setup_Player' function, likely used for initializing game states, player properties, or starting conditions. ```Scar menuItem.addItem("Setup ","../function_list.htm#Group_Setup "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Setup_Player","../function_list.htm#Setup_Player"); menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; ``` -------------------------------- ### SCAR: Add Rule with Interval Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scripting.htm Adds a SCAR rule to be evaluated at a specified interval. This example shows how to add the 'Rule_GivePlayerMoney' rule every 30 seconds. It requires the 'Rule_GivePlayerMoney' function to be defined. ```SCAR --\nhere we're going to add the rule in every 30 seconds Rule_AddInterval( Rule_GivePlayerMoney, 30 ) function Rule_GivePlayerMoney( ) --this checks to see how much requisition the indicated player has if Player_GetResource(playerID, RT_Requisition) < 1000 then Player_AddResource(playerID, RT_Requisition, 500) else Rule_Remove(Rule_GivePlayerMoney ) end end ``` -------------------------------- ### Dawn of War SCAR: Event Handling Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This section covers SCAR functions for managing game events, including delays, checking event status, skipping, starting, and timing events. These are essential for creating dynamic game logic and responses. ```SCAR menuItem2.addItem("Event_Delay","../function_list.htm#Event_Delay"); menuItem2.addItem("Event_IsAnyRunning","../function_list.htm#Event_IsAnyRunning"); menuItem2.addItem("Event_IsRunning","../function_list.htm#Event_IsRunning"); menuItem2.addItem("Event_Skip","../function_list.htm#Event_Skip"); menuItem2.addItem("Event_Start","../function_list.htm#Event_Start"); menuItem2.addItem("Event_TimeSinceLast","../function_list.htm#Event_TimeSinceLast"); ``` -------------------------------- ### Marker Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Functions for interacting with markers, including getting attributes, position, proximity, and type. These functions are essential for locating and querying game entities. ```SCAR addItem("Marker_GetNumberAttribute","../function_list.htm#Marker_GetNumberAttribute"); addItem("Marker_GetPosition","../function_list.htm#Marker_GetPosition"); addItem("Marker_GetProximity","../function_list.htm#Marker_GetProximity"); addItem("Marker_GetStringAttribute","../function_list.htm#Marker_GetStringAttribute"); addItem("Marker_GetType","../function_list.htm#Marker_GetType"); addItem("Marker_InProximity","../function_list.htm#Marker_InProximity"); ``` -------------------------------- ### Timer Management Functions in SCAR Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Details SCAR functions for managing in-game timers, including adding, displaying, ending, retrieving remaining time, pausing, resuming, and starting timers. ```SCAR menuItem.addItem("Timer ","../function_list.htm#Group_Timer "); menuItem2.addItem("Timer_Add","../function_list.htm#Timer_Add"); menuItem2.addItem("Timer_Display","../function_list.htm#Timer_Display"); menuItem2.addItem("Timer_End","../function_list.htm#Timer_End"); menuItem2.addItem("Timer_GetRemaining","../function_list.htm#Timer_GetRemaining"); menuItem2.addItem("Timer_Pause","../function_list.htm#Timer_Pause"); menuItem2.addItem("Timer_Resume","../function_list.htm#Timer_Resume"); menuItem2.addItem("Timer_Start","../function_list.htm#Timer_Start"); ``` -------------------------------- ### SCAR Entity and Squad Selection Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Provides functions for getting selected entities and squads, checking selection status, and managing entity selection focus. These functions are crucial for game logic that interacts with player-selected units. ```SCAR menuItem2.addItem("Misc_GetSelectedEntities","../function_list.htm#Misc_GetSelectedEntities"); menuItem2.addItem("Misc_GetSelectedSquads","../function_list.htm#Misc_GetSelectedSquads"); menuItem2.addItem("Misc_IsEntitySelected","../function_list.htm#Misc_IsEntitySelected"); menuItem2.addItem("Misc_IsSquadSelected","../function_list.htm#Misc_IsSquadSelected"); menuItem2.addItem("W40k_SelectEGroup","../function_list.htm#W40k_SelectEGroup"); menuItem2.addItem("W40k_SelectionFocus","../function_list.htm#W40k_SelectionFocus"); menuItem2.addItem("W40k_SelectSGroup","../function_list.htm#W40k_SelectSGroup"); ``` -------------------------------- ### SCAR Visual and Presentation Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Includes functions for visual effects and presentation, such as image fading, letterboxing, and controlling camera focus. These are used to enhance the visual experience and guide the player's attention. ```SCAR menuItem2.addItem("W40k_ImageFade","../function_list.htm#W40k_ImageFade"); menuItem2.addItem("W40k_IsLetterboxed","../function_list.htm#W40k_IsLetterboxed"); menuItem2.addItem("W40k_Letterbox","../function_list.htm#W40k_Letterbox"); ``` -------------------------------- ### MetaMap Functions: Player and Game State Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode_nojs.htm Functions for querying player-specific game states, such as starting squads and cooperative play status. Also includes functions for updating player-related data like wargear. ```SCAR MetaMap_GetRaceStartingSquadsList MetaMap_IsAttackingTerritoryIndexValid MetaMap_IsCoop MetaMap_UpdatePlayerWargear ``` -------------------------------- ### SCAR Player and Race Management Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Provides functions for managing player properties and race-specific data, including getting player counts, indices, and determining if a race uses requisition. These are fundamental for multiplayer and AI logic. ```SCAR menuItem2.addItem("World_DoesRaceUseRequisition","../function_list.htm#World_DoesRaceUseRequisition"); menuItem2.addItem("World_GetPlayerAt","../function_list.htm#World_GetPlayerAt"); menuItem2.addItem("World_GetPlayerCount","../function_list.htm#World_GetPlayerCount"); menuItem2.addItem("World_GetPlayerIndex","../function_list.htm#World_GetPlayerIndex"); menuItem2.addItem("World_GetRaceIndex","../function_list.htm#World_GetRaceIndex"); ``` -------------------------------- ### Player Functions for Entity and Squad Management Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet groups SCAR functions related to getting, adding, and managing player-owned entities and squads. It covers functionalities like retrieving entities near a marker or position, checking visibility, and adding squads to groups. ```SCAR menuItem.addItem("SPath_Start","../function_list.htm#SPath_Start"); menuItem2.addItem("SPath_StartEx","../function_list.htm#SPath_StartEx"); menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; menuItem.addItem("Player ","../function_list.htm#Group_Player "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("*Player_GetEntities","../function_list.htm#*Player_GetEntities"); menuItem2.addItem("*Player_GetSquads","../function_list.htm#*Player_GetSquads"); menuItem2.addItem("Player_AddResource","../function_list.htm#Player_AddResource"); menuItem2.addItem("Player_AddSquadsToSGroup","../function_list.htm#Player_AddSquadsToSGroup"); menuItem2.addItem("Player_AreSquadsNearMarker","../function_list.htm#Player_AreSquadsNearMarker"); menuItem2.addItem("Player_CanSeeEGroup","../function_list.htm#Player_CanSeeEGroup"); menuItem2.addItem("Player_CanSeeEntity","../function_list.htm#Player_CanSeeEntity"); menuItem2.addItem("Player_CanSeePosition","../function_list.htm#Player_CanSeePosition"); menuItem2.addItem("Player_CanSeeSGroup","../function_list.htm#Player_CanSeeSGroup"); menuItem2.addItem("Player_CanSeeSquad","../function_list.htm#Player_CanSeeSquad"); menuItem2.addItem("Player_DespawnAll","../function_list.htm#Player_DespawnAll"); menuItem2.addItem("Player_DestroyAll","../function_list.htm#Player_DestroyAll"); menuItem2.addItem("Player_ForceSetMaxSquadCap","../function_list.htm#Player_ForceSetMaxSquadCap"); menuItem2.addItem("Player_ForceSetMaxSupportCap","../function_list.htm#Player_ForceSetMaxSupportCap"); menuItem2.addItem("Player_FromId","../function_list.htm#Player_FromId"); menuItem2.addItem("Player_FromName","../function_list.htm#Player_FromName"); menuItem2.addItem("Player_GetActiveSquadCount","../function_list.htm#Player_GetActiveSquadCount"); menuItem2.addItem("Player_GetAllEntitiesNearMarker","../function_list.htm#Player_GetAllEntitiesNearMarker"); menuItem2.addItem("Player_GetAllEntitiesNearPos","../function_list.htm#Player_GetAllEntitiesNearPos"); menuItem2.addItem("Player_GetAllSquadsNearMarker","../function_list.htm#Player_GetAllSquadsNearMarker"); menuItem2.addItem("Player_GetAllSquadsNearPos","../function_list.htm#Player_GetAllSquadsNearPos"); menuItem2.addItem("Player_GetBlueprintCount","../function_list.htm#Player_GetBlueprintCount"); menuItem2.addItem("Player_GetBuildingsCount","../function_list.htm#Player_GetBuildingsCount"); menuItem2.addItem("Player_GetBuildingsCountExcept","../function_list.htm#Player_GetBuildingsCountExcept"); menuItem2.addItem("Player_GetBuildingsCountOnly","../function_list.htm#Player_GetBuildingsCountOnly"); menuItem2.addItem("Player_GetBuildingSpawnedCount","../function_list.htm#Player_GetBuildingSpawnedCount"); menuItem2.addItem("Player_GetCurrentSquadCap","../function_list.htm#Player_GetCurrentSquadCap"); menuItem2.addItem("Player_GetDisplayName","../function_list.htm#Player_GetDisplayName"); menuItem2.addItem("Player_GetEntities","../function_list.htm#Player_GetEntities"); menuItem2.addItem("Player_GetEntityCount","../function_list.htm#Player_GetEntityCount"); menuItem2.addItem("Player_GetEntityName","../function_list.htm#Player_GetEntityName"); menuItem2.addItem("Player_GetID","../function_list.htm#Player_GetID"); menuItem2.addItem("Player_GetMaxSquadCap","../function_list.htm#Player_GetMaxSquadCap"); menuItem2.addItem("Player_GetNumStrategicObjectives","../function_list.htm#Player_GetNumStrategicObjectives"); menuItem2.addItem("Player_GetNumStrategicPoints","../function_list.htm#Player_GetNumStrategicPoints"); menuItem2.addItem("Player_GetRace","../function_list.htm#Player_GetRace"); menuItem2.addItem("Player_GetRaceName","../function_list.htm#Player_GetRaceName"); menuItem2.addItem("Player_GetRelationship","../function_list.htm#Player_GetRelationship"); menuItem2.addItem("Player_GetResearchState","../function_list.htm#Player_GetResearchState"); menuItem2.addItem("Player_GetResource","../function_list.htm#Player_GetResource"); menuItem2.addItem("Player_GetSquadCount","../function_list.htm#Player_GetSquadCount"); menuItem2.addItem("Player_GetSquads","../function_list.htm#Player_GetSquads"); menuItem2.addItem("Player_GetStartPosition","../function_list.htm#Player_GetStartPosition"); menuItem2.addItem("Player_GetStrategicPoints","../function_list.htm#Player_GetStrategicPoints"); menuItem2.addItem("Player_GetTeam","../function_list.htm#Player_GetTeam"); menuItem2.addItem("Player_GetUnitCount","../function_list.htm#Player_GetUnitCount"); menuItem2.addItem("Player_GetUnitSpawnedCount","../function_list.htm#Player_GetUnitSpawnedCount"); menuItem2.addItem("Player_GrantResearch","../function_list.htm#Player_GrantResearch"); menuItem2.addItem("Player_HasBuildingsExcept","../function_list.htm#Player_HasBuildingsExcept"); menuItem2.addItem("Player_HasBuildingType","../function_list.htm#Player_HasBuildingType"); ``` -------------------------------- ### Marker Functions in Scar Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet details Scar functions for interacting with game markers. It includes functions to check for the existence of markers and their attributes (both numeric and string), retrieve markers by name, and get the name of a marker. These are useful for placing and referencing objects or locations in the game world. ```scar menuItem.addItem("Marker ","../function_list.htm#Group_Marker "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Marker_DoesNumberAttributeExist","../function_list.htm#Marker_DoesNumberAttributeExist"); menuItem2.addItem("Marker_DoesStringAttributeExist","../function_list.htm#Marker_DoesStringAttributeExist"); menuItem2.addItem("Marker_Exists","../function_list.htm#Marker_Exists"); menuItem2.addItem("Marker_FromName","../function_list.htm#Marker_FromName"); menuItem2.addItem("Marker_GetName","../function_list.htm#Marker_GetName"); ``` -------------------------------- ### SCAR Strategic Objective Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Functions related to strategic objectives, including getting their counts. These are important for victory conditions and game flow. ```SCAR menuItem2.addItem("World_GetNumStrategicObjectives","../function_list.htm#World_GetNumStrategicObjectives"); ``` -------------------------------- ### Documenting Lua Functions with ScarDoc Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_usingscardoc.htm Demonstrates how to document Lua functions using ScarDoc. It requires type information for arguments and results using '@args' and '@result' tags, alongside a short description with '@shortdesc'. ```lua --? @shortdesc Set the race for a player. --? @extdesc --? The race name must be a valid race name from the attribute editor.\n\n --? This function will return false if the raceName does not exist.\n\n --? This comment will be in a new paragraph. --? @result Void --? @args PlayerID playerID, String raceName --? @refs PlayerRaces.txt, SomeOtherDoc.doc function Player_SetRace( playerID, raceName ) -- end ``` -------------------------------- ### Add and Execute a Simple Lua Rule Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scripting.htm Demonstrates how to add a Lua rule to the game's evaluation queue and define a function that prints 'Hello world!' to the console every frame. The rule is automatically removed after its first execution. ```lua -- add the Rule_HelloWorld to the queue of Rules being evaluated -- here the Rule_HelloWorld function is defined, in the LUA standard Rule_Add( Rule_HelloWorld ) function Rule_HelloWorld() print( "Hello world!" ) end ``` -------------------------------- ### Get Squad From Game ID Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode_nojs.htm Retrieves a squad object using its unique game ID. This is a fundamental function for accessing and manipulating specific squads. ```SCAR *Squad_GetSquadFromGameID ``` -------------------------------- ### SCitE Compilation with F5 for Logic Scripts Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scite.htm For test scripts focusing on logic without game-specific functions, SCitE can compile them using F5. The output is displayed in the Output Window (F8). Ensure files are saved with the .lua extension. ```SCAR/Lua F5 ``` -------------------------------- ### Body Load Event for Menu Initialization Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treecode_ai.htm This code snippet is part of the HTML body tag and specifies a JavaScript function `MTMStartMenu(true)` to be executed when the page finishes loading. This is typically used to initialize or display the menu system configured in the header. ```html ``` -------------------------------- ### Documenting C++ Functions with ScarDoc Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_usingscardoc.htm Illustrates documenting C++ functions with ScarDoc. ScarDoc translates complex C++ type-names into simpler, 'Designer Friendly' names for scriptwriters. It uses '@shortdesc' for a brief description. ```cpp //? @shortdesc Set the race for a player. //? @extdesc //? The race name must be a valid race name from the attribute editor.\n\n //? This function will return false if the raceName does not exist.\n\n //? This comment will be in a new paragraph. //? @refs PlayerRaces.txt, SomeOtherDoc.doc static bool Player_SetRace( Player * playerID, const char * raceName ) { } ``` -------------------------------- ### SCAR Debug Binding Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scripting.htm Includes the SCAR Rule Profiler within the game using a hotkey. This command should be placed in an 'autoexec.lua' file in the Warhammer\Root directory. ```SCAR dofile("Dev/ScarDebugBindings.lua") ``` -------------------------------- ### MTM Menu Initialization and Configuration Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treecode_ai.htm This JavaScript block configures and initializes a menu system (MTM). It sets default target frames, icon paths, menu text, and various behavior properties like submenu display and linking. It also defines how to add menu items and submenus. ```javascript var MTMDefaultTarget = "mainFrame"; // default target frame MTMRootIcon = "menu_link_ref.gif"; // root image MTMenuText = "Warhammer40K"; // root text title MTMSubsGetPlus = "Always"; // always give submenus a +/- sign MTMTimeOut = 0; // time to wait before loading the menu MTMEmulateWE = true; // submenus with a URL act like windows explorer when clicked on MTMLinkedSS = true; // use a linked style sheet MTMSSHREF = "treestyles.css"; // use this as the linked stylesheet //////////////////////////////////////////////////////////////////////////// // User-configurable list of icons. var MTMIconList = null; MTMIconList = new IconList(); //MTMIconList.addIcon(new MTMIcon("menu_pixel.gif", "http://", "pre")); //MTMIconList.addIcon(new MTMIcon("menu_pixel.gif", ".pdf", "post")); //MTMIconList.addIcon(new MTMIcon("menu_pixel.gif", ".html", "post")); //////////////////////////////////////////////////////////////////////////// // User-configurable menu. // create root. var menu = null; menu = new MTMenu(); var menuItem = null; var menuItem2 = null; // menu.addItem("About"); menuItem = null; menuItem = new MTMenu(); menuItem.addItem("Overview","../scar_overview.htm"); menuItem.addItem("Tutorials","../scar_tutorials.htm"); menuItem.addItem("Using ScarDoc","../scar_usingscardoc.htm"); menu.makeLastSubmenu(menuItem, true); delete menuItem; // menu.addItem("Classes"); menuItem = null; menuItem = new MTMenu(); menu.makeLastSubmenu(menuItem, true); delete menuItem; ``` -------------------------------- ### SCAR Initialization Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scripting.htm Functions to manage script initialization. Scar_AddInit registers a Lua function to be called during script initialization, while Scar_RemoveInit unregisters it. These are crucial for setting up game events and logic. ```SCAR Scar_AddInit( LuaFunction func ) ``` ```SCAR Scar_RemoveInit( LuaFunction func ) ``` -------------------------------- ### JavaScript Menu Item Creation Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This JavaScript code demonstrates the creation of menu items and submenus for the Scar documentation. It includes adding items for Scar overview, tutorials, blueprint categories (Entities, Squadrons), and specific functions like Camera and Balance. ```JavaScript menu = new MTMenu(); var menuItem = null; var menuItem2 = null; menuItem = new MTMenu(); menuItem.addItem("Scar"); menuItem.addItem("Overview","../scar_overview.htm"); menuItem.addItem("Tutorials","../scar_tutorials.htm"); menuItem.addItem("Using ScarDoc","../scar_usingscardoc.htm"); menu.makeLastSubmenu(menuItem, true); delete menuItem; menuItem = new MTMenu(); menuItem.addItem("Blueprints"); var eitem = null; eitem = new MTMenu(); eitem.addItem("Entities", "../entity_blueprints.htm"); eitem.addItem("Environment", "../entity_blueprints.htm#Environment"); eitem.addItem("chaos_marine_race", "../entity_blueprints.htm#chaos_marine_race"); // ... other entity items ... menuItem.makeLastSubmenu(eitem, false); delete eitem; menuItem.addItem("Squadrons", "../squad_blueprints.htm"); eitem = null; eitem = new MTMenu(); eitem.addItem("chaos_marine_race", "../squad_blueprints.htm#chaos_marine_race"); // ... other squadron items ... menuItem.makeLastSubmenu(eitem, false); delete eitem; menu.makeLastSubmenu(menuItem, true); delete menuItem; menuItem = new MTMenu(); menuItem.addItem("Functions"); menuItem.addItem("Balance ","../function_list.htm#Group_Balance "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Balance_CreateSquadsAtMarkerByResource","../function_list.htm#Balance_CreateSquadsAtMarkerByResource"); menuItem2.addItem("Balance_SetInit","../function_list.htm#Balance_SetInit"); menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; menuItem.addItem("Camera ","../function_list.htm#Group_Camera "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Camera_FocusOnTargetMarker","../function_list.htm#Camera_FocusOnTargetMarker"); menuItem2.addItem("CameraShake_Large","../function_list.htm#CameraShake_Large"); // ... other camera items ... menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; ``` -------------------------------- ### Event Management Functions in Dawn of War SCAR Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode_nojs.htm Handles game events, allowing for delays, checks on running events, skipping, starting, and timing events. These functions are essential for scripting complex sequences and reactive gameplay. ```SCAR Event_Delay Event_IsAnyRunning Event_IsRunning Event_Skip Event_Start Event_TimeSinceLast ``` -------------------------------- ### Dawn of War SCAR: SCAR Initialization and Loading Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet details SCAR functions for managing the initialization and loading of SCAR scripts, including adding, checking existence, and removing init and load routines. This is vital for script lifecycle management. ```SCAR menuItem2.addItem("Scar_AddInit","../function_list.htm#Scar_AddInit"); menuItem2.addItem("Scar_AddLoad","../function_list.htm#Scar_AddLoad"); menuItem2.addItem("Scar_InitExists","../function_list.htm#Scar_InitExists"); menuItem2.addItem("Scar_LoadExists","../function_list.htm#Scar_LoadExists"); menuItem2.addItem("Scar_RemoveInit","../function_list.htm#Scar_RemoveInit"); menuItem2.addItem("Scar_RemoveLoad","../function_list.htm#Scar_RemoveLoad"); ``` -------------------------------- ### SCitE Compilation with CTRL+F7 Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_scite.htm SCitE can compile scripts using CTRL+F7 to check for formatting errors that would prevent the game from running. This includes checks for missing 'end' statements or unbalanced brackets. ```SCAR/Lua CTRL+F7 ``` -------------------------------- ### Framebuster Script for MSIE Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treecode_ai.htm This script checks if the page is loaded within frames. If it's not (indicated by `parent.frames.length == 0`), it redirects the browser to the root URL of the website to prevent MSIE from bookmarking the individual frame. ```javascript // Framebuster script to relocate browser when MSIE bookmarks this // page instead of the parent frameset. Set variable relocateURL to // the index document of your website (relative URLs are ok): var relocateURL = "/"; if(parent.frames.length == 0) { if(document.images) { location.replace(relocateURL); } else { location = relocateURL; } } ``` -------------------------------- ### Add SCAR Commands to Menu Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet demonstrates how to add various SCAR commands to a menu object in the game's scripting language. It initializes a menu item and then populates it with specific commands. ```SCAR item2; menuItem.addItem("Command ","../function_list.htm#Group_Command "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Cmd_AttachSquads","../function_list.htm#Cmd_AttachSquads"); menuItem2.addItem("Cmd_AttackEGroup","../function_list.htm#Cmd_AttackEGroup"); menuItem2.addItem("Cmd_AttackGroundMarker","../function_list.htm#Cmd_AttackGroundMarker"); menuItem2.addItem("Cmd_AttackGroundPos","../function_list.htm#Cmd_AttackGroundPos"); menuItem2.addItem("Cmd_AttackMoveMarker","../function_list.htm#Cmd_AttackMoveMarker"); menuItem2.addItem("Cmd_AttackMovePos","../function_list.htm#Cmd_AttackMovePos"); menuItem2.addItem("Cmd_AttackSGroup","../function_list.htm#Cmd_AttackSGroup"); menuItem2.addItem("Cmd_Capture","../function_list.htm#Cmd_Capture"); menuItem2.addItem("Cmd_CastAbilityEGroupS","../function_list.htm#Cmd_CastAbilityEGroupS"); menuItem2.addItem("Cmd_CastAbilityMarker","../function_list.htm#Cmd_CastAbilityMarker"); menuItem2.addItem("Cmd_CastAbilityPos","../function_list.htm#Cmd_CastAbilityPos"); menuItem2.addItem("Cmd_CastAbilitySelf","../function_list.htm#Cmd_CastAbilitySelf"); menuItem2.addItem("Cmd_CastAbilitySGroup","../function_list.htm#Cmd_CastAbilitySGroup"); menuItem2.addItem("Cmd_CastAbilitySGroupE","../function_list.htm#Cmd_CastAbilitySGroupE"); menuItem2.addItem("Cmd_ConstructBlueprintMarker","../function_list.htm#Cmd_ConstructBlueprintMarker"); menuItem2.addItem("Cmd_ConstructBlueprintOnEGroup","../function_list.htm#Cmd_ConstructBlueprintOnEGroup"); menuItem2.addItem("Cmd_ConstructBlueprintPos","../function_list.htm#Cmd_ConstructBlueprintPos"); menuItem2.addItem("Cmd_EmptyBuilding","../function_list.htm#Cmd_EmptyBuilding"); menuItem2.addItem("Cmd_EmptyTransport","../function_list.htm#Cmd_EmptyTransport"); menuItem2.addItem("Cmd_EnterBuilding","../function_list.htm#Cmd_EnterBuilding"); menuItem2.addItem("Cmd_EnterTransport","../function_list.htm#Cmd_EnterTransport"); menuItem2.addItem("Cmd_Infiltrate","../function_list.htm#Cmd_Infiltrate"); menuItem2.addItem("Cmd_IsCapturing","../function_list.htm#Cmd_IsCapturing"); menuItem2.addItem("Cmd_IsConstructingBuilding","../function_list.htm#Cmd_IsConstructingBuilding"); menuItem2.addItem("Cmd_IsProducingSquads","../function_list.htm#Cmd_IsProducingSquads"); menuItem2.addItem("Cmd_IsReinforcing","../function_list.htm#Cmd_IsReinforcing"); menuItem2.addItem("Cmd_IsReinforcingLeader","../function_list.htm#Cmd_IsReinforcingLeader"); menuItem2.addItem("Cmd_IsUpgrading","../function_list.htm#Cmd_IsUpgrading"); menuItem2.addItem("Cmd_JumpToMarker","../function_list.htm#Cmd_JumpToMarker"); menuItem2.addItem("Cmd_JumpToPos","../function_list.htm#Cmd_JumpToPos"); menuItem2.addItem("Cmd_MoveToClosestMarker","../function_list.htm#Cmd_MoveToClosestMarker"); menuItem2.addItem("Cmd_MoveToEGroup","../function_list.htm#Cmd_MoveToEGroup"); menuItem2.addItem("Cmd_MoveToMarker","../function_list.htm#Cmd_MoveToMarker"); menuItem2.addItem("Cmd_MoveToSGroup","../function_list.htm#Cmd_MoveToSGroup"); menuItem2.addItem("Cmd_Possesion","../function_list.htm#Cmd_Possesion"); menuItem2.addItem("Cmd_RampageMarker","../function_list.htm#Cmd_RampageMarker"); menuItem2.addItem("Cmd_RampagePos","../function_list.htm#Cmd_RampagePos"); menuItem2.addItem("Cmd_ReinforceLeader","../function_list.htm#Cmd_ReinforceLeader"); menuItem2.addItem("Cmd_ReinforceTrooper","../function_list.htm#Cmd_ReinforceTrooper"); menuItem2.addItem("Cmd_SetMeleeStance","../function_list.htm#Cmd_SetMeleeStance"); menuItem2.addItem("Cmd_SetStance","../function_list.htm#Cmd_SetStance"); menuItem2.addItem("Cmd_StopEntities","../function_list.htm#Cmd_StopEntities"); menuItem2.addItem("Cmd_StopSquads","../function_list.htm#Cmd_StopSquads"); menuItem2.addItem("Command_ConstructBuilding","../function_list.htm#Command_ConstructBuilding"); menuItem2.addItem("Command_Entity","../function_list.htm#Command_Entity"); menuItem2.addItem("Command_EntityAbilityPos","../function_list.htm#Command_EntityAbilityPos"); menuItem2.addItem("Command_EntityAbilitySelf","../function_list.htm#Command_EntityAbilitySelf"); menuItem2.addItem("Command_EntityAbilitySGroup","../function_list.htm#Command_EntityAbilitySGroup"); menuItem2.addItem("Command_EntityBuild","../function_list.htm#Command_EntityBuild"); menuItem2.addItem("Command_EntityEntity","../function_list.htm#Command_EntityEntity"); menuItem2.addItem("Command_EntityPos","../function_list.htm#Command_EntityPos"); menuItem2.addItem("Command_EntityRelocate","../function_list.htm#Command_EntityRelocate"); menuItem2.addItem("Command_EntitySquad","../function_list.htm#Command_EntitySquad"); menuItem2.addItem("Command_HasBeenIssued","../function_list.htm#Command_HasBeenIssued"); menuItem2.addItem("Command_HasBeenIssuedSquad","../function_list.htm#Command_HasBeenIssuedSquad"); menuItem2.addItem("Command_Squad ``` -------------------------------- ### Grouping Functions with ScarDoc's @group Tag Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_usingscardoc.htm Shows how to categorize functions into named subgroups using the '@group' tag in ScarDoc. Functions listed after a '@group' tag are added to that group. If no group is specified, functions fall under the 'Various' group. ```cpp /* In this example "Group1" will contain Function1 and Function2, "Group2" will contain Function3 and Function4. Function0 will be added to "Various" */ //? @shortdesc Function0 description. static void Function0( ){} //? @group Group1 //? @shortdesc Function1 description. static void Function1( ){} //? @shortdesc Function2 description. static void Function2( ){} //? @group Group2 //? @shortdesc Function3 description. static void Function3( ){} //? @shortdesc Function4 description. static void Function4( ){} ``` -------------------------------- ### JavaScript Menu Tree Configuration Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This JavaScript code configures a dynamic menu tree for the Scar documentation. It sets various properties for menu appearance and behavior, including icons, text, and submenu display options. ```JavaScript MTMDefaultTarget = "mainFrame"; // default target frame MTMRootIcon = "menu_link_ref.gif"; // root image MTMenuText = "Warhammer40K"; // root text title MTMSubsGetPlus = "Always"; // always give submenus a +/- sign MTMTimeOut = 0; // time to wait before loading the menu MTMEmulateWE = true; // submenus with a URL act like windows explorer when clicked on MTMLinkedSS = true; // use a linked style sheet MTMSHREF = "treestyles.css"; // use this as the linked stylesheet var MTMIconList = null; MTMIconList = new IconList(); ``` -------------------------------- ### Scar: Entity Functions for Creation and Management Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet lists Scar functions for creating and managing individual game entities. It includes functions for spawning, despawning, destroying, and forcing add-ons onto entities, as well as retrieving entity properties like blueprint ID, health, and owner. ```Scar menuItem2.addItem("Entity_CanSeeEntity","../function_list.htm#Entity_CanSeeEntity"); menuItem2.addItem("Entity_CanSeeSquad","../function_list.htm#Entity_CanSeeSquad"); menuItem2.addItem("Entity_ContainsAddOn","../function_list.htm#Entity_ContainsAddOn"); menuItem2.addItem("Entity_Create","../function_list.htm#Entity_Create"); menuItem2.addItem("Entity_CreateBuildingMarker","../function_list.htm#Entity_CreateBuildingMarker"); menuItem2.addItem("Entity_CreateBuildingPosition","../function_list.htm#Entity_CreateBuildingPosition"); menuItem2.addItem("Entity_CreateBuildingPositionForce","../function_list.htm#Entity_CreateBuildingPositionForce"); menuItem2.addItem("Entity_DeSpawn","../function_list.htm#Entity_DeSpawn"); menuItem2.addItem("Entity_Destroy","../function_list.htm#Entity_Destroy"); menuItem2.addItem("Entity_ForceAddOn","../function_list.htm#Entity_ForceAddOn"); menuItem2.addItem("Entity_FromWorldID","../function_list.htm#Entity_FromWorldID"); menuItem2.addItem("Entity_GetActiveCommand","../function_list.htm#Entity_GetActiveCommand"); menuItem2.addItem("Entity_GetBlueprintID","../function_list.htm#Entity_GetBlueprintID"); menuItem2.addItem("Entity_GetBlueprintIDFromName","../function_list.htm#Entity_GetBlueprintIDFromName"); menuItem2.addItem("Entity_GetBlueprintName","../function_list.htm#Entity_GetBlueprintName"); menuItem2.addItem("Entity_GetBuildingProgress","../function_list.htm#Entity_GetBuildingProgress"); menuItem2.addItem("Entity_GetCoverType","../function_list.htm#Entity_GetCoverType"); menuItem2.addItem("Entity_GetGameID","../function_list.htm#Entity_GetGameID"); menuItem2.addItem("Entity_GetHealth","../function_list.htm#Entity_GetHealth"); menuItem2.addItem("Entity_GetHealthInvulnerable","../function_list.htm#Entity_GetHealthInvulnerable"); menuItem2.addItem("Entity_GetHealthMax","../function_list.htm#Entity_GetHealthMax"); menuItem2.addItem("Entity_GetPlayerOwner","../function_list.htm#Entity_GetPlayerOwner"); menuItem2.addItem("Entity_GetPosition","../function_list.htm#Entity_GetPosition"); menuItem2.addItem("Entity_GetProductionQueueItemName","../function_list.htm#Entity_GetProductionQueueItemName"); menuItem2.addItem("Entity_GetProductionQueueItemType","../function_list.htm#Entity_GetProductionQueueItemType"); menuItem2.addItem("Entity_GetProductionQueueSize","../function_list.htm#Entity_GetProductionQueueSize"); menuItem2.addItem("Entity_GetSquad","../function_list.htm#Entity_GetSquad"); menuItem2.addItem("Entity_GetWorldOwner","../function_list.htm#Entity_GetWorldOwner"); menuItem2.addItem("Entity_HasProductionQueue","../function_list.htm#Entity_HasProductionQueue"); menuItem2.addItem("Entity_HasSquad","../function_list.htm#Entity_HasSquad"); menuItem2.addItem("Entity_IsAbilityActive","../function_list.htm#Entity_IsAbilityActive"); menuItem2.addItem("Entity_IsBuilding","../function_list.htm#Entity_IsBuilding"); menuItem2.addItem("Entity_IsCapturedByPlayer","../function_list.htm#Entity_IsCapturedByPlayer"); menuItem2.addItem("Entity_IsInCover","../function_list.htm#Entity_IsInCover"); menuItem2.a ``` -------------------------------- ### SCAR World Geometry and Position Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Offers functions for calculating distances between points and entities, and finding spawnable positions. These are used for pathfinding, unit placement, and collision detection. ```SCAR menuItem2.addItem("World_DistanceEGroupToPoint","../function_list.htm#World_DistanceEGroupToPoint"); menuItem2.addItem("World_DistancePointToPoint","../function_list.htm#World_DistancePointToPoint"); menuItem2.addItem("World_DistanceSGroupToPoint","../function_list.htm#World_DistanceSGroupToPoint"); menuItem2.addItem("World_GetSpawnablePosition","../function_list.htm#World_GetSpawnablePosition"); ``` -------------------------------- ### SCAR Build Zone Management Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Functions for managing build zones, including setting positions, removing them, and marking them as no-build areas. ```SCAR menuItem2.addItem("W40k_NoBuildZoneMarker","../function_list.htm#W40k_NoBuildZoneMarker"); menuItem2.addItem("W40k_NoBuildZonePosition","../function_list.htm#W40k_NoBuildZonePosition"); menuItem2.addItem("W40k_NoBuildZoneRemove","../function_list.htm#W40k_NoBuildZoneRemove"); ``` -------------------------------- ### Dawn of War Scar: AI Class Preferences Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet demonstrates how to set AI class preferences in Dawn of War using Scar. It includes functions to set build demand, building limits, and difficulty. ```Scar setClassPreferences"); menuItem2.addItem("Cpu_SetBuildDemand","../function_list.htm#Cpu_SetBuildDemand"); menuItem2.addItem("Cpu_SetBuildingLimit","../function_list.htm#Cpu_SetBuildingLimit"); menuItem2.addItem("Cpu_SetBuildingLimitsTable","../function_list.htm#Cpu_SetBuildingLimitsTable"); menuItem2.addItem("Cpu_SetBuildTable","../function_list.htm#Cpu_SetBuildTable"); menuItem2.addItem("Cpu_SetClassPreference","../function_list.htm#Cpu_SetClassPreference"); menuItem2.addItem("Cpu_SetDifficultyForDummies","../function_list.htm#Cpu_SetDifficultyForDummies"); menuItem2.addItem("Cpu_SetLippy","../function_list.htm#Cpu_SetLippy"); menuItem2.addItem("Cpu_SetMaxPercentage","../function_list.htm#Cpu_SetMaxPercentage"); menuItem2.addItem("Cpu_UnlockAll","../function_list.htm#Cpu_UnlockAll"); menuItem2.addItem("Cpu_UnlockEGroup","../function_list.htm#Cpu_UnlockEGroup"); menuItem2.addItem("Cpu_UnlockEGroupAcrossPlayers","../function_list.htm#Cpu_UnlockEGroupAcrossPlayers"); menuItem2.addItem("Cpu_UnlockEntity","../function_list.htm#Cpu_UnlockEntity"); menuItem2.addItem("Cpu_UnlockSGroup","../function_list.htm#Cpu_UnlockSGroup"); menuItem2.addItem("Cpu_UnlockSGroupAcrossPlayers","../function_list.htm#Cpu_UnlockSGroupAcrossPlayers"); menuItem2.addItem("Cpu_UnlockSquad","../function_list.htm#Cpu_UnlockSquad"); menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; menuItem.addItem("Entity ","../function_list.htm#Group_Entity "); ``` -------------------------------- ### SCAR Building and Squad Data Retrieval Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm Provides functions to retrieve counts and names of possible buildings and squads. This information is useful for UI elements like build menus or unit production queues. ```SCAR menuItem2.addItem("World_GetPossibleBuildingsCount","../function_list.htm#World_GetPossibleBuildingsCount"); menuItem2.addItem("World_GetPossibleBuildingsName","../function_list.htm#World_GetPossibleBuildingsName"); menuItem2.addItem("World_GetPossibleSquadsCount","../function_list.htm#World_GetPossibleSquadsCount"); menuItem2.addItem("World_GetPossibleSquadsName","../function_list.htm#World_GetPossibleSquadsName"); ``` -------------------------------- ### Production Management Functions in JavaScript Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This snippet lists JavaScript functions for managing production queues and construction status in Dawn of War. It includes functions for adding items to production lists, checking production status, and retrieving player-specific production data. These functions are crucial for controlling unit and upgrade production. ```javascript menuItem.addItem("Production ","../function_list.htm#Group_Production "); menuItem2 = null; menuItem2 = new MTMenu(); menuItem2.addItem("Prod_AddAddOnToList","../function_list.htm#Prod_AddAddOnToList"); menuItem2.addItem("Prod_AddResearchToList","../function_list.htm#Prod_AddResearchToList"); menuItem2.addItem("Prod_AddSquadToList","../function_list.htm#Prod_AddSquadToList"); menuItem2.addItem("Prod_DoesListContainAddOn","../function_list.htm#Prod_DoesListContainAddOn"); menuItem2.addItem("Prod_DoesListContainResearch","../function_list.htm#Prod_DoesListContainResearch"); menuItem2.addItem("Prod_DoesListContainSquad","../function_list.htm#Prod_DoesListContainSquad"); menuItem2.addItem("Prod_GetPlayerProductionList","../function_list.htm#Prod_GetPlayerProductionList"); menuItem2.addItem("Prod_GetProductionList","../function_list.htm#Prod_GetProductionList"); menuItem2.addItem("Prod_IsPlayerConstructing","../function_list.htm#Prod_IsPlayerConstructing"); menuItem2.addItem("Prod_IsPlayerProducing","../function_list.htm#Prod_IsPlayerProducing"); menuItem2.addItem("Prod_IsProducing","../function_list.htm#Prod_IsProducing"); menuItem.makeLastSubmenu(menuItem2, false); delete menuItem2; ``` -------------------------------- ### Control Event Flow with Controller Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/scar_overview_event_system.htm Illustrates the use of controller functions prefixed with 'CTRL.' and 'CTRL.WAIT()' to enforce a linear execution order for game events. CTRL.WAIT() pauses execution until preceding functions complete. ```lua CTRL.Speech_Play( "Hello" ) CTRL.WAIT( ) CTRL.Event_Delay( 2 ) CTRL.WAIT( ) CTRL.Speech_Play( "How are you?" ) CTRL.WAIT() ``` -------------------------------- ### SCAR Miscellaneous Utility Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm A collection of utility functions for various game-related tasks, including checking mouse-over status, assigning hotkey groups, and enabling player-to-player Fog of War. ```SCAR menuItem2.addItem("Misc_IsMouseOverEntity","../function_list.htm#Misc_IsMouseOverEntity"); menuItem2.addItem("W40k_AssignHotkeyEGroup","../function_list.htm#W40k_AssignHotkeyEGroup"); menuItem2.addItem("W40k_AssignHotkeySGroup","../function_list.htm#W40k_AssignHotkeySGroup"); menuItem2.addItem("World_EnablePlayerToPlayerFOW","../function_list.htm#World_EnablePlayerToPlayerFOW"); ``` -------------------------------- ### Dawn of War SCAR: CPU Interface Functions Source: https://github.com/cannibaltoast/dawn-of-war-scar/blob/main/treeview/treecode.htm This section describes SCAR functions related to the CPU (AI) interface, covering actions like assigning waypoints, managing building limits, enabling/disabling components, forcing attacks, and setting AI difficulty. These functions are key for AI behavior scripting. ```SCAR menuItem2.addItem("Cpu_AssignWaypoint","../function_list.htm#Cpu_AssignWaypoint"); menuItem2.addItem("Cpu_ClearBuildingLimits","../function_list.htm#Cpu_ClearBuildingLimits"); menuItem2.addItem("Cpu_CounterVictoryObj","../function_list.htm#Cpu_CounterVictoryObj"); menuItem2.addItem("Cpu_DoString","../function_list.htm#Cpu_DoString"); menuItem2.addItem("Cpu_Enable","../function_list.htm#Cpu_Enable"); menuItem2.addItem("Cpu_EnableAll","../function_list.htm#Cpu_EnableAll"); menuItem2.addItem("Cpu_EnableComponent","../function_list.htm#Cpu_EnableComponent"); menuItem2.addItem("Cpu_ForceAttack","../function_list.htm#Cpu_ForceAttack"); menuItem2.addItem("Cpu_GetDifficulty","../function_list.htm#Cpu_GetDifficulty"); menuItem2.addItem("Cpu_IsCpuPlayer","../function_list.htm#Cpu_IsCpuPlayer"); menuItem2.addItem("Cpu_IsDebugging","../function_list.htm#Cpu_IsDebugging"); menuItem2.addItem("Cpu_IsEnabled","../function_list.htm#Cpu_IsEnabled"); menuItem2.addItem("Cpu_LockEGroup","../function_list.htm#Cpu_LockEGroup"); menuItem2.addItem("Cpu_LockEGroupAcrossPlayers","../function_list.htm#Cpu_LockEGroupAcrossPlayers"); menuItem2.addItem("Cpu_LockEntity","../function_list.htm#Cpu_LockEntity"); menuItem2.addItem("Cpu_LockSGroup","../function_list.htm#Cpu_LockSGroup"); menuItem2.addItem("Cpu_LockSGroupAcrossPlayers","../function_list.htm#Cpu_LockSGroupAcrossPlayers"); menuItem2.addItem("Cpu_LockSquad","../function_list.htm#Cpu_LockSquad"); menuItem2.addItem("Cpu_ResetBuildTable","../function_list.htm#Cpu_ResetBuildTable"); menuItem2.addItem("Cpu_ResetClassPreferences","../function_list.htm#Cpu_ResetClassPreferences"); ```