Advertisement
SteelGolem

item_data_list.txt

Mar 12th, 2021 (edited)
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. class ITEM
  2. {
  3.     public string name;
  4.     public int roll_chance;
  5.     public ITEM() {}
  6.     public ITEM(ITEM other)
  7.     {
  8.         this.name = other.name;
  9.         this.roll_chance = other.roll_chance;
  10.     }
  11. }
  12.  
  13. ITEM[] potion_data_list =
  14. {
  15.     potion_data("confusion",         8,  50),
  16.     potion_data("paralysis",        10,  50),
  17.     potion_data("poison",            8,  50),
  18.     potion_data("gain strength",    15, 150),
  19.     potion_data("see invisible",     2, 170),
  20.     potion_data("healing",          15,  30),
  21.     potion_data("monster detection", 6, 120),
  22.     potion_data("magic detection",   6, 105),
  23.     potion_data("raise level",       2, 220),
  24.     potion_data("extra healing",     5, 180),
  25.     potion_data("haste self",        4, 200),
  26.     potion_data("restore strength", 14, 120),
  27.     potion_data("blindness",         4,  50),
  28.     potion_data("thirst quenching",  1,  50),
  29.     // roll_chances must add up to 100
  30. };
  31.  
  32. // used to make entries in potion_data_list
  33. ITEM potion_data(string name, int roll_chance, int worth)
  34. {
  35.     ITEM potion = new ITEM();
  36.     potion.name = name;
  37.     potion.roll_chance = roll_chance;
  38.     return potion;
  39. }
  40.  
  41. ITEM[] scroll_data_list =
  42. {
  43.     scroll_data("monster confusion", 8, 170),
  44.     scroll_data("magic mapping", 5, 180),
  45.     scroll_data("light", 10, 100),
  46.     scroll_data("hold monster", 2, 200),
  47.     scroll_data("sleep", 5, 50),
  48.     scroll_data("enchant armor", 8, 130),
  49.     scroll_data("identify", 21, 100),
  50.     scroll_data("scare monster", 4, 180),
  51.     scroll_data("gold detection", 4, 110),
  52.     scroll_data("teleportation", 7, 175),
  53.     scroll_data("enchant weapon", 10, 150),
  54.     scroll_data("create monster", 5, 75),
  55.     scroll_data("remove curse", 8, 105),
  56.     scroll_data("aggravate monsters", 1, 60),
  57.     scroll_data("blank paper", 1, 50),
  58.     scroll_data("genocide", 1, 200),
  59. };
  60.  
  61. ITEM scroll_data(string name, int roll_chance, int worth)
  62. {
  63.     ITEM scroll = new ITEM();
  64.     scroll.name = name;
  65.     scroll.roll_chance = roll_chance;
  66.     return scroll;
  67. }
  68.  
  69. ITEM roll_item_data_list(ITEM[] item_data_list)
  70. {
  71.     int num_to_beat = 0;
  72.     int roll = random(100);
  73.     for (int i = 0; i < item_data_list.Length; i++)
  74.     {
  75.         num_to_beat += item_data_list[i].roll_chance;
  76.         if (roll < num_to_beat)
  77.         return new ITEM(item_data_list[i]);
  78.     }
  79. }
  80.  
  81. // in place_items() in new_level() ...
  82.  
  83. // rolling new potion
  84. ITEM item = roll_item_data_list(potion_data_list);
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement