[5017] Item Information Packet - Color Offset

10/04/2013 21:29 abdeen#16
Quote:
Originally Posted by Mr_PoP View Post
I don't know why you guys using strings with numbers(integers) , if it's int there is no need to convert it to string then select what you want , basically if it's an int you have to do Math(calculation)....

here how to change the color :-

Code:
uint newItemColor = TypeId-((TypeId/100)%10)*100+newColor*100;
thanks bro i`ll try it :D
10/04/2013 22:02 pro4never#17
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