Author Topic: trying to make a small addition to UOA crafting  (Read 1145 times)

Legacy_graywolf.theheathen

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« on: May 29, 2016, 06:33:00 pm »


               

I'm trying to have the exceptionally crafted item be created with a custom description.


I'm pretty sure I should be able to do this with SetDescription but I'm not sure how to add it into this script.


example:


(item name) + (added text) + GetName(oPC)


Shadow Iron Longsword (Exceptional Quality) + from the forges of + PC name


Finished description:  Shadow Iron Longsword (Exceptional Quality) from the forges of Bob


 


The line where the exceptional item is created is here:


if (iSuccess2 == 3)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefExceptional,oPC,1)));


 


Posting the part of the script that creates the item below.


 



   Spoiler
   


 


Thanks,


 



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #1 on: May 29, 2016, 07:10:51 pm »


               

Since the item is created with a Delay you don't have access to the item object in the code that contains the line you showed in text above. You will need to find the CreateAnObject routine and either add your description code into that or create your own wrapper function that calls that or otherwise does what that does. I suspect it is just a wrapper to CreateItemOnObject anyway.  But you are on the right track with SetDescription. 



               
               

               
            

Legacy_graywolf.theheathen

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #2 on: June 03, 2016, 06:43:10 pm »


               

Wanted to thank you for replying. I'll probably just leave this alone for now. It is beyond me at the moment. I'll turn some attention back to it another time.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #3 on: June 03, 2016, 08:52:27 pm »


               

Did not mean to scare you off '<img'> 


 


It's a pretty easy change once you get to the code that actually creates the item. There is probably an include at the top of that script which contains the CreateAnObject method.   If you can find that and post it I'm sure we can make something work. Just need to see the code in case it does more than just wrap CreateItemOnObject.  I don't have or use the UOA crafting system so I don't have the code. But if you want to drop it that's fine too.



               
               

               
            

Legacy_graywolf.theheathen

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #4 on: June 03, 2016, 09:07:37 pm »


               

Thank you again. Sounds good. When I get home this evening from work I'll put the script in another spoiler tag.


               
               

               
            

Legacy_graywolf.theheathen

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #5 on: June 05, 2016, 03:33:03 pm »


               

The only include in the script is the standard #nw_i0_plot .  I did a search through files for CreateAnObject and the only scripts that showed up were all the UOA scripts. It is used through all of them. Here is the Anvil script that produces weapons and armor.



//#include "_persist_01a"
#include "nw_i0_plot"

void CreateAnObject(string sResource, object oPC, int iStackSize);
void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef);
void GetNextItemPossessedBy(object oPC, string sItemTag);
string CraftLookup(string sResRef, int iIngotType);

