Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for campaign status #1639

Open
4 tasks
ottml opened this issue Nov 14, 2023 · 9 comments
Open
4 tasks

Add support for campaign status #1639

ottml opened this issue Nov 14, 2023 · 9 comments

Comments

@ottml
Copy link
Contributor

ottml commented Nov 14, 2023

  • Store/Load campaign status in/from settings (mission playable/finished)
  • Api for querying and setting status of a campaign
    isFinished(UID,missionId) setFinished(UID,missionId)
    isPlayable(UID,missionId) setPlayable(UID,missionId)
  • Add unique identifier for each campaign to identify it in the api uniquely
  • Add unit-tests
@Spikeone
Copy link
Member

Just thinking, isn't the UID (guess thats the campaign ID?) the folder name? Since they are unique, otherwise you'd overwrite an existing campaign. That'd also allows easy manual unlocking of missions (e.g. you don't want to play mission 3 of the roman campaign).

I think we should allow campaign creators to unlock missions by Id (as you mentioned it I guess), since that'd allow branching stories, e.g. if you decide to defeat player 2 in mission 2, you unlock mission 4 instead of 3, while defeating player 3 would unlock mission 3. Alas this is currently not required and maybe is never, I still like having the option :)

@Flamefire
Copy link
Member

The API looks good. Question is only how to get the UID. I guess as you only need them from within a campaign it would be great to not having to specify it at all but make the C++ code calculate it, e.g. a hash of the path to the campaign description. But I'm not sure how'd we be able to get that from inside a running game or a savegame.

So "missionId" = index of the mission in the campaign, and UID is what we need to determine somehow. If it needs to be passed by the LUA script, it can't be the folder name as a campaign might reside in different folders (for different users) and still be the same (e.g. "world" and "world-testing-for-dev"). So how would a lua script know about it?

@Spikeone
Copy link
Member

So "missionId" = index of the mission in the campaign, and UID is what we need to determine somehow. If it needs to be passed by the LUA script, it can't be the folder name as a campaign might reside in different folders (for different users) and still be the same (e.g. "world" and "world-testing-for-dev"). So how would a lua script know about it?

But does that really matter? Since they are two different campaigns at all, they should have different IDs as well or am I missing something?

@Flamefire
Copy link
Member

That is exactly my point. The lua script would call isFinished("world", 2) not knowing it is modifying a potentially different campaign status

@ottml
Copy link
Contributor Author

ottml commented Nov 15, 2023

After starting a game we do not know anymore from which campaign we are coming. The same is true for a savegame. Therefore we need a UID to have the relation between the campaign and the currently played game.

I think we have different options here.

  1. Add the UID to the campaign.lua file and to all *.lua files of the missions. This is not optimal because we have to duplicate the UID at several places which leads to errors.
  2. Like 1. but we can provide an uid.lua in the campaign folder containing the id and include this in the campaign.lua and the missions lua files so we we have only one place of truth. I am not sure if this is supported by the savegame.

How the UID is computed is another thing. We can for example take the path to the campaign folder and apply a sha1 hash to it and us it as UID as @Flamefire already mentioned. We can also choose an arbitrary UUID (https://de.wikipedia.org/wiki/Universally_Unique_Identifier) 550e8400-e29b-11d4-a716-446655440000, which is independent from all pathes.

@ottml
Copy link
Contributor Author

ottml commented Nov 15, 2023

Just thinking, isn't the UID (guess thats the campaign ID?) the folder name? Since they are unique, otherwise you'd overwrite an existing campaign. That'd also allows easy manual unlocking of missions (e.g. you don't want to play mission 3 of the roman campaign).

I think we should allow campaign creators to unlock missions by Id (as you mentioned it I guess), since that'd allow branching stories, e.g. if you decide to defeat player 2 in mission 2, you unlock mission 4 instead of 3, while defeating player 3 would unlock mission 3. Alas this is currently not required and maybe is never, I still like having the option :)

For the old World campaign we need the possibility to enable more then one mission. For example if Europa is conquered Africa,Grönland and North Asia is enabled.

@Flow86
Copy link
Member

Flow86 commented Nov 17, 2023

why not storing the campaign (the script / the folder, whatever) in the map info? we already have that as a struct now, so starting from a campaign the game could simply recognize the campaign and trigger something on loss/win?

No weird uid, no complicated stuff, only the campaign info available.

Then:

  • maps can be in multiple campaigns
  • map scripts can be reused
  • only important thing is the campaign script itself.
  • Unlocks can be configured in the campaign lua with methods, which are called by the isfinished/failed from the map lua

@Flamefire
Copy link
Member

No weird uid, no complicated stuff, only the campaign info available.

I see trouble keeping that available when continuing a savegame. We currently store the gamestate with the map and map script. Did you intend to add the campaign script to that and let that declare some kind of name the campaign screen then recognizes? And where would you store the unlocked/finished map states? That would need to be available in the campaign-mission screen which reloads the campaign script from scratch.

@Flow86
Copy link
Member

Flow86 commented Nov 20, 2023

we would need to have a campaign savegame - adding additional information to the savegame shouldnt be a problem, I thought we anyway have a custom format? storing the campaign name to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants