About potion learning scripts.

+
About potion learning scripts.

Hello.

I'm currently trying to make a mod that adds new potions to TW1 main adventure, but I'm stuck with something.
I think I know how to create and modificate potions, but I need to make the scrolls that teach Geralt how to make them, that place the new ones in the journal and in the alchemy session.
I think that the key to do that is in the .NCS files of the scrolls (for instance, iit_scroll_105.ncs, wich is the Book of the Tawny Owl). Unfortunately, .NCS files can't be opened/edited, and thus I can't figure out how to get it done.
I already looked into the .LUA and .NSS files freed by CDPR for the Ifrit team, but the ones for scrolls are not there.

My question is: Does anyone know how can I make a scroll that teaches a new potion?
I'm asking about the script, wich I also couldn't find in the D'Jinni Wikia.
 
I have just browsed through files from the adventure "And A Curse, and Love, and Betrayal" because there are several new potions added ( Wildcat Potion and others). Here's one of the scripts:

string sRecipe="it_potion_110";

void main()
{PrintString("adding the recipe part 2");
AddJournalEntry("Recipe",sRecipe);
AlchemyLearnMixture(sRecipe);
AlchemyLearnItem(sRecipe);
}

If I remember correctly you call the script when the player reads the recipe. You have to add new entries to 2DA tables and create new icons as well.
 
Many thanks for your reply.

What I'm trying to do, actually, is creating variations of the potions that already exist, depending on the quality of the base that's used. I created copies of the scripts (.NSS) and the items (.UTI) of the 24 existent potions and their albedo/nigredo/rubedo dominant ones and put them into the .2DA file that contains the recipes (alchemy_recip.2da). Then I tried to create one of the "new" potions in the game, making the combination by hand, because I didn't know how to create a recipe to add it to the journal, but the result is the original potion. I also tried changing the ingredients of one of the "new" potions, but the result is always the original one; even if the ingredient combination of the "new" potion is different from the combination of the original . For example: I made a Tawny Owl with a different duration and named the files "it_vpotion_003.nss" and "it_vpotion_003.uti". Then I made a new row in the "alchemy_recip.2da" file and put that name in it, with a different combination of ingredients (different from any other potion). But, when I go to the game and make that combination by hand, it gives back the common Tawny Owl, wich is unlikely, because it's not even the same combination.

EDIT: When I make the potion I get the "new" one, but when I drink it, it lasts the same time than the original, wich shouldn't happen, because I set the time to haalf of the original, in the .NSS file of the "new" potion.

I was thinking about changing the "TYPE" column of the "alchemy_base.2da" file, and then changing the "Base_Type" column to fit the previous ones. I thought it would make the game to give back different potions depending on the quality of the base I use, but if I change, for instance an E for another letter in the "TYPE" column of the "alchemy_base.2da" file, the game stops to recognise all the alcohols of a certain quality as alchemic bases. Perhaps there is another files where the types of the bases are set (these original types are: E for potion bases, B for bomb bases, and S for oil bases).
 
Last edited:
Could you clarify what you mean by: "creating variations of the potions that already exist, depending on the quality of the base that's used", because "the base" thing is a bit unclear to me. Do you want to modify existing potions? All of them? How? Change their durations? Effects? Change rubedo, albedo, nigredo variants? As far as I remember you cant change base types, E is always used for potions. Could you present here, please, one of your nss scripts which you use to change the time of the original potion? And where do you place it, in which folder?
 
Hello again.
I'm sorry for the murkiness of my writing; I'm not a native English speaker.

First of all, I know very, very little about modding, scripting, designing, etc., so I'm exploring the files of the game, reading their contents and trying to get a way to do the things I want, so perhaps I say or intend to do something that is not possible for this game.
I'll answer your questions in order:

