Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.61 KB | None | 0 0
  1. dofile([[C:\Program Files\Steam\steamapps\common\dawn of war 2\test\Macros\lua\utils.lua]])
  2.  
  3. modname = [[test]]
  4. base = [[C:\Program Files\Steam\steamapps\common\dawn of war 2\]] .. modname .. [[\DataAttrib\simulation\attrib\]]
  5. output = io.open("spawn_squads_info.txt", "w+")
  6.  
  7. -- table with all details in it
  8. local UCS_start = 0
  9. local tier2 = [[upgrade\_game\menu\tier_2]]
  10. local tier3 = [[upgrade\_game\menu\tier_3]]
  11. local backIcon = [[icon]]
  12. local BackUCS1, BackUCS2 = 12124234,134235
  13. local spawnBuildings = {space_marines = [[ebps\_space_marines\buildings\spawn_beacon.rbf]]}
  14.  
  15. local t =
  16. {
  17.     Menus =
  18.     {
  19.         top_level =
  20.         {
  21.             baseSavePath = base .. [[sbps\_game\menu\]],
  22.             relativePath = [[_game\menu\]],
  23.             iconPath = [[]],
  24.             {"hq", tier1, 1, [[icon]]},
  25.             {"troop",tier1, 2, [[icon]]},
  26.             {"elite",tier1, 3, [[icon]]},
  27.             {"fast_attack",tier1, 4, [[icon]]},
  28.             {"heavy_support",tier1, 5, [[icon]]},
  29.         },
  30.     },
  31.     Units = {
  32.     space_marines =
  33.     {
  34.         relativePath = [[sbps\_space_marines\menu]],
  35.         {"tactical_space_marines", "troop", [[icon]]},
  36.         {"scout_marines", "troop", [[icon]]},
  37.         {"captain", "hq", [[icon]]},
  38.     },
  39. },
  40. }
  41. local ucs = {}
  42.  
  43. function create_base_squad_file(file)
  44.     -- add the tables we need
  45.     local top = file.GameData
  46.     local topT = file._TYPE.GameData
  47.    
  48.    
  49.     -- squad_loadout_ext
  50.     top.squad_loadout_ext, topT.squad_loadout_ext = refrence([[squad_extentions\squad_loadout_ext]])
  51.     top.squad_loadout_ext.squad_type = [[scout_marine]]
  52.    
  53.    
  54.     -- adding the unit
  55.     local info = {"squad_loadout_unit_entry" ,["type"] = [[ebps\_game\invisible_entity]]}
  56.     local files = {top.squad_loadout_ext.unit_list, topT.squad_loadout_ext.unit_list}
  57.     insert_entry([[entries\unit_list\squad_loadout_unit_entry]], files, info)
  58.    
  59.     -- squad requirments
  60.     top.squad_requirement_ext, topT.squad_requirement_ext = refrence([[squad_extentions\squad_requirement_ext]])
  61.    
  62.    
  63.     -- squad_UI
  64.     top.squad_ui_ext, topT.squad_ui_ext = refrence([[squad_extentions\squad_ui_ext]])
  65.    
  66.     -- add formation
  67.     top.squad_formation_ext, topT.squad_formation_ext = refrence([[squad_extentions\squad_formation_ext]])
  68.    
  69.     -- add combat AI (to stop fatal AI errors)
  70.     top.squad_combat_behaviour_ext, topT.squad_combat_behaviour_ext = refrence([[squad_extentions\squad_combat_behaviour_ext]])
  71.    
  72.    
  73. end
  74.  
  75. -- create the tier upgrades
  76. for r = 2, 3 do
  77.     --load blank file
  78.     local upg = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  79.     local top, topT = Shorten(upg)
  80.     -- add the bag
  81.     top.upgrade_bag, topT.upgrade_bag = refrence([[bags\upgrade_bag]])
  82.     -- insert the multiplayer stuff
  83.     local files = {top.upgrade_bag.multiplayer_usage, topT.upgrade_bag.multiplayer_usage}
  84.    
  85.     local info = {[[tech_tier]], r}
  86.     insert_entry([[entries\upgrade_bag\multiplayer_usage\tech_tier]], files, info)
  87.    
  88.     local info = {[[button_index]], 1}
  89.     insert_entry([[entries\upgrade_bag\multiplayer_usage\button_index]], files, info)
  90.    
  91.     local path = tier2
  92.     if r == 3 then
  93.         path = tier3
  94.     end
  95.    
  96.     local save = base .. path .. [[.rbf]]
  97.     --compiler_make_rbf(upg, save)
  98.    
  99. end
  100.  
  101.  
  102.  
  103. local UCS1, UCS2
  104. local openUPGS = {}
  105. -- first make the menus
  106. output:write([[Menus]] .. "\n\n")
  107. for k,v in pairs(t.Menus) do
  108.     for i = 1, table.getn(v) do
  109.         -- first we need to make ALL the open upgs
  110.         -- load blank file
  111.         openUpgrade = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  112.         -- create the base file
  113.         openUpgrade.GameData.upgrade_bag, openUpgrade._TYPE.GameData.upgrade_bag = refrence([[bags\upgrade_bag]])
  114.         -- create its path
  115.         local upgRelative = [[upgrade\]] .. v.relativePath .. v[i][1] .. [[_open]]
  116.         local upgSavePath = base .. upgRelative .. [[.rbf]]
  117.        
  118.         -- insert into table
  119.         openUPGS[v[i][1]] = {save = upgSavePath, relative = upgRelative}
  120.         -- create upg
  121.         compiler_make_rbf(openUpgrade, upgSavePath)
  122.        
  123.         -- create ability that removes upg
  124.         -- again load the blank file and lets start from scratch
  125.         removeAbility = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  126.         top, topT = Shorten(removeAbility)
  127.         -- now add the base extentions or in this case bag
  128.         top.ability_bag, topT.ability_bag = refrence([[bags\ability_bag]])
  129.        
  130.         -- setup some options
  131.         top.ability_bag.castable_in_buildings_or_holds = true
  132.         top.ability_bag.activation = "timed"
  133.         top.ability_bag.casters_can_evacuate = true
  134.         -- add the action
  135.         local files = {top.ability_bag.action_list.start_self_actions, topT.ability_bag.action_list.start_self_actions}
  136.         info = {"upgrade_remove", upgrade = upgRelative}
  137.         insert_entry([[actions\upgrade_remove]], files, info)
  138.        
  139.        
  140.         -- all done, now save
  141.         openUPGS[v[i][1]].ability = [[ability\]] .. v.relativePath .. v[i][1] .. [[_remove]]
  142.         --compiler_make_rbf(removeAbility, base .. openUPGS[v[i][1]].ability .. [[.rbf]])
  143.        
  144.     end
  145.     for i = 1, table.getn(v) do
  146.         if not UCS2 then
  147.             UCS1 = UCS_start
  148.             UCS2 = UCS1 + 1
  149.             UCS_start = UCS_start + 2
  150.         else
  151.             UCS1 = UCS2 + 1
  152.             UCS2 = UCS1 + 1
  153.             UCS_start = UCS_start + 2
  154.         end
  155.        
  156.         -- load up the blank_file
  157.         squadFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  158.        
  159.         -- create the base
  160.         create_base_squad_file(squadFile)
  161.        
  162.         local top = squadFile.GameData
  163.         local topT = squadFile._TYPE.GameData
  164.         -- add the tier requirement if needed
  165.         if v[i][2] then
  166.            
  167.         end
  168.        
  169.         -- set screen position
  170.         top.squad_ui_ext.ui_group_position = v[i][3]
  171.         top.squad_ui_ext.build_button_index = v[i][3]
  172.         -- add icon path
  173.         top.squad_ui_ext.icon_name = v[i][4]
  174.         -- add UCS entries
  175.         top.squad_ui_ext.squad_name = UCS1
  176.         top.squad_ui_ext.screen_name = UCS1
  177.         top.squad_ui_ext.help_text = UCS2
  178.        
  179.        
  180.         -- loop through the created open UPGS and have it require NON of them to be present
  181.         for menuName,value in pairs(openUPGS) do
  182.             -- insert a requirement into the sbps
  183.             local info =
  184.             {
  185.                 "required_player_upgrade",
  186.                 is_present = false,
  187.                 reason = [[display_and_usage_and_produce]],
  188.                 upgrade_name = value.relative
  189.             }
  190.             local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
  191.             insert_entry([[requirements\required_player_upgrade]], files, info)
  192.         end
  193.        
  194.         -- create file
  195.         local savePath = v.baseSavePath .. v[i][1] .. [[.rbf]]
  196.         --compiler_make_rbf(squadFile, savePath)
  197.        
  198.        
  199.         -- create back squad
  200.        
  201.         -- load up blank file
  202.         backSquadFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  203.         -- create the base
  204.         create_base_squad_file(backSquadFile)
  205.        
  206.         local top, topT = Shorten(backSquadFile)
  207.        
  208.         -- back icons will be teir 3, pos 5
  209.         -- set screen position
  210.         top.squad_ui_ext.ui_group_position = 5
  211.         top.squad_ui_ext.build_button_index = 6
  212.         -- add icon path
  213.         top.squad_ui_ext.icon_name = backIcon
  214.         -- add UCS entries
  215.         top.squad_ui_ext.squad_name = BackUCS1
  216.         top.squad_ui_ext.screen_name = BackUCS1
  217.         top.squad_ui_ext.help_text = BackUCS2
  218.        
  219.         -- to show up it needs its corresponding open upg to be present
  220.         -- also add requirement for tier 3 upgrade
  221.         local names = {{tier3, [[usage_and_produce]]}, {openUPGS[v[i][1]].relative, [[display_and_usage_and_produce]]}}
  222.         for f = 1, table.getn(names) do
  223.             print(names[f][1])
  224.             local info =
  225.             {
  226.                 "required_player_upgrade",
  227.                 is_present = true,
  228.                 reason = names[f][2],
  229.                 upgrade_name = names[f][1]
  230.             }
  231.             local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
  232.             insert_entry([[requirements\required_player_upgrade]], files, info)
  233.         end
  234.        
  235.         local backRPath = [[sbps\]] .. v.relativePath .. v[i][1] .. [[_back]]
  236.         local backPath = v.baseSavePath .. v[i][1] .. [[_back.rbf]]
  237.         --compiler_make_rbf(backSquadFile, backPath)
  238.        
  239.        
  240.         -- now loop throught the spawn buildings and add these two squads to its spawner
  241.         for s,building in pairs(spawnBuildings) do
  242.             local buildingFile = compiler_load_rbf([[::simulation\attrib\]] .. building)
  243.             local top, topT = Shorten(buildingFile)
  244.            
  245.             local names = {backRPath, [[sbps\]] .. v.relativePath .. v[i][1]}
  246.             for f = 1, table.getn(names) do
  247.                 local info =
  248.                 {
  249.                     "squad",
  250.                     names[f]
  251.                 }
  252.                 local files = {top.spawner_ext.squad_table, topT.spawner_ext.squad_table}
  253.                 insert_entry([[entries\squad_table\squad]], files, info)
  254.             end
  255.            
  256.             -- and save the file again
  257.             --compiler_make_rbf(buildingFile, base .. building)
  258.         end
  259.        
  260.        
  261.        
  262.         -- add entry to output tieing the spawn squad with the upgrade
  263.         -- and another entry tieing the remove squad with the remove ability
  264.         local s = "[\"sbps\\\\" .. string.gsub(v.relativePath, [[\]], [[\\]]) .. v[i][1] .. "\"] = {[[upgrade]], World_GetPropertyBagGroupID([[" .. openUPGS[v[i][1]].relative .. "]])}, \n"
  265.         s = s .. "[\"" .. string.gsub(backRPath, [[\]], [[\\]]) .. "\"] = {[[ability]], World_GetPropertyBagGroupID([[" ..  openUPGS[v[i][1]].ability .. "]])},\n\n"
  266.        
  267.         --print(s)
  268.        
  269.         output:write(s)
  270.         --output:flush()
  271.     end
  272. end
  273.  
  274. -- now do all the units
  275. -- set up the UCS numbers
  276. local tabs =
  277. {
  278.     "hq",
  279.     "troop",
  280.     "elite",
  281.     "fast_attack",
  282.     "heavy_support",
  283. }
  284.  
  285. for k,v in pairs(tabs) do
  286.     if not tabs[v] then
  287.         tabs[v] = {}
  288.     end
  289.    
  290.     for tier = 1, 3 do
  291.         for pos = 1, 6 do
  292.             local name = tostring(tier) .. "x" .. tostring(pos)
  293.             local ucs1 = UCS_start + 1
  294.             local UCS2 = ucs1 + 1
  295.             UCS_start = UCS_start + 2
  296.            
  297.             tabs[v][name] = {ucs1, ucs2}
  298.            
  299.             if tier == 3 and pos == 6 then
  300.                 -- this is where the back icon goes.
  301.                 tabs[v][name] = nil
  302.             end
  303.         end
  304.     end
  305. end
  306.  
  307. --[[
  308. space_marines =
  309. {
  310.     basePath = base .. sbps\_space_marines\menu,
  311.     iconPath = ,
  312.     {"tactical_space_marines", "troop"},
  313.     {"scout_marines", "troop"},
  314.     {"captain", "hq", ""},
  315. },
  316. ]]
  317.  
  318. output:write("\n" .. [[Units]] .. "\n\n")
  319. for race, value in pairs(t.Units) do
  320.     output:write(race .. "\n\n")
  321.    
  322.     -- load the blank file and set the basics
  323.     local unitFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
  324.     create_base_squad_file(unitFile)
  325.    
  326.     local top, topT = Shorten(unitFile)
  327.    
  328.     for i = 1, table.getn(value) do
  329.         local name = value[i][1]
  330.         local unitType = value[i][2]
  331.         local icon = value[i][3]
  332.        
  333.         for tier = 1, 3 do
  334.             for pos = 1, 6 do
  335.                 local grid = tostring(tier) .. "x" .. tostring(pos)
  336.                 if grid ~= "3x6" then
  337.                    
  338.                     -- do some edits
  339.                     top.squad_ui_ext.build_button_index = pos
  340.                     top.squad_ui_ext.icon_name = icon
  341.                     top.squad_ui_ext.screen_name = tabs[unitType][grid][1]
  342.                     top.squad_ui_ext.squad_name = tabs[unitType][grid][1]
  343.                     top.squad_ui_ext.help_text = tabs[unitType][grid][2]
  344.                    
  345.                     -- depending of their teir, they may need 1 or 2 upgrades as requirement
  346.                     local upgs = {}
  347.                     if tier == 1 then
  348.                         upgs = {{openUPGS[unitType].relative, [[usage_and_produce]]}}
  349.                     elseif tier == 2 then
  350.                         upgs = {{tier2, [[usage_and_produce]]}, {openUPGS[unitType].relative, [[usage_and_produce]]}}
  351.                     else
  352.                         upgs = {{tier3, [[usage_and_produce]]}, {openUPGS[unitType].relative, [[usage_and_produce]]}}
  353.                     end
  354.                    
  355.                     for f = 1, table.getn(upgs) do
  356.                         local info =
  357.                         {
  358.                             "required_player_upgrade",
  359.                             is_present = true,
  360.                             reason = upgs[f][2],
  361.                             upgrade_name = upgs[f][1]
  362.                         }
  363.                         local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
  364.                         insert_entry([[requirements\required_player_upgrade]], files, info)
  365.                     end
  366.                    
  367.                     -- save it
  368.                     local rPath = value.relativePath .. [[\]] .. name .. [[\]] .. grid
  369.                     local path = base .. rPath .. [[.rbf]]
  370.                     print(path)
  371.                    
  372.                     compiler_make_rbf(unitFile, path)
  373.                    
  374.                     -- add to spawn building
  375.                     -- open up spawn building
  376.                     local spawn = compiler_load_rbf([[::simulation\attrib\]] .. spawnBuildings[race])
  377.                     local spawnBuilding, spawnBuildingT = Shorten(spawn)
  378.                     local info =
  379.                     {
  380.                         "squad",
  381.                         rPath,
  382.                     }
  383.                     local files = {spawnBuilding.spawner_ext.squad_table, spawnBuildingT.spawner_ext.squad_table}
  384.                     insert_entry([[entries\squad_table\squad]], files, info)
  385.                    
  386.                     -- save spawn building
  387.                     compiler_make_rbf(spawn, base .. spawnBuildings[race])
  388.                    
  389.                 end
  390.             end
  391.         end
  392.     end
  393.    
  394. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement