This is the 2nd thread I’m starting with similar gripes, script should work, all resrefs, tags, spell needed are correctly used, double checked - still nothing. This script was generated with Lilac Soul. Tried 2 different spells for sanity check. Nothing. It’s going to make me throw in the towel on mod building and go do something else. I suppose I could resort to blueprinting everything and try Scriptease. It worked pretty well when I scripted Phantasie 10 years ago. Anyway, here was the latest:
/* BLACKSMITH SCRIPT, format 1.0
- Smith type: 0
- 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 OnSpellCastAt 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 Potion of Mage Armor.
SetLocalString(oVarHolder, “LS_SMITH_0_ResRef”, “potionofmagearmo”);
SetLocalInt (oVarHolder, “LS_SMITH_0_gold”, 0);
SetLocalInt (oVarHolder, “LS_SMITH_0_ingredient_count”, 2);
SetLocalString(oVarHolder, “LS_SMITH_0_ingredient0”, “x2_it_cfm_pbottl”); // Magic Potion Bottle
SetLocalString(oVarHolder, “LS_SMITH_0_ingredient1”, “NW_IT_MSMLMISC11”); // Quartz Crystal
SetLocalInt (oVarHolder, “LS_SMITH_0_quantity0”, 1);
SetLocalInt (oVarHolder, “LS_SMITH_0_quantity1”, 2);
SetLocalInt (oVarHolder, “LS_SMITH_0_spell”, SPELL_NEGATIVE_ENERGY_RAY);
SetLocalInt (oVarHolder, “LS_SMITH_0_vfx”, VFX_FNF_SMOKE_PUFF);
}
// -----------------------------------------------------------------------------
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;
// Spell requirement.
if ( bIsMatch )
bIsMatch = GetLastSpell() == GetLocalInt(oVarHolder, sVarPrefix + "spell");
// 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 )
}