Custom Campaign Support (ZE_ccsupport)

New maps and mods are coming out quickly. If you release something (even a beta) please post it here. Be sure to give details in the topic such as Map/Mod name and version

Moderator: Moderators

Post Reply
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Custom Campaign Support (ZE_ccsupport)

Post by Nedarb7 »

ZE_ccsupport

Custom Campaign Support


"Have you ever dreamed of making your own campaign series for SWBF2, only to give up because lack of support? Well now you can with this magical [unexplained] folder that gives you the opportunity to make that dream come true!" - Random Commercial Guy

Because this is such a random release, I couldn't think of any other way to introduce this. The mod gives custom campaigns for SWBF2 their own
dedicated menu, and it saves progress for them as well. To add your campaign with the support of ZE_ccsupport, read the tutorial below.

Readme:
Hidden/Spoiler:
-------------- ZE_ccsupport (v1) --------------


ZE_ccsupport allows for custom campaigns in SWBF2.

Install:
- Place in addon folder (reverse process to uninstall)

Supports:
- Custom campaigns
- Custom campaign missions
- Custom campaign names (up to ??? characters)
- Custom campaign descriptions (up to 196 characters)
- Custom campaign preview images
- Custom campaign saves (automatically generated)

Changes/Adds:
- Ordered the "Load" and "Start Campaign" buttons above the "Campaign List" button
- Single player campaign menu has "Added Campaigns" button
- Added "Added Campaigns" menu; dropdown list of downloaded campaigns
- Added "Battlecard" menu; serves as a launcher to custom campaigns

Info:
- Saves are automatically generated, and they do not need to be loaded through the
-- campaign menu's loading menu. However, the campaign loading menu allows you to
-- access your saved games. DO NOT LOAD THEM, only delete. All auto generated saves
-- are named in this fashion <playername><campaign>_ccsupport.

Developer: Nedarb7
Date of release: 28/1/2015 DMY
Concerns: Gametoast.com --> http://www.gametoast.com/viewtopic.php?f=35&t=31002

Tutorial can be found at the link above as well.



DISCLAIMER: THIS MOD IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY LUCASARTS, A DIVISION OF LUCASFILM ENTERTAINMENT COMPANY LTD. ELEMENTS TM & (C) LUCASARTS, A DIVISION OF LUCASFILM ENTERTAINMENT COMPANY LTD.
Download Link

Tutorial
Notice: Tutorial does not provide instruction for mission scripting, and assumes you know how to load game modes in the mission REQ file.
Suggested tutorials to read beforehand:
viewtopic.php?p=470531#p470531 - Shell
http://www.gametoast.com/viewtopic.php?t=971 - Localize
http://www.gametoast.com/viewtopic.php? ... 96#p287596 - Era / Game Mode

This goes in your addme script:
Hidden/Spoiler:
[code]if cc_campaign_missions == nil then -- Important, this block creates the tables if they don't exist already
cc_campaign_missions = {}
cc_missions = {}
cc_n = 0 else
cc_n = table.getn(cc_campaign_missions)
end -- End of that

-- Add Campaign to list
cc_campaign_missions[cc_n+1] = {

screen = "", -- Your campaign's unique name. NO SPACES or PUNCTUATION (be safe and only use abcs and numbers)
showstr = "", -- Your campaign's unique title. (The name seen in the dropdown)


}

-- Campaign contents
cc_missions[cc_campaign_missions[cc_n+1]["screen"]] = {

[1] = { -- This subtable is designated 1 (mission 1); for each additional mission increase by one
preview = "", -- Preview image (tga: 512x256); load in your shell.lvl
desc = "", -- Description (196 characters max); use string if you like (localize), but you can write it here
name = "", -- Name (??? characters max); use string if you like (localize), but you can write it here
lua = "", -- Name of LUA script
}, -- end of subtable
}

cc_n = nil[/code]
You will need to fill in the quotations. Leave every thing else as it is. Example:
Hidden/Spoiler:
[code]if cc_campaign_missions == nil then
cc_campaign_missions = {}
cc_missions = {}
cc_n = 0 else
cc_n = table.getn(cc_campaign_missions)
end

