Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile([[C:\Program Files\Steam\steamapps\common\dawn of war 2\test\Macros\lua\utils.lua]])
- modname = [[test]]
- base = [[C:\Program Files\Steam\steamapps\common\dawn of war 2\]] .. modname .. [[\DataAttrib\simulation\attrib\]]
- output = io.open("spawn_squads_info.txt", "w+")
- -- table with all details in it
- local UCS_start = 0
- local tier2 = [[upgrade\_game\menu\tier_2]]
- local tier3 = [[upgrade\_game\menu\tier_3]]
- local backIcon = [[icon]]
- local BackUCS1, BackUCS2 = 12124234,134235
- local spawnBuildings = {space_marines = [[ebps\_space_marines\buildings\spawn_beacon.rbf]]}
- local t =
- {
- Menus =
- {
- top_level =
- {
- baseSavePath = base .. [[sbps\_game\menu\]],
- relativePath = [[_game\menu\]],
- iconPath = [[]],
- {"hq", tier1, 1, [[icon]]},
- {"troop",tier1, 2, [[icon]]},
- {"elite",tier1, 3, [[icon]]},
- {"fast_attack",tier1, 4, [[icon]]},
- {"heavy_support",tier1, 5, [[icon]]},
- },
- },
- Units = {
- space_marines =
- {
- relativePath = [[sbps\_space_marines\menu]],
- {"tactical_space_marines", "troop", [[icon]]},
- {"scout_marines", "troop", [[icon]]},
- {"captain", "hq", [[icon]]},
- },
- },
- }
- local ucs = {}
- function create_base_squad_file(file)
- -- add the tables we need
- local top = file.GameData
- local topT = file._TYPE.GameData
- -- squad_loadout_ext
- top.squad_loadout_ext, topT.squad_loadout_ext = refrence([[squad_extentions\squad_loadout_ext]])
- top.squad_loadout_ext.squad_type = [[scout_marine]]
- -- adding the unit
- local info = {"squad_loadout_unit_entry" ,["type"] = [[ebps\_game\invisible_entity]]}
- local files = {top.squad_loadout_ext.unit_list, topT.squad_loadout_ext.unit_list}
- insert_entry([[entries\unit_list\squad_loadout_unit_entry]], files, info)
- -- squad requirments
- top.squad_requirement_ext, topT.squad_requirement_ext = refrence([[squad_extentions\squad_requirement_ext]])
- -- squad_UI
- top.squad_ui_ext, topT.squad_ui_ext = refrence([[squad_extentions\squad_ui_ext]])
- -- add formation
- top.squad_formation_ext, topT.squad_formation_ext = refrence([[squad_extentions\squad_formation_ext]])
- -- add combat AI (to stop fatal AI errors)
- top.squad_combat_behaviour_ext, topT.squad_combat_behaviour_ext = refrence([[squad_extentions\squad_combat_behaviour_ext]])
- end
- -- create the tier upgrades
- for r = 2, 3 do
- --load blank file
- local upg = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- local top, topT = Shorten(upg)
- -- add the bag
- top.upgrade_bag, topT.upgrade_bag = refrence([[bags\upgrade_bag]])
- -- insert the multiplayer stuff
- local files = {top.upgrade_bag.multiplayer_usage, topT.upgrade_bag.multiplayer_usage}
- local info = {[[tech_tier]], r}
- insert_entry([[entries\upgrade_bag\multiplayer_usage\tech_tier]], files, info)
- local info = {[[button_index]], 1}
- insert_entry([[entries\upgrade_bag\multiplayer_usage\button_index]], files, info)
- local path = tier2
- if r == 3 then
- path = tier3
- end
- local save = base .. path .. [[.rbf]]
- --compiler_make_rbf(upg, save)
- end
- local UCS1, UCS2
- local openUPGS = {}
- -- first make the menus
- output:write([[Menus]] .. "\n\n")
- for k,v in pairs(t.Menus) do
- for i = 1, table.getn(v) do
- -- first we need to make ALL the open upgs
- -- load blank file
- openUpgrade = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- -- create the base file
- openUpgrade.GameData.upgrade_bag, openUpgrade._TYPE.GameData.upgrade_bag = refrence([[bags\upgrade_bag]])
- -- create its path
- local upgRelative = [[upgrade\]] .. v.relativePath .. v[i][1] .. [[_open]]
- local upgSavePath = base .. upgRelative .. [[.rbf]]
- -- insert into table
- openUPGS[v[i][1]] = {save = upgSavePath, relative = upgRelative}
- -- create upg
- compiler_make_rbf(openUpgrade, upgSavePath)
- -- create ability that removes upg
- -- again load the blank file and lets start from scratch
- removeAbility = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- top, topT = Shorten(removeAbility)
- -- now add the base extentions or in this case bag
- top.ability_bag, topT.ability_bag = refrence([[bags\ability_bag]])
- -- setup some options
- top.ability_bag.castable_in_buildings_or_holds = true
- top.ability_bag.activation = "timed"
- top.ability_bag.casters_can_evacuate = true
- -- add the action
- local files = {top.ability_bag.action_list.start_self_actions, topT.ability_bag.action_list.start_self_actions}
- info = {"upgrade_remove", upgrade = upgRelative}
- insert_entry([[actions\upgrade_remove]], files, info)
- -- all done, now save
- openUPGS[v[i][1]].ability = [[ability\]] .. v.relativePath .. v[i][1] .. [[_remove]]
- --compiler_make_rbf(removeAbility, base .. openUPGS[v[i][1]].ability .. [[.rbf]])
- end
- for i = 1, table.getn(v) do
- if not UCS2 then
- UCS1 = UCS_start
- UCS2 = UCS1 + 1
- UCS_start = UCS_start + 2
- else
- UCS1 = UCS2 + 1
- UCS2 = UCS1 + 1
- UCS_start = UCS_start + 2
- end
- -- load up the blank_file
- squadFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- -- create the base
- create_base_squad_file(squadFile)
- local top = squadFile.GameData
- local topT = squadFile._TYPE.GameData
- -- add the tier requirement if needed
- if v[i][2] then
- end
- -- set screen position
- top.squad_ui_ext.ui_group_position = v[i][3]
- top.squad_ui_ext.build_button_index = v[i][3]
- -- add icon path
- top.squad_ui_ext.icon_name = v[i][4]
- -- add UCS entries
- top.squad_ui_ext.squad_name = UCS1
- top.squad_ui_ext.screen_name = UCS1
- top.squad_ui_ext.help_text = UCS2
- -- loop through the created open UPGS and have it require NON of them to be present
- for menuName,value in pairs(openUPGS) do
- -- insert a requirement into the sbps
- local info =
- {
- "required_player_upgrade",
- is_present = false,
- reason = [[display_and_usage_and_produce]],
- upgrade_name = value.relative
- }
- local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
- insert_entry([[requirements\required_player_upgrade]], files, info)
- end
- -- create file
- local savePath = v.baseSavePath .. v[i][1] .. [[.rbf]]
- --compiler_make_rbf(squadFile, savePath)
- -- create back squad
- -- load up blank file
- backSquadFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- -- create the base
- create_base_squad_file(backSquadFile)
- local top, topT = Shorten(backSquadFile)
- -- back icons will be teir 3, pos 5
- -- set screen position
- top.squad_ui_ext.ui_group_position = 5
- top.squad_ui_ext.build_button_index = 6
- -- add icon path
- top.squad_ui_ext.icon_name = backIcon
- -- add UCS entries
- top.squad_ui_ext.squad_name = BackUCS1
- top.squad_ui_ext.screen_name = BackUCS1
- top.squad_ui_ext.help_text = BackUCS2
- -- to show up it needs its corresponding open upg to be present
- -- also add requirement for tier 3 upgrade
- local names = {{tier3, [[usage_and_produce]]}, {openUPGS[v[i][1]].relative, [[display_and_usage_and_produce]]}}
- for f = 1, table.getn(names) do
- print(names[f][1])
- local info =
- {
- "required_player_upgrade",
- is_present = true,
- reason = names[f][2],
- upgrade_name = names[f][1]
- }
- local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
- insert_entry([[requirements\required_player_upgrade]], files, info)
- end
- local backRPath = [[sbps\]] .. v.relativePath .. v[i][1] .. [[_back]]
- local backPath = v.baseSavePath .. v[i][1] .. [[_back.rbf]]
- --compiler_make_rbf(backSquadFile, backPath)
- -- now loop throught the spawn buildings and add these two squads to its spawner
- for s,building in pairs(spawnBuildings) do
- local buildingFile = compiler_load_rbf([[::simulation\attrib\]] .. building)
- local top, topT = Shorten(buildingFile)
- local names = {backRPath, [[sbps\]] .. v.relativePath .. v[i][1]}
- for f = 1, table.getn(names) do
- local info =
- {
- "squad",
- names[f]
- }
- local files = {top.spawner_ext.squad_table, topT.spawner_ext.squad_table}
- insert_entry([[entries\squad_table\squad]], files, info)
- end
- -- and save the file again
- --compiler_make_rbf(buildingFile, base .. building)
- end
- -- add entry to output tieing the spawn squad with the upgrade
- -- and another entry tieing the remove squad with the remove ability
- local s = "[\"sbps\\\\" .. string.gsub(v.relativePath, [[\]], [[\\]]) .. v[i][1] .. "\"] = {[[upgrade]], World_GetPropertyBagGroupID([[" .. openUPGS[v[i][1]].relative .. "]])}, \n"
- s = s .. "[\"" .. string.gsub(backRPath, [[\]], [[\\]]) .. "\"] = {[[ability]], World_GetPropertyBagGroupID([[" .. openUPGS[v[i][1]].ability .. "]])},\n\n"
- --print(s)
- output:write(s)
- --output:flush()
- end
- end
- -- now do all the units
- -- set up the UCS numbers
- local tabs =
- {
- "hq",
- "troop",
- "elite",
- "fast_attack",
- "heavy_support",
- }
- for k,v in pairs(tabs) do
- if not tabs[v] then
- tabs[v] = {}
- end
- for tier = 1, 3 do
- for pos = 1, 6 do
- local name = tostring(tier) .. "x" .. tostring(pos)
- local ucs1 = UCS_start + 1
- local UCS2 = ucs1 + 1
- UCS_start = UCS_start + 2
- tabs[v][name] = {ucs1, ucs2}
- if tier == 3 and pos == 6 then
- -- this is where the back icon goes.
- tabs[v][name] = nil
- end
- end
- end
- end
- --[[
- space_marines =
- {
- basePath = base .. sbps\_space_marines\menu,
- iconPath = ,
- {"tactical_space_marines", "troop"},
- {"scout_marines", "troop"},
- {"captain", "hq", ""},
- },
- ]]
- output:write("\n" .. [[Units]] .. "\n\n")
- for race, value in pairs(t.Units) do
- output:write(race .. "\n\n")
- -- load the blank file and set the basics
- local unitFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- create_base_squad_file(unitFile)
- local top, topT = Shorten(unitFile)
- for i = 1, table.getn(value) do
- local name = value[i][1]
- local unitType = value[i][2]
- local icon = value[i][3]
- for tier = 1, 3 do
- for pos = 1, 6 do
- local grid = tostring(tier) .. "x" .. tostring(pos)
- if grid ~= "3x6" then
- -- do some edits
- top.squad_ui_ext.build_button_index = pos
- top.squad_ui_ext.icon_name = icon
- top.squad_ui_ext.screen_name = tabs[unitType][grid][1]
- top.squad_ui_ext.squad_name = tabs[unitType][grid][1]
- top.squad_ui_ext.help_text = tabs[unitType][grid][2]
- -- depending of their teir, they may need 1 or 2 upgrades as requirement
- local upgs = {}
- if tier == 1 then
- upgs = {{openUPGS[unitType].relative, [[usage_and_produce]]}}
- elseif tier == 2 then
- upgs = {{tier2, [[usage_and_produce]]}, {openUPGS[unitType].relative, [[usage_and_produce]]}}
- else
- upgs = {{tier3, [[usage_and_produce]]}, {openUPGS[unitType].relative, [[usage_and_produce]]}}
- end
- for f = 1, table.getn(upgs) do
- local info =
- {
- "required_player_upgrade",
- is_present = true,
- reason = upgs[f][2],
- upgrade_name = upgs[f][1]
- }
- local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
- insert_entry([[requirements\required_player_upgrade]], files, info)
- end
- -- save it
- local rPath = value.relativePath .. [[\]] .. name .. [[\]] .. grid
- local path = base .. rPath .. [[.rbf]]
- print(path)
- compiler_make_rbf(unitFile, path)
- -- add to spawn building
- -- open up spawn building
- local spawn = compiler_load_rbf([[::simulation\attrib\]] .. spawnBuildings[race])
- local spawnBuilding, spawnBuildingT = Shorten(spawn)
- local info =
- {
- "squad",
- rPath,
- }
- local files = {spawnBuilding.spawner_ext.squad_table, spawnBuildingT.spawner_ext.squad_table}
- insert_entry([[entries\squad_table\squad]], files, info)
- -- save spawn building
- compiler_make_rbf(spawn, base .. spawnBuildings[race])
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement