Data \ leveldata \ campaign \ <CampaignName>.campaign

The table elements are pre-written, and added into Mission table when player make choice.

Do you overwrite the existing table entry, or do you insert the element at the end of the table to make the table larger?

Where is this stored? The actual campaign file?

If so this doesn’t work with RM after the patch - the ONLY place you can read/write in LUA from (aside from executing pre-existing LUA files) - is the current user’s Profile folder.

Coming up with a way to do ‘non linear’ or even auto/programmatically generated campaigns is something I’m happy to explore, maybe for a future patch…

2 Likes

Actually - now that I think about it…

I know how to do pretty much exactly what you want, including some crazy stuff… even in the upcoming patch. Heck, you could even generate a ‘map’ (like, an ASCII image) that you store in the user’s profile. Then, in the campaign file, it has only a single mission - but after that mission is declared in the campaign, it reads this file from the profile folder, which says 'here’s a map, we are at X,Y", and based on what is there, loads a specific map (one generic, or a small palette of them, etc).

Once the game starts, it populates the map as needed (and you can change the background and stuff from lua) - and when loading a save, the map’s internal state says ‘we were at X,Y’ - so if you win or decide to leave, it’ll update the X,Y in the player’s profile, and continue.

Lots of details to lock down - but I think it’d work fairy well actually. With a bit of effort you could even make a custom campaign button that loaded and displayed that map, where you’d been, enabling clicks for where you want to go, etc… The UI handling would just update the user’s XY data in the profile, and load the base mission again - causing it to ‘jump’.

1 Like

Care to elaborate ? When you have time of course :wink:

Issue #1 I’ve been having is that when you complete whatever the game considers to be the last mission, the game automatically kicks you to the main menu. However, if the campaign is really supposed to be non-linear, then a hard cap of this kind doesn’t make much sense. What I did to work around this was to make the Mission table in “ascension.campaign” very very large, and filling it with lots of dummy missions. Not sure what the side effects of this might be.

Issue #2 is save games. I tested them, and they work mostly. The nondetermchunk stuff in the level file gets messed up, though. For example, when reloading a saved game, the level background image or music may be the wrong one for the map.

[edited]

the mission table has two element at first, others are just outside the table, like this:
MAP1=…,
MAP2=…,

Mission={}
Mission[1]=MAP1
Mission[2]=MAP0–dosen’t matter what this is, just be here so the game won’t jump to the main menu
then we read a file from profile folder to redefine mission table (empty at first of course).
now, player is at mission 1, finished his business, and decided to jump to MAPX, so mission completed, the script write new data into that file to arrange mission table like this:
Mission[1]=MAP1
Mission[2]=MAPX
Mission[3]=MAP0–still here because player is at mission2 now
basically this is how it works, the only problem I can see is that your mission table will get bigger and bigger.
And if you don’t need persist fleet, then I suggest you use Restart rather than Complete, then you only need 1 element in mission table, exactly what I did in the Trading Mode, and you should really check it out.

Have you tested creating/loading save games? Does everything work?

I use my own saving system in the Trading Mode. Too many UI things that can’t be recorded by the game, and I use [restart] to load the new map so persist fleet is also useless to me.

Like what for example ?

Custom UI, the Trading Mode use A LOT of them

yes, but when you say “can’t be recorded by the game”, you meant by the normal way I suppose ? You can still use the write/read methods, no ?

yeah, that is what I mean. but without the normal way, I can only use I/O to save when player jumps to another map, because I can then restart the mission with the new map and new data, while saving all data at any other time is impossible.

So you are having basically the same issues I am having.

I think for both of you (because you can’t edit the mission list after the patch) there’s probably a ‘nice’ way to do lots of this - and support save-game data, etc…

I just need some downtime to help experiment a bit :wink: And for the next few weeks that is certainly not going to be the case…

1 Like

Would you need to save some data at another moment (like during the mission for example) ? And if the answer is yes, why can’t you ? You could have a specific rule running from time to time, no ?

I don’t have the issue where the game back to main menu, my mission table is always 1 element larger. not to say that I use another way in Trading Mode: restart the mission rather than complete it.

So my method won’t work? I mean I write file in profile folder, it worked in HW2C, why can’t edit mission table after this patch?

No, it works fine, at other moment, without the normal way, you can’t save EVERYTHING and restore it, but when player is leaving to another map, you don’t need to. Still, it could be better if I can set control groups…

ok, I understand now.
Concerning the control groups, you can use MainUI_UserEventData( eGroup, x) / MainUI_UserEventData( eSelectGroup, x) (x being the slot number) to set a control group with the current selection / select a control group.
I don’t see how you could “save” those between session, though.

wow, never noticed this before, thanks a lot. Use SobGroup_IsInControlGroup and this, I think I can save and reset control groups now.

You’re welcome :slight_smile:
Note that MainUI_UserEventData( eSelectGroup, x) is the command which is used in the newtaskbar.lua file (/ui/newui folder), so I’m 100% sure it works (and because I’ve already used it in the past).
I don’t manage to remember if I’ve already used the MainUI_UserEventData( eGroup, x) command, so there is still a chance that it won’t work (even if I can’t see why it wouldn’t). Just so you know, I’ve extrapolated the format of the command with the help of the keybindings.lua file (found in /locale/scripts if I remember well).

Edit :
to reset controlgroups, you can also use ClearSelectedFromControlGroups() and ClearAllControlGroups() (the two are found in keybindings.lua, the shorcut keys being respectively “CTRL”+"-" and “CTRL”+“SHIFT”+"-")