- Joined
- Nov 13, 2006
- Messages
- 1,814
if i want make a random stat bonus maker function, what give random stat to droped items, if i use 3 array that slow down the function?
who cant image it, i show:
usage
who cant image it, i show:
JASS:
function AddRandomBonus takes integer id, integer grade, integer itype, integer amount returns nothing
local integer i = 1
local integer rnd
local integer array index //real index
local integer array bonus //bonus attached to index
local integer maxindex //max index for loop
local real array c //chance array, assigned to indexs
local real rc // random chance (0,99)
if itype == 1 or itype ==2 or itype == 4 or itype == 5 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 27 // hp reg
set index[4] = 31 // mp reg
set index[5] = 73 // accurancy bonus
set index[6] = 74 // evasion bonus
set index[7] = 8 // level req decrease
set index[8] = 44 // bonus str
set index[9] = 45 // bonus agi
set index[10] = 46 // bonus int
set index[11] = 40 // bonus movment speed
set index[12] = 47 // bonus attack speed
set index[13] = 48 // reflect damage
set index[14] = 51 // defence level
set index[15] = 75 // pdef
set index[16] = 76 // fire def
set index[17] = 77 // water def
set index[18] = 78 // lightning def
set index[19] = 79 // poison def
set index[20] = 80 // earth def
set index[21] = 64 // hp
set index[22] = 65 // mp
set index[23] = 68 // bonus socket
set index[24] = 67 // bonus duratibility
set index[25] = 62 // pattack
set index[26] = 63 // mattack
set index[27] = 28 // hp steal
set index[28] = 29 // hp per kill
set index[29] = 32 // mp steal
set index[30] = 33 // mp per kill
set index[31] = 81 // shop discount
set c[0] = 10 // experience bonus after a kill
set c[1] = 5 // drop rate for rare item
set c[2] = 7 // gold rate
set c[3] = 20 // hp reg
set c[4] = 20 // mp reg
set c[5] = 10 // accurancy bonus
set c[6] = 10 // evasion bonus
set c[7] = 7 // level req decrease
set c[8] = 5 // bonus str
set c[9] = 5 // bonus agi
set c[10] = 5 // bonus int
set c[11] = 5 // bonus movment speed
set c[12] = 3 // bonus attack speed
set c[13] = 3 // reflect damage
set c[14] = 2 // defence level
set c[15] = 15 // pdef
set c[16] = 15 // fire def
set c[17] = 15 // water def
set c[18] = 15 // lightning def
set c[19] = 15 // poison def
set c[20] = 15 // earth def
set c[21] = 13 // hp
set c[22] = 13 // mp
set c[23] = 3 // bonus socket
set c[24] = 12 // bonus duratibility
set c[25] = 2 // pattack
set c[26] = 2 // mattack
set c[27] = 2 // hp steal
set c[28] = 6 // hp per kill
set c[29] = 3 // mp steal
set c[30] = 6 // mp per kill
set c[31] = 2 // shop discount
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // hp reg
set bonus[4] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set bonus[5] = GetRandomInt(grade / 2 + 1, grade * 3) // accurancy bonus
set bonus[6] = GetRandomInt(grade / 3 + 1, grade * 2) // evasion bonus
set bonus[7] = GetRandomInt(1, 2) * - 1 // level req decrease
set bonus[8] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[11] = GetRandomInt(grade / 10 + 1, grade / 2 + 15) // bonus movment speed
set bonus[12] = GetRandomInt(grade / 10 + 1, grade / 2 + 10) // bonus attack speed
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 20 + 2) // reflect damage
set bonus[14] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[15] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[16] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[17] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[18] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[19] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[20] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[21] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[22] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
if itype != 5 then
set bonus[23] = GetRandomInt(1, grade / 50 + 1) // inc socket
else
set bonus[23] = 0 // inc socket
endif
set bonus[24] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[25] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[26] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[27] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // hp steal
set bonus[28] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // hp per kill
set bonus[29] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // mp steal
set bonus[30] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // mp per kill
set bonus[31] = GetRandomInt(1, 3) // //shop discount
set maxindex = 31
elseif itype == 3 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 28 // hp steal
set index[4] = 29 // hp per kill
set index[5] = 32 // mp steal
set index[6] = 33 // mp per kill
set index[7] = 73 // accurancy bonus
set index[8] = 8 // level req decrease
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 47 // bonus attack speed
set index[13] = 49 // chance for armor penetration
set index[14] = 69 // attack level
set index[15] = 66 // critical chance
set index[16] = 55 // critical damage
set index[17] = 56 // pet power
set index[18] = 57 // bonus fire damage
set index[19] = 58 // bonus water damage
set index[20] = 59 // bonus lightning damage
set index[21] = 60 // bonus poison damage
set index[22] = 61 // bonus earth damage
set index[23] = 75 // pdef
set index[24] = 76 // fire def
set index[25] = 77 // water def
set index[26] = 78 // lightning def
set index[27] = 79 // poison def
set index[28] = 80 // earth def
set index[29] = 64 // hp
set index[30] = 65 // mp
set index[31] = 68 // bonus socket
set index[32] = 67 // bonus duratibility
set index[33] = 62 // pattack
set index[34] = 63 // mattack
set index[35] = 70 // defence level
set index[36] = 81 // shop discount
set index[37] = 27 // hp reg
set index[38] = 31 // mp reg
set c[0] = 4 // experience bonus after a kill
set c[1] = 9 // drop rate for rare item
set c[2] = 9 // gold rate
set c[3] = 11 // hp steal
set c[4] = 7 // hp per kill
set c[5] = 11 // mp steal
set c[6] = 7 // mp per kill
set c[7] = 10 // accurancy bonus
set c[8] = 9 // level req decrease
set c[9] = 5 // bonus str
set c[10] = 5 // bonus agi
set c[11] = 5 // bonus int
set c[12] = 10 // bonus attack speed
set c[13] = 2 // chance for armor penetration
set c[14] = 9 // attack level
set c[15] = 12 // critical chance
set c[16] = 5 // critical damage
set c[17] = 1 // pet power
set c[18] = 3 // bonus fire damage
set c[19] = 3 // bonus water damage
set c[20] = 3 // bonus lightning damage
set c[21] = 3 // bonus poison damage
set c[22] = 3 // bonus earth damage
set c[23] = 4 // pdef
set c[24] = 4 // fire def
set c[25] = 4 // water def
set c[26] = 4 // lightning def
set c[27] = 4 // poison def
set c[28] = 4 // earth def
set c[29] = 5 // hp
set c[30] = 5 // mp
set c[31] = 2 // bonus socket
set c[32] = 12 // bonus duratibility
set c[33] = 17 // pattack
set c[34] = 17 // mattack
set c[35] = 5 // defence level
set c[36] = 3 // shop discount
set c[37] = 4 // hp reg
set c[38] = 4 // mp reg
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // hp steal
set bonus[4] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // hp per kill
set bonus[5] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // mp steal
set bonus[6] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // mp per kill
set bonus[7] = GetRandomInt(grade + 1, grade * 5 + 5) // accurancy bonus
set bonus[8] = GetRandomInt( - 1, - 3) // level req decrease
set bonus[9] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus str
set bonus[10] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus agi
set bonus[11] = GetRandomInt(grade / 30 + 1, grade / 10 + 2) // bonus int
set bonus[12] = GetRandomInt(grade / 20 + 1, grade) // bonus attack speed
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 50 + 3) // chance for armor penetration
set bonus[14] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[15] = GetRandomInt(1, grade / 20 + 1) // critical chance
set bonus[16] = GetRandomInt(3, grade / 10 + 10) // critical damage
set bonus[17] = GetRandomInt(3, grade / 10 + 10) // pet power
set bonus[18] = GetRandomInt(grade, grade * 3) // bonus fire damage
set bonus[19] = GetRandomInt(grade, grade * 3) // bonus water damage
set bonus[20] = GetRandomInt(grade, grade * 3) // bonus lightning damage
set bonus[21] = GetRandomInt(grade, grade * 3) // bonus poison damage
set bonus[22] = GetRandomInt(grade, grade * 3) // bonus earth damage
set bonus[23] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[24] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[25] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[26] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[27] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[28] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[29] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[30] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[31] = GetRandomInt(1, grade / 50 + 1) // inc socket
set bonus[32] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[33] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[34] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[35] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[36] = GetRandomInt(2, 5) // //shop discount
set bonus[37] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // hp reg
set bonus[38] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set maxindex = 38
elseif itype == 9 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 27 // hp reg
set index[4] = 28 // hp steal
set index[5] = 29 // hp per kill
set index[6] = 31 // mp reg
set index[7] = 32 // mp steal
set index[8] = 33 // mp per kill
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 48 // reflect damage
set index[13] = 49 // chance for armor penetration
set index[14] = 75 // pdef
set index[15] = 76 // fire def
set index[16] = 77 // water def
set index[17] = 78 // lightning def
set index[18] = 79 // poison def
set index[19] = 80 // earth def
set index[20] = 64 // hp
set index[21] = 65 // mp
set index[22] = 68 // bonus socket
set index[23] = 67 // bonus duratibility
set index[24] = 62 // pattack
set index[25] = 63 // mattack
set index[26] = 69 // attack level
set index[27] = 70 // defence level
set index[28] = 66 // critical chance
set index[29] = 55 // critical damage
set index[30] = 81 // shop discount
set index[31] = 74 // evasion
set c[0] = 10 // experience bonus after a kill
set c[1] = 10 // drop rate for rare item
set c[2] = 10 // gold rate
set c[3] = 7 // hp reg
set c[4] = 10 // hp steal
set c[5] = 7 // hp per kill
set c[6] = 7 // mp reg
set c[7] = 8 // mp steal
set c[8] = 7 // mp per kill
set c[9] = 3 // bonus str
set c[10] = 3 // bonus agi
set c[11] = 3 // bonus int
set c[12] = 3 // reflect damage
set c[13] = 2 // chance for armor penetration
set c[14] = 2 // pdef
set c[15] = 2 // fire def
set c[16] = 2 // water def
set c[17] = 2 // lightning def
set c[18] = 2 // poison def
set c[19] = 2 // earth def
set c[20] = 11 // hp
set c[21] = 11 // mp
set c[22] = 7 // bonus socket
set c[23] = 4 // bonus duratibility
set c[24] = 3 // pattack
set c[25] = 3 // mattack
set c[26] = 10 // attack level
set c[27] = 10 // defence level
set c[28] = 6 // critical chance
set c[29] = 5 // critical damage
set c[30] = 7 // shop discount
set c[31] = 1 // evasion
set bonus[0] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[3] = GetRandomInt(grade / 15 + 1, grade / 8 + 5) // hp reg
set bonus[4] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // hp steal
set bonus[5] = GetRandomInt(grade / 2 + 1, grade * 2 + 1) // hp per kill
set bonus[6] = GetRandomInt(grade / 15 + 1, grade / 8 + 1) // mp reg
set bonus[7] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // mp steal
set bonus[8] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // mp per kill
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[11] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[12] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // reflect damage
set bonus[13] = GetRandomInt(grade / 50 + 1, grade / 50 + 3) // chance for armor penetration
set bonus[14] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[15] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[16] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[17] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[18] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[19] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[20] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[21] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[22] = GetRandomInt(1, grade / 50 + 1) // inc socket
set bonus[23] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[24] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[25] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[26] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[27] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[28] = GetRandomInt(1, grade / 20 + 1) // critical chance
set bonus[29] = GetRandomInt(3, grade / 10 + 10) // critical damage
set bonus[30] = GetRandomInt(3, 7) // //shop discount
set bonus[31] = GetRandomInt(grade + 1, grade * 2 + 10) // evasion
set maxindex = 31
elseif itype == 6 or itype == 8 then
set index[1] = 69 // attack level
set index[2] = 66 // critical chance
set index[3] = 55 // critical damage
set index[4] = 48 // reflect damage
set index[5] = 70 // defence level
set index[6] = 22 // experience bonus after a kill
set index[7] = 23 // drop rate for rare item
set index[8] = 24 // gold rate
set index[9] = 44 // bonus str
set index[10] = 45 // bonus agi
set index[11] = 46 // bonus int
set index[12] = 27 // hp reg
set index[13] = 28 // hp steal
set index[14] = 29 // hp per kill
set index[15] = 31 // mp reg
set index[16] = 32 // mp steal
set index[17] = 33 // mp per kill
set index[18] = 67 // bonus duratibility
set index[19] = 62 // pattack
set index[20] = 63 // mattack
set index[21] = 75 // pdef
set index[22] = 76 // fire def
set index[23] = 77 // water def
set index[24] = 78 // lightning def
set index[25] = 79 // poison def
set index[26] = 80 // earth def
set index[27] = 64 // hp
set index[28] = 65 // mp
set index[29] = 81 // shop discount
set index[30] = 73 // accurancy bonus
set index[31] = 74 // evasion bonus
set c[1] = 9 // attack level
set c[2] = 12 // critical chance
set c[3] = 10 // critical damage
set c[4] = 5 // reflect damage
set c[5] = 5 // defence level
set c[6] = 6 // experience bonus after a kill
set c[7] = 4 // drop rate for rare item
set c[8] = 5 // gold rate
set c[9] = 3 // bonus str
set c[10] = 3 // bonus agi
set c[11] = 3 // bonus int
set c[12] = 8 // hp reg
set c[13] = 8 // hp steal
set c[14] = 8 // hp per kill
set c[15] = 8 // mp reg
set c[16] = 8 // mp steal
set c[17] = 8 // mp per kill
set c[18] = 11 // bonus duratibility
set c[19] = 13 // pattack
set c[20] = 13 // mattack
set c[21] = 4 // pdef
set c[22] = 4 // fire def
set c[23] = 4 // water def
set c[24] = 4 // lightning def
set c[25] = 4 // poison def
set c[26] = 4 // earth def
set c[27] = 7 // hp
set c[28] = 7 // mp
set c[29] = 3 // shop discount
set c[30] = 6 // accurancy bonus
set c[31] = 6 // evasion bonus
set bonus[1] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // attack level
set bonus[2] = GetRandomInt(1, grade / 20 + 1) // critical chance
set bonus[3] = GetRandomInt(3, grade / 10 + 10) // critical damage
set bonus[4] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // reflect damage
set bonus[5] = GetRandomInt(grade / 50 + 1, grade / 20 + 3) // defence level
set bonus[6] = GetRandomInt(grade / 10 + 1, grade / 5 + 7) // experience bonus after a kill
set bonus[7] = GetRandomInt(grade / 20 + 1, grade / 10 + 5) // drop rate for rare item
set bonus[8] = GetRandomInt(grade / 10 + 1, grade / 5 + 12) // gold rate
set bonus[9] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus str
set bonus[10] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus agi
set bonus[11] = GetRandomInt(grade / 20 + 1, grade / 10 + 1) // bonus int
set bonus[12] = GetRandomInt(grade / 15 + 1, grade / 8 + 5) // hp reg
set bonus[13] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // hp steal
set bonus[14] = GetRandomInt(grade / 2 + 1, grade * 2 + 2) // hp per kill
set bonus[15] = GetRandomInt(grade / 15 + 1, grade / 8 + 2) // mp reg
set bonus[16] = GetRandomInt(grade / 20 + 1, grade / 10 + 2) // mp steal
set bonus[17] = GetRandomInt(grade / 2 + 1, grade * 2 + 5) // mp per kill
set bonus[18] = GetRandomInt(grade / 2 + 10, grade * 2 + 15) // inc duratibility
set bonus[19] = GetRandomInt(grade + 3, grade * 2 + 5) // pattack
set bonus[20] = GetRandomInt(grade + 3, grade * 2 + 5) // mattack
set bonus[21] = GetRandomInt(grade + 1, grade * 3 + 3) // pdef
set bonus[22] = GetRandomInt(grade + 1, grade * 3 + 3) // fire def
set bonus[23] = GetRandomInt(grade + 1, grade * 3 + 3) // water def
set bonus[24] = GetRandomInt(grade + 1, grade * 3 + 3) // lightning def
set bonus[25] = GetRandomInt(grade + 1, grade * 3 + 3) // poison def
set bonus[26] = GetRandomInt(grade + 1, grade * 3 + 3) // earth def
set bonus[27] = GetRandomInt(grade + 5, grade * 2 + 10) // hp
set bonus[28] = GetRandomInt(grade + 5, grade * 2 + 10) // mp
set bonus[29] = GetRandomInt(2, 5) // //shop discount
set bonus[30] = GetRandomInt(grade / 2 + 1, grade * 3) // accurancy bonus
set bonus[31] = GetRandomInt(grade / 3 + 1, grade * 2) // evasion bonus
set maxindex = 31
elseif itype == 11 then
set index[0] = 22 // experience bonus after a kill
set index[1] = 23 // drop rate for rare item
set index[2] = 24 // gold rate
set index[3] = 29 // hp per kill
set index[4] = 33 // mp per kill
set index[5] = 44 // bonus str
set index[6] = 45 // bonus agi
set index[7] = 46 // bonus int
set index[8] = 69 // attack level
set index[9] = 70 // defence level
set index[10] = 66 // critical chance
set index[11] = 55 // critical damage
set index[12] = 81 // shop discount
set index[13] = 27 // hp reg
set index[14] = 31 // mp reg
set index[15] = 73 // accurancy bonus
set index[16] = 74 // evasion bonus
set c[0] = 15 // experience bonus after a kill
set c[1] = 10 // drop rate for rare item
set c[2] = 20 // gold rate
set c[3] = 8 // hp per kill
set c[4] = 8 // mp per kill
set c[5] = 9 // bonus str
set c[6] = 9 // bonus agi
set c[7] = 9 // bonus int
set c[8] = 4 // attack level
set c[9] = 4 // defence level
set c[10] = 3 // critical chance
set c[11] = 2 // critical damage
set c[12] = 7 // shop discount
set c[13] = 5 // hp reg
set c[14] = 5 // mp reg
set c[15] = 3 // accurancy bonus
set c[16] = 3 // evasion bonus
set bonus[0] = GetRandomInt(grade / 30 + 1, grade / 15 + 2) // experience bonus after a kill
set bonus[1] = GetRandomInt(grade / 50 + 1, grade / 30 + 2) // drop rate for rare item
set bonus[2] = GetRandomInt(grade / 30 + 1, grade / 15 + 5) // gold rate
set bonus[3] = GetRandomInt(grade / 10 + 1, grade/2 + 1) // hp per kill
set bonus[4] = GetRandomInt(grade / 10 + 1, grade/2 + 5) // mp per kill
set bonus[5] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus str
set bonus[6] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus agi
set bonus[7] = GetRandomInt(grade / 50 + 1, grade / 25 + 1) // bonus int
set bonus[8] = GetRandomInt(grade / 50 + 1, grade / 20 + 2) // attack level
set bonus[9] = GetRandomInt(grade / 50 + 1, grade / 20 + 2) // defence level
set bonus[10] = GetRandomInt(1, grade / 50 + 1) // critical chance
set bonus[11] = GetRandomInt(1, grade / 33 + 3) // critical damage
set bonus[12] = GetRandomInt(1, grade / 30) // //shop discount
set bonus[13] = GetRandomInt(grade / 25 + 1, grade / 15 + 2) // hp reg
set bonus[14] = GetRandomInt(grade / 25 + 1, grade / 15 + 2) // mp reg
set bonus[15] = GetRandomInt(grade / 2 + 1, grade +1) // accurancy bonus
set bonus[16] = GetRandomInt(grade / 3 + 1, grade +1) // evasion bonus
set maxindex = 16
endif
loop
exitwhen i > amount
set rnd = GetRandomInt(0, maxindex)
set rc = GetRandomReal(0,99)
loop
exitwhen c[rnd] > rc
set rnd = GetRandomInt(0, maxindex)
set rc = GetRandomReal(0,99)
endloop
if index[rnd] == 8 then
if (LoadInteger(udg_CItem_Table, id, 8) + bonus[rnd]) < 0 then
set bonus[rnd] = 0
else
call SaveInteger(udg_CItem_Table, id, 72, bonus[rnd])
call SaveInteger(udg_CItem_Table, id, 8, LoadInteger(udg_CItem_Table, id, 8) + bonus[rnd])
endif
elseif index[rnd] == 67 then
call SaveInteger(udg_CItem_Table, id, 67, bonus[rnd])
call SaveReal(udg_CItem_Table, id, 15, LoadReal(udg_CItem_Table, id, 15) + bonus[rnd])
call SaveReal(udg_CItem_Table, id, 14, LoadReal(udg_CItem_Table, id, 14) + bonus[rnd])
elseif index[rnd] == 68 then
call SaveInteger(udg_CItem_Table, id, 68, bonus[rnd])
set index[rnd] = 20
endif
if index[rnd] != 8 and index[rnd] != 67 then
call SaveInteger(udg_CItem_Table, id, index[rnd], LoadInteger(udg_CItem_Table, id, index[rnd]) + bonus[rnd])
endif
set i = i + 1
endloop
endfunction
usage
JASS:
call AddRandomBonus (GetHandleId(udg_Item), GetHeroLevel(udg_Hero), 3, 5)
//call AddRandomBonus (itemhandleid, level or grade, item type, random bonus amount)