The calculations are not hard-coded and are handled by the database in the TQ Binary's case. If you dev your own source, you can either handle things off the db either hard-code them.
The calculations in the original bins database are done by using type "121" which represents a "randomization". The parameter for this type to work, is "param1 param2" where "param1" stands for the number of times the "id_next" (which triggers the action about to be executed) will be repeated. The "param2" stands for the "chance", indexation starts from you and can go up to uint32 I guess so the things will look like, "param1=1 (one time) && param2=10000 (even if there are no divisions for the second param, it goes like "uint32/1 = randomization rate" and it "reads" like "one in ten thousand").
I don't know if I explained it correctly, but more or less, that's the way it works and the baseline here is that the calculations are not hard-coded but handled by the database.
Actual example from the original bins db (actual rate for the ToughDrill socket rate, handled by the NPC):
Code:
INSERT INTO `cq_action` VALUES ('5057052', '5057059', '5057053', '0121', '0', '1 10');
This has been taken out of the EO source files:
Code:
ACTION_RAND = 121, // ??????"data1 data2"?"10 100"???1/10????true?