Here is the code that I put together for
the Blacksmith who makes items for the PC. I grew frustrated with trying
to mod the script that Marrok used in the Single Player Module in
Chapter 1 so I started working on my own. Again I apologize for the
script being somewhat combersome, I am not fluent in C (They only taught
us how to program in FORTRAN back when I was in college). I don't know
the syntax of things that might make this more fluid, but perhaps a C
person can help out. The script here works for two items, but I have
expanded it to over 30 in my module without errors.
In the smiths "OnConversation" event put the following script at the end
of the default, I don't know if you need the default, but I was not
about to mess with it yet.
NWScript:
SetLocalString(OBJECT_SELF,"NW_L_MYFORGE","M1Q1CForge");
object oContainer = GetObjectByTag(GetLocalString(OBJECT_SELF,"NW_L_MYFORGE"));
object oItem1 = GetFirstItemInInventory(oContainer);
object oItem2 = GetNextItemInInventory(oContainer);
string sReagent1;
string sReagent2;
{
int nBaseType = GetBaseItemType(oItem1);
if (
(nBaseType == BASE_ITEM_GEM) ||
(nBaseType == BASE_ITEM_MISCLARGE) || (nBaseType == BASE_ITEM_MISCMEDIUM) ||
(nBaseType == BASE_ITEM_MISCTALL) || (nBaseType == BASE_ITEM_MISCSMALL) ||
(nBaseType == BASE_ITEM_MISCTHIN)
)
{
sReagent1 = GetTag(oItem1);
sReagent2 = GetTag(oItem2);
}
else
{
sReagent1 = GetTag(oItem2);
sReagent2 = GetTag(oItem1);
}
}
{
if (
((sReagent1 == "NW_IT_GEM009") && (sReagent2 == "NW_WSWLS001")) ||
((sReagent1 == "NW_IT_GEM009") && (sReagent2 == "NW_WSWMLS002")) ||
((sReagent1 == "NW_IT_GEM009") && (sReagent2 == "NW_WSWMLS010")) ||
((sReagent1 == "NW_IT_GEM009") && (sReagent2 == "NW_WSWMLS012"))
)
{
SetLocalInt(OBJECT_SELF, "VALID_COMBO", TRUE);
SetLocalString(OBJECT_SELF, "REAGENT_1", sReagent1);
SetLocalString(OBJECT_SELF, "REAGENT_2", sReagent2);
SetLocalString(OBJECT_SELF, "REWARD", "BURNBLADE_LS");
SetLocalInt(OBJECT_SELF, "ITEM_COST", 500);
SetLocalInt(OBJECT_SELF, "ORDER_UP", 1);
}
else if ((sReagent1 == "NW_IT_GEM009") && (sReagent2 == "BURNBLADE_LS"))
{
SetLocalInt(OBJECT_SELF, "VALID_COMBO", TRUE);
SetLocalString(OBJECT_SELF, "REAGENT_1", sReagent1);
SetLocalString(OBJECT_SELF, "REAGENT_2", sReagent2);
SetLocalString(OBJECT_SELF, "REWARD", "NW_WSWMLS005");
SetLocalInt(OBJECT_SELF, "ITEM_COST", 1000);
SetLocalInt(OBJECT_SELF, "ORDER_UP", 2);
}
else
{
SetLocalInt(OBJECT_SELF, "VALID_COMBO", FALSE);
}
}
SetCustomToken(5575, IntToString(GetLocalInt(OBJECT_SELF, "ITEM_COST")));
}
Now put the following in the conversation with the smith whenever he has
agreed to make the item. I have included a few checks at the end of this
post that verify the PC can pay for the item, and that a valid combo
exists on the forge.
NWScript:
void create_item()
{
SetLocalString(OBJECT_SELF,"NW_L_MYFORGE","M1Q1CForge");
object oContainer = GetObjectByTag(GetLocalString(OBJECT_SELF,"NW_L_MYFORGE"));
DestroyObject(GetItemPossessedBy(oContainer,GetLocalString(OBJECT_SELF, "REAGENT_1")));
DestroyObject(GetItemPossessedBy(oContainer,GetLocalString(OBJECT_SELF, "REAGENT_2")));
CreateItemOnObject(GetLocalString(OBJECT_SELF, "REWARD") ,oContainer);
TakeGoldFromCreature(GetLocalInt(OBJECT_SELF, "ITEM_COST"), GetPCSpeaker(), TRUE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_MAGICAL_VISION), OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_AC_BONUS),oContainer);
}
void main()
{
if((GetLocalInt(OBJECT_SELF, "ORDER_UP") == 1))
{
create_item();
}
else if((GetLocalInt(OBJECT_SELF, "ORDER_UP") == 2))
{
create_item();
}
else
{
}
}
A couple of other scripts to include in the conversation are conditional
checks for the combo being valid (i.e. Listed in the OnConversation
event script)
NWScript: int StartingConditional()
{
if((GetLocalInt(OBJECT_SELF, "ORDER_UP") == 1))
return TRUE;
else
return FALSE;
}
And one for making sure the PC can pay for the item
NWScript: int StartingConditional()
{
int iResult;
iResult =GetGold(GetPCSpeaker()) >= GetLocalInt(OBJECT_SELF, "ITEM_COST");
return iResult;
}
One more note, I made a custom item called the burning blade to test and
make sure custom items work with the creation, so you will need to
change that or make an item with that name before you drop and go with
the script. I know this script can be improved on, but for now it works.
Milamber-POL
Paladins of Light
www.pofl.org
|