Skip to content

Commit

Permalink
Conditional gendering of factions
Browse files Browse the repository at this point in the history
  • Loading branch information
kaosnyrb committed Dec 11, 2023
1 parent 0ff3847 commit 3156cc2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 55 deletions.
2 changes: 0 additions & 2 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 26 additions & 44 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,19 @@ public void UpdatePlan()
factionPlanTree.Nodes.Add("Plan");
for (int i = 0; i < Armory.plans.Count; i++)
{
Armory.plans[i].faction = Armory.factions[Armory.plans[i].faction.Name];
string originalfaction = Armory.plans[i].faction.Name;
string gendered = Armory.plans[i].faction.Name;
factionPlanTree.Nodes[0].Nodes.Add(Armory.plans[i].faction.Name);
if (originalfaction.Contains(" - Female Only"))
{
originalfaction = originalfaction.Substring(0,originalfaction.IndexOf(" - Female Only"));
}
if (originalfaction.Contains(" - Male Only"))
{
originalfaction = originalfaction.Substring(0, originalfaction.IndexOf(" - Male Only"));
}
// Armory.plans[i].faction = Armory.factions[originalfaction];
Armory.plans[i].faction.Name = gendered;
factionPlanTree.Nodes[0].Nodes[i].Nodes.Add("Clear Vanilla: " + Armory.plans[i].clearvanillaitems.ToString());
for (int j = 0; j < Armory.plans[i].mods.Count; j++)
{
Expand Down Expand Up @@ -241,46 +252,44 @@ private void ExportESMButton(object sender, EventArgs e)
//Levelled Lists
//Here we inject the modded items into the levelled lists defined in the faction files.
//If we're gendered ignore this section
if (plan.gender == "All" || plan.gender == null)
{
if (plan.faction.Hats != null)
{
foreach (var hat in plan.faction.Hats)
{
lastformkey = hat;
LeveledItem.AddItemsToLevelledList(myMod, Armory.hats, hat.modname, hat.formkey, plan.clearvanillaitems);
LeveledItem.AddItemsToLevelledList(myMod, Armory.hats, hat.modname, hat.formkey, plan.clearvanillaitems,plan.gender);
}
}
if (plan.faction.Clothes != null)
{
foreach (var clothes in plan.faction.Clothes)
{
lastformkey = clothes;
LeveledItem.AddItemsToLevelledList(myMod, Armory.clothes, clothes.modname, clothes.formkey, plan.clearvanillaitems);
LeveledItem.AddItemsToLevelledList(myMod, Armory.clothes, clothes.modname, clothes.formkey, plan.clearvanillaitems, plan.gender);
}
}
if (plan.faction.Spacesuits != null)
{
foreach (var suit in plan.faction.Spacesuits)
{
lastformkey = suit;
LeveledItem.AddItemsToLevelledList(myMod, Armory.spacesuits, suit.modname, suit.formkey, plan.clearvanillaitems);
LeveledItem.AddItemsToLevelledList(myMod, Armory.spacesuits, suit.modname, suit.formkey, plan.clearvanillaitems, plan.gender);
}
}
if (plan.faction.SpaceHelmets != null)
{
foreach (var helm in plan.faction.SpaceHelmets)
{
lastformkey = helm;
LeveledItem.AddItemsToLevelledList(myMod, Armory.spacehelmets, helm.modname, helm.formkey, plan.clearvanillaitems);
LeveledItem.AddItemsToLevelledList(myMod, Armory.spacehelmets, helm.modname, helm.formkey, plan.clearvanillaitems, plan.gender);
}
}
if (plan.faction.Boostpacks != null)
{
foreach (var pack in plan.faction.Boostpacks)
{
lastformkey = pack;
LeveledItem.AddItemsToLevelledList(myMod, Armory.boostpacks, pack.modname, pack.formkey, plan.clearvanillaitems);
LeveledItem.AddItemsToLevelledList(myMod, Armory.boostpacks, pack.modname, pack.formkey, plan.clearvanillaitems, plan.gender);
}
}
if (plan.faction.RangedWeapons != null)
Expand All @@ -307,7 +316,6 @@ private void ExportESMButton(object sender, EventArgs e)
LeveledItem.AddItemsToLevelledList(myMod, Armory.grenades, nade.modname, nade.formkey, plan.clearvanillaitems);
}
}
}
//Outfits
//Outfits have another layer of complexity to the levelled lists
//In vanilla some outfits link directly to armor, things like the starborn.
Expand Down Expand Up @@ -404,7 +412,7 @@ private static void BuildSpaceOutfit(FactionPlan plan, IGameEnvironment<IStarfie
Reference = suit.ToLink<ILeveledItemGetter>()
});
}
LeveledItem.AddItemsToList(myMod, Armory.spacesuits, ListOutfitSpacesuit.Entries, 0);
LeveledItem.AddItemsToList(myMod, Armory.spacesuits, ListOutfitSpacesuit.Entries, 0, plan.gender);
newoutfit.Items.Add(ListOutfitSpacesuit);
if (outfit.Helmet == null)
{
Expand All @@ -422,7 +430,7 @@ private static void BuildSpaceOutfit(FactionPlan plan, IGameEnvironment<IStarfie
Reference = helmets.ToLink<ILeveledItemGetter>()
});
}
LeveledItem.AddItemsToList(myMod, Armory.spacehelmets, ListOutfitSpacehelmets.Entries, 0);
LeveledItem.AddItemsToList(myMod, Armory.spacehelmets, ListOutfitSpacehelmets.Entries, 0, plan.gender);
newoutfit.Items.Add(ListOutfitSpacehelmets);
}
foreach (var boost in boostpacks)
Expand All @@ -435,7 +443,7 @@ private static void BuildSpaceOutfit(FactionPlan plan, IGameEnvironment<IStarfie
Reference = boost.ToLink<ILeveledItemGetter>()
});
}
LeveledItem.AddItemsToList(myMod, Armory.boostpacks, ListOutfitBoostPacks.Entries, 0);
LeveledItem.AddItemsToList(myMod, Armory.boostpacks, ListOutfitBoostPacks.Entries, 0, plan.gender);
newoutfit.Items.Add(ListOutfitBoostPacks);
}
catch (Exception ex)
Expand Down Expand Up @@ -490,7 +498,7 @@ private static void BuildClothesOutfit(FactionPlan plan, IGameEnvironment<IStarf
}
//clear outfit
var newoutfit = myMod.Outfits.GetOrAddAsOverride(link);
newoutfit.Items.Clear();
//newoutfit.Items.Clear();

