I apologize for not following up on this earlier. This explanation will be broken up into multiple posts where each focuses on a specific point of how we determined the weapon and armor statistics. This first post will outline the behavior of the blacksmithy script in the demo as it relates to internally calculated values:
To understand how we know the accuracy of armor and weapon stats, we need to first look at how the demo blacksmithy script calculates difficulties for creating items, as well as some primer information on how the scripts themselves work.
In the demo, when a script is attached to an object, a particular trigger we call the
created trigger executes. This piece of code handles any necessary initialization for a script that may be needed later on when the script is first created. Some scripts also contain another trigger called the
objectloaded trigger. This code triggers when an object is loaded into memory, and does much the same thing.
In the demo, the blacksmith script has both a created and objectloaded trigger, and both contain the following code:
This code runs the function Q4Y8, which is responsible for checking and setting up a global array stored on the server. The relevant code that begins this process is as follows:
Code: Select all
void Q4Y8()
{
if(hasObjVar(this, "debugSkillInfo"))
{
deleteArray(0);
}
if(isArrayInit(0))
{
return();
}
The above code does two things. First it will delete the global array stored at index 0 if a particular variable is present on the object. Then it checks to see if the global array stored at index 0 in the server memory is present (initialized) or not (which it will never be if the object variable exists). If the array is present, then the function exits and the trigger finishes. However, if the array is
not present then the script continues with some code that builds this array. The significant point of this explanation is to note a few things. First, blacksmithy references a global array stored on the server that holds all of the relevant information about items and their difficulties. This differs from other crafting skills that all set up their menus based on internally stored lists of information. Second, this allows for a much more efficient design with a single table serving all items with the blacksmithy script. Third, this array is re-calculated every time that the server comes back up (assuming the array is not intialized on server start), which allows the blacksmithy script to stay up to date with the latest changes to weapons and armor via the template files. This is how OSI ended up with two different sets of statistics for weapon types, one from before the first weapon patch on 2/12/98, and one afterwards.
So, beyond the beginning piece of the script shown above, the rest of the script builds the global array for blacksmithy. This entails building a 61 row, 6 column, array where each of the sub-menu categories, and specific items are stored. For each row, the 6 corresponding column entries are as follows:
- Column 1: Item ID
- Column 2: Hue
- Column 3: String description of the row item.
- Column 4: Sub category layer identifier
- Column 5: Resources required (metal)
- Column 6: Internally calculated value
For these 6 columns, each row entries fall into two categories; sub-category headers (i.e. build armor) & specific entries (i.e. build a longsword). Since sub-category headers are not of concern, they aren't covered, so, let's take a look at the properties of specific items. Among specific item entries, columns 1 through 4 are of minimal interest, it is primarily columns 5 and 6 that concern us. Specifically, we want to know how the script calculates the internal values for column 6, which is partially dependent on the resources (column 5) required to make the item. This calculation for column 6 is very important to item difficulties and is calculated as follows:
- For weapons: Average weapon damage * weapon speed / 12 + required resources
- For armor: Base armor class * 2 + required resources
These different calculations make up the interal values stored in column 6.
Once a value has been calculated for column 6, the function then performs some recursive calculations using these new values in column 6. This starts by calculating the range between the highest and lowest value among all specific item entries stored in column 6. Then, this range is used in a calculation that recursively replaces the values stored in column 6 for each specific item using the following equation:
Code: Select all
new value for column 6 = (old value for column 6 - old minimum value from all column 6 entries) * 1000 / range
This new internal value represents the difficulty for the item.
To give you an example of what happens, consider the following:
One of the rows in the array is for a buckler. The armor rating for a buckler is 7, and a buckler takes 10 metal to create. This makes the
initial calculation for column 6 equal to 24. Another row in the array is for a platemail tunic which has an armor rating of 30, and requires 25 metal to make. This makes it's initial calculation for row 6 equal to 85. These two rows also happen to have the highest and lowest values among all rows, thus making the range between them 61. Finally, a third row in the array is for a halberd. The halberd has an average damage of 22, a speed of 25, and takes 20 metal to produce (on the demo). This creates an initial value for column 6 of 65. Using these 3 values and the range, let's calculate the new values for column 6:
Buckler: (24 - 24) * 1000 / 61 = 0
Platemail: (85 - 24) * 1000 / 61 = 1000
Halberd: (65 - 24) * 1000 / 61 = 672
The new numbers calculated above become the final values for column 6 for each of those rows, and these values represent the actual difficulty check for creating the item.
Using the example numbers above, we can see the method by which the difficulties of items are set. The lowest and highest internal values mark the least and most difficult items to create, and all other difficulties lie in-between these two boundaries and use their own properties to determine their relative difficulty compared to the two extremes. The take home is this:
Item difficulties are on a relative scale between the least and most difficult items.
More to come in a second post, probably tomorrow.