-By "creating variations of the potions that already exist, depending on the quality of the base that's used" I mean, in one hand, creating new potions, that have the same effect than the original ones, but last less; in the other hand, with "base" I mean alchemic base (alcohols, greases and powders). The recipes of the originals and the new ones would be the same, exept for the base used. For example, in the alchemy session when making a Tawny Owl Potion, if I use a low quality alcohol, the result is a low quality Tawny Owl, wich is one of the new potions and was set to last less, and if I use a high quality alcohol, then the potion will be another one, that has the same effect, but lasts longer than the other. That's the main idea I have in mind, though I don't know if it's possible.

-I want to keep the existent potions, and create other new ones, that have the same effects, but different time durations. The idea is to create low, medium and high quality versions of each potion. The high quality ones would be the originals, and the medium and low quality ones would last less, respectively. So, indtead of 25 potions, there would be 75, more or less.

-I would also like to create another group of potions/greases/bombs, that would have greater potency, and make them the result of using minerals as ingredients. I was thinking of creating a fourth additional substance to do this. I mean, if the potion/grease/bomb has this fourth substance as dominant, then it would be stronger.

-The scripts of the new potions have the same content as the original ones, though I changed a number that corresponds the the time they last. For example, the one of the Tawny Owl:

#include "inc_alchemy"

void main()
{
object oCreature = GetItemPossessor(OBJECT_SELF);

AddAbility("potion_003", oCreature, 480);

//Dodanie buffa albedo
if(CompareTags(GetTag(OBJECT_SELF), "albedo"))
AddAbility("Albedo_buff", oCreature, 60);
//Dodanie buffa rubedo
if(CompareTags(GetTag(OBJECT_SELF), "rubedo"))
AddAbility("Rubedo_buff", oCreature, 240);
//Dodanie buffa nigredo
if(CompareTags(GetTag(OBJECT_SELF), "nigredo"))
AddAbility("Nigredo_buff", oCreature, 240);
//Dzialanie buffa alboedo
if(HasAbility("Albedo_buff", oCreature))
{
AddLowToxicity(oCreature);
}
else
{
AddMediumToxicity(oCreature);
}
CreateVisualEffectAtCreature("fx_potion_006", "origin", oCreature);
}

480, 240 and 60 are the durations of the effects. What I tried to do was triplicating each .NSS file and change those nombers in each one. Then I put them in the \Override folder of the game.

I hope my writing is clear enough; I sometimes can't find the correct way to say something in English.
 
Ok, now it's more clear. Your script should work, but have a look at your Data folder and check if you have any other mod/adventure installed that may contain 2da tables and potion scripts. Override folder (with your alchemy_recip.2da) will not be taken into account if there is for example "walm" folder connected with Witcher Alchemy Mod that contains a different alchemy_recip.2da. The game checks folders that begin with the letter "Z" first, then "Y", etc. etc. Your Override folder begins with the letter "O" and it may never be checked.
As far as your mod idea goes, the problem is that alchemy tables do not differentiate between minerals and plants. The alchemy mixing process just throws all the ingredients into one sack and all that matters are substances: aether, hydragenum, quebrith, rebis, vermilion and vitriol plus three additional: albedo, nigredo and rubedo. At first glance it doesn't seem possible to differantiate between potions on the basis of the base quality. You can manipulate on the level of ingredients and their templates, and say if they are of top quality, standard quality or poor quality and decide how many ingredients are needed for the particular potion/powder - 5, 4 or 3. For example, my Witcher Alchemy Mod removes the possibility of creating potions from cheap vodkas, and brings more order to the classification of alchemy bases: http://www.moddb.com/mods/the-witch...ds/the-table-of-changes-in-the-alchemy-system
The only exception to the rules mentioned above are special potions that require special ingredient such as Hellhound's Soul, but they are mutagenic potions that add talents. Perhaps you would have to treat all minerals as special ingredients to make it work, hmmm. So go and check if your scripts and 2da tables are working now and then you can tell us about the progress of your work ;)
 
Thanks again for the reply. I didn't know many of the things you say there.

I've checked the folders of the game, and everything appears to be alright. I changed the name of the folder with my modificated archives to one that starts with Z, in order for it to be the last one inside \Data. There are also no other mods inside the game's folder.
The problem that I still have is that, upon mixing the ingredients I set for the variation of a potion, like for example, the medium quality Tawny Owl I created, the result is always the original one. Even if the item says that it is the medium quality one, the duration upon consuming it is 8 hours, as the original.

