Currency Mod Idea

Talk about the mods or features you'd like to see in Daggerfall Unity. Give mod creators some ideas!
User avatar
NikitaTheTanner
Posts: 266
Joined: Sun Oct 18, 2015 7:57 pm

Re: Currency Mod Idea

Post by NikitaTheTanner » Sun Apr 16, 2017 12:12 am

Narf the Mouse wrote:Given the relative sizes of the coins, 1:100 seems reasonable. I'd think something like 1:20, which is more historical AFAIK, would be more for coins that are roughly the same size (but different materials, of course).

Should probably investigate DFU sources again. In fact... *Heads off to do just that*
Yeah, I've tried to make coins different in size for that reason specifically, to make it more reasonable. Still not sure if one large gold coin is worth 100 silver ones, but maybe it's thicker IDK ;)

As for Dime - bronze sounds cool and is easily memorized (like in Olympics - gold, silver, bronze medal), but copper is more hystorical, I think (though there obviously were bronze coins, don't think they were the least valueable). But it's Tamriel and things are different, Ebony is not even made of wood! :P So I think bronze can be a bit more common, I guess.

Which one we choose - bronze or copper is not really the biggest question right now. Implementation in the game - that's what I want.

As for sources, if you do check them out, can you point me in the general direction? I am only learning C#, and I kinda get lost in the repo right now, but with some directions will try to figure out how it works. :ugeek:

Here's an approximation of how it may look in the character sheet and inventory (pretty much simply added icons):
Image

Narf the Mouse
Posts: 354
Joined: Mon Nov 30, 2015 6:32 pm

Re: Currency Mod Idea

Post by Narf the Mouse » Sun Apr 16, 2017 12:50 am

NikitaTheTanner wrote:
Narf the Mouse wrote:Given the relative sizes of the coins, 1:100 seems reasonable. I'd think something like 1:20, which is more historical AFAIK, would be more for coins that are roughly the same size (but different materials, of course).

Should probably investigate DFU sources again. In fact... *Heads off to do just that*
As for sources, if you do check them out, can you point me in the general direction? I am only learning C#, and I kinda get lost in the repo right now, but with some directions will try to figure out how it works. :ugeek:
Have you gone through the tutorial Interkarma posted? Once you do that, you should have DU as a Unity project.

From there, well, I'm afraid the best and only way to get familiar with source code is trial and error... :)

You could also put comments on code as you figure out what it does, then submit that as a *pull request, meaning you contribute, and figure out what stuff does at the same time. :)

If you're wondering how to clone the repository in the first place, first you need a github (website) registration, and then you download and install **Github Desktop.

For installing Unity Game Engine, go ***here and download and install "Patch 5.5.0p3" for either Windows or Mac, whichever you use.

If you've got all that done, this tutorial will walk you through the rest: viewtopic.php?f=4&t=479

Be aware that all this could take up 40+ GB, depending on how many "additional options" you select.

For learning C# in general, what generally helps me learn a new thing is to type, for example, "learn C#" into Amazon, then check the highest-reviewed books - Nothing less than 4.5. Next, check the highest reviews, and the lowest reviews.

A positive review that says "Really gets deep into the complex details" can be a definite negative for a beginner, depending on how you learn, while a negative review that says "Not enough detail" can be a positive review under vice-versa.

In short, you kinda gotta review the reviews.

Also, Googling "good beginning book for X" can help, too.

Also, Quill18 has some fantastic beginner and advanced Unity tutorials on Youtube.

Youtube with "X tutorial" or "X beginner tutorial" can also be a good idea. However, check that there's a series of tutorials - If there's a single tutorial, or two or three on the topic, then probably the person themselves doesn't really know.

* https://help.github.com/articles/about-pull-requests/
** https://desktop.github.com/
*** https://unity3d.com/unity/qa/patch-rele ... 5.5&page=3
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

Narf the Mouse
Posts: 354
Joined: Mon Nov 30, 2015 6:32 pm

