Sounds cool, right? I thought so at least.
I thought the most complicated part would be making the paths between the planets, as I won't be able to tell what other planets the player would use. I came up with 2 solutions for that:
1: Have a series of stars running through the map, with all the planets connected to at least one of them, that way everything would be connected.
2: Use some of the game's standard planets as hubs instead of stars, though still allow people to switch them out with custom maps if they wish (for example have Pandemic's Coruscant, or one of the many Coruscant mod maps out there, or any mixture of the above).
In either case, each planet would also connect to one, two or three other planets, and if the player happened to also use that planet, a connection would be made to create a more interesting layout. I'd tell players there was a limit of say 20-25 planets at any one time to avoid hitting the (apparently) hardcoded 50 pathway limit.
I'd hoped it would simply require a bunch of IF statements in the lua code, and by a bunch I mean a very very large number, but nothing unreasonable as it would mostly be a lot of copy and pasting on my part. Here's an example for that including Dantooine might look like, where Dantooine would replace star09 (in reality I'd give Dantooine its own coordinates on the map, this is just because I was writing a quick example):
Code: Select all
this.cameraOffset = {
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1 then
["DAN"] = { 0, 1, 1 },
end
}
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1 then
-- Make the Dantooine planet appear
CreateEntity(GetEntityClass("tat"), GetEntityMatrix("star09"), "DAN");
end
Unfortunately when I went to munge it to run a test, I was repeatedly getting this error message:
I experimented with a few things, and while the 'if' code is happy to work for making the planet appear, it doesn't work anywhere else. It would appear that lua doesn't like using 'if' functions within a table, and the gc code is all about tables. Basically anywhere an if would appear within a { and a }, it would fail. It makes sense I guess, as otherwise the table doesn't know how long it's supposed to be.C:\BF2_ModTools\data_C14\_BUILD\Shell\..\..\..\ToolsFL\Bin\luac.exe: ..\..\shell\scripts\ifs_freeform_init_xxx.lua:26: unexpected symbol near `if'
ERROR[scriptmunge scripts\ifs_freeform_init_xxx.lua]:Could not read input file.ERROR[scriptmunge scripts\ifs_freeform_init_xxx.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
One solution would be to have the if statements on the outside of the table, and within each option of the ifs, have different tables, like so:
(I've just used Coruscant - COR - and Geonosis - GEO - as examples here. If you were to really do this, the "NOT"s would need to be lower case, they're just upper case here for emphasis)
Code: Select all
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["DAN"] = { 0, 1, 1 },
["COR"] = { 0, 1, 1 },
["GEO"] = { 0, 1, 1 }
}
else
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["DAN"] = { 0, 1, 1 },
["COR"] = { 0, 1, 1 },
}
else
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["DAN"] = { 0, 1, 1 },
["GEO"] = { 0, 1, 1 },
}
else
if NOT ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["COR"] = { 0, 1, 1 },
["GEO"] = { 0, 1, 1 },
}
else
if ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["DAN"] = { 0, 1, 1 },
}
else
if NOT ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["COR"] = { 0, 1, 1 },
}
else
if NOT ScriptCB_IsFileExist("..\\..\\addon\\DAN\\addme.lvl") == 1
and if NOT ScriptCB_IsFileExist("..\\..\\addon\\COR\\addme.lvl") == 1
and if ScriptCB_IsFileExist("..\\..\\addon\\GEO\\addme.lvl") == 1
then
this.cameraOffset = {
["GEO"] = { 0, 1, 1 },
}
end
end
end
end
end
end
end
planets = nested ifs
And that's just for the one table, that would need to be repeated for all 5 tables needed for the GC scripts. And the work would double for the 'this.planetMission table every time you wanted to add another map option to a planet. You get the idea, doing it that way simply isn't practical. I suspect the game would crash long before you got to anything good.4=15
5=31
6=63
10 = 1023
I have no idea if this idea is even possible, but I really want it to be. The only reasonable way of it working is having the changing factors within the tables, and the way the code is written at the moment, I don't believe that it's possible. You'd probably need to rewrite the entire code to change the way the function works. Or maybe there's an easier function that I don't know about? I'm not a coder, I don't know lua, except the small amount I need to know to write basic scripts for the game mods. If you are a coder, for all I know you're laughing at me right now because the solution is so obvious. I'm not the one to say either way.
That's why I thought I'd just share the idea here. If you've got any solutions then I'd love to hear them. Or if you want to go ahead and make it yourself, feel free, or include me in on it (though if you do make it yourself with or without me, please credit me for the initial idea).