Shops have limited gold supply

Show off your mod creations or just a work in progress.
User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Thu Apr 09, 2020 11:36 pm

So another small progress update. I figured out how to get various useful details about a building that was just entered, and will very likely be using that info to keep track of what shops have had their gold supplies "set" for a given amount of time, and what ones have not when you enter one.

The other thing being most of the formula being created that will actually "generate" the amount of gold that a given shop that was just entered will be assigned when first entered. This currently being determined mostly by shop quality, as well as the "regional adjuster" which is mostly a random number at the moment. As well as another random number multiplying the whole thing to give more variable gold values, instead of boring values like 20000.

In reality, this was the easy parts, still need to actually figure out how to save data to a JSON file to keep the gold values of shops from being reset every-time one is entered before the restock cycle has expired. As well as being able to keep the values saved after the game is saved/loaded. This is quite the big hurdle for someone who has never did any read/writing to JSON files for data, but hopefully with the example of the "PersistentDungeons" mod I will be able to figure this out much more quickly.

Code: Select all

private static void Testing_OnTransitionInterior(PlayerEnterExit.TransitionEventArgs args)
		{
			int buildingQuality = 0;
			int buildingKey = 0;
			int mapID = 0;
			int currentGoldSupply = 0;
			
			buildingQuality = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.quality;
			buildingKey = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey;
			mapID = GameManager.Instance.PlayerGPS.CurrentLocation.MapTableData.MapId;
			
			if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop)
			{
				Debug.Log("You Just Entered An Open Shop, Good Job!...");
				currentGoldSupply = GoldSupplyAmountGenerator (buildingQuality);
			}
			else
				Debug.Log("You Just Entered Something Other Than An Open Shop...");
			
			Debug.LogFormat("mapID = {1} and buildingKey = {0}. The Quality of the building is {2}. currentGoldSupply = {3}.", buildingKey, mapID, buildingQuality, currentGoldSupply); // Higher Quality value = better shop quality.
		} // So MapID and BuildingKey seem to be what is used to identify a specific "Scene" or building interior. So these would likely be needed to track different shops.
		
		
public static int GoldSupplyAmountGenerator(int buildingQuality)
		{
			int currentRegionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
			int regionCostAdjust = GameManager.Instance.PlayerEntity.RegionData[currentRegionIndex].PriceAdjustment / 100;
			float varianceMaker = (UnityEngine.Random.Range(1.001f, 2.001f));
			
			return (int)Mathf.Ceil(((buildingQuality * 2) + (regionCostAdjust + 1)) * (float)(500 * varianceMaker));
		}

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Mon Apr 13, 2020 9:09 pm

BadLuckBurt helped me get across the latest barricade in my path, hopefully any other mod creators might find this post useful at some point. Now I have to work on reading and writing to a JSON file for persisting store data.

viewtopic.php?f=22&t=3598

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Wed Apr 22, 2020 8:47 pm

Made some more progress and was recommended that I make a Github Repository for the current state of the mod, so I made one. Here it is if anyone wants to mess with it, or do anything with it, will try and update it as I work on the mod.


https://github.com/magicono43/Alpha_DFU ... Gold-Shops

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Tue May 05, 2020 5:29 pm

Lots more progress thanks to BadLuckBurt as well as Pango. So now basically all of the "sava-data" related problems have been dealt with, which was a big wall for me at first. Now the next part is probably going to be just as much of a new experience as the last, but hopefully can go smoothly as well. Being able to give the player the amount of gold that the store they are in currently has.

Now I could go the lazy route and just have a scrolling message inform them of this value, but that's sort of lame, so i'm going to try and have this value displayed on the trade menu (even with how little unoccupied space there is to work with). I'm going to be using the code from the "Inventory Filter" mod as an example on how to hopefully do this in a similar way that it does.

Then the next problem (that might only be resolvable in a clean way in the next update) is updating this gold value as the player makes trades, both buying and selling items from a shop, as well as disallowing further trades if the gold amount would go into the negatives for the shop. This will likely be the last thing that gets worked on before releasing the mod into 1.0.

Depending on how things are looking with coding issues that pop-up, I will either implement the "Shop Investment" system into 1.0, or release this feature in a 1.1 update, depending on how difficult it is looking, but I already have a decent idea of how i'm going to do it thankfully, the main hurdle will be adding into the merchant talk window the option to "Invest" in shops, similar to how you can do in Oblivion.

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Fri May 15, 2020 5:18 pm

Not sure why, but I went a bit overboard with a mostly minor thing after some suggestions from people on the Discord. So figure may as well post a few examples of what I have been doing in this sense. I added an "attitude" attribute to the save-data for shops, for now it's either just a 0 or a 1, one being "nice" the other being "mean". Practically this does not change anything (for now) besides the dialogue that the shop owner will give in the sell and possibly buy menus when certain text-boxes appear, the quality of the shop also determines some of these dialogues for added flavor.
Worst Quality Shop Text Mean.JPG
Worst Quality Shop Text Mean.JPG (92.78 KiB) Viewed 122 times
Second Best Quality Shop Text.JPG
Second Best Quality Shop Text.JPG (85.28 KiB) Viewed 122 times
Best Quality Shop Text.JPG
Best Quality Shop Text.JPG (85.34 KiB) Viewed 122 times

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Sun May 17, 2020 12:15 am

This now finally works.
Working_Text_Update.gif
Working_Text_Update.gif (18.77 KiB) Viewed 106 times

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Mon May 18, 2020 2:58 am

So feature-wise, I pretty much have everything done in terms of general functionality as well as some bugs resolved. Now I mostly need to clean up the code and make an organized "release" version of the mod. Before all of that though, i'm going to work on the Investment mechanic.

Question with this one if anyone feels like putting their opinion out there. Should the investment mechanic be gated behind a minimum mercantile skill level like it is in Oblivion? Or should you be allowed to invest in a shop no matter how low your mercantile skill is? Either way i'm going to have the mercantile skill of the player effect how much the outcome in the end is from the investment at the time they invested, so a higher mercantile skill will increase the end-outcome of an investment in a shop. The question is if this feature should be locked off to anyone below say 30 mercantile skill? What is your opinion on that part of the mechanic?

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Thu May 21, 2020 2:45 pm

Here is the first of the two altered UI window assets I made.
Finished_Image_Replacement.png
Finished_Image_Replacement.png (7.26 KiB) Viewed 42 times

Here is what it looks like in game:
Untitled545.png
Untitled545.png (1.69 MiB) Viewed 42 times
It's slightly squashed by about 9 pixels, i'm attempting to fix that panel size problem.

Fixed it:
Untitled546.png
Untitled546.png (1.61 MiB) Viewed 34 times

User avatar
Magicono43
Posts: 271
Joined: Tue Nov 06, 2018 7:06 am

Re: Shops have limited gold supply

Post by Magicono43 » Sat May 23, 2020 4:29 pm

So as I've been working on the code for the investing feature of this mod, I thought of something potentially interesting. Basically having the ability to possibly raise a shop's base quality by investing in said shop with enough gold, as well as have enough time pass with those investments and such.

The idea being with enough time and resources even the worst squaller merchants can make their shop even just a little bit better than it was before. I don't plan on adding this for release of the mod by any means, but possibly something to think of for a potential later version of the mod. It would not be easy as these quality values are pre-determined by the world-data and such, but i'm sure it would be possible.

Post Reply