I’m trying to write script which will smelt armors and place metal ingots on workbench for gold and for that I’ve modified i_smithhammer_ac and put it in override.
Problem is that this while loop seems to get executed in parallel instead of “processing” each item one by one. For example, script will convert all items even if player doesn’t have enough gold for all items.
Do you know what I’ve missed?
Thanks
if (IsSmithWorkbench(oTarget))
{
// AssignCommand(oTarget, DoMundaneCrafting(oPC));
string sFullPlateResRef = "mwa_hvfp_mth_4";
string sHalfPlateResRef = "mwa_hvhp_mth_4";
string sBandedMailResRef = "mwa_hvbm_mth_3";
string sChainmailResRef = "mwa_mdcm_mth_4";
string sBreastPlateResRef = "mwa_mdbp_mth_4";
string sScaleMailResRef = "mwa_mdsm_mth_4";
string sChainShirtResRef = "mwa_ltcs_mth_4";
string sTowerShield = "mwa_shtw_mth_4";
string sIngotResRef = "n2_crft_plkshed";
string sIngot = "n2_crft_ingmithral";
string sChainOfFrost = "nx1_chainshirt_frost";
string sHeavyShield = "mwa_shhv_mth_4";
string sLightShield = "mwa_shlt_mth_4";
string sImaskariBattlemage = "nx1_chainmail01";
object oItemOnBench = GetFirstItemInInventory(oTarget);
object oDebug = GetFirstPC(FALSE);
int counter = 0;
while (GetIsObjectValid(oItemOnBench))
{
if (GetResRef(oItemOnBench) == sFullPlateResRef && GetGold(oPC) >= 16000)
{
SendMessageToPC(oDebug, "Gold before " + "sFullPlateResRef" + ": " + IntToString(GetGold(oPC)));
AssignCommand(oPC, TakeGoldFromCreature(16000, oPC, TRUE, TRUE));
DestroyObject(oItemOnBench);
CreateItemOnObject(sIngotResRef, oTarget, 8);
}
else if(GetResRef(oItemOnBench) == sHalfPlateResRef && GetGold(oPC) >= 14000)
{
SendMessageToPC(oDebug, "Gold before " + "sHalfPlateResRef" + ": " + IntToString(GetGold(oPC)));
AssignCommand(oPC, TakeGoldFromCreature(14000, oPC, TRUE, TRUE));
DestroyObject(oItemOnBench);
CreateItemOnObject(sIngotResRef, oTarget, 7);
}
else if(GetResRef(oItemOnBench) == "sBandedMailResRef" && GetGold(oPC) >= 12000)
{
SendMessageToPC(oDebug, "Gold before " + sBandedMailResRef + ": " + IntToString(GetGold(oPC)));
AssignCommand(oPC, TakeGoldFromCreature(12000, oPC, TRUE, TRUE));
DestroyObject(oItemOnBench);
CreateItemOnObject(sIngotResRef, oTarget, 6);
}
oItemOnBench = GetNextItemInInventory(oTarget);
}