Perhaps I'm missing some kind of file. For one potion (Tawny Owl, for example) I have:
- a compiled .NSS named "it_mpotion_003.ncs" that contains the script I posted above, but with a minor number, instead of those 480. It says: "CreateVisualEffectAtCreature("fx_potion_006", "origin", oCreature);", but I think nothing happens if two potions share the same viasual effect.
-a .UTI file, named it_mpotion_003.uti that shows what I'm going to see when passing the pointer over the icon of that potion, in the inventory. I changed some parts of the description there.
-a .2DA file, "named alchemy_recip.2da", where the recipes are set. There I added this line there:

RecipeUniqueVitriolRebisAetherQuebrithHydragenumVermilionAlbedoNigredoRubedoBase_typeItem_templateNameStrRef
123it_mpotion_003****112000000Eit_mpotion_0031225
The recipe is the same as the original Tawny Owl, plus 1 rebis, to make it unrepeated. That's just temporal, untill I find a way that fits my purposes.

Note that the names of the first two files ans in the line inside the .2DA are "it_mpotion_003", with an "m", instead of "it_potion_003"
Then, when creating the potion in the game, with that combination of ingredients, I see it in my inventory, with the name and description that figures in the "it_mpotion_003.uti" file, but when I drink it, the time is the same as the original Tawny Owl.

All in all, I have these doubts:

-Am I missing other kind of files to add the new potion to the game and make it function?
-What is the line named "Tag" inside the .UTI files? Originaly, the "it_mpotion_003.uti" file sayed "it_potion_003" there; so I thought that if I changed it for "it_mpotion_003" the potion would work, but instead it says "Unknown" when I pass the pointer over the item, in the game.
-What's the columm "NameStrRef" inside the "named alchemy_recip.2da" file for? It has a number for each potion. In the one of your Wild Cat mod it says "2430", for example.

Sorry for the long writing; I have a lot of doubts in my mind, though I wouldn't like to bother anyone with them.
I'd also like to post screenshots to be more clear, but for some unknown reason, they result all black.
 
A quick question or two: are you sure you compiled your script without errors? Because when I try to compile the Tawny Owl script I can't do that because I don't have "inc_alchemy" script and Aurora log says: "NWNScript Compiler: it_mpotion_003.nss(1): ERROR: FILE NOT FOUND".
Do you have "inc_alchemy" script?
 
To be totally sincere, I don't know practially anything about scripting. I took that script from the ones released by CDPR, that can be downloaded from here:
http://www.moddb.com/games/the-witcher/downloads/lua-nss-scripts
I don't have that "inc_alchemy" script and I don't know where to find it; sorry for my ignorance :(

It's odd, because only one time I could compile sucessfuly (don't know how), and the other times I get these errors:

-NWNScript Compiler: it_lpotion_003.nss(4): ERROR: INVALID DECLARATION TYPE
or
-NWNScript Compiler: it_mpotion_003.nss(19): ERROR: UNDEFINED IDENTIFIER (AddLowToxicity)
or
-NWNScript Compiler: it_mpotion_003.nss(18 ): ERROR: UNDEFINED IDENTIFIER (AddMediumToxicity)


The second and third ones can be fixed by eliminating these lines from the script:

//Dzialanie buffa alboedo
if(HasAbility("Albedo_buff", oCreature))
{
AddLowToxicity(oCreature);
}
else
{
AddMediumToxicity(oCreature);
}

The problem with that is that the potion will not add toxicity when consumed.

EDIT: Now that I see it again, it looks like the only reason why I could compile successfully was because the line #include "inc_alchemy" was also erased. The script I put in the other post was from a not compiled .NSS file that I had.
If I want to compile it including that line, I get the same error as you.
 
