added worldarea -> will be responsible for world map rendering
[dboe.git] / itemdata.c
blob69f492413f8edc3db2f6c8921c9ecdb1ffe2bf4f
2 #include <windows.h>
4 #include "global.h"
5 #include "itemdata.h"
6 #include "stdio.h"
7 #include "string.h"
10 item_record_type convert_item (short_item_record_type s_item);
11 extern piles_of_stuff_dumping_type *data_store;
12 extern piles_of_stuff_dumping_type2 *data_store2;
14 short loot_min[5] = {0,0,5,50,400};
15 short loot_max[5] = {3,8,40,800,4000};
16 //// whole file
17 item_record_type return_dummy_item()
19 item_record_type dummy_item = {0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0, 0,0, {0,0},"", "",0,0,0,0};
21 return dummy_item;
26 item_record_type get_stored_item(short which)
28 short_item_record_type item;
29 item_record_type s_item;
31 if ((which >= 400) || (which < 0)) {
32 s_item = return_dummy_item();
33 return s_item;
36 s_item = data_store2->scen_item_list.scen_items[which];
37 return s_item;
40 item_record_type get_food()
42 item_record_type food =
43 {11,0, 0,0,0,0,0,0, 62,0,0,0,0,0, 0, 0,0, {0,0},"Food", "Food",0,0,0,0};
44 food.graphic_num += get_ran(1,0,2);
45 food.item_level = get_ran(1,5,10);
46 if (get_ran(1,0,9) == 5)
47 food.graphic_num = 113;
48 if (get_ran(1,0,9) == 5)
49 food.graphic_num = 114;
50 // food doesn't always appear
51 if (get_ran(1,0,2) != 1)
52 food.variety = 0;
54 return food;
58 item_record_type pull_item_of_type(short loot_max,short min_val,short max_val,short t1, short t2, short t3)
60 short i,j,val;
61 item_record_type temp_i;
63 // occasionally get nice item
64 if (get_ran(1,0,160) == 80) {
65 loot_max += 2;
66 max_val += 2000;
68 for (i = 0; i < 80; i++) {
69 j = get_ran(1,0,399);
70 temp_i = get_stored_item(j);
71 if ((temp_i.variety == t1) || (temp_i.variety == t2) || (temp_i.variety == t3)) {
72 val = (temp_i.charges > 0) ? temp_i.charges * temp_i.value : temp_i.value;
73 if ((val >= min_val) && (val <= max_val) && (temp_i.treas_class != 0) &&
74 (temp_i.treas_class <= loot_max))
75 return temp_i;
78 temp_i = return_dummy_item();
79 return temp_i;
82 item_record_type get_weapon(short loot,short level)
84 short r1,i;
85 item_record_type weapon;
87 if (loot == 0)
88 return return_dummy_item();
89 weapon = pull_item_of_type(loot,loot_min[loot],loot_max[loot],1,2,-1);
91 return weapon;
95 item_record_type get_armor(short loot,short level)
97 short r1;
98 item_record_type armor;
100 if (loot == 0)
101 return return_dummy_item();
102 r1 = get_ran(1,(loot - 1) * 5 + 124,142);
104 armor = pull_item_of_type(loot,loot_min[loot],loot_max[loot],13,-1,-1);
106 return armor;
109 item_record_type get_helm(short loot)
111 short r1;
113 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],14,-1,-1);
116 item_record_type get_gloves(short loot)
118 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],15,-1,-1);
123 item_record_type get_boots(short loot)
125 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],17,-1,-1);
128 item_record_type get_shield(short loot)
130 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],12,-1,-1);
133 item_record_type get_potion(short loot)
135 item_record_type p;
137 if (get_ran(1,0,80) < 20 * (4 - loot))
138 p = pull_item_of_type(loot,loot_min[loot],loot_max[loot] / 2,7,-1,-1);
139 else p = pull_item_of_type(loot,loot_min[loot],loot_max[loot],7,-1,-1);
141 return p;
144 item_record_type get_scroll(short loot)
146 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],8,-1,-1);
149 item_record_type get_missile(short loot)
151 if (get_ran(1,0,2) < 2)
152 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],5,6,4);
153 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],23,24,25);
157 item_record_type get_poison(short loot,short level)
159 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],20,-1,-1);
162 item_record_type get_wand(short loot)
164 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],9,-1,-1);
167 item_record_type get_ring(short loot)
169 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],18,-1,-1);
172 item_record_type get_necklace(short loot)
174 item_record_type necklace;
176 return pull_item_of_type(loot,loot_min[loot],loot_max[loot],19,-1,-1);