void main()
{
 object oItem = GetInventoryDisturbItem();
 object oPC = GetLastDisturbed();
 object oSelf = OBJECT_SELF;
 string sTag = GetTag(oItem);
 string sSuccess = "";
 string sFail = "";
 string sItemResRef = "";
 string sItemResRefPoor = "";
 string sItemResRefExceptional = "";
 int iRandom = 0;
 int iSuccess = 0;
 int iSuccess2 = 0;
 int iSkillGain = 0;
 int iComponent1 = 1;
 int iComponent2 = 0;
 int iComponent3 = 0;
 int iComponent1Stackable = 1;
 int iComponent2Stackable = 0;
 int iComponent3Stackable = 0;
 int iStackSize = 0;
 int iCraftStackSize = 0;  // for stackable end products
 int iCraftType = 0;  // default to Weapons for skill check
 int iIngotType = GetLocalInt(oPC,"iUseIngotType");  // get the current ingot type used
 int iIngotMod = iIngotType *25;                     // set the skill modifier for the ingot type used.
 string sComponent1 = "";
 string sComponent2 = "";
 string sComponent3 = "";
 string sComponent1Name = "";
 string sComponent2Name = "";
 string sComponent3Name = "";
 string sComponentResRef = "";
 object oTemp = OBJECT_INVALID;
 object oTool = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);

 if (GetTag(oTool) != "ITEM_SMITHHAMMER_NORMAL") oTool = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
 int iHammerUse = GetLocalInt(oPC,"iHammerUsed");



 if (iIngotType==9) iIngotMod = 90;    // Silver is little easier than Bronze
 if (iIngotType==10) iIngotMod = 175;  // Mithril is hard as Verite
 if (iIngotType==11) iIngotMod = 200;  // Adamantite is hard as Valorite
 if (iIngotType==12) iIngotMod = 150;  // Platinum is hard as Agapite

 if (GetInventoryDisturbType()== INVENTORY_DISTURB_TYPE_ADDED)
  {
   // The following 3 lines are to ensure compatability with UOAbigal's Persistent Token System.
   // You can replace them with whatever 'no-drop' code you have or comment them out.
   string sNoDropFlag = (GetStringLeft(GetTag(oItem),6));
   if (sNoDropFlag == "NoDrop" || sNoDropFlag == "TOKEN_"||sNoDropFlag=="_TBOX_")
    return;
   if (GetBaseItemType(oItem)==BASE_ITEM_LARGEBOX)
    {
     DestroyObject(oItem);
     SendMessageToPC(oPC,"To avoid possible dupe exploits, the container placed in this bag may be destroyed.");
     return;
    }
   // End of compatability portion.
   CopyItem(oItem,oPC,TRUE);
   DestroyObject(oItem);
   FloatingTextStringOnCreature("You can only craft by removing pattern tokens from this station.",oPC,FALSE);
  }

 // Check for ingot type switch or non-flagswitch/pattern item
 if (GetStringLeft(GetResRef(oItem),7)!="pattern")
  {
   if (sTag == "SWITCH_IRON"){SetLocalInt(oPC,"iUseIngotType",0);sComponent1 = "Iron";}
   if (sTag == "SWITCH_DULL"){SetLocalInt(oPC,"iUseIngotType",1);sComponent1 = "Dull Copper";}
   if (sTag == "SWITCH_SHADOW"){SetLocalInt(oPC,"iUseIngotType",2);sComponent1 = "Shadow Iron";}
   if (sTag == "SWITCH_COPPER"){SetLocalInt(oPC,"iUseIngotType",3);sComponent1 = "Copper";}
   if (sTag == "SWITCH_BRONZE"){SetLocalInt(oPC,"iUseIngotType",4);sComponent1 = "Bronze";}
   if (sTag == "SWITCH_GOLD"){SetLocalInt(oPC,"iUseIngotType",5);sComponent1 = "Gold";}
   if (sTag == "SWITCH_AGAPITE"){SetLocalInt(oPC,"iUseIngotType",6);sComponent1 = "Agapite";}
   if (sTag == "SWITCH_VERITE"){SetLocalInt(oPC,"iUseIngotType",7);sComponent1 = "Verite";}
   if (sTag == "SWITCH_VALORITE"){SetLocalInt(oPC,"iUseIngotType",8);sComponent1 = "Valorite";}
   if (sTag == "SWITCH_SILVER"){SetLocalInt(oPC,"iUseIngotType",9);sComponent1 = "Silver";}
   if (sTag == "SWITCH_MITHRIL"){SetLocalInt(oPC,"iUseIngotType",10);sComponent1 = "Mithril";}
   if (sTag == "SWITCH_ADAMANTITE"){SetLocalInt(oPC,"iUseIngotType",11);sComponent1 = "Adamantite";}
   if (sTag == "SWITCH_PLATINUM"){SetLocalInt(oPC,"iUseIngotType",12);sComponent1 = "Platinum";}
   if (GetStringLeft(sTag,7)=="SWITCH_")
    {
     FloatingTextStringOnCreature("Re-tooling to use "+sComponent1+" ingots.",oPC,FALSE);
     DestroyObject(oItem);
     //ExecuteScript("_onclose_clear",OBJECT_SELF);
     //ExecuteScript("_open_anvil",OBJECT_SELF);
     string sTagSelf = GetTag(oSelf);
     AssignCommand(oPC,DoPlaceableObjectAction(oSelf,PLACEABLE_ACTION_USE));
     AssignCommand(oPC,DelayCommand(1.5,DoPlaceableObjectAction(GetNearestObjectByTag(sTagSelf,oPC,1),PLACEABLE_ACTION_USE)));
    }
   return;
  }
 CopyObject(oItem,GetLocation(oPC),OBJECT_SELF,GetTag(oItem));
 DestroyObject(oItem);

 if (GetLocalInt(OBJECT_SELF,"iAmInUse") != 0)
    {
     SendMessageToPC(oPC,"You must wait till the current weapon or armor is completed before starting another.");
     return;
    }

 if (GetTag(oTool) != "ITEM_SMITHHAMMER_NORMAL")
  {
   FloatingTextStringOnCreature("You must have a smithy hammer equipped in order to attempt this craft...",oPC,FALSE);
   return;
  }

 //int iSmithSkill = GetTokenPair(oPC,13,4); // Weaponsmith
 int iSmithSkill = GetCampaignInt("UOACraft","iSmithSkill",oPC);
 int iSmithChance = iSmithSkill;
 //int iArmorSkill = GetTokenPair(oPC,13,5); // ArmorCraft
 int iArmorSkill = GetCampaignInt("UOACraft","iArmorSkill",oPC);
 int iArmorChance = iArmorSkill;

 if (iSmithChance < 350)
  {
   iSmithChance = GetAbilityScore(oPC,ABILITY_STRENGTH)*5;
   iSmithChance = iSmithChance+(GetAbilityScore(oPC,ABILITY_DEXTERITY)*3);
   iSmithChance = iSmithChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*2);
   iSmithChance = iSmithChance*3;
   if (iSmithChance>350)iSmithChance=350;
   if (iSmithSkill > iSmithChance) iSmithChance=iSmithSkill;
  }
 if (iArmorChance < 350)
  {
   iArmorChance = GetAbilityScore(oPC,ABILITY_STRENGTH)*5;
   iArmorChance = iArmorChance+(GetAbilityScore(oPC,ABILITY_DEXTERITY)*3);
   iArmorChance = iArmorChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*2);
   iArmorChance = iArmorChance*3;
   if (iArmorChance>350)iArmorChance=350;
   if (iArmorSkill > iArmorChance) iArmorChance=iArmorSkill;
  }

 // Modify skill chance based on ingot type used
 if (iIngotMod >0) iIngotMod = iIngotMod + 250;
 iSmithChance = iSmithChance - iIngotMod;
 iArmorChance = iArmorChance - iIngotMod;

 // Begin Crafting Test
 if (sTag == "P_DAGGER")
  {
   iSmithChance = iSmithChance - 100;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a dagger.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the dagger useless.";
   sItemResRefPoor = CraftLookup("wswdg002",iIngotType);
   sItemResRef = CraftLookup("nw_wswdg001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswdg003",iIngotType);
   iComponent1 = 2;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_SHORTSWORD")
  {
   iSmithChance = iSmithChance-150;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a shortsword.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the shortsword useless.";
   sItemResRefPoor = CraftLookup("wswss002",iIngotType);
   sItemResRef = CraftLookup("nw_wswss001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswss003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_RINGMAIL")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 100;
   sSuccess = "You carefully forge the rings and sew them into the leather backing to make ringmail armor.";
   sFail = "The rings fail to link properly and the leather backing is ruined.";
   sItemResRefPoor = CraftLookup("ringmail001",iIngotType);
   sItemResRef = CraftLookup("ringmail",iIngotType);
   sItemResRefExceptional = CraftLookup("ringmail002",iIngotType);
   iComponent1 = 6;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 2;
  }
 if (sTag == "P_CHAINSHIRT")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 250;
   sSuccess = "You carefully forge the small chain links and link them together to make a chainmail shirt.";
   sFail = "The link pattern for the small chain links is wrong, and the chain shirt is ruined.";
   sItemResRefPoor = CraftLookup("aarcl013",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl012",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl014",iIngotType);
   iComponent1 = 8;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_CHAINMAIL")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 350;
   sSuccess = "You carefully forge the small chain links and link them together with the leather to make chainmail armor.";
   sFail = "The link pattern for the small chain links is wrong, and the chainmail armor is ruined.";
   sItemResRefPoor = CraftLookup("aarcl005",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl004",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl006",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 1;
  }
 if (sTag == "P_SCALEMAIL")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 300;
   sSuccess = "You carefully forge the small metal scales and hook them into the leather to make scale mail armor.";
   sFail = "The scales do not hook properly, and the scale mail armor is ruined.";
   sItemResRefPoor = CraftLookup("aarcl006",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl003",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl007",iIngotType);
   iComponent1 = 8;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 2;
  }
 if (sTag == "P_BREASTPLATE")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 350;
   sSuccess = "You carefully pound the metal into a form-fitting breastplate.";
   sFail = "The metal warps and turns brittle as you try to pound it into a form-fitting shape.";
   sItemResRefPoor = CraftLookup("aarcl011",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl010",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl016",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_BANDEDMAIL")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 400;
   sSuccess = "You carefully forge the small metal bands and fix them into the leather to make banded mail armor.";
   sFail = "The bands do not fix properly, and the banded mail armor is ruined.";
   sItemResRefPoor = CraftLookup("aarcl014",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl011",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl015",iIngotType);
   iComponent1 = 14;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 1;
  }
 if (sTag == "P_SPLINTMAIL")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 400;
   sSuccess = "You carefully forge the small metal plates and fix them into the leather to make splint mail armor.";
   sFail = "The small metal plates are too brittle to fix properly, and the splint mail armor is ruined.";
   sItemResRefPoor = CraftLookup("aarcl018",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl005",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl019",iIngotType);
   iComponent1 = 14;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 2;
  }
 if (sTag == "P_HALFPLATE")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 450;
   sSuccess = "You carefully forge the metal plates and affix the leather to create a suit of half plate armor.";
   sFail = "The metal plates are too brittle to server as armor, and the suit of half plate is ruined.";
   sItemResRefPoor = CraftLookup("aarcl010",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl006",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl017",iIngotType);
   iComponent1 = 20;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 2;
   sComponent3 = "HARDLEATHER_SMALL"; // Small Hardened Leather
   sComponent3Name = "small hardened leathers";
   iComponent3 = 2;
  }
 if (sTag == "P_FULLPLATE")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 500;
   sSuccess = "You carefully forge the metal plates and affix the leather to create a suit of full plate armor.";
   sFail = "The metal plates are too brittle to server as armor, and the suit of full plate is ruined.";
   sItemResRefPoor = CraftLookup("aarcl008",iIngotType);
   sItemResRef = CraftLookup("nw_aarcl007",iIngotType);
   sItemResRefExceptional = CraftLookup("aarcl009",iIngotType);
   iComponent1 = 30;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 3;
   sComponent3 = "HARDLEATHER_MEDIUM"; // Medium Hardened Leather
   sComponent3Name = "medium hardened leathers";
   iComponent3 = 2;
  }
 if (sTag == "P_LONGSWORD")
  {
   iSmithChance = iSmithChance-250;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a longsword.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the longsword useless.";
   sItemResRefPoor = CraftLookup("wswls002",iIngotType);
   sItemResRef = CraftLookup("nw_wswls001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswls003",iIngotType);
   iComponent1 = 6;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_BASTARDSWORD")
  {
   iSmithChance = iSmithChance-350;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a bastard sword.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the bastard sword useless.";
   sItemResRefPoor = CraftLookup("wswbs002",iIngotType);
   sItemResRef = CraftLookup("nw_wswbs001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswbs003",iIngotType);
   iComponent1 = 7;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_GREATSWORD")
  {
   iSmithChance = iSmithChance-400;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a greatsword.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the greatsword useless.";
   sItemResRefPoor = CraftLookup("wswgs002",iIngotType);
   sItemResRef = CraftLookup("nw_wswgs001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswgs003",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_HORSEHAIRHELMET")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 150;
   sSuccess = "You carefully pound the metal plate into the form of a horsehair helmet.";
   sFail = "The metal turns brittle as you pound it, ruining the horsehair helmet.";
   sItemResRefPoor = CraftLookup("arhe005",iIngotType);
   sItemResRef = CraftLookup("nw_arhe004",iIngotType);
   sItemResRefExceptional = CraftLookup("arhe007",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_POTHELMET")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 150;
   sSuccess = "You carefully pound the metal plate into the form of a pot helmet.";
   sFail = "The metal turns brittle as you pound it, ruining the pot helmet.";
   sItemResRefPoor = CraftLookup("arhe002",iIngotType);
   sItemResRef = CraftLookup("nw_arhe001",iIngotType);
   sItemResRefExceptional = CraftLookup("arhe008",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_SPIKEHELMET")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 150;
   sSuccess = "You carefully pound the metal plate into the form of a spike helmet.";
   sFail = "The metal turns brittle as you pound it, ruining the spike helmet.";
   sItemResRefPoor = CraftLookup("arhe003",iIngotType);
   sItemResRef = CraftLookup("nw_arhe002",iIngotType);
   sItemResRefExceptional = CraftLookup("arhe009",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_STAGHELMET")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 150;
   sSuccess = "You carefully pound the metal plate into the form of a stag helmet.";
   sFail = "The metal turns brittle as you pound it, ruining the stag helmet.";
   sItemResRefPoor = CraftLookup("arhe006",iIngotType);
   sItemResRef = CraftLookup("nw_arhe005",iIngotType);
   sItemResRefExceptional = CraftLookup("arhe010",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_WINGEDHELMET")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 150;
   sSuccess = "You carefully pound the metal plate into the form of a winged helmet.";
   sFail = "The metal turns brittle as you pound it, ruining the winged helmet.";
   sItemResRefPoor = CraftLookup("arhe004",iIngotType);
   sItemResRef = CraftLookup("nw_arhe003",iIngotType);
   sItemResRefExceptional = CraftLookup("arhe011",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_SMALLSHIELD")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 250;
   sSuccess = "You carefully craft the metal edges and affix the wooden boards to form a small shield.";
   sFail = "The metal fails to conform to the wooden portion of the shield, ruining both.";
   sItemResRefPoor = CraftLookup("ashsw002",iIngotType);
   sItemResRef = CraftLookup("nw_ashsw001",iIngotType);
   sItemResRefExceptional = CraftLookup("ashsw003",iIngotType);
   iComponent1 = 2;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "WOOD_NORMAL"; // normal wood logs
   sComponent3Name = "normal wood logs";
   iComponent3 = 1;
  }
 if (sTag == "P_MEDIUMSHIELD")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 350;
   sSuccess = "You carefully craft the metal edges and affix the wooden boards to form a large shield.";
   sFail = "The metal fails to conform to the wooden portion of the shield, ruining both.";
   sItemResRefPoor = CraftLookup("ashlw002",iIngotType);
   sItemResRef = CraftLookup("nw_ashlw001",iIngotType);
   sItemResRefExceptional = CraftLookup("ashlw003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
   sComponent3 = "WOOD_NORMAL"; // normal wood logs
   sComponent3Name = "normal wood logs";
   iComponent3 = 2;
  }

 if (sTag == "P_LARGESHIELD")
  {
   iCraftType=1;
   iArmorChance = iArmorChance - 450;
   sSuccess = "You carefully pound and form the metal plate into a tower shield.";
   sFail = "The metal turns brittle as you work it, rendering the shield useless.";
   sItemResRefPoor = CraftLookup("ashto002",iIngotType);
   sItemResRef = CraftLookup("nw_ashto001",iIngotType);
   sItemResRefExceptional = CraftLookup("ashto003",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_MACE")
  {
   iSmithChance = iSmithChance-200;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a mace.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the mace useless.";
   sItemResRefPoor = CraftLookup("wblml002",iIngotType);
   sItemResRef = CraftLookup("nw_wblml001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblml003",iIngotType);
   iComponent1 = 5;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_MORNINGSTAR")
  {
   iSmithChance = iSmithChance-300;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a maorning star.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the morning star useless.";
   sItemResRefPoor = CraftLookup("wblms002",iIngotType);
   sItemResRef = CraftLookup("nw_wblms001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblms003",iIngotType);
   iComponent1 = 6;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
   sComponent3 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent3Name = "small cast molds";
   iComponent3 = 1;
  }
 if (sTag == "P_LIGHTFLAIL")
  {
   iSmithChance = iSmithChance-250;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a light flail.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the light flail useless.";
   sItemResRefPoor = CraftLookup("wblfl002",iIngotType);
   sItemResRef = CraftLookup("nw_wblfl001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblfl003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_HEAVYFLAIL")
  {
   iSmithChance = iSmithChance-350;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a heavy flail.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the heavy flail useless.";
   sItemResRefPoor = CraftLookup("wblfh002",iIngotType);
   sItemResRef = CraftLookup("nw_wblfh001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblfh003",iIngotType);
   iComponent1 = 7;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_LIGHTHAMMER")
  {
   iSmithChance = iSmithChance-250;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a light hammer.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the light hammer useless.";
   sItemResRefPoor = CraftLookup("wblhl002",iIngotType);
   sItemResRef = CraftLookup("nw_wblhl001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblhl003",iIngotType);
   iComponent1 = 5;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_WARHAMMER")
  {
   iSmithChance = iSmithChance-350;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a warhammer.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the warhammer useless.";
   sItemResRefPoor = CraftLookup("wblhw002",iIngotType);
   sItemResRef = CraftLookup("nw_wblhw001",iIngotType);
   sItemResRefExceptional = CraftLookup("wblhw003",iIngotType);
   iComponent1 = 9;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_HANDAXE")
  {
   iSmithChance = iSmithChance-150;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a handaxe.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the handaxe useless.";
   sItemResRefPoor = CraftLookup("waxhn002",iIngotType);
   sItemResRef = CraftLookup("nw_waxhn001",iIngotType);
   sItemResRefExceptional = CraftLookup("waxhn003",iIngotType);
   iComponent1 = 3;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_BATTLEAXE")
  {
   iSmithChance = iSmithChance-150;
   sSuccess = "You carefully heat, fold, and pound the metal into the form of a battleaxe.";
   sFail = "The metal turns brittle as you heat, fold, and pound it, rending the battleaxe useless.";
   sItemResRefPoor = CraftLookup("waxbt002",iIngotType);
   sItemResRef = CraftLookup("nw_waxbt001",iIngotType);
   sItemResRefExceptional = CraftLookup("waxbt003",iIngotType);
   iComponent1 = 7;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_DART")
  {
   iCraftStackSize = 50;
   iSmithChance = iSmithChance-50;
   sSuccess = "You carefully forge the throwing darts.";
   sFail = "The metal fails to cool properly and the throwing darts are ruined.";
   sItemResRefPoor = CraftLookup("wthdt002",iIngotType);
   sItemResRef = CraftLookup("nw_wthdt001",iIngotType);
   sItemResRefExceptional = CraftLookup("wthdt003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_SHURIKEN")
  {
   iCraftStackSize = 50;
   iSmithChance = iSmithChance-50;
   sSuccess = "You carefully forge the shuriken.";
   sFail = "The metal fails to cool properly and the shuriken are ruined.";
   sItemResRefPoor = CraftLookup("wthsh002",iIngotType);
   sItemResRef = CraftLookup("nw_wthsh001",iIngotType);
   sItemResRefExceptional = CraftLookup("wthsh003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_THROWINGAXE")
  {
   iCraftStackSize = 50;
   iSmithChance = iSmithChance-150;
   sSuccess = "You carefully forge the throwing axes.";
   sFail = "The metal fails to cool properly and the throwing axes are ruined.";
   sItemResRefPoor = CraftLookup("wthax002",iIngotType);
   sItemResRef = CraftLookup("nw_wthax001",iIngotType);
   sItemResRefExceptional = CraftLookup("wthax003",iIngotType);
   iComponent1 = 6;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_HALBERD")
  {
   iSmithChance = iSmithChance-400;
   sSuccess = "You carefully forge the halberd blade and affix it to the shaft.";
   sFail = "The metal turns brittle as you attempt to forge and the halberd is ruined.";
   sItemResRefPoor = CraftLookup("wplhb002",iIngotType);
   sItemResRef = CraftLookup("nw_wplhb001",iIngotType);
   sItemResRefExceptional = CraftLookup("wplhb003",iIngotType);
   iComponent1 = 20;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 1;
   sComponent3 = "WOOD_NORMAL"; // Normal wooden log
   sComponent3Name = "normal wooden logs";
   iComponent3 = 1;
  }
 if (sTag == "P_SCYTHE")
  {
   iSmithChance = iSmithChance-400;
   sSuccess = "You carefully forge the scythe blade and affix it to the shaft.";
   sFail = "The metal turns brittle as you attempt to forge and the scythe is ruined.";
   sItemResRefPoor = CraftLookup("wplsc002",iIngotType);
   sItemResRef = CraftLookup("nw_wplsc001",iIngotType);
   sItemResRefExceptional = CraftLookup("wplsc003",iIngotType);
   iComponent1 = 20;
   sComponent2 = "ITEM_LARGECASTMOLD"; // large cast mold
   sComponent2Name = "large cast molds";
   iComponent2 = 1;
   sComponent3 = "WOOD_NORMAL"; // Normal wooden log
   sComponent3Name = "normal wooden logs";
   iComponent3 = 1;
  }
 if (sTag == "P_SPEAR")
  {
   iSmithChance = iSmithChance-300;
   sSuccess = "You carefully forge the spear tip and affix it to the shaft.";
   sFail = "The metal turns brittle as you attempt to forge and the spear is ruined.";
   sItemResRefPoor = CraftLookup("wplss002",iIngotType);
   sItemResRef = CraftLookup("nw_wplss001",iIngotType);
   sItemResRefExceptional = CraftLookup("wplss003",iIngotType);
   iComponent1 = 3;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
   sComponent3 = "WOOD_NORMAL"; // Normal wooden log
   sComponent3Name = "normal wooden logs";
   iComponent3 = 1;
  }
 if (sTag == "P_KAMA")
  {
   iSmithChance = iSmithChance-50;
   sSuccess = "You carefully fold and pound the metal into the form of a kama.";
   sFail = "The metal turns brittle as you attempt to forge and the kama is ruined.";
   sItemResRefPoor = CraftLookup("wspka002",iIngotType);
   sItemResRef = CraftLookup("nw_wspka001",iIngotType);
   sItemResRefExceptional = CraftLookup("wspka003",iIngotType);
   iComponent1 = 3;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_KUKRI")
  {
   iSmithChance = iSmithChance-100;
   sSuccess = "You carefully fold and pound the metal into the form of a kukri.";
   sFail = "The metal turns brittle as you attempt to forge and the kukri is ruined.";
   sItemResRefPoor = CraftLookup("wspku002",iIngotType);
   sItemResRef = CraftLookup("nw_wspku001",iIngotType);
   sItemResRefExceptional = CraftLookup("wspku003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_SICKLE")
  {
   iSmithChance = iSmithChance-150;
   sSuccess = "You carefully fold and pound the metal into the form of a sickle.";
   sFail = "The metal turns brittle as you attempt to forge and the sickle is ruined.";
   sItemResRefPoor = CraftLookup("wspsc002",iIngotType);
   sItemResRef = CraftLookup("nw_wspsc001",iIngotType);
   sItemResRefExceptional = CraftLookup("wspsc003",iIngotType);
   iComponent1 = 4;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_DIREMACE")
  {
   iSmithChance = iSmithChance-450;
   sSuccess = "You carefully fold and pound the metal into the form of a dire mace.";
   sFail = "The metal turns brittle as you attempt to forge and the dire mace is ruined.";
   sItemResRefPoor = CraftLookup("wdbma002",iIngotType);
   sItemResRef = CraftLookup("nw_wdbma001",iIngotType);
   sItemResRefExceptional = CraftLookup("wdbma003",iIngotType);
   iComponent1 = 15;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 2;
  }
 if (sTag == "P_DOUBLEAXE")
  {
   iSmithChance = iSmithChance-450;
   sSuccess = "You carefully fold and pound the metal into the form of a double axe.";
   sFail = "The metal turns brittle as you attempt to forge and the double axe is ruined.";
   sItemResRefPoor = CraftLookup("wdbax002",iIngotType);
   sItemResRef = CraftLookup("nw_wdbax001",iIngotType);
   sItemResRefExceptional = CraftLookup("wdbax003",iIngotType);
   iComponent1 = 15;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 2;
  }
 if (sTag == "P_TWOBLADEDSWORD")
  {
   iSmithChance = iSmithChance-500;
   sSuccess = "You carefully fold and pound the metal into the form of a two-bladed sword.";
   sFail = "The metal turns brittle as you attempt to forge and the two-bladed sword is ruined.";
   sItemResRefPoor = CraftLookup("wdbsw002",iIngotType);
   sItemResRef = CraftLookup("nw_wdbsw001",iIngotType);
   sItemResRefExceptional = CraftLookup("wdbsw003",iIngotType);
   iComponent1 = 25;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 2;
  }
 if (sTag == "P_BULLET")
  {
   iSmithChance = iSmithChance+50;  //Bullets are easy to make
   iCraftStackSize = 99;
   sSuccess = "You carefully forge the bullets.";
   sFail = "The metal fails to cool properly and the bullets are ruined.";
   sItemResRefPoor = CraftLookup("wambu002",iIngotType);
   sItemResRef = CraftLookup("nw_wambu001",iIngotType);
   sItemResRefExceptional = CraftLookup("wambu003",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_ARROWHEAD")
  {
   iSmithChance = iSmithChance - 50;
   iCraftStackSize = 50;
   sSuccess = "You carefully forge the arrowheads.";
   sFail = "The metal fails to cool properly and the arrowheads are ruined.";
   sItemResRefPoor = CraftLookup("arrowhead001",iIngotType);
   sItemResRef = CraftLookup("arrowhead",iIngotType);
   sItemResRefExceptional = CraftLookup("arrowhead002",iIngotType);
   iComponent1 = 5;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_BOLTTIP")
  {
   iSmithChance = iSmithChance - 50;
   iCraftStackSize = 50;
   sSuccess = "You carefully forge the bolt tips.";
   sFail = "The metal fails to cool properly and the bolt tips are ruined.";
   sItemResRefPoor = CraftLookup("arrowhead004",iIngotType);
   sItemResRef = CraftLookup("arrowhead003",iIngotType);
   sItemResRefExceptional = CraftLookup("arrowhead005",iIngotType);
   iComponent1 = 5;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
 if (sTag == "P_METALSTUD")
  {
   iCraftType=1;
   iArmorChance = iArmorChance + 100;  // metal studs are super-easy
   iCraftStackSize = 99;
   sSuccess = "You carefully forge the metal studs.";
   sFail = "The metal fails to cool properly and the metal studs are ruined.";
   sItemResRefPoor = CraftLookup("metalstud001",iIngotType);
   sItemResRef = CraftLookup("metalstud",iIngotType);
   sItemResRefExceptional = CraftLookup("metalstud002",iIngotType);
   iComponent1 = 10;
   sComponent2 = "ITEM_SMALLCASTMOLD"; // small cast mold
   sComponent2Name = "small cast molds";
   iComponent2 = 1;
  }
  if (sTag == "P_KATANA")
  {
   iSmithChance = iSmithChance-350;
   sSuccess = "You carefully fold and pound the metal into the form of a katana.";
   sFail = "The metal turns brittle as you attempt to forge and the katana is ruined.";
   sItemResRefPoor = CraftLookup("wswka002",iIngotType);
   sItemResRef = CraftLookup("nw_wswka001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswka003",iIngotType);
   iComponent1 = 9;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
  if (sTag == "P_RAPIER")
  {
   iSmithChance = iSmithChance-250;
   sSuccess = "You carefully fold and pound the metal into the form of a rapier.";
   sFail = "The metal turns brittle as you attempt to forge and the rapier is ruined.";
   sItemResRefPoor = CraftLookup("wswrp002",iIngotType);
   sItemResRef = CraftLookup("nw_wswrp001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswrp003",iIngotType);
   iComponent1 = 5;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
  if (sTag == "P_SCIMITAR")
  {
   iSmithChance = iSmithChance-300;
   sSuccess = "You carefully fold and pound the metal into the form of a scimitar.";
   sFail = "The metal turns brittle as you attempt to forge and the scimitar is ruined.";
   sItemResRefPoor = CraftLookup("wswsc002",iIngotType);
   sItemResRef = CraftLookup("nw_wswsc001",iIngotType);
   sItemResRefExceptional = CraftLookup("wswsc003",iIngotType);
   iComponent1 = 6;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
  if (sTag == "pattern123")
  {
   iSmithChance = iSmithChance-400;
   sSuccess = "You carefully fold and pound the metal into the form of a great axe.";
   sFail = "The metal turns brittle as you attempt to forge and the great axe is ruined.";
   sItemResRefPoor = CraftLookup("waxgr002",iIngotType);
   sItemResRef = CraftLookup("nw_waxgr001",iIngotType);
   sItemResRefExceptional = CraftLookup("waxgr003",iIngotType);
   iComponent1 = 8;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }
  if (sTag == "pattern124")
  {
   if (GetRacialType(oPC)!=RACIAL_TYPE_DWARF)
    {
     FloatingTextStringOnCreature("You are not a dwarf!  You cannot craft a Dwarven Waraxe!",oPC,FALSE);
     return;
    }
   iSmithChance = iSmithChance-400;
   sSuccess = "You carefully fold and pound the metal into the form of a dwarven waraxe.";
   sFail = "The metal turns brittle as you attempt to forge and the dwarven waraxe is ruined.";
   sItemResRefPoor = CraftLookup("wdwraxe002",iIngotType);
   sItemResRef = CraftLookup("x2_wdwraxe001",iIngotType);
   sItemResRefExceptional = CraftLookup("wdwraxe003",iIngotType);
   iComponent1 = 7;
   sComponent2 = "ITEM_MEDIUMCASTMOLD"; // medium cast mold
   sComponent2Name = "medium cast molds";
   iComponent2 = 1;
  }


 // Set Ingot Tag and name based on ingot selection
 switch (iIngotType)
  {
   case 0:{sComponent1 = "INGOT_IRON";sComponent1Name = "iron ingots";break;}
   case 1:{sComponent1 = "INGOT_DULL";sComponent1Name = "dull copper ingots";break;}
   case 2:{sComponent1 = "INGOT_SHADOW";sComponent1Name = "shadow iron ingots";break;}
   case 3:{sComponent1 = "INGOT_COPPER";sComponent1Name = "copper ingots";break;}
   case 4:{sComponent1 = "INGOT_BRONZE";sComponent1Name = "bronze ingots";break;}
   case 5:{sComponent1 = "INGOT_GOLD";sComponent1Name = "gold ingots";break;}
   case 6:{sComponent1 = "INGOT_AGAPITE";sComponent1Name = "agapite ingots";break;}
   case 7:{sComponent1 = "INGOT_VERITE";sComponent1Name = "verite ingots";break;}
   case 8:{sComponent1 = "INGOT_VALORITE";sComponent1Name = "valorite ingots";break;}
   case 9:{sComponent1 = "INGOT_SILVER";sComponent1Name = "silver ingots";break;}
   case 10:{sComponent1 = "INGOT_MITHRIL";sComponent1Name = "mithril ingots";break;}
   case 11:{sComponent1 = "INGOT_ADAMANTITE";sComponent1Name = "adamantite ingots";break;}
   case 12:{sComponent1 = "INGOT_PLATINUM";sComponent1Name = "platinum ingots";break;}
   default:{FloatingTextStringOnCreature("Error in ingot selection..",oPC,FALSE);return;break;}
  }

 // Check for negative chance due to ingot type and other modifiers
 if (iCraftType==0)
   {
    if (iSmithChance <1)
     {
      FloatingTextStringOnCreature("You do not have the skill needed to craft this.",oPC,FALSE);
      return;
     }
   }
  else
   {
    if (iArmorChance <1)
     {
      FloatingTextStringOnCreature("You do not have the skill needed to craft this.",oPC,FALSE);
      return;
     }
   }

 // check for components
 if (GetNumItems(oPC,sComponent1) < iComponent1)
  {
   FloatingTextStringOnCreature("You do not have enough "+sComponent1Name+" to do this.",oPC,FALSE);
   return;
  }
 if (iComponent2 > 0)
  {
   if (GetNumItems(oPC,sComponent2) < iComponent2)
    {
     FloatingTextStringOnCreature("You do not have enough "+sComponent2Name+" to do this.",oPC,FALSE);
     return;
    }
  }
 if (iComponent3 > 0)
  {
   if (GetNumItems(oPC,sComponent3) < iComponent3)
    {
     FloatingTextStringOnCreature("You do not have enough "+sComponent3Name+" to do this.",oPC,FALSE);
     return;
    }
  }

// This is extra code.. not needed I think
// if (iArmorChance <1)
//  {
//   if (iCraftType==1)
//    {
//     FloatingTextStringOnCreature("You do not yet possess the skill required to craft this armor.",oPC,FALSE);
//     return;
//    }
//  }
// if (iSmithChance <1)
//  {
//   if (iCraftType==0)
//    {
//     FloatingTextStringOnCreature("You do not yet possess the skill required to craft this weapon.",oPC,FALSE);
//     return;
//    }
//  }


 // visual and audio crafting effects
 AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,12.0));
 if (iCraftType==0)
   {
    if (Random(1000)<500)
      {
       PlaySound("as_cv_smithhamr2");
       DelayCommand(6.0,PlaySound("as_cv_smithhamr2"));
      }
     else
      {
       PlaySound("as_cv_smithhamr1");
       DelayCommand(6.0,PlaySound("as_cv_smithhamr1"));
      }

   }
  else
   {
    PlaySound("as_cv_smithmet2");
    if (Random(1000)<500)
      {
       DelayCommand(6.0,PlaySound("as_cv_smithhamr3"));
      }
     else
      {
       DelayCommand(6.0,PlaySound("as_cv_smithhamr1"));
      }
   }

 // Set Anvil to 'in use'
 SetLocalInt(OBJECT_SELF,"iAmInUse",99);
 DelayCommand(12.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));

 // This snippet of code is cut-n-paste direct from ATS
 // Reason for this is because I had no clue how to assign an increase
 // in the z-axis of the location of the anvil for sparks to display.
 // After reading through this code, it is obvious that vEffecrPos.z
 // is the line which assigns this.  Due to my own ignorance in this issue
 // I have decided to leave this snippet of code intact with this credit to
 // the original ATS script coders, whomever they may have been.

  location locAnvil = GetLocation(OBJECT_SELF);
  vector vEffectPos = GetPositionFromLocation(locAnvil);
  vEffectPos.z += 1.0;
  location locEffect = Location( GetAreaFromLocation(locAnvil), vEffectPos,GetFacingFromLocation(locAnvil) );
  ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect);
  DelayCommand(1.7, ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
  DelayCommand(2.4, ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
  DelayCommand(3.1, ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
  DelayCommand(3.8, ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));

  // end of ATS snippet ^^^^
  //


  DelayCommand(4.6,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_WHITE_ORANGE,FALSE),locEffect));
  DelayCommand(5.9,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPARKS_PARRY,FALSE),locEffect));
  DelayCommand(7.1,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_RED_ORANGE,FALSE),locEffect));
  DelayCommand(8.2,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPARKS_PARRY,FALSE),locEffect));
  DelayCommand(9.6,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_WHITE_BLUE,FALSE),locEffect));
  DelayCommand(11.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPARKS_PARRY,FALSE),locEffect));


 // Remove all components
 float fPause = 0.0;
 if (iComponent1Stackable != 0)
   {
    oTemp = GetItemPossessedBy(oPC,sComponent1);
    sComponentResRef = GetResRef(oTemp);
    iStackSize = GetNumStackedItems(oTemp);
    DestroyObject(oTemp);
    if (iStackSize < iComponent1)
      {
       iComponent1 = iComponent1 - iStackSize;
       DelayCommand(2.0,GetNextStackedItem(oPC,sComponent1,iComponent1,1,sComponentResRef));
      }
     else
      {
       if (iStackSize > iComponent1)
        {
         iStackSize = iStackSize - iComponent1;
         DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize));
        }
      }
   }
  else
   {
    for (iComponent1; iComponent1>0; iComponent1--)
     {
      fPause = fPause+0.5;
      AssignCommand(oPC,DelayCommand(fPause,GetNextItemPossessedBy(oPC,sComponent1)));
     }
   }
 if (sComponent2 != "")
  {
   if (iComponent2Stackable != 0)
     {
      oTemp = GetItemPossessedBy(oPC,sComponent2);
      sComponentResRef = GetResRef(oTemp);
      iStackSize = GetNumStackedItems(oTemp);
      DestroyObject(oTemp);
      if (iStackSize < iComponent2)
        {
         iComponent2 = iComponent2 - iStackSize;
         DelayCommand(2.0,GetNextStackedItem(oPC,sComponent2,iComponent2,1, sComponentResRef));
        }
       else
        {
         if (iStackSize > iComponent2)
          {
           iStackSize = iStackSize - iComponent2;
           DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize));
          }
        }
     }
    else
     {
      for (iComponent2; iComponent2>0; iComponent2--)
       {
        fPause = fPause+0.5;
        AssignCommand(oPC,DelayCommand(fPause,GetNextItemPossessedBy(oPC,sComponent2)));
       }
     }
  }
 if (sComponent3 != "")
  {
   if (iComponent3Stackable != 0)
     {
      oTemp = GetItemPossessedBy(oPC,sComponent3);
      sComponentResRef = GetResRef(oTemp);
      iStackSize = GetNumStackedItems(oTemp);
      DestroyObject(oTemp);
      if (iStackSize < iComponent3)
        {
         iComponent3 = iComponent3 - iStackSize;
         DelayCommand(2.0,GetNextStackedItem(oPC,sComponent3,iComponent3,1, sComponentResRef));
        }
       else
        {
         if (iStackSize > iComponent3)
          {
           iStackSize = iStackSize - iComponent3;
           DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize));
          }
        }
     }
    else
     {
      for (iComponent3; iComponent3>0; iComponent3--)
       {
        fPause = fPause +0.5;
        AssignCommand(oPC,DelayCommand(fPause,GetNextItemPossessedBy(oPC,sComponent3)));
       }
     }
   }


 // check for success
 if (iCraftType ==0)
   {
    // Adjusted the starting chance down from 1000 to 800 to facilitate more lowend successes
    if (Random(800) <= iSmithChance)
      {
       DelayCommand(8.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SMOKE_PUFF,FALSE),OBJECT_SELF,1.0));
       if (Random(1000)<500)
         {
          DelayCommand(12.0,PlaySound("as_cv_smithwatr2"));
         }
        else
         {
          DelayCommand(12.0,PlaySound("as_cv_smithwatr1"));
         }
       iSuccess = 1;
       iSuccess2 = 1;
       iSmithChance = iSmithChance - 50;
       if (Random(1000) <= iSmithChance) iSuccess2 = iSuccess2+1;
       iSmithChance = iSmithChance-100;
       if (Random(1000) <= iSmithChance) iSuccess2 = iSuccess2+1;
       iSmithChance = iSmithChance + 150;
       if (iCraftStackSize != 0) iSuccess2 =4;
       if (iSuccess2 == 1)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefPoor,oPC,1)));
       if (iSuccess2 == 2)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRef,oPC,1)));
       if (iSuccess2 == 3)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefExceptional,oPC,1)));
       AssignCommand(oPC,DelayCommand(12.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
       if (Random(1000) >= iSmithSkill)
        {
         if (d10(1)+1 >= iSmithChance/100) iSkillGain = 1;
        }
      }
     else
      {
       AssignCommand(oPC,DelayCommand(12.0,FloatingTextStringOnCreature(sFail,oPC,FALSE)));
       return;
      }
   }
  else
   {
    // Adjusted the starting chance down from 1000 to 800 to facilitate more lowend successes
    if (Random(800) <= iArmorChance)
      {
       iSuccess = 1;
       iSuccess2 = 1;
       iArmorChance = iArmorChance - 50;
       if (Random(1000) <= iArmorChance) iSuccess2 = iSuccess2+1;
       iArmorChance = iArmorChance - 100;
       if (Random(1000) <= iArmorChance) iSuccess2 = iSuccess2+1;
       iArmorChance = iArmorChance+150;
       if (iSuccess2 == 1)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefPoor,oPC,1)));
       if (iSuccess2 == 2)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRef,oPC,1)));
       if (iSuccess2 == 3)AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefExceptional,oPC,1)));
       AssignCommand(oPC,DelayCommand(12.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
       if (Random(1000) >= iArmorSkill)
        {
         if (d10(1)+1 >= iArmorChance/100) iSkillGain = 1;
        }
      }
     else
      {
       AssignCommand(oPC,DelayCommand(12.0,FloatingTextStringOnCreature(sFail,oPC,FALSE)));
       return;
      }
   }

 // Adjust stacksize for items that have stackable properties (throwing axes, etc)
 if (iCraftStackSize>0)
  {
   int iStackPoor = 0;
   int iStackNormal = 0;
   int iStackExceptional = 0;
   int iQuality = 0;
   string sQuality = "";
   for (iCraftStackSize; iCraftStackSize>0; iCraftStackSize--)
    {
     iQuality = 0;
     if (Random(1000)<= iSmithChance) iQuality++;
     if (Random(1000)<= iSmithChance) iQuality++;
     if (Random(1000)<= iSmithChance) iQuality++;
     if (iQuality==1) iStackPoor++;
     if (iQuality==2) iStackNormal++;
     if (iQuality==3) iStackExceptional++;
    }
   sQuality = "Created - ("+IntToString(iStackPoor)+" Poor) ("+IntToString(iStackNormal)+" Normal) ("+IntToString(iStackExceptional)+" Exceptional)";
   if (iStackPoor >0) AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRefPoor,oPC,iStackPoor)));
   if (iStackNormal>0) AssignCommand(oPC,DelayCommand(12.5,CreateAnObject(sItemResRef,oPC,iStackNormal)));
   if (iStackExceptional>0) AssignCommand(oPC,DelayCommand(13.0,CreateAnObject(sItemResRefExceptional,oPC,iStackExceptional)));
   AssignCommand(oPC,DelayCommand(13.0,FloatingTextStringOnCreature(sQuality,oPC,FALSE)));
  }

 //Ensure no more than 1 skill gain every 10 seconds to avoid token droppage.
      if (iSkillGain ==1)
       {
        if (GetLocalInt(oPC,"iSkillGain")!= 0)
          {
           iSkillGain = 0;
          }
         else
          {
           SetLocalInt(oPC,"iSkillGain",99);
           AssignCommand(GetArea(oPC),DelayCommand(10.0,SetLocalInt(oPC,"iSkillGain",0)));
          }
       }




 // Do skill gains
 if (iSkillGain ==1)
  {
   string sOldSkill = "";
   string sOldSkill2 = "";
   if (iCraftType==0)
     {
      iSmithSkill++;
      sOldSkill2 = IntToString(iSmithSkill);
      sOldSkill = "."+GetStringRight(sOldSkill2,1);
      if (iSmithSkill > 9)
        {
         sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
        }
       else
        {
         sOldSkill = "0"+sOldSkill;
        }
      if (iSmithSkill <= 1000)
       {
        //DelayCommand(13.0,SetTokenPair(oPC,13,4,iSmithSkill));
        DelayCommand(13.0,SetCampaignInt("UOACraft","iSmithSkill",iSmithSkill,oPC));
        DelayCommand(13.0,SendMessageToPC(oPC,"========================================="));
        DelayCommand(13.0,SendMessageToPC(oPC,"Your skill in weaponsmithing has gone up!"));
        DelayCommand(13.0,SendMessageToPC(oPC,"Current weaponsmithing skill : "+ sOldSkill+"%"));
        DelayCommand(13.0,SendMessageToPC(oPC,"========================================="));
        if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(12.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
       }
     }
    else
     {
      iArmorSkill++;
      sOldSkill2 = IntToString(iArmorSkill);
      sOldSkill = "."+GetStringRight(sOldSkill2,1);
      if (iArmorSkill > 9)
        {
         sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
        }
       else
        {
         sOldSkill = "0"+sOldSkill;
        }
      if (iArmorSkill <= 1000)
       {
        //DelayCommand(13.0,SetTokenPair(oPC,13,5,iArmorSkill));
        DelayCommand(13.0,SetCampaignInt("UOACraft","iArmorSkill",iArmorSkill,oPC));
        DelayCommand(13.0,SendMessageToPC(oPC,"====================================="));
        DelayCommand(13.0,SendMessageToPC(oPC,"Your skill in armorcraft has gone up!"));
        DelayCommand(13.0,SendMessageToPC(oPC,"Current armorcraft skill : "+ sOldSkill+"%"));
        DelayCommand(13.0,SendMessageToPC(oPC,"====================================="));
        if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(12.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
       }
     }
  }

 //Check for broken tool
 iHammerUse++;
 if (iHammerUse>60+Random(20))
  {
   AssignCommand(oPC,DelayCommand(10.0,FloatingTextStringOnCreature("Your hammer has broken while crafting..",oPC,FALSE)));
   DestroyObject(oTool,9.5);
   iHammerUse=0;
  }
 SetLocalInt(oPC,"iHammerUsed",iHammerUse);


}

void CreateAnObject(string sResource, object oPC, int iStackSize)
 {
  CreateItemOnObject(sResource,oPC,iStackSize);
  return;
 }

void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef)
 {
  object oTemp = GetItemPossessedBy(oPC,sItemTag);
  int iStackCount = GetNumStackedItems(oTemp);
  int iTemp = iCount - iStackCount;
  iStackCount = iStackCount-iCount;
  DestroyObject(oTemp);
  if (iStackCount > 0)
   {
    SendMessageToPC(oPC,"You should get back "+IntToString(iStackCount));
    DelayCommand(1.0,CreateAnObject(sStackResRef,oPC,iStackCount));
   }
  // this next line *should* recursively call this function if the number of
  // stacked items does not meet the required number of items to be destroyed.
  if (iTemp > 0) DelayCommand(1.0,GetNextStackedItem(oPC,sItemTag,iTemp, iMode, sStackResRef));
  return;
 }

