Thou Shalt Not Replace Factions via XSL.
Seriously, what gives, lol. If you do a XSLT replacement of any Faction's entry (note; minor change to a value in an Attribute; we're not talking about trying to nuke a Node), it generates some very weird issue with saves; the game can run normally, but will crash the next time the save is loaded (something about BanditComponent / getting the Owner returns null). This doesn't affect brand-new Factions, just old ones. So, er... how on Earth can we do minor things like replacing a Faction's name, even? Post-load code changes? Specific XLST replacement of just that Attribute value? IDK. Not the end of the universe, but it's just bizarre that a bug like this is still in 3 years later.
Meanwhile, I've finally started digging into the economy a bit. Wheeeeeeeeeee. There's a lot to unpack here, and so much I don't know and can't know, because the source involved isn't available.
1. There are bizarre relationships between how much money is in a Town's shop and the contents of its Shop inventory. Seriously. I encountered this with an early build to address the next problem on this list; if a Town has a lot of items in its inventory, available cash disappears for some bizarre reason.
Moreover, that cash isn't accessible via an obvious place (like, "shopGold" etc.); I'm sure I'll find it eventually, but what on Earth was the thinking here? Shop gold should be basically infinite and shouldn't be in any way tied to the inventory; the least-Fun idea in videogames about getting massive piles of loot is that you have literally nowhere to sell it, lol.
2. I've written some basic, crude code that addressed the other major elephant in the room in terms of how shops work now. That's the explicit, obvious, heavy-handed level-gating.
I presume most people who've played the game for a bit know this, but you simply won't see high-tier gear in the Towns until pretty late in the game. There's a giant, yawning period in the midgame where the player can afford better gear, but there's literally nothing to buy, anywhere.
I think that's Not Fun, so I've written another inventory-management script to address that, along with culling the CraftedItems. Basically, it now culls CraftedItems (so that only my new weapons tend to show up) and if there isn't much gear in the shop, it puts more in, using a "curated" list of known-safe items. Now that I know about the weird money issues that'll happen w/ inventories, I've culled trade goods, with the thought that that's maybe what's going on here; probably at some point soon I'll do an "always check" to make sure that the Town has some Food in its inventory, cull random items, etc., but this basic version allows all items a chance to spawn over time.
Seriously, what gives, lol. If you do a XSLT replacement of any Faction's entry (note; minor change to a value in an Attribute; we're not talking about trying to nuke a Node), it generates some very weird issue with saves; the game can run normally, but will crash the next time the save is loaded (something about BanditComponent / getting the Owner returns null). This doesn't affect brand-new Factions, just old ones. So, er... how on Earth can we do minor things like replacing a Faction's name, even? Post-load code changes? Specific XLST replacement of just that Attribute value? IDK. Not the end of the universe, but it's just bizarre that a bug like this is still in 3 years later.
Meanwhile, I've finally started digging into the economy a bit. Wheeeeeeeeeee. There's a lot to unpack here, and so much I don't know and can't know, because the source involved isn't available.
1. There are bizarre relationships between how much money is in a Town's shop and the contents of its Shop inventory. Seriously. I encountered this with an early build to address the next problem on this list; if a Town has a lot of items in its inventory, available cash disappears for some bizarre reason.
Moreover, that cash isn't accessible via an obvious place (like, "shopGold" etc.); I'm sure I'll find it eventually, but what on Earth was the thinking here? Shop gold should be basically infinite and shouldn't be in any way tied to the inventory; the least-Fun idea in videogames about getting massive piles of loot is that you have literally nowhere to sell it, lol.
2. I've written some basic, crude code that addressed the other major elephant in the room in terms of how shops work now. That's the explicit, obvious, heavy-handed level-gating.
I presume most people who've played the game for a bit know this, but you simply won't see high-tier gear in the Towns until pretty late in the game. There's a giant, yawning period in the midgame where the player can afford better gear, but there's literally nothing to buy, anywhere.
I think that's Not Fun, so I've written another inventory-management script to address that, along with culling the CraftedItems. Basically, it now culls CraftedItems (so that only my new weapons tend to show up) and if there isn't much gear in the shop, it puts more in, using a "curated" list of known-safe items. Now that I know about the weird money issues that'll happen w/ inventories, I've culled trade goods, with the thought that that's maybe what's going on here; probably at some point soon I'll do an "always check" to make sure that the Town has some Food in its inventory, cull random items, etc., but this basic version allows all items a chance to spawn over time.
C#:
public static void removeAllCraftedWeapons()
{
List<ItemObject> curatedList = new List<ItemObject>();
foreach(ItemObject itmObj in Items.All)
{
if( !itmObj.IsCraftedWeapon &&
!itmObj.IsUniqueItem &&
!itmObj.HasBannerComponent &&
!itmObj.IsFood &&
!itmObj.IsAnimal &&
!itmObj.NotMerchandise &&
!itmObj.IsTradeGood
)
{
curatedList.Add(itmObj);
}
}
foreach(Settlement set in Settlement.All)
{
Roster.ItemRoster roster = set.ItemRoster;
if (roster != null)
{
foreach (ItemRosterElement item in roster)
{
EquipmentElement element = item.EquipmentElement;
ItemObject itemobject = element.Item;
if (itemobject.IsCraftedWeapon || itemobject.NotMerchandise)
{
roster.Remove(item);
}
}
}
//In towns, generate a much wider number of items, to ensure that everything's always buyable... somewhere!
//This gets around Taleworld's rather-transparent level-gating systems, which I find boring.
if (set.IsTown)
{
if (roster.Count < 150)
{
if (curatedList.Count > 0)
{
for (int i = 0; i < 10; i++)
{
ItemObject randomItem = curatedList.GetRandomElementInefficiently();
//InformationManager.DisplayMessage(new InformationMessage("Adding randomized item: " + randomItem.StringId, new Color(1f, 0f, 0f)));
roster.AddToCounts(randomItem, 1);
}
}
}
}
}
}