-- Add Campaign to list
cc_campaign_missions[cc_n+1] = {

screen = "the_old_republic",
showstr = "The Old Republic",


}

-- Campaign contents
cc_missions[cc_campaign_missions[cc_n+1]["screen"]] = {

[1] = {
preview = "tor_prev1",
desc = "Mountain Defenses - Alderaan",
name = "Mountain Defenses",
lua = "SNWt_c",
},
[2] = {
preview = "tor_prev2",
desc = "Revan's Revenge - Endor",
name = "Revan's Revenge",
lua = "FRSt_c",
},
[3] = {
preview = "tor_prev3",
desc = "Rise of Malgus - Coruscant",
name = "Rise of Malgus",
lua = "TMPt_c",
},
[4] = {
preview = "tor_prev4",
desc = "Battle on Korriban - Moraband",
name = "Battle on Korriban",
lua = "KORt_c",
},
}

cc_n = nil[/code]
I'd suggest placing all this content at the top of the addme.

After that you need to add your game modes at the bottom along with the others, add one of these for each mission:
Hidden/Spoiler:
[code]AddDownloadableContent("<ABC>","<ABC><era>_<mode>",4)[/code]
Here's an example of a complete addme:
Hidden/Spoiler:
[code]if cc_campaign_missions == nil then
cc_campaign_missions = {}
cc_missions = {}
cc_n = 0 else
cc_n = table.getn(cc_campaign_missions)
end

-- Add Campaign to list
cc_campaign_missions[cc_n+1] = {

screen = "the_old_republic", -- cc_missions[screen]
showstr = "The Old Republic",


}

-- Campaign contents
cc_missions[cc_campaign_missions[cc_n+1]["screen"]] = {

[1] = {
preview = "tor_prev1",
desc = "Mountain Defenses - Hoth",
name = "Mountain Defenses",
lua = "SNWt_c",
},
[2] = {
preview = "tor_prev2",
desc = "Revan's Revenge - Endor",
name = "Revan's Revenge",
lua = "FRSt_c",
},
[3] = {
preview = "tor_prev3",
desc = "Rise of Malgus - Coruscant",
name = "Rise of Malgus",
lua = "TMPt_c",
},
[4] = {
preview = "tor_prev4",
desc = "Battle on Korriban - Geonosis",
name = "Battle on Korriban",
lua = "KORt_c",
},
}

cc_n = nil

-- 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

--insert totally new maps here:
ReadDataFile("..\\..\\addon\\TOR\\data\\_LVL_PC\\shell.lvl")
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


-- 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("SNW","SNWt_c",4)
AddDownloadableContent("FRS","FRSt_c",4)
AddDownloadableContent("TMP","TMPt_c",4)
AddDownloadableContent("KOR","KORt_c",4)


-- all done
newEntry = nil
n = nil

-- Now load our core.lvl into the shell to add our localize keys
ReadDataFile("..\\..\\addon\\TOR\\data\\_LVL_PC\\core.lvl")
[/code]
Now all you need to do is load the scripts through the mission REQ file like an era or game mode mod.
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Custom Campaign Support (ZE_ccsupport)

Post by AQT »

Good to see you were able to figure everything out, Nedarb! Great work! :thumbs: :D
hunpeter12
Command Sergeant Major
Command Sergeant Major
Posts: 260
Joined: Mon Apr 18, 2011 2:53 pm
Projects :: Underground City The Complex [WIP]
Games I'm Playing :: SWBF2

Re: Custom Campaign Support (ZE_ccsupport)

Post by hunpeter12 »

Yeah! Custom campaigns here I come!
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: Custom Campaign Support (ZE_ccsupport)

Post by Anakin »

i'm a bit confused. wasn't thtat possible before, too?? as far as i remember there were a campaign for dt without this. So i think i don't really understand what this mod here is good for.

Or maybe i haven't read/understand all from your intro text
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Custom Campaign Support (ZE_ccsupport)