Re: Currency Mod Idea

Post by Narf the Mouse » Sun Apr 16, 2017 12:58 am

So it turns out "5.5.0p3" is not the same thing as "5.5.0f3", and I don't see a "5.5.0f3" in the patch releases.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

User avatar
NikitaTheTanner
Posts: 266
Joined: Sun Oct 18, 2015 7:57 pm

Re: Currency Mod Idea

Post by NikitaTheTanner » Sun Apr 16, 2017 12:58 am

Well, my primary focus right now is on learning ASP.NET MVC, while Unity is more of a side hobby. So, yeah, I am working with GitHub and know most basic stuff, it's just that it's a lot of code to go through. But thanks for all the advice. I will try to poke around some more ;)

If you find objects related to gold, though, just let me know. It might be easier to know where exactly to look for it. But of course, only if you want to look for it yourself.

Narf the Mouse
Posts: 354
Joined: Mon Nov 30, 2015 6:32 pm

Re: Currency Mod Idea

Post by Narf the Mouse » Sun Apr 16, 2017 1:03 am

NikitaTheTanner wrote:Well, my primary focus right now is on learning ASP.NET MVC, while Unity is more of a side hobby. So, yeah, I am working with GitHub and know most basic stuff, it's just that it's a lot of code to go through. But thanks for all the advice. I will try to poke around some more ;)

If you find objects related to gold, though, just let me know. It might be easier to know where exactly to look for it. But of course, only if you want to look for it yourself.
I'll keep an eye out. :)

Looks like "Unity5.5.0f3" is "unpatched" "Unity 5.5.0", only not actually "unpatched", as the only expansion I can think of for "f3" is "fix 3". Or maybe they just like hanging random alphanumerics off the name for fun. *Shrug*

https://unity3d.com/get-unity/download/ ... 1457766490

So just the base 5.5.0, tl;dr.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

Narf the Mouse
Posts: 354
Joined: Mon Nov 30, 2015 6:32 pm

Re: Currency Mod Idea

Post by Narf the Mouse » Sun Apr 16, 2017 5:24 am

Do you want a hint, or a filename? :)

Or just having fun exploring? :)
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

User avatar
NikitaTheTanner
Posts: 266
Joined: Sun Oct 18, 2015 7:57 pm

Re: Currency Mod Idea

Post by NikitaTheTanner » Sun Apr 16, 2017 11:15 am

Right now, I am checking out "Assets\Scripts\Game\Items" folder, definitely has good stuff.

ItemBuilder.cs:
/// <summary>
/// Generates gold pieces.
/// </summary>
/// <param name="amount">Total number of gold pieces in stack.</param>
/// <returns></returns>
public static DaggerfallUnityItem CreateGoldPieces(int amount)
{
DaggerfallUnityItem newItem = CreateItem(ItemGroups.Currency, (int)Currency.Gold_pieces);
newItem.stackCount = amount;

return newItem;
}
I will continue looking when I have some free time, though I am not sure about the method of implementation. Finding several stacks of coins in inventory is rather clunky, so it would probably just be one stack, which on pick up would tell you how many different coins it has. So, I don't want to change the actual item, just how it shows up.

As for visual representation, later it should be possible to choose one of a few different images, depending on amount of coins in the stack. E.g. only bronze coins if < 100, some bronze and a bit of silver if < 1.000, silver only if < 10.000, some silver and some gold if < 100.000, only gold in the rest of cases (though you would rarely find such amounts in vanilla game anyway :P )

P.S. As for Character Sheet, we can find it in Assets\Scripts\Game\UserInterfaceWindows\DaggerfallCharacterSheetWindow.

