A fun project for myself - The Skyrim Alchemy System

I've played a bit of Skyrim today, a cool project came to me when doing some alchemy: To implement an ingredients and potions mechanism.

Don't ask for code, when the light bulb struck my xbox was off and this message being typed.

The idea I have in my head is both the ingredients and potions are classes ( I'm leaning toward structs for ingredients ) but I'm not sure how to code the actual "effect".

Each ingredient has 4 effects, I'm not sure whether an effect could be a struct:

1
2
3
4
5
6
struct Effect
{
    int ID;            // Each effect is just an ID number?
    std::string name;  // Effect has a name
    int value;         // The strength of the ingredient
};


I feel like I am missing something here, now how does a potion get made?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
struct Ingredient
{
    Effect Effects[4]; // Give the ingredient effects
    std::string name;  // Ingredient name
};

class Potion
{
private:
     Effect Effects[4]; // Potion have up to 4 effects for simplicities sake
public:
     void AddEffect(Effects);
};

Potion MakePotion(Ingredient1, Ingredient2) // return a potion from given ingredients
{
    Potion temp;
    for(int i = 0; i < 4; i++) // Loop through all 16 combinations
    {
         for(int j = 0; j < 4; j++)
         {
             if(Ingredient1.Effects[i] == Ingredient2.Effects[j]) // If ingredient effects match, add them to potion
             {
                 temp.AddEffect(Ingredient1.Effects[i];
             }
         }
    }
    delete Ingredient1; delete Ingredient2; // "Use" the ingredients
    return temp;
}



I oughta stop coding in the code tabs and copy and paste from a text editor.

Looking for comments and feedback, cheers.
Effect Effects[4]; // Potion have up to 4 effects for simplicities sake

Mathematically, the most effects any potion can have is 6, not 4:


3 ingredients
* 4 effects per ingredient
/ 2 like ingredients to produce an effect
= 6 effects maximum per potion


Though if you are sticking to only 2 ingredients (as you appear to be in your code), then 4 would be the max.

I oughta stop coding in the code tabs and copy and paste from a text editor.


Yes. I pretty much always have Notepad++ open when posting code (or making really long posts that I fear might get deleted due to connection problems)




Anyway your pseudo code looks fine to me. One thing to change might be to take the "stronger" effect rather than simply ingredient1's effect. IE: Giant's Toes make stronger potions regardless of which "slot" you put them in when mixing.
Good evening Disch, thanks for the reply.

I am aware of 6 being the max ( Though I've only got 5 at most I think, care to share your recipes? ;) though I wasn't sure how to make a variadic function to cope with 2 or 3 ingredients ( I didn't think I should be focusing on that, anyway )


Again I cannot fault taking the "stronger" ingredient, I'm not exactly sure how to calculate which ingredient is stronger.

Could you also touch up a little how the effect would actually work in practice? How would an effect ID actually turn into that extra 120 carry weight for 300 seconds.
If you want to copy Skyrim alchemy system, these links might help you:
http://www.uesp.net/wiki/Skyrim:Alchemy_Effects
http://www.uesp.net/wiki/Skyrim:Ingredients

Topic archived. No new replies allowed.