Post by Nedarb7 »

What Mav did for DT was a galactic conquest that he very successfully managed to make in a campaign fashion. Here's what's different (from readme):
Hidden/Spoiler:
Supports:
- Custom campaigns
- Custom campaign missions
- Custom campaign names (up to ??? characters)
- Custom campaign descriptions (up to 196 characters)
- Custom campaign preview images
- Custom campaign saves (automatically generated)

Changes/Adds:
- Ordered the "Load" and "Start Campaign" buttons above the "Campaign List" button
- Single player campaign menu has "Added Campaigns" button
- Added "Added Campaigns" menu; dropdown list of downloaded campaigns
- Added "Battlecard" menu; serves as a launcher to custom campaigns

We could always make custom campaigns, either through GC or IA, but they were never their own dedicated thing, which is what this does. Both GC and IA weren't really designed for campaign. While a GC campaign can be done, from what I understand there is a limit of 11, and it can't be done directly from the project's folder. Further, IA campaigns lacked any form of saved progress, making it more of an objective game mode. So basically what this does is gives modders a campaign format for custom campaigns instead of using a GC or game mode in IA.

plus it's easy :P
hunpeter12
Command Sergeant Major
Command Sergeant Major
Posts: 260
Joined: Mon Apr 18, 2011 2:53 pm
Projects :: Underground City The Complex [WIP]
Games I'm Playing :: SWBF2

Re: Custom Campaign Support (ZE_ccsupport)

Post by hunpeter12 »

However, in GC you can have a choice of which planet you want to continue with, like in DT.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Custom Campaign Support (ZE_ccsupport)

Post by Maveritchell »

