How to make an era mod w/ working icon

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Tears2Roses
Chief Warrant Officer
Chief Warrant Officer
Posts: 336
Joined: Thu Jul 07, 2011 9:20 am
Projects :: Oh some random stuff who knows
Games I'm Playing :: SWBF2
xbox live or psn: PC beats xbox.

How to make an era mod w/ working icon

Post by Tears2Roses »

I know there is a tutorial on how to make an era mod on GT, but not really the addme.lua or the era icon. So, I have decided to type up a tutorial for you guys. There is a much less explained tutorial in the 1.3 docs, so I thought I would explain it for everyone.

Ok, here we go. This tutorial assumes 1) you know basics of modding 2) your will be willing to learn 3) you will not ask me how to make a side mod 4) you will ask me for clarification if needed 5) you have the 1.3 patch installed

Ok, here we go.

Munge a new world. Pretty easy, is it not?

Now, create your side and then set-up your era mod according to THIS tutorial. Do not do the addme.lua part though.

So, here is where I come in. Chances are you want your era mod on a stock map, no? And you want an icon too, right? If so, here is the breakdown of the process.

The icon:
Go into data_GUN. Replace gun with your 3 letter mod ID. Now, create a new folder and call it shell. Create a texture folder in there. Ok, moving on. Your texture should be 128 x 128 in gimp. You can use whatever picture you want. If you want transparency then it gets tricky, and im not covering gimp in this. So, if you have your icon, save it with no RLE and call it era_icon_f( it could be named anything, but its just simpelest to do that). You now need a .tga.option file. Open notepad and put this in:
Hidden/Spoiler:
-maps 1 -format compressed
and save it as era_icon_f.tga.option. Now, go back into data_GUN\shell and open notepad and put this in:
Hidden/Spoiler:
ucft
{

REQN
{
"texture"
"era_icon_f"
}
}
and save it as shell.req. That should be it as far as the shell goes, now onto the really fun part. Go to data_GUN\_lvl_pc_ and copy shell.lvl to gamedata\addon\GUN\_lvl_pc_. That’s that, next part.

The addme.lua:

So you have your icon, you have your sides, and now you want it on the stock maps. Never fear, this tutorial covers that too! First, go into your addme.lua and replace the top section with this:
Hidden/Spoiler:
-- recursively merges the second given table into the first given table
function MergeTables( mission, newFlags )
--for each table entry,
local array = type({})
for key,value in pairs(newFlags) do
--check for nested tables
if type(value) == array then
--mission must have this key as a table too
if type(mission[key]) ~= array then
mission[key] = {}
end
--merge these two tables recursively
MergeTables(mission[key], value)
else
--the key is a simple variable, so simply store it
mission[key] = value
end
end
end

--Search through the missionlist to find a map that matches mapName,
--then insert the new flags into said entry.
--Use this when you know the map already exists, but this content patch is just
--adding new gamemodes (otherwise you should just add whole new entries to the missionlist)
function AddNewGameModes(missionList, mapName, newFlags)
for i, mission in missionList do
if mission.mapluafile == mapName then
MergeTables(mission, newFlags)
end
end
end
Now, we want the game to read our shell.lvl
Hidden/Spoiler:
ReadDataFile("..\\..\\addon\\GUN\\data\\_LVL_PC\\shell.lvl")
Replace GUN with your 3-letter mod ID. So it could be CAR, LOL, FML, who knows.

Next, you need this.
Hidden/Spoiler:
--insert totally new maps here
local sp_n = 0
local mp_n = 0
sp_n = table.getn(sp_missionselect_listbox_contents)

--add my modes to the singleplayer map selection screen

And below it you need this:

[hide]AddNewGameModes(
sp_missionselect_listbox_contents,
"myg1%s_%s",
{
era_f = 1,
mode_con_f= 1,
change = {
era_f = { name="Purple vs Yellow", icon2="era_icon_f"},

},
}
)
Ok, im going to break down what this means. The add new game modes and sp_missionselect part don’t matter that much, it just needs to be there. However, you need the myg1%s_%s. What that does is tell the game what map you want your sides on. If you want death star, use dea1%s_%s. Next is era_f = 1. This needs to be the same as your edited scripts from the first steps. So if you have dea1f_con.lua then its era_f. Same goes for the mode_con_f = 1. If your mode inst conquest though, change the con to something else. Like mode_eli_f. Next is the era_f = { name=”Purple vs Yellow”, icon2=”era_icon_f”}, line. Remember the shell texture we made? You reference that here. Purple vs Yellow is what I called my era mod. It could be anything, like Droid attack, clone rampage, Jedi rulez!, who knows. Anyhow, that line makes sure the game reads your era as the name you want + your icon. If you called your icon in data_GUN\shell\textures something other than era_icon_f call it that.

Now, if you want your sides on more than one map (and you probably do) then you need to copy over the ENTIRE table above. So, if you want your era on mygeeto and death star then your addme.lua looks like this:
Hidden/Spoiler:
AddNewGameModes(
sp_missionselect_listbox_contents,
"myg1%s_%s",
{
era_f = 1,
mode_con_f= 1,
change = {
era_f = { name="Purple vs Yellow", icon2="era_icon_f"},

},
}
)
AddNewGameModes(
sp_missionselect_listbox_contents,
"dea1%s_%s",
{
era_f = 1,
mode_con_f= 1,
change = {
era_f = { name="Purple vs Yellow", icon2="era_icon_f"},

},
}
)
That’s it! Repeat the table for as many modes and maps as you want. Eventually, you will finish and then you need the following after you’ve inserted all your maps.
Hidden/Spoiler:
-- associate this mission name with the current downloadable content directory
-- (this tells the engine which maps are downloaded, so you need to include all new mission lua's here)
-- first arg: mapluafile from above
-- second arg: mission script name
-- third arg: level memory modifier. the arg to LuaScript.cpp: DEFAULT_MODEL_MEMORY_PLUS(x)

AddDownloadableContent("myg1","myg1f_con",4)
AddDownloadableContent("dea1","dea1f_con",4)

You need the AddDownloadableContent lines, otherwise your map will crash. Use the AddDownloadableContent lines for however many maps you have. Once you finish that, then put this in:

-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\GUN\\data\\_LVL_PC\\core.lvl")
This reads the localize keys and tells the game we are done adding stuff. Replace GUN with your 3-letter map ID. So it could be YAY, YES, FUN, and so forth.

That’s it! I hope this helped everyone out a lot!

NOTE: If you want to have your your own map, then you need two data_ABC folders. You need a seperate data_ABC folder for the era mod to avoid problems.
Hidden/Spoiler:
CREDITS:
[RDH]Zerted for the 1.3 patch and addme codes
Marth8880: For helping me with the addme
Last edited by Tears2Roses on Sat Dec 24, 2011 2:03 pm, edited 1 time in total.
User avatar
Unlucky13
Sergeant Major
Sergeant Major
Posts: 239
Joined: Mon Jan 24, 2011 11:11 am
Projects :: Models models models
Games I'm Playing :: Random stuff

Re: How to make an era mod w/ working icon

Post by Unlucky13 »

Thanks!

I was having problems setting up my icon. :)
Post Reply