Learning to code and need some maths help

Not about OpenMW? Just about Morrowind in general? Have some random babble? Kindly direct it here.
Post Reply
User avatar
ArashiAganawa
Posts: 52
Joined: 02 Feb 2017, 02:11

Learning to code and need some maths help

Post by ArashiAganawa » 17 Jun 2020, 05:50

Hi, it's been a while. Someone suggested on here learning Python, and so I have been. It's a ton of fun and I'm doing well with it. I have started on my own project, an app (for phones) that will basically be a "Morrowind Helper" thing. Now I'm doing this because I love Morrowind and so it makes learning easier, I am well aware of all the apps out there that do the things I want to do in terms of being a "Morrowind Helper", but it's for the practice. Anywho, I've been doing an alchemy script that will allow the user to make potions on the go, using all the apparatuses, and taking into account fatigue, skills, and attributes, and allows you to name the potion. The script then tells them the Effect magnitude, duration, worth in gold, name, and chance of success.

My issue comes in with the duration. It's not a straight 3X multiplier when using more than just the mortar and pestle. I've been using OpenMW to run Morrowind and make potions, and testing the results with vanilla Morrowind, and those all match up, but I can't get the duration to match up on my script. My question to you is, how did you do it? What math am I missing? The multiplier seems to range from 2.86 to 3.1 (so far) and that's not consistent either. I've tried all I know, so now I'm asking for help. When you have time, could someone give me some tips?

On a side note, I'm actually really enjoying learning to code and C++ is the next language I will get into once I'm comfortable with Python. My brother just made the jump from C++ to Python, and he's learning as well, and can help teach me a few things. If you know of any online courses or lectures on the C++ that are current, once I'm done, I'd be happy to try them out!
Wisdom ,without love, is foolishness. Knowledge, without heart, is ignorance.

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Learning to code and need some maths help

Post by cc9cii » 17 Jun 2020, 08:28

Should be somewhere in MWMechanics::Alchemy.

EDIT: in case you're wondering - I just used "git grep" (or something equivalent) from my editor.

User avatar
Atahualpa
Posts: 1128
Joined: 09 Feb 2016, 20:03

Re: Learning to code and need some maths help

Post by Atahualpa » 17 Jun 2020, 08:50

Isn't our wiki research page up to date anymore?
=> Research:Player Craft Skills

(Double-checking with the actual code is, of course, a good idea.)

User avatar
ArashiAganawa
Posts: 52
Joined: 02 Feb 2017, 02:11

Re: Learning to code and need some maths help

Post by ArashiAganawa » 17 Jun 2020, 20:46

Atahualpa wrote:
17 Jun 2020, 08:50
Isn't our wiki research page up to date anymore?
=> Research:Player Craft Skills

(Double-checking with the actual code is, of course, a good idea.)
I did check that out, and from what I'm reading (keep in mind I am new to coding so I'm probably missing something), you're getting duration and other information from variables and functions defined elsewhere. I'm not looking to copy your code, as that would not be a learning experience, but rather I'm looking to figure out how you make the duration work. Basically what I want to know is, how did you figure it out?

Presently I have it as

Code: Select all

    if (retqual >= 0.5 and calqual == 0 and alemqual == 0):
        BPD = round(BPS) * 2.95
    elif (retqual == 0 and calqual >= 0.5 and alemqual == 0):
        BPD = round(BPS) * 2.95
    elif (retqual >= 0.5 and calqual >= 0.5 and alemqual == 0):
        BPD = round(BPS) * 2.86
    elif (alemqual >= 0.5 and retqual == 0 and calqual == 0):
        BPD = round(BPS) * 3.1
    elif (alemqual >= 0.5 and retqual == 0 and calqual >= 0.5):
        BPD = round(BPS) * 3
    elif (retqual == 0 and calqual == 0 and alemqual == 0):
        BPD = round(BPS) * 3
Which is highly in efficient. BPD is Base Potion Duration, and BPS is Base Potion Strength. So basically I'm taking the strength and multiplying it to get the duration (based on some information I found on the UESP wiki). I feel I am doing it wrong, so I am looking for some tips you might have on how to solve the issue. I have thought about downloading the source code and using a C++ IDE to look at it as well. However, I have done nothing with C++ and therefore don't know what IDE would be best to do this in. I really do need to do this, as I have a great desire to learn C++ at some point.
cc9cii wrote:
17 Jun 2020, 08:28
Should be somewhere in MWMechanics::Alchemy.

EDIT: in case you're wondering - I just used "git grep" (or something equivalent) from my editor.
I looked up git grep. Is the UI easy on the eyes? Like, is there a high contrast version?
Wisdom ,without love, is foolishness. Knowledge, without heart, is ignorance.

User avatar
AnyOldName3
Posts: 1928
Joined: 26 Nov 2015, 03:25

Re: Learning to code and need some maths help

Post by AnyOldName3 » 17 Jun 2020, 23:18

UI? In Git grep?
AnyOldName3, Master of Shadows

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Learning to code and need some maths help

Post by cc9cii » 18 Jun 2020, 00:48

I'm on Vim plus a bunch of plugins, one of which is [fugitive](https://github.com/tpope/vim-fugitive). But as usual, I had to modify it to do what I want (I don't think tpope was too impressed). I'm lazy so I have a macro setup - just hit <F2> and look for something that might relate to what I'm looking for.

EDIT: running git grep from a terminal gives you a nice colour-coded output which you can pipe to less (but doing so loses the colour I think).

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Learning to code and need some maths help

Post by cc9cii » 18 Jun 2020, 01:39

ArashiAganawa wrote:
17 Jun 2020, 20:46
Basically what I want to know is, how did you figure it out?
A combination of info from experienced players, many volunteers doing empirical studies and possibly some magic (reverse engineering) when all else fails.

User avatar
ArashiAganawa
Posts: 52
Joined: 02 Feb 2017, 02:11

Re: Learning to code and need some maths help

Post by ArashiAganawa » 18 Jun 2020, 02:55

AnyOldName3 wrote:
17 Jun 2020, 23:18
UI? In Git grep?
To be fair, I'm really really new to this, and am just hearing about all these programs for the first time :lol:
cc9cii wrote:
18 Jun 2020, 01:39
ArashiAganawa wrote:
17 Jun 2020, 20:46
Basically what I want to know is, how did you figure it out?
A combination of info from experienced players, many volunteers doing empirical studies and possibly some magic (reverse engineering) when all else fails.
Reverse engineering sounds both fun and frustrating... and tempting.
Wisdom ,without love, is foolishness. Knowledge, without heart, is ignorance.

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Learning to code and need some maths help

Post by cc9cii » 18 Jun 2020, 03:58

Personally I don't find much joy in that - it's just copying somebody else's work by navigating through assembler syntax.

Post Reply