//create levelled list for each category for this outfit
var ListOutfitHats = myMod.LeveledItems.AddNew();
Expand Down Expand Up @@ -523,41 +531,15 @@ private static void BuildClothesOutfit(FactionPlan plan, IGameEnvironment<IStarf
});
}
//add modded items to each levelled list
LeveledItem.AddItemsToList(myMod, Armory.hats, ListOutfitHats.Entries, 0);
LeveledItem.AddItemsToList(myMod, Armory.clothes, ListOutfitClothes.Entries, 0);
LeveledItem.AddItemsToList(myMod, Armory.hats, ListOutfitHats.Entries, 0, plan.gender);
LeveledItem.AddItemsToList(myMod, Armory.clothes, ListOutfitClothes.Entries, 0, plan.gender);
//Add each levelled list to outfit
if (plan.gender == "All")
if (outfit.Helmet == null)
{
if (outfit.Helmet == null)
{
newoutfit.Items.Add(ListOutfitHats);
}
newoutfit.Items.Add(ListOutfitClothes);
newoutfit.Items.Add(ListOutfitHats);
}
else
{
var topleveloutfit = myMod.Outfits.AddNew();
topleveloutfit.EditorID = newoutfit.EditorID + "_SA_" + plan.gender;
topleveloutfit.Items = new ExtendedList<IFormLinkGetter<IOutfitTargetGetter>>();
if (!outfitmapping.Keys.Contains(newoutfit.EditorID))
{
outfitmapping.Add(newoutfit.EditorID, newoutfit.EditorID + "_SA_" + plan.gender);
}
if (outfit.Helmet == null)
{
topleveloutfit.Items.Add(ListOutfitHats);
}
topleveloutfit.Items.Add(ListOutfitClothes);

//Fun part, now we need to update every npc of a bodytype to wear the new outfit.
//Loop through all npcs.... :|
//Mutagen doesn't support this yet...
/*
foreach (var mod in env.LoadOrder)
{
mod.Value.Mod.Npcs
}*/
}
newoutfit.Items.Add(ListOutfitClothes);
}
catch (Exception ex)
{
Expand Down
71 changes: 62 additions & 9 deletions LeveledItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
using Mutagen.Bethesda;
using Noggog;
using Microsoft.VisualBasic.Logging;
using log4net.Core;

namespace StarArmory
{

class LeveledItem
{
public static void AddItemsToLevelledList(StarfieldMod myMod, List<IArmorGetter> newitems, string esmname, uint levellist, bool clearlist = false)
public static void AddItemsToLevelledList(StarfieldMod myMod, List<IArmorGetter> newitems, string esmname, uint levellist, bool clearlist = false, string gender = "All")
{
using (var env = StarArmory.GetGameEnvironment())
{
Expand Down Expand Up @@ -82,13 +83,38 @@ public static void AddItemsToLevelledList(StarfieldMod myMod, List<IArmorGetter>
{
level = (short)(newitems[i].ArmorRating / 10);
}
newlist.Entries.Add(new LeveledItemEntry()

var entry = new LeveledItemEntry()
{
Level = level,
ChanceNone = new Noggog.Percent(0),
Count = 1,
Reference = newitems[i].ToLink<ILeveledItemGetter>()
});
Reference = newitems[i].ToLink<ILeveledItemGetter>(),

};
var condition = new ConditionFloat();
if (gender == "Male Only") {
condition.CompareOperator = CompareOperator.EqualTo;
condition.ComparisonValue = 1;
condition.Data = new GetIsSexConditionData()
{
RunOnType = Condition.RunOnType.Subject,
FirstParameter = Mutagen.Bethesda.Plugins.Records.MaleFemaleGender.Male,
};
entry.Conditions.Add(condition);
}
if (gender == "Female Only")
{
condition.CompareOperator = CompareOperator.EqualTo;
condition.ComparisonValue = 1;
condition.Data = new GetIsSexConditionData()
{
RunOnType = Condition.RunOnType.Subject,
FirstParameter = Mutagen.Bethesda.Plugins.Records.MaleFemaleGender.Female,
};
entry.Conditions.Add(condition);
}
newlist.Entries.Add(entry);
}
}
}
Expand Down Expand Up @@ -147,17 +173,44 @@ public static void AddItemsToLevelledList(StarfieldMod myMod, List<IWeaponGetter
}
}

public static void AddItemsToList(StarfieldMod myMod, List<IArmorGetter> newitems, ExtendedList<LeveledItemEntry> leveledItemEntries, double ChanceNone)
public static void AddItemsToList(StarfieldMod myMod, List<IArmorGetter> newitems, ExtendedList<LeveledItemEntry> leveledItemEntries, double ChanceNone, string gender = "All")
{

for (int i = 0; i < newitems.Count; i++)
{
leveledItemEntries.Add(new LeveledItemEntry()
var entry = new LeveledItemEntry()
{
Level = 1,
ChanceNone = new Noggog.Percent(ChanceNone),
ChanceNone = new Noggog.Percent(0),
Count = 1,
Reference = newitems[i].ToLink<ILeveledItemGetter>()
});
Reference = newitems[i].ToLink<ILeveledItemGetter>(),

};
var condition = new ConditionFloat();
if (gender == "Male Only")
{
condition.CompareOperator = CompareOperator.EqualTo;
condition.ComparisonValue = 1;
condition.Data = new GetIsSexConditionData()
{
RunOnType = Condition.RunOnType.Subject,
FirstParameter = Mutagen.Bethesda.Plugins.Records.MaleFemaleGender.Male,
};
entry.Conditions.Add(condition);
}
if (gender == "Female Only")
{
condition.CompareOperator = CompareOperator.EqualTo;
condition.ComparisonValue = 1;
condition.Data = new GetIsSexConditionData()
{
RunOnType = Condition.RunOnType.Subject,
FirstParameter = Mutagen.Bethesda.Plugins.Records.MaleFemaleGender.Female,
};
entry.Conditions.Add(condition);
}

leveledItemEntries.Add(entry);
}
}
}
Expand Down

0 comments on commit 3156cc2

Please sign in to comment.