People have asked about this before sorry it took so long but here are the details. You access this system by clicking the blue icon in the players bag

You need two Gems. One controls the Stats added and chance of success and the other controls the chance of losing Stats if an attempt fails and the chance of gems breaking on fail.

Stdmode 55
This is the left slot item and the following DB entries affect it like so.

Shape: Can set what item type the Gem works on. For example 5 will mean it only works on Weapons. 0 will make it so the gem works on any item.
Anicount: Set to 0, unsure what other values do here.
DuraMax: Chance of success, the larger the number the less chance of success.
Need: Set the max level the Gem can be used up to. For example 5 would mean if an item is level 6 the gem will no longer work on it. Set to 0 if you want no limit
Ac, Ac2, Mac, Mac2, Dc, Dc2, Mc, Mc2, Sc, SC2: The amount to add per item. For example SC 0-1 if it's an SC Gem

Stdmode 56
This is the right slot item the the following DB entries affect it like so.

Shape: Can set what item type the Gem works on. For example 5 will mean it only works on Weapons. 0 will make it so the gem works on any item.
Anicount:If set to 0 will cause item to lose stats as per the values set in AC,DC,MC etc etc
DuraMax: Chance to break gems on fail, the larger the number the less chance of success.
Need:Number of Item levels to lose on fail? Need confirming
NeedLevel:Chance of losing Item levels on fail if Need is set. the larger the number the less chance of losing item levels.
Ac, Ac2, Mac, Mac2, Dc, Dc2, Mc, Mc2, Sc, SC2: The amount to lose if upgrade fails (And has been set to lose stats on fail)

From my testing I've found that 0 = Always work, 10 very high chance to fail. 5 should be 50/50

Here are two sample items, DCGem(Small) has a 50/50 chance of adding 0-1 DC and UpgradeGem has a 100% chance of breaking gems if upgrade fails.

Code:

901	DCGem(Small)	55	0	5	0	0	0	610	5	0	0	0	0	0	1	0	0	0	0	0	0	8000	5	
902	UpgradeGem	56	0	5	0	0	0	650	100	0	0	0	0	0	0	0	0	0	0	0	0	8000	5

