On your consumable item XML object, for this new active effect, have two descriptors, one for each item you are using for the upgrade. You can either use strings and the item names, or integers and the object id's of the item. You then call these descriptors in your code to specify which item to look for, and replace with the other. I will leave a poorly written example below using string variables.
Code:
case ActivateEffects.ForgeItem:
{
string item = ""; //item being upgraded
string upgrade = ""; //upgraded item
for (int i = 4; i < Inventory.Length; i++)
{
if (Inventory[i].ItemName == item) //find item to replace
{
Inventory[i].ObjectId = NameToObjectId(upgrade); //replace item with upgrade
SaveToCharacter();
UpdateCount++;
SendInfo("You've obtained the " + upgrade + "!");
return true;
}
else
{
SendHelp("Legendary item must be in inventory.");
return false;
}
SendError("Error");
return false;
}
}
break;