class ITEM
{
public string name;
public int roll_chance;
public ITEM() {}
public ITEM(ITEM other)
{
this.name = other.name;
this.roll_chance = other.roll_chance;
}
}
ITEM[] potion_data_list =
{
potion_data("confusion", 8, 50),
potion_data("paralysis", 10, 50),
potion_data("poison", 8, 50),
potion_data("gain strength", 15, 150),
potion_data("see invisible", 2, 170),
potion_data("healing", 15, 30),
potion_data("monster detection", 6, 120),
potion_data("magic detection", 6, 105),
potion_data("raise level", 2, 220),
potion_data("extra healing", 5, 180),
potion_data("haste self", 4, 200),
potion_data("restore strength", 14, 120),
potion_data("blindness", 4, 50),
potion_data("thirst quenching", 1, 50),
// roll_chances must add up to 100
};
// used to make entries in potion_data_list
ITEM potion_data(string name, int roll_chance, int worth)
{
ITEM potion = new ITEM();
potion.name = name;
potion.roll_chance = roll_chance;
return potion;
}
ITEM[] scroll_data_list =
{
scroll_data("monster confusion", 8, 170),
scroll_data("magic mapping", 5, 180),
scroll_data("light", 10, 100),
scroll_data("hold monster", 2, 200),
scroll_data("sleep", 5, 50),
scroll_data("enchant armor", 8, 130),
scroll_data("identify", 21, 100),
scroll_data("scare monster", 4, 180),
scroll_data("gold detection", 4, 110),
scroll_data("teleportation", 7, 175),
scroll_data("enchant weapon", 10, 150),
scroll_data("create monster", 5, 75),
scroll_data("remove curse", 8, 105),
scroll_data("aggravate monsters", 1, 60),
scroll_data("blank paper", 1, 50),
scroll_data("genocide", 1, 200),
};
ITEM scroll_data(string name, int roll_chance, int worth)
{
ITEM scroll = new ITEM();
scroll.name = name;
scroll.roll_chance = roll_chance;
return scroll;
}
ITEM roll_item_data_list(ITEM[] item_data_list)
{
int num_to_beat = 0;
int roll = random(100);
for (int i = 0; i < item_data_list.Length; i++)
{
num_to_beat += item_data_list[i].roll_chance;
if (roll < num_to_beat)
return new ITEM(item_data_list[i]);
}
}
// in place_items() in new_level() ...
// rolling new potion
ITEM item = roll_item_data_list(potion_data_list);
Comments