void GetNextItemPossessedBy(object oPC, string sItemTag)
 {
  object oTemp = GetItemPossessedBy(oPC,sItemTag);
  DestroyObject(oTemp);
  return;
 }

string CraftLookup(string sResRef, int iIngotType)
 {
  switch (iIngotType)
   {
    case 0:
     {
      return sResRef;
      break;
     }
    case 1:
     {
      //Dull Copper Dagger
      if (sResRef=="wswdg002") return "wswdg005";
      if (sResRef=="nw_wswdg001") return "wswdg004";
      if (sResRef=="wswdg003") return "wswdg006";
      //Dull Copper ShortSword
      if (sResRef=="wswss002") return "wswss005";
      if (sResRef=="nw_wswss001") return "wswss004";
      if (sResRef=="wswss003") return "wswss006";
 ************ snipping all the metals and items for length ***********************
      //Platinum Dwarven WarAxe
      if (sResRef=="wdwraxe002") return "wdwraxe032";
      if (sResRef=="x2_wdwraxe001") return "wdwraxe031";
      if (sResRef=="wdwraxe003") return "wdwraxe033";
      break;
     }
    default:{return "null";break;}
   }
  return "null";
 }

               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #6 on: June 05, 2016, 03:59:31 pm »


               

As I thought was likely, it's just a void wrapper for CreateItemOnObject.   So...


 


You could put a routine like this in that include file:



void createCraftedItem(string sRef, string sDescExtra, object oPC) {
        object oNew = CreateItemOnObject(sRef, oPC, 1);

        if (GetIsObjectValid(oNew)) {
                string sDesc = GetDescription(oNew);
                string sExtra = "";
                if (sDescExtra != "")
                        sExtra = " (" + sDescExtra + ")";

                sDesc += "\n";
                sDesc += GetName(oNew) + sExtra + " from the forges of " + GetName(oPC);
                SetDescription(oNew, sDesc);
        } else {
                SendMessageToPC(oPC, "Error - unable to create item " + sRef);
        }     
}

And then make a call to this in place of the call to CreateAnObject in the code snippet you started with.  Note, the arguments are a bit dfferent. Here you will pass in the resref and the PC still, but also the text you want in the parentheses. If you don't want anything there (e.g. for the normal item) just pass in  an empty string ("").  I have not tested this other than to compile it.  Right now it tries to preserve any existing description but you can disable that if you want to overwrite anything that was already there.



 



               
               

               
            

Legacy_graywolf.theheathen

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
trying to make a small addition to UOA crafting
« Reply #7 on: June 05, 2016, 04:52:27 pm »


               

Thank you for this. I'll give it a try and let you know.