Vampirism & Lycanthropy & Potions

Discuss coding questions, pull requests, and implementation details.
User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Vampirism & Lycanthropy & Potions

Post by Interkarma »

I'm looking at building out these parts of 0.9 while wrapping up effect system elements. Not only is there some crossover, it gives me something fun to alternate with rather than being stuck in the drudgery of building effects one after another.

I'm on leave as of today and hoping to work on this over next few weeks. I just wanted to make sure nobody else has made a start on this before I dive in.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Vampirism & Lycanthropy

Post by Hazelnut »

I'd started to give some thought to how this could be done, mainly when it comes to guild memberships etc, but we're talking a few minutes here and there. Nothing more than idle speculation with no conclusions. Seems that Vampires lose their rank but not rep so can re-join and get promoted back to old rank. If cured UESP isn't clear but I did wonder if we'll need a second tracker for membership during life as a vamp. Please let me know when you have any guild / logistics stuff to change and I'll pitch in.

I've been thinking that I should make potions work, if you think the effects systems are developed enough. I know you said you'd done some of the foundations back in June, is it at the point you would be happy for me to try and use it?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Vampirism & Lycanthropy

Post by Interkarma »

Hazelnut wrote: Sat Dec 15, 2018 4:09 pm I've been thinking that I should make potions work, if you think the effects systems are developed enough. I know you said you'd done some of the foundations back in June, is it at the point you would be happy for me to try and use it?
I made a start and laid down some concepts but it still needs work. If you're happy to progress this, I know you'll do a good job. Here are the core concepts so far:
  • PotionRecipe.cs formalises an array of Ingredient[] with equality comparison, hashing, and string output. Any potion recipe can be collapsed to a single int with a hashing function.
  • PotionRecipes.txt is a JSON file with all classic potion recipes extracted from FALL.EXE. This is mainly used for reference purposes. Classic effect implementations instead redefine recipes per effect.
  • Any effect class inheriting from BaseEntityEffect can define a recipe for themselves. They should also set MagicCraftingStations.PotionMaker (see below).
  • When enumerating BaseEntityEffect classes, the EntityEffectBroker will also index any potion recipes exposed by an effect. An effect can define 0-N potion recipes provided the recipes are completely unique.
  • See HealHealth.cs as an example of an implemented potion effect. By overriding SetPotionProperties() and defining the ingredient list for both variants of this effect, it's basically ready to use in-game.
  • HealthHealth effect also sets the MagicCraftingStations.PotionMaker for properties.AllowedCraftingStations to denote this effect is ready for potions. Other effects without this flag should be ignored by potion maker. See spellmaker as a reference for this concept using MagicCraftingStations.SpellMaker.
  • When player crafts a potion, ingredient lists will define the effect based on matching recipe. All you need to reference the potion effect is a single int on the potion item itself. This can even be derived from raw ingredient list if needed. Or reversed from a hash lookup back to an ingredient list.
  • When player consumes a potion, effect is invoked with properties and settings in the usual way (see magic items for an example) and potion item is destroyed or stack decremented.
  • I was planning to make some allowance for custom vial textures for potions, so different recipe variants can have a unique look. For example, TEXTURE.205 has some nice bottles with various coloured liquids that could be used for this. That wasn't a firm idea though, just something to play with.
Feel free to iterate on base ideas if you need to, but please keep in mind that I want effects to be modable by either addition or replacement. The whole effect system has been built around the idea that a single registered EffectFile.cs can do everything from spells to potions to items and support any crafting station. The classic potions need to be supported and referenced by classic data but the DFU potions should be a superset of that.

Anyone adding a new custom effect in future should be able to provide it in a single class like all other effects. That's why I'm explicitly defining the potion ingredients in HealHealth.cs rather than reading from classic data directly.

Please PM me know if any questions and I'll be happy to help. :)

For vamp/were stuff, happy to do a tag-team on this one. I'm mostly interested in the compound race support, cursing and curing, and effect setup. Maybe I can get these fundamentals running and you can look at adding the special quest deployment and stuff relating to guilds and rep?

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Vampirism & Lycanthropy

Post by Hazelnut »

Any idea how IC generated the JSON file PotionRecipes.txt? It doesn't match classic or UESP with Heal and Heal True recipes being swapped so my previous assumption (and yours from what you posted) that it was auto-generated from original game files in some way seems incorrect.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Vampirism & Lycanthropy

Post by Interkarma »

You're right, I didn't generate this. The file is extant from a couple of years back when IC did initial pass on potions in inventory. My memory was faulty here.

I wouldn't worry about it too much, that file can be deleted once potion implementation is completed. The potion recipes should be manually defined by effect anyway.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Vampirism & Lycanthropy

Post by Hazelnut »

Cheers, that's what I'm thinking because there's no equivalent data file for potions like SPELLS.STD so if the EntityEffect classes will contain all of the data. Unfortunately that would mean re-writing the recipe code IC wrote.

Lastly, mind if I add potion/recipe name to the PotionProperties? I'll put the strings in a text table for translation.

(also I updated the topic title since I hijacked it a bit, sorry :oops: )

EDIT: Query removed. I found the effect template dict and the hashcode used for IDs :)
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Vampirism & Lycanthropy & Potions

Post by Interkarma »

For modded effects, there will be a method in EntityEffectBroker with a definition something like below:

Code: Select all

RegisterEffect(IEntityEffect effectTemplate, bool allowReplace=false)
Mods can register their own custom effects and optionally replace classic effects by setting allowReplace to true when registering (the old version will be removed from dict and replace by modded effect). If allowReplace is false for a conflicting effect registration, then effect will not be registered and an error logged instead.

With the way potions are setup, it's possible for an effect mod to either fail to define potion or create a conflict with an unrelated effect. It's also possible for two effect mods to replace same effect or create conflicting potions. But that's the nature of modding, and good mod authors usually find a way to work around each other and fix problems.

I'm happy for you to add the title to PotionProperties. Not sure why I didn't think of this. And no problems with hijack. :)

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Vampirism & Lycanthropy & Potions

Post by Hazelnut »

Anyone care whether the recipe displays ingredients in the same order as classic? The order is irrelavent when mixing potions, so it's not neccessary and for technical reasons they have to be stored in template index order. I could store two arrays, one which is only used for display purposes. Only going to do that if enough people care though, because I sure don't. :)
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Vampirism & Lycanthropy & Potions

Post by Interkarma »

I don't mind the order ingredients are listed in. It's certainly not critical. :)

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Vampirism & Lycanthropy & Potions

Post by Hazelnut »

Another aspect that I'd like to gauge interest in is mixing potions that don't match a recipe. Classic creates a potion of "Unknown Power" which don't do anything, so I was thinking of just saying straight up that you failed to mix a useful potion and not bother putting one in inventory. Opinions?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply