Neverwinter Nights: Enhanced Edition

Neverwinter Nights: Enhanced Edition

Adventures await!
Gather your mods before venturing forth. Discover planes filled with player-created adventures in Steam Workshop, then build your own Neverwinter Nights modules using the Aurora Toolset to share!
Learn More
Baryonyx 7 Oct, 2019 @ 11:57am
Crafting Script Help
Hello, I am trying to make a module to recreate a certain other fantasy RPG and I need a script that will help me create a crafting system. I have looked through a few tutorials already, but none of them really helped me get what I wanted.

What I imagined is a script that makes an object with inventory turn certain items into certain other items, once all the required ones are present. Also, there should be a certain percentage that this would return different items than expected (i.e. the crafting has failed). Finally, if the object container can be switched on (light, camp fire, etc) the crafting can only work if the item is switched on.

Other things that are related to this project that I would need help with:
How can I make it so that switchable objects cannot be switched on by players, but will switch on when a certain item has been put into its inventory, and it will consume or transform this item after a certain amount of time and switch off when there is none of this item left. (Example: Put wood into a campfire, fire turns on, burns for some time, wood turns into ash, when there is no wood left, fire turns off)

Any help would be appreciated and of course also credited, should this module get published.
Thanks.
< >
Showing 1-3 of 3 comments
Jimmy MacReady 8 Oct, 2019 @ 6:05am 
From what you've described most of it can be done by scripting it yourself. If your pretty new to scripting I'd advise using two things;

https://neverwintervault.org/project/nwn1/script/nwn-lexicon-169

https://neverwintervault.org/project/nwn1/other/tool/ls-tk-script-generator

The first link takes you to the lexicon to download, That will help you learn some scripting there. The second is Lilac Souls script generator which is excellent for beginners. Its a huge learning curve when you first get into scripting but it pays off.
Baryonyx 19 Oct, 2019 @ 3:05pm 
I have experimented with the script generator, the concept is wonderful, so many thanks for letting me know something like that exists.

I tried to create a "blacksmith script" with the generator to get a cooking function going, where the script would check a campfire for having a piece of wood and a raw shrimp in it, then when the inventory is closed, it would transform this into a cooked shrimp, and play a fire effect when successful.

/* BLACKSMITH SCRIPT, format 1.0 * Smith type: 2 * Script generated by LS Script Generator, v.TK.0 * * For download info, please visit: * http://nwvault.ign.com/View.php?view=Other.Detail&id=1502 */ // Put this OnClose for a placeable. // Note that this will only create one item, even if there are enough ingredients for multiple recipes. #include "x0_inc_skills" // The number of combinations this script accepts for item creation. const int NUM_RECIPES = 1; // Initializes the local variables that define what can be created and how to // create them. void SetRecipeLocals(object oVarHolder); void SetRecipeLocals(object oVarHolder) { // Recipe for creating Gekochte Garnele. SetLocalString(oVarHolder, "LS_SMITH_0_ResRef", "rs_cookedshri001"); SetLocalInt (oVarHolder, "LS_SMITH_0_gold", 0); SetLocalInt (oVarHolder, "LS_SMITH_0_ingredient_count", 2); SetLocalString(oVarHolder, "LS_SMITH_0_ingredient0", "rawshrimp"); // Rohe Garnele SetLocalString(oVarHolder, "LS_SMITH_0_ingredient1", "RS_wood"); // Holz SetLocalInt (oVarHolder, "LS_SMITH_0_quantity0", 1); SetLocalInt (oVarHolder, "LS_SMITH_0_quantity1", 1); SetLocalInt (oVarHolder, "LS_SMITH_0_vfx", VFX_COM_HIT_FIRE); } // ----------------------------------------------------------------------------- void main() { // Basic configuration: object oItemHolder = OBJECT_SELF; object oVarHolder = OBJECT_SELF; int nAvailableGold = GetGold(oItemHolder); // Make sure the recipes are initialized. if ( !GetLocalInt(oVarHolder, "LS_SMITH_variables_set") ) { SetRecipeLocals(oVarHolder); SetLocalInt(oVarHolder, "LS_SMITH_variables_set", TRUE); } // Variables set inside the following loop. int nNumIngredients, nIngredient, nGold; string sVarPrefix; // Find a matching recipe. int bIsMatch = FALSE; int nRecipe = 0; while ( nRecipe++ < NUM_RECIPES && !bIsMatch ) { sVarPrefix = "LS_SMITH_" + IntToString(nRecipe) + "_"; // Gold requirement. nGold = GetLocalInt(oVarHolder, sVarPrefix + "gold"); bIsMatch = nAvailableGold >= nGold; // Item requirements. nNumIngredients = GetLocalInt(oVarHolder, sVarPrefix + "ingredient_count"); nIngredient = 0; while ( bIsMatch && nIngredient++ < nNumIngredients ) // OK to continue if we have enough of the specified item. // (This function was written for trap components, but it works for this, too.) bIsMatch = skillCTRAPGetHasComponent( GetLocalString(oVarHolder, sVarPrefix + "ingredient" + IntToString(nIngredient)), oItemHolder, GetLocalInt(oVarHolder, sVarPrefix + "quantity" + IntToString(nIngredient))); // Done checking. Can we go ahead and create? if ( bIsMatch ) { // Gold cost: if ( nGold > 0 ) DestroyNumItems(oItemHolder, "NW_IT_GOLD001", nGold); // Remove the ingredients. for ( nIngredient = 1; nIngredient <= nNumIngredients; nIngredient++ ) DestroyNumItems(oItemHolder, GetLocalString(oVarHolder, sVarPrefix + "ingredient" + IntToString(nIngredient)), GetLocalInt(oVarHolder, sVarPrefix + "quantity" + IntToString(nIngredient))); // Now create the item. CreateItemOnObject(GetLocalString(oVarHolder, sVarPrefix + "ResRef"), oItemHolder); // Add a spiffy visual effect? int nVFX = GetLocalInt(oVarHolder, sVarPrefix + "vfx"); if ( nVFX != VFX_NONE ) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(nVFX), oItemHolder); } }//while ( nRecipe ) }

But ingame it does not work for some reason. It plays a sound whenever the campfire container is closed, but never transforms anything. I have double and triple checked whether all the items are appropriately named and tagged and the script is set into the OnClose position of the campfire.

What else could be going wrong?
Лёв 1 20 Oct, 2019 @ 8:34am 
Very simple example without thousand of recipes and without skills check:

void main() { // Yor ingredients object oIng1 = GetItemPossessedBy(OBJECT_SELF, "it_raw"); // raw food object oIng2 = GetItemPossessedBy(OBJECT_SELF, "it_wood"); // wood // If this ingredients in inventory of your campfire if (GetIsObjectValid(oIng1) && GetIsObjectValid(oIng2)) { // Destroy ingredients DestroyObject(oIng1); DestroyObject(oIng2); // Create cooked food in inventory of campfire CreateItemOnObject("it_cook"); } }
< >
Showing 1-3 of 3 comments
Per page: 1530 50