… | |
… | |
77 | did_make_save_item (object *op, int type, object *originator) |
77 | did_make_save_item (object *op, int type, object *originator) |
78 | { |
78 | { |
79 | int i, roll, saves = 0, attacks = 0, number; |
79 | int i, roll, saves = 0, attacks = 0, number; |
80 | materialtype_t *mt; |
80 | materialtype_t *mt; |
81 | |
81 | |
82 | if (op->materialname == NULL) |
82 | if (!op->materialname) |
83 | { |
83 | { |
84 | for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) |
84 | for (mt = materialt; mt && mt->next; mt = mt->next) |
85 | if (op->materials & mt->material) |
85 | if (op->materials & mt->material) |
86 | break; |
86 | break; |
87 | } |
87 | } |
88 | else |
88 | else |
89 | mt = name_to_material (op->materialname); |
89 | mt = name_to_material (op->materialname); |
… | |
… | |
104 | if (type != AT_MAGIC) |
104 | if (type != AT_MAGIC) |
105 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
105 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
106 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
106 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
107 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
107 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
108 | |
108 | |
109 | if (type == 0) |
109 | if (type == 0) return TRUE; |
110 | return TRUE; |
110 | |
111 | if (roll == 20) |
111 | if (roll == 20) return TRUE; |
112 | return TRUE; |
112 | if (roll == 1) return FALSE; |
113 | if (roll == 1) |
|
|
114 | return FALSE; |
|
|
115 | |
113 | |
116 | for (number = 0; number < NROFATTACKS; number++) |
114 | for (number = 0; number < NROFATTACKS; number++) |
117 | { |
115 | { |
118 | i = 1 << number; |
116 | i = 1 << number; |
|
|
117 | |
119 | if (!(i & type)) |
118 | if (!(i & type)) |
120 | continue; |
119 | continue; |
|
|
120 | |
121 | attacks++; |
121 | attacks++; |
122 | if (op->resist[number] == 100) |
122 | if (op->resist[number] == 100) |
123 | saves++; |
123 | saves++; |
124 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
124 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
125 | saves++; |
125 | saves++; |
… | |
… | |
152 | op = stop_item (op); |
152 | op = stop_item (op); |
153 | if (op == NULL) |
153 | if (op == NULL) |
154 | return; |
154 | return; |
155 | |
155 | |
156 | /* Hacked the following so that type LIGHTER will work. |
156 | /* Hacked the following so that type LIGHTER will work. |
157 | * Also, objects which are potenital "lights" that are hit by |
157 | * Also, objects which are potential "lights" that are hit by |
158 | * flame/elect attacks will be set to glow. "lights" are any |
158 | * flame/elect attacks will be set to glow. "lights" are any |
159 | * object with +/- glow_radius and an "other_arch" to change to. |
159 | * object with +/- glow_radius and an "other_arch" to change to. |
160 | * (and please note that we cant fail our save and reach this |
160 | * (and please note that we cant fail our save and reach this |
161 | * function if the object doesnt contain a material that can burn. |
161 | * function if the object doesnt contain a material that can burn. |
162 | * So forget lighting magical swords on fire with this!) -b.t. |
162 | * So forget lighting magical swords on fire with this!) -b.t. |
… | |
… | |
169 | fix_stopped_item (op, m, originator); |
169 | fix_stopped_item (op, m, originator); |
170 | |
170 | |
171 | if ((op = archetype::get (arch))) |
171 | if ((op = archetype::get (arch))) |
172 | { |
172 | { |
173 | if (env) |
173 | if (env) |
174 | { |
|
|
175 | op->x = env->x, op->y = env->y; //???? wtf |
|
|
176 | env->insert (op); |
174 | env->insert (op); |
177 | } |
|
|
178 | else |
175 | else |
179 | { |
|
|
180 | op->x = x, op->y = y; |
|
|
181 | insert_ob_in_map (op, m, originator, 0); |
176 | m->insert (op, x, y, originator); |
182 | } |
|
|
183 | } |
177 | } |
184 | |
178 | |
185 | return; |
179 | return; |
186 | } |
180 | } |
187 | |
181 | |
… | |
… | |
196 | { |
190 | { |
197 | if (op->decrease (rndm (0, op->nrof - 1))) |
191 | if (op->decrease (rndm (0, op->nrof - 1))) |
198 | fix_stopped_item (op, m, originator); |
192 | fix_stopped_item (op, m, originator); |
199 | } |
193 | } |
200 | else |
194 | else |
|
|
195 | { |
|
|
196 | // drop everything to the ground, if possible |
|
|
197 | while (op->inv) |
|
|
198 | op->inv->insert_at (originator); |
|
|
199 | |
201 | op->destroy (); |
200 | op->destroy (); |
|
|
201 | } |
202 | |
202 | |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
204 | if (env) |
204 | if (env) |
205 | { |
205 | { |
206 | op = archetype::get (shstr_burnout); |
206 | op = archetype::get (shstr_burnout); |
… | |
… | |
214 | } |
214 | } |
215 | |
215 | |
216 | /* The value of 50 is arbitrary. */ |
216 | /* The value of 50 is arbitrary. */ |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
218 | { |
218 | { |
219 | object *tmp; |
|
|
220 | archetype *at = archetype::find (shstr_icecube); |
219 | archetype *at = archetype::find (shstr_icecube); |
221 | |
220 | |
222 | if (at == NULL) |
221 | if (at == NULL) |
223 | return; |
222 | return; |
224 | |
223 | |
225 | op = stop_item (op); |
224 | op = stop_item (op); |
226 | if (op == NULL) |
225 | if (op == NULL) |
227 | return; |
226 | return; |
228 | |
227 | |
229 | if ((tmp = present_arch (at, op->map, op->x, op->y)) == NULL) |
228 | object *tmp = present_arch (at, op->map, op->x, op->y); |
|
|
229 | if (!tmp) |
230 | { |
230 | { |
231 | tmp = arch_to_object (at); |
231 | tmp = arch_to_object (at); |
232 | tmp->x = op->x, tmp->y = op->y; |
232 | tmp->x = op->x, tmp->y = op->y; |
233 | /* This was in the old (pre new movement code) - |
233 | /* This was in the old (pre new movement code) - |
234 | * icecubes have slow_move set to 1 - don't want |
234 | * icecubes have slow_move set to 1 - don't want |
… | |
… | |
237 | tmp->move_slow_penalty = 0; |
237 | tmp->move_slow_penalty = 0; |
238 | tmp->move_slow = 0; |
238 | tmp->move_slow = 0; |
239 | insert_ob_in_map (tmp, op->map, originator, 0); |
239 | insert_ob_in_map (tmp, op->map, originator, 0); |
240 | } |
240 | } |
241 | |
241 | |
242 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
242 | tmp->insert (op); |
243 | op->remove (); |
|
|
244 | |
|
|
245 | insert_ob_in_ob (op, tmp); |
|
|
246 | return; |
243 | return; |
247 | } |
244 | } |
248 | } |
245 | } |
249 | |
246 | |
250 | /* Object op is hitting the map. |
247 | /* Object op is hitting the map. |