Last edited:
Ah, now I remember... You did nothing wrong, don't be sorry for your ignorance, we can blame CDPR for everything ;) The problem is CDPR released source scripts without the possibility of re-compiling them because there's no "inc_alchemy" script to be found anywhere in Witcher files. The thing that puzzles me is how the heck it works in the game without the script. Anyway, there are workarounds.
1) You can use Hex editor to change the number 480 to anything you want. Unfortunately, you can replace only small pieces, you can't rewrite bigger parts of the code.
2) You can remove the line "#include "inc_alchemy" and replace commands AddLowToxicity(oCreature), AddMediumToxicity(oCreature) with something else, probably with GetCurrentToxicity and SetCurrentToxicity. I used the second method in my Wildcat potion script but I don't have my source scripts any longer so I can't say exactly what it was but we can get back to toxicity, just check if your new potion works as far as the duration goes. And you need to find out how the toxicity works in The Witcher, how potions change the toxicity level, you will need the exact numbers.
You asked about the NameStrRef number before - the number refers to a localized TLK file and to the name of the potion. If you create a new potion, its name should be recorded in the TLK table, otherwise it wont show properly in game. If you use old names you don't have to change anything.
EDIT: as I said I don't remember the exact numbers as far as toxicity goes, but here's an example of how to rewrite potion scripts, you will change the numbers probably:

void main()
{object oCreature = GetItemPossessor(OBJECT_SELF);
object oPotion=OBJECT_SELF;
int nToxic=GetCurrentToxicity(oCreature);
string sTag=GetTag(oPotion);

AddAbility("potion_003", oCreature, 480);
if(CompareTags(GetTag(oPotion), "albedo"))
{
AddAbility("Albedo_buff", oCreature, 60);
}
if(CompareTags(GetTag(oPotion), "rubedo"))
{
AddAbility("Rubedo_buff", oCreature, 240);
}

if(CompareTags(GetTag(oPotion), "nigredo"))
{
AddAbility("Nigredo_buff", oCreature, 240);
}

if(HasAbility("Albedo_buff", oCreature))

{
SetCurrentToxicity(nToxic+25,oCreature);
}
else
{
SetCurrentToxicity(nToxic+50,oCreature);
}


CreateVisualEffectAtCreature("fx_potion_006", "origin", oCreature);
}
 
Last edited:
Yes! I figured out the problem with the durations of the potions! :) ... Actually, I proved a lot of things untill one of them resulted, haha.
It looks like it was my mistake; in the "it_mpotion_003.uti" file, in the "OnUsed" line it sayed "it_potion_003", when it should say "it_mpotion_003", for the game to 'understand' that when this item is consumed, it must apply the effect of the new potion and not the one of the original.

Many thanks for the script you posted above, fantasta; it allowed me to compile the scripts of the new potions and make them functional in the game.

About the Toxicity thing: "AddLowToxicity", "AddMediumToxicity", "AddHighToxicity" and "AddHigherToxicity"; they don't seem to be anywhere, or at least I couldn't find them. I don't know how can they work if they are included in the original scripts that come with the game. I was testing the durations of each potion in order the set them in your script, but it seems that they variate randomly between certain limits and depending on the type of toxicity. According to the Witcher Wikia, these are the ranges:

Low (10–14)
Medium (15–20)
High (21–25)
Very High (26–30)

So, I searched in the D'Jinni Wikia and came across this function: Random (int nMaxInteger)
wich, as it says, gets a random integer between 0 and nMaxInteger-1.
Then, to get, for example, the medium toxicity range I changed this line of your script:
SetCurrentToxicity(nToxic+25,oCreature);
for this one:
SetCurrentToxicity(nToxic+15+Random (6),oCreature);
and it worked! :) It gives Geralt an additional toxicity of 15, plus a number between 0 and 5, fitting the Medium Toxicity range.

Now I can move forward to the next step; to think how can I make the resulting potions vary depending on the quality type of the base that's used.
I tryied giving the alcohols (like the Cherry Spirit Cordial) different substances (like rebis, vitriol, etc.), but it makes the game crash. Apparently an item can't be base and ingredient at the same time. I'll have to keep trying.
 
Last edited:
Top Bottom