|
If you want to replace the 3rd digit with a known number then I'd do something like...
var itemType = originalID / 1000 * 1000;
///139399 /1000 * 1000 = 139000 (clear last 3 digits out)
var itemQualityLevel = originalID % 100;
//139399 % 100 = 99 (get last 2 digits)
var newID = itemType + newColor * 100 + itemQualityLevel;
//Get the full ID by using the itemID, ItemColor (in 3rd digit) and itemQualityLevel to create a properly formatted item ID
That's of course a massively broken down version of the calculation and it could be simplified. This is just to give you the thought process behind what it is you're trying to do so that you can code it yourself.
You also then need to verify that the item ID does in fact exist and is the same item type as it originally was.
Alternative (and much simpler) calculation would be...
itemID += newColor - (itemID % 1000 / 100) * 100
Fully broken down example calculation (Note: make sure it's processing as an int. You need it supporting negative numbers to work obviously)
139399 += 4 - (139399 % 1000 / 100) * 100
139399 += 4 - 3 * 100
139399 += 100
Result: 139499
|