Here's what I see there:
void UpdatePlayerValues()
{
// Update main labels
nameLabel.Text = PlayerEntity.Name;
raceLabel.Text = PlayerEntity.RaceTemplate.Name;
classLabel.Text = PlayerEntity.Career.Name;
levelLabel.Text = PlayerEntity.Level.ToString();
goldLabel.Text = PlayerEntity.GoldPieces.ToString();
fatigueLabel.Text = string.Format("{0}/{1}", PlayerEntity.CurrentFatigue, PlayerEntity.MaxFatigue);
healthLabel.Text = string.Format("{0}/{1}", PlayerEntity.CurrentHealth, PlayerEntity.MaxHealth);

// Update stat labels
for (int i = 0; i < DaggerfallStats.Count; i++)
{
statLabels.Text = PlayerEntity.Stats.GetStatValue(i).ToString();
}
}


Don't want to change the amount in PlayerEntity.GoldPieces, I would rather convert it, first probably into string, but later might think of a way to add icons as well. Easiest method is to create a separate method for it and there separate the number into 3 elements: 00 Gold 00 Silver 00 Bronze, and only display as much as needed, depending on amount of "gold" (meaning that it shouldn't display 0 coins).

User avatar
NikitaTheTanner
Posts: 266
Joined: Sun Oct 18, 2015 7:57 pm

Re: Currency Mod Idea

Post by NikitaTheTanner » Sun Apr 16, 2017 4:36 pm

So, I am thinking about something like this at the moment, what do you think? It seems to work in theory and I did some basic tests, but didn't test it in game yet. If somebody can optimize it, I wouldn't mind, maybe it can be optimized a bit.
public string ConvertGold(string totalMoney) {
//Get total gold into String Array
//totalMoney = PlayerEntity.GoldPieces.ToString(), for example

char[] total = totalMoney.ToCharArray();

//Reverse the Array, so it is in correct order
Array.Reverse(total);

string coins = "";

//Check for Gold coins
if (total.Length > 4)
{
int n = 1;

while (n <= total.Length - 4)
{
coins += total[total.Length - n].ToString();
n++;
}

coins += " Gold ";

}

//Check for Silver coins
if (total.Length > 3)
{
coins += total[3].ToString();
}

if (total.Length > 2)
{
coins += total[2].ToString() + " Silver ";
}

//Check for Bronze coins
if (total.Length > 1)
{
coins += total[1].ToString();
}

if (total.Length > 0)
{
coins += total[0].ToString() + " Bronze";
}

if(total.Length == 1 && total[0].ToString() == "0")
{
coins = "None";
}

return (coins);
}
The result is pretty obvious. It converts amount of gold you have, let's say 54120 into:
"5 Gold 41 Silver 20 Bronze"

I have also decided to keep zeros for coins, which are lesser than ones you have. So if you have 10000, it would show:
"1 Gold 00 Silver 00 Bronze"

But if you have only 50, you would get: "50 Bronze"

I think it makes sense, so you can also easily track the full amount of money, but still gives illusion of having different coins.

Narf the Mouse
Posts: 354
Joined: Mon Nov 30, 2015 6:32 pm

Re: Currency Mod Idea

Post by Narf the Mouse » Sun Apr 16, 2017 9:23 pm

A hint for you: Since PlayerEntity.GoldPieces returns an integer:

If you have 10,000+ coins, dividing by Coins by 10,000 gives you gp and modulo by 100 gives you cp. From there, you can figure sp.

Point the second: Strings are slow, and should never be used for math operations where you can use an integer or float. :) Unless the compiler does some optimization better with strings in some specific case.

Point the third: Prefer StringBuilder to string addition; it is very often faster unless you are adding three or fewer strings. However, under some conditions the compiler may convert string addition to StringBuilder.Append(), although I don't know if the older Mono compiler used for Unity C# does that.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

User avatar
NikitaTheTanner
Posts: 266
Joined: Sun Oct 18, 2015 7:57 pm

Re: Currency Mod Idea

Post by NikitaTheTanner » Sun Apr 16, 2017 9:47 pm

That's all true and I was thinking about it. Yeah, I guess using an int is much more sensible rather than splitting the string in parts, plus it gives you values straight away for other uses, if you don't want just to display them.

Post Reply