How to create joinable kingdoms with C#?

Users who are viewing this thread

Suurnil

Recruit
I'm trying to create joinable kingdom factions from independent clans.
Currently I can create clans using the following code:
Code:
Clan clan = MBObjectManager.Instance.CreateObject<Clan>();
TextObject clanName = new TextObject($"{clanLeader.Name} {mainClan.Name}");
CultureObject clanCulture = clanLeader.Culture;
Banner clanBanner = mainClan.Banner;
clan.InitializeClan(clanName, clanName, clanCulture, clanBanner);

This adds the clan into the game, with an encyclopedia entry, and any changes I make in the code are reflected in the game.
I tried to do the same thing with kingdoms, but for some reason they don't show up in the encyclopedia, and aren't listed as a joinable kingdom when I use the console command: campaign.join_kingdom help

This is the code I'm currently using for creating a kingdom:
Code:
Kingdom kingdom = MBObjectManager.Instance.CreateObject<Kingdom>();
TextObject name = new TextObject($"{ruler.Name} {mainKingdom.Name}");
CultureObject culture = ruler.Culture;
Banner banner = mainKingdom.Banner;
uint color1 = ruler.Clan.Color;
uint color2 = ruler.Clan.Color2;
Settlement homeland = ruler.HomeSettlement;
kingdom.InitializeKingdom(name, name, culture, banner, color1, color2, homeland);

Does anyone know how to make a kingdom joinable using C#?
 
Solution
It turns out that the code I'm using actually DOES work.
For some reasons kingdoms only show up in the encyclopedia after a save is loaded. This includes the player-created kingdom.
I've tested it in-game and the kingdom can be joined by the player, and seems to engage in diplomacy. (one of the kingdoms I made was at war by the time I was able to join it)
It turns out that the code I'm using actually DOES work.
For some reasons kingdoms only show up in the encyclopedia after a save is loaded. This includes the player-created kingdom.
I've tested it in-game and the kingdom can be joined by the player, and seems to engage in diplomacy. (one of the kingdoms I made was at war by the time I was able to join it)
 
Upvote 0
Solution
Back
Top Bottom