hello everyone. Im re-doing treasure class generation for my item
generator, and im wanting to have all my % drops for specific
items into a single table (so i can create an olc for it, to modify it online)
Anywho, a sub function of armor generation selects the base item type
Basicly it goes something like
if (count <= thri_armor_selection_table[base_item].body_type[0])
{
armor_type = 0;
}
else if (count <= (thri_armor_selection_table[base_item].body_type[0] +
thri_armor_selection_table[base_item].body_type[1]))
{
armor_type = 1;
}
else if (count <= (thri_armor_selection_table[base_item].body_type[0] +
thri_armor_selection_table[base_item].body_type[1]
+
thri_armor_selection_table[base_item].body_type[2]
))
{
armor_type = 2;
}
(count is number_range(1, 100))
Basicly, it checks to see if various values of the table are less than the
count, then finds the item
Anywho, with about 30 base armor types, this code gets really ugly down the
line
else if (count <= ( thri_armor_selection_table[base_item].body_type[0] +
thri_armor_selection_table[base_item].body_type[1]
+ thri_armor_selection_table[base_item].body_type[2] +
thri_armor_selection_table[base_item].body_type[3]
+ thri_armor_selection_table[base_item].body_type[4] +
thri_armor_selection_table[base_item].body_type[5]
+ thri_armor_selection_table[base_item].body_type[6] +
thri_armor_selection_table[base_item].body_type[7]
+ thri_armor_selection_table[base_item].body_type[8] +
thri_armor_selection_table[base_item].body_type[9]
+ thri_armor_selection_table[base_item].body_type[10] +
thri_armor_selection_table[base_item].body_type[11]
))
for example ;)
Is there a way to shorten this down to say..
table.body_type[0] + table.body_type[1]?
I plan on releasing this code, and i dont want to release something this ugly
-Thri