For what it's worth, I only used GC as a fall-back plan. I think it eventually made for a more unique experience overall, but I would've used something like this had I figured it out (which I didn't). Kudos, Nedarb - this is really nice work.
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: Custom Campaign Support (ZE_ccsupport)

Post by Anakin »

Sounds great :D
Maybe i'll give that a try after my CGC will work
User avatar
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Re: Custom Campaign Support (ZE_ccsupport)

Post by GAB »

This is great! :D
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Custom Campaign Support (ZE_ccsupport)

Post by [RDH]Zerted »

Another shell enhancement. Yay. :thumbs:

Did you use SaveAndLoadUtils.lua for the saving/loading or something else?
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: Custom Campaign Support (ZE_ccsupport)

Post by jedimoose32 »

This is excellent - actually my current project is a new campaign so this is well-timed indeed. Thanks for working hard on this and releasing it Nedarb!
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Custom Campaign Support (ZE_ccsupport)

Post by Nedarb7 »

[RDH]Zerted wrote:Another shell enhancement. Yay. :thumbs:

Did you use SaveAndLoadUtils.lua for the saving/loading or something else?
No I didn't, but I used it as one of my references. (The stock scripts had it scattered around various different scripts which got a little overwhelming after a while, so it was nice to see a working save system set up all together.) What I needed to do for this project was figure out how to work saving through the ScriptCB functions since Battlefront's saving works through a menu, erasing important variables from my menu. I narrowed it down to about eight functions that exist, and they are managed through the battlecard menu.

SaveAndLoadUtils is great btw, it helps a bunch with one of my game mode mods.
User avatar
willinator
Major
Major
Posts: 517
Joined: Sun Mar 13, 2011 3:11 pm
Projects :: [Coming of the Sentinels]
Games I'm Playing :: SWBF2 Minecraft Halo
xbox live or psn: PC pwns all!
Location: The rings of Saturn...

Re: Custom Campaign Support (ZE_ccsupport)

Post by willinator »

Wow, this is great Nedarb! I was just wondering, is it possible to have a campaign with this tool, without the preview screens in-between missions, and yet still have the saving take place. What I'm suggesting is this: Player finishes mission 1, next mission starts automatically. If the player quits to the menu, the game has saved their progress, just like the stock campaign (minus pause screens).
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: Custom Campaign Support (ZE_ccsupport)

Post by Nedarb7 »

I appreciate the feedback, willinator. What you suggested is actually a feature that was lost during the development of the mod. When I first began this project I had no idea how saving worked, and I hoped that I'd be able to figure it out for the purposes of the mod. That meant I had to do some research (obviously). After digging the code down to the ScriptCB functions I was ready to implement the save feature. There was, however, one problem that I came across. This had to do with one of the two saving ScriptCB functions; it is used to save a state (so keep the information in the game, not save to a file). The issue was that if you have a campaign state saved, you will be immediately sent to the stock campaign mission launcher on returning to the shell. Now, why that matters. In order to keep information from a play sequence, it would be required to save the campaign state at the end of each mission. That means that if I were to return to the main menu I have the option to go to the stock campaign mission launcher (due to the saved campaign state) or lose the information that tells ZE_ccsupport what the outcome of the battle was (if the saved data were to be erased on going to the shell). Which means data can't be saved. Now, the only solution to this was to make the next mission launch right when you return to the shell, mimicking a play sequence. That too had a problem. Since that solution requires returning to the shell, you would have to wait for two loading screens, making it completely pointless.

--- That said ---


It may be possible to work around it through your mission script. The mission list is setup with this function:

Code: Select all

ScriptCB_SetMissionNames(luaname, nil)
The idea is to load the temporary saved data via Zerted's SaveAndLoadUtils, set the next mission name in the current mission with the code above, save over the temporary saved data via Zerted's SaveAndLoadUtils, and end the mission. I could further explain this, but I'm not sure if the second part would work. However, if I understand correctly, something similar or the same thing is/can be done by a server admin. So again, the second part would need to be tested alone before trying anything else.
Jaspo
Command Sergeant Major
Command Sergeant Major
Posts: 282
Joined: Sun Mar 01, 2009 4:34 am
Projects :: AotC DoW+++Boonta Eve Classic
Games I'm Playing :: WoT MBWBVC Robocraft
xbox live or psn: No gamertag set
Contact:

Re: Custom Campaign Support (ZE_ccsupport)

Post by Jaspo »

Quick question without much thought or reading:
Could this be used to solve the problem of only being able to have 1 custom galactic conquest active at a time?
User avatar
lucasfart
Sith
Sith
Posts: 1440
Joined: Tue Feb 24, 2009 5:32 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Australia

Re: Custom Campaign Support (ZE_ccsupport)

Post by lucasfart »

From what I can tell it has nothing to do with GC? I'm pretty sure this is meant to be used like the stock campaign following the 501st, not like the galactic conquest mode.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Custom Campaign Support (ZE_ccsupport)

Post by [RDH]Zerted »

The one cGC limitation is due to a bug in the cGC template. You need to replace

Code: Select all

return cgc5_custom_PressedGCButton()
with

Code: Select all

return cgc5_custom_PressedGCButton(tag)
(assuming you're using slot 5. Change the number to whatever it needs to be.). If you do that and the other cGCs do that then you'll have multiple cGCs. I've been too busy to release an official fix (would have to install Windows, setup a SWBF2 dev environment, and do a bunch of testing).
Lako3000
Posts: 4
Joined: Mon Feb 26, 2018 4:51 am
Projects :: No Mod project currently.
Games I'm Playing :: BF2
xbox live or psn: No gamertag set

Re: Custom Campaign Support (ZE_ccsupport)

Post by Lako3000 »

hey guys, ive got a problem with a custom campaign im trying to make, any help would be greatly appreciated.

so i want to just copy and paste the original campaign except just remove some objective and add some sounds to it, but i cant for the life of my, figure out how to munge a map which has the gamemode for campaign, moreso, i tried to follow this guide to add the dropdown for a campaign and it doesnt seem to be doing anything?. did i put my script in the wrong addme? am i supposed to put it into the addme that is in the addon folder of the game?. also, do i do this inside a munged data_ABC or can i copy the maps from assets since thats what i want to use?

im not very good at this modding stuff and im quite new, so be gentle XD thanks for any help
Post Reply