I've checked the demo script for blacksmithy, and the demo employs a very simple set of checks to determine whether something should or shouldn't be repaired. This is the part of script that is relevant for repairing an item:
Code: Select all
#on targetobj(object user, object usedon)
{
cleanup();
if(Q4BL(user, "The blacksmith skill", 0x00))
{
return(0x00);
}
if(!Q4ZM(user))
{
return(0x00);
}
if(isWeapon(usedon) && hasResource(usedon, resourceTypeToId("metal")))
{
if(isInContainer(usedon))
{
object container = getTopmostContainer(usedon);
if(isMobile(container))
{
if(container != user)
{
systemMessage(user, "You can't work on that item.");
return(0x00);
}
}
}
integer Q4G6 = getWeaponCurHP(usedon);
integer Q56H = getWeaponMaxHP(usedon);
if((Q56H == 0x00) || (Q4G6 >= Q56H))
{
systemMessage(user, "That is already in full repair.");
return(0x00);
}
integer Q5MK = (Q56H - Q4G6) * 0x04E2 / Q56H - 0xFA;
integer Q4Q1;
integer success = testAndLearnSkill(user, 0x07, Q5MK, 0x32);
Q56H --;
Q4G6 --;
if(Q4G6 < 0x01)
{
systemMessage(user, "You destroyed the item.");
deleteObject(usedon);
}
else
{
if(success > 0x00)
{
Q4G6 = Q56H;
systemMessage(user, "You repair the item.");
}
Q4Q1 = setWeaponMaxHP(usedon, Q56H);
Q4Q1 = setWeaponCurHP(usedon, Q4G6);
}
One small note about this code: In the demo all weapons and armor are classified in weapon files using the same templating format. This means that all armor pieces are treated as weapons, which is why the isWeapon function works the way it does. The code will work just fine on armor as well as weapons.
Now, with that out of the way, the hasResource function call is the important one here. This function checks to see if a given item has a specific type of resource that is present with the item, and this particular function is based off of the overall resource system in UO, where resources spawn in chunks on the map based on the type of map tile shown (e.g. any trees within a specific chunk will spawn wood, and any water tiles within a chunk will spawn fish). These resources are then transferred from the chunk to the raw resources as they're harvested, and these raw resources transfer the resource type & amount to the finished product when it's crafted. In this way, an item carries some sort of "resource" of a particular type as part of it's makeup. So when the game checks to see if a particular item actually carries a particular resource, it is checking to see if the item itself has gotten the resources from some other location.
Given the above information, we don't know exactly why some higher level pieces of studded leather are repairiable, but there are some possible explanations. It may be possible that starting with the meditation patch in 1999, newly spawning magical items of a certain strength or higher were simply given a component of metal as part of gaining those magical properties. This would explain why higher strength magical studded armor would sometimes tell you that you had too much armor on to meditate as reported from stratics during the era. This would have also made the armor repairable, but would have yielded no metal as part of the unraveling process, which took place via tailoring (and would likely have checked for leather as the resource to return). Another explanation is simply that armor with a base AR rating of a certain amount or higher would have been eligible for repair, but this does ignore the fact that the available information indicates that no leather was repairable, although some sweet spot number may have existed to write the code with. Either way, these are just hypotheses on how it worked, and unfortunately, we don't really have any concrete information for why it was possible to repair higher level studded armor, as opposed to all other types.