Skip to content

Discard add_opinion effects in vanilla CK3 characters #2128

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

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ImperatorToCK3/CK3/Characters/CharactersLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public void LoadCK3Characters(ModFilesystem ck3ModFS, Date bookmarkDate) {
string[] irrelevantEffects = ["set_relation_rival", "set_relation_potential_rival", "set_relation_nemesis",
"set_relation_lover", "set_relation_soulmate",
"set_relation_friend", "set_relation_potential_friend", "set_relation_best_friend",
"set_relation_ward", "set_relation_mentor",];
"set_relation_ward", "set_relation_mentor",
"add_opinion",
];

foreach (var character in loadedCharacters) {
// Remove post-bookmark history except for births and deaths.
Expand Down
19 changes: 10 additions & 9 deletions ImperatorToCK3/CK3/Dynasties/DynastyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,15 @@ public void FlattenDynastiesWithNoFounders(CharacterCollection characters, House
continue;
}

var dynastyHouses = houses.Where(h => h.DynastyId == dynasty.Id).ToArray();
List<Character> cadetHouseMembers = [];
foreach (var house in dynastyHouses) {
var houseMembers = characters.Where(c => c.GetDynastyHouseId(date) == house.Id);
cadetHouseMembers.AddRange(houseMembers);
}
var dynastyHouseIds = houses
.Where(h => h.DynastyId == dynasty.Id)
.Select(h => h.Id)
.ToArray();
var cadetHouseMembers = characters
.Where(c => dynastyHouseIds.Contains(c.GetDynastyHouseId(date)))
.ToArray();

if (cadetHouseMembers.Count == 0) {
if (cadetHouseMembers.Length == 0) {
continue;
}

Expand All @@ -163,8 +164,8 @@ public void FlattenDynastiesWithNoFounders(CharacterCollection characters, House
}

// Remove all the cadet houses.
foreach (var house in dynastyHouses) {
houses.Remove(house.Id);
foreach (var houseId in dynastyHouseIds) {
houses.Remove(houseId);
}

++count;
Expand Down
Loading