… | |
… | |
25 | #include <living.h> |
25 | #include <living.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
27 | #include <skills.h> |
27 | #include <skills.h> |
28 | #include <tod.h> |
28 | #include <tod.h> |
29 | |
29 | |
30 | #ifndef __CEXTRACT__ |
|
|
31 | # include <sproto.h> |
30 | #include <sproto.h> |
32 | #endif |
|
|
33 | |
31 | |
34 | /* Want this regardless of rplay. */ |
32 | /* Want this regardless of rplay. */ |
35 | #include <sounds.h> |
33 | #include <sounds.h> |
36 | |
34 | |
37 | /* need math lib for double-precision and pow() in dragon_eat_flesh() */ |
35 | /* need math lib for double-precision and pow() in dragon_eat_flesh() */ |
… | |
… | |
195 | apply_potion (object *op, object *tmp) |
193 | apply_potion (object *op, object *tmp) |
196 | { |
194 | { |
197 | int got_one = 0, i; |
195 | int got_one = 0, i; |
198 | object *force = 0, *floor = 0; |
196 | object *force = 0, *floor = 0; |
199 | |
197 | |
200 | floor = get_map_ob (op->map, op->x, op->y); |
198 | floor = GET_MAP_OB (op->map, op->x, op->y); |
201 | |
199 | |
202 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
200 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
203 | { |
201 | { |
204 | if (op->type == PLAYER) |
202 | if (op->type == PLAYER) |
205 | new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!"); |
203 | new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!"); |
206 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
204 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
207 | return 0; |
205 | return 0; |
208 | } |
206 | } |
209 | |
207 | |
210 | if (op->type == PLAYER) |
208 | if (op->type == PLAYER) |
211 | { |
|
|
212 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
209 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
213 | identify (tmp); |
210 | identify (tmp); |
214 | } |
|
|
215 | |
211 | |
216 | handle_apply_yield (tmp); |
212 | handle_apply_yield (tmp); |
217 | |
213 | |
218 | /* Potion of restoration - only for players */ |
214 | /* Potion of restoration - only for players */ |
219 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
215 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
… | |
… | |
221 | object *depl; |
217 | object *depl; |
222 | archetype *at; |
218 | archetype *at; |
223 | |
219 | |
224 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
220 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
225 | { |
221 | { |
226 | drain_stat (op); |
222 | op->drain_stat (); |
227 | fix_player (op); |
223 | op->update_stats (); |
228 | decrease_ob (tmp); |
224 | decrease_ob (tmp); |
229 | return 1; |
225 | return 1; |
230 | } |
226 | } |
|
|
227 | |
231 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
228 | if (!(at = archetype::find (ARCH_DEPLETION))) |
232 | { |
229 | { |
233 | LOG (llevError, "Could not find archetype depletion\n"); |
230 | LOG (llevError, "Could not find archetype depletion\n"); |
234 | return 0; |
231 | return 0; |
235 | } |
232 | } |
236 | depl = present_arch_in_ob (at, op); |
233 | depl = present_arch_in_ob (at, op); |
|
|
234 | |
237 | if (depl != NULL) |
235 | if (depl) |
238 | { |
236 | { |
239 | for (i = 0; i < NUM_STATS; i++) |
237 | for (i = 0; i < NUM_STATS; i++) |
240 | if (get_attr_value (&depl->stats, i)) |
238 | if (get_attr_value (&depl->stats, i)) |
241 | { |
|
|
242 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
239 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
243 | } |
240 | |
244 | remove_ob (depl); |
241 | depl->destroy (); |
245 | free_object (depl); |
242 | op->update_stats (); |
246 | fix_player (op); |
|
|
247 | } |
243 | } |
248 | else |
244 | else |
249 | new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); |
245 | new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); |
250 | |
246 | |
251 | decrease_ob (tmp); |
247 | decrease_ob (tmp); |
… | |
… | |
253 | } |
249 | } |
254 | |
250 | |
255 | /* improvement potion - only for players */ |
251 | /* improvement potion - only for players */ |
256 | if (op->type == PLAYER && tmp->attacktype & AT_GODPOWER) |
252 | if (op->type == PLAYER && tmp->attacktype & AT_GODPOWER) |
257 | { |
253 | { |
258 | |
|
|
259 | for (i = 1; i < MIN (11, op->level); i++) |
254 | for (i = 1; i < MIN (11, op->level); i++) |
260 | { |
255 | { |
261 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
256 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
262 | { |
257 | { |
263 | if (op->contr->levhp[i] != 1) |
258 | if (op->contr->levhp[i] != 1) |
… | |
… | |
293 | op->contr->levgrace[i] = 3; |
288 | op->contr->levgrace[i] = 3; |
294 | break; |
289 | break; |
295 | } |
290 | } |
296 | } |
291 | } |
297 | } |
292 | } |
|
|
293 | |
298 | /* Just makes checking easier */ |
294 | /* Just makes checking easier */ |
299 | if (i < MIN (11, op->level)) |
295 | if (i < MIN (11, op->level)) |
300 | got_one = 1; |
296 | got_one = 1; |
|
|
297 | |
301 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
298 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
302 | { |
299 | { |
303 | if (got_one) |
300 | if (got_one) |
304 | { |
301 | { |
305 | fix_player (op); |
302 | op->update_stats (); |
306 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods smile upon you and remake you"); |
303 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods smile upon you and remake you"); |
307 | new_draw_info (NDI_UNIQUE, 0, op, "a little more in their image."); |
304 | new_draw_info (NDI_UNIQUE, 0, op, "a little more in their image."); |
308 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a little more perfect."); |
305 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a little more perfect."); |
309 | } |
306 | } |
310 | else |
307 | else |
… | |
… | |
312 | } |
309 | } |
313 | else |
310 | else |
314 | { /* cursed potion */ |
311 | { /* cursed potion */ |
315 | if (got_one) |
312 | if (got_one) |
316 | { |
313 | { |
317 | fix_player (op); |
314 | op->update_stats (); |
318 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); |
315 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); |
319 | } |
316 | } |
320 | else |
317 | else |
321 | new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); |
318 | new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); |
322 | } |
319 | } |
|
|
320 | |
323 | decrease_ob (tmp); |
321 | decrease_ob (tmp); |
324 | return 1; |
322 | return 1; |
325 | } |
323 | } |
326 | |
324 | |
327 | |
325 | |
… | |
… | |
349 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
347 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
350 | |
348 | |
351 | decrease_ob (tmp); |
349 | decrease_ob (tmp); |
352 | /* if youre dead, no point in doing this... */ |
350 | /* if youre dead, no point in doing this... */ |
353 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
351 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
354 | fix_player (op); |
352 | op->update_stats (); |
355 | return 1; |
353 | return 1; |
356 | } |
354 | } |
357 | |
355 | |
358 | /* Deal with protection potions */ |
356 | /* Deal with protection potions */ |
359 | force = NULL; |
357 | force = NULL; |
… | |
… | |
403 | * that were grouped with the one consumed, his |
401 | * that were grouped with the one consumed, his |
404 | * stat will not be raised by them. fix_player just clears |
402 | * stat will not be raised by them. fix_player just clears |
405 | * up all the stats. |
403 | * up all the stats. |
406 | */ |
404 | */ |
407 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
405 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
408 | fix_player (op); |
406 | op->update_stats (); |
409 | decrease_ob (tmp); |
407 | decrease_ob (tmp); |
410 | return 1; |
408 | return 1; |
411 | } |
409 | } |
412 | |
410 | |
413 | /**************************************************************************** |
411 | /**************************************************************************** |
… | |
… | |
570 | weapon->last_eat++; |
568 | weapon->last_eat++; |
571 | new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon's bonus to %s improved by %d", statname, sacrifice_count); |
569 | new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon's bonus to %s improved by %d", statname, sacrifice_count); |
572 | decrease_ob (improver); |
570 | decrease_ob (improver); |
573 | |
571 | |
574 | /* So it updates the players stats and the window */ |
572 | /* So it updates the players stats and the window */ |
575 | fix_player (op); |
573 | op->update_stats (); |
576 | return 1; |
574 | return 1; |
577 | } |
575 | } |
578 | |
576 | |
579 | /* Types of improvements, hidden in the sp field. */ |
577 | /* Types of improvements, hidden in the sp field. */ |
580 | #define IMPROVE_PREPARE 1 |
578 | #define IMPROVE_PREPARE 1 |
… | |
… | |
883 | |
881 | |
884 | if (op->type == PLAYER) |
882 | if (op->type == PLAYER) |
885 | { |
883 | { |
886 | esrv_send_item (op, armour); |
884 | esrv_send_item (op, armour); |
887 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
885 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
888 | fix_player (op); |
886 | op->update_stats (); |
889 | } |
887 | } |
890 | decrease_ob (improver); |
888 | decrease_ob (improver); |
891 | if (tmp) |
889 | if (tmp) |
892 | { |
890 | { |
893 | insert_ob_in_ob (tmp, op); |
891 | insert_ob_in_ob (tmp, op); |
… | |
… | |
952 | price_in = nr * CONV_NEED (converter) * item->value; |
950 | price_in = nr * CONV_NEED (converter) * item->value; |
953 | } |
951 | } |
954 | else |
952 | else |
955 | { |
953 | { |
956 | price_in = item->value; |
954 | price_in = item->value; |
957 | remove_ob (item); |
955 | item->destroy (); |
958 | free_object (item); |
|
|
959 | } |
956 | } |
960 | } |
957 | } |
961 | |
958 | |
962 | if (converter->inv != NULL) |
959 | if (converter->inv != NULL) |
963 | { |
960 | { |
… | |
… | |
1027 | if (op->type != PLAYER) |
1024 | if (op->type != PLAYER) |
1028 | return 0; /* This might change */ |
1025 | return 0; /* This might change */ |
1029 | |
1026 | |
1030 | if (sack == NULL || sack->type != CONTAINER) |
1027 | if (sack == NULL || sack->type != CONTAINER) |
1031 | { |
1028 | { |
1032 | LOG (llevError, "apply_container: %s is not container!\n", &sack->name); |
1029 | LOG (llevError, "apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1033 | return 0; |
1030 | return 0; |
1034 | } |
1031 | } |
1035 | op->contr->last_used = NULL; |
1032 | |
1036 | op->contr->last_used_id = 0; |
1033 | op->contr->last_used = 0; |
1037 | |
1034 | |
1038 | if (sack->env != op) |
1035 | if (sack->env != op) |
1039 | { |
1036 | { |
1040 | if (sack->other_arch == NULL || sack->env != NULL) |
1037 | if (sack->other_arch == NULL || sack->env != NULL) |
1041 | { |
1038 | { |
1042 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1039 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1043 | return 1; |
1040 | return 1; |
1044 | } |
1041 | } |
|
|
1042 | |
1045 | /* It's on the ground, the problems begin */ |
1043 | /* It's on the ground, the problems begin */ |
1046 | if (op->container != sack) |
1044 | if (op->container != sack) |
1047 | { |
1045 | { |
1048 | /* it's closed OR some player has opened it */ |
1046 | /* it's closed OR some player has opened it */ |
1049 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1047 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1050 | { |
1048 | { |
1051 | for (tmp = get_map_ob (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above); |
1049 | for (tmp = GET_MAP_OB (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above); |
1052 | if (tmp) |
1050 | if (tmp) |
1053 | { |
1051 | { |
1054 | /* some other player have opened it */ |
1052 | /* some other player have opened it */ |
1055 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack)); |
1053 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack)); |
1056 | return 1; |
1054 | return 1; |
… | |
… | |
1076 | } |
1074 | } |
1077 | else |
1075 | else |
1078 | { |
1076 | { |
1079 | sack->move_off = 0; |
1077 | sack->move_off = 0; |
1080 | tmp = sack->inv; |
1078 | tmp = sack->inv; |
|
|
1079 | |
1081 | if (tmp && tmp->type == CLOSE_CON) |
1080 | if (tmp && tmp->type == CLOSE_CON) |
1082 | { |
1081 | tmp->destroy (); |
1083 | remove_ob (tmp); |
|
|
1084 | free_object (tmp); |
|
|
1085 | } |
|
|
1086 | } |
1082 | } |
1087 | } |
1083 | } |
1088 | } |
1084 | } |
1089 | |
1085 | |
1090 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1086 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
… | |
… | |
1122 | tmp = find_key (op, op, sack); |
1118 | tmp = find_key (op, op, sack); |
1123 | if (tmp) |
1119 | if (tmp) |
1124 | { |
1120 | { |
1125 | sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp)); |
1121 | sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp)); |
1126 | SET_FLAG (sack, FLAG_APPLIED); |
1122 | SET_FLAG (sack, FLAG_APPLIED); |
|
|
1123 | |
1127 | if (sack->env == NULL) |
1124 | if (sack->env == NULL) |
1128 | { /* if it's on ground,open it also */ |
1125 | { /* if it's on ground,open it also */ |
1129 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1126 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1130 | apply_container (op, sack); |
1127 | apply_container (op, sack); |
1131 | return 1; |
1128 | return 1; |
1132 | } |
1129 | } |
1133 | } |
1130 | } |
1134 | else |
1131 | else |
1135 | { |
|
|
1136 | sprintf (buf, "You don't have the key to unlock %s.", query_name (sack)); |
1132 | sprintf (buf, "You don't have the key to unlock %s.", query_name (sack)); |
1137 | } |
|
|
1138 | } |
1133 | } |
1139 | else |
1134 | else |
1140 | { |
1135 | { |
1141 | sprintf (buf, "You readied %s.", query_name (sack)); |
1136 | sprintf (buf, "You readied %s.", query_name (sack)); |
1142 | SET_FLAG (sack, FLAG_APPLIED); |
1137 | SET_FLAG (sack, FLAG_APPLIED); |
|
|
1138 | |
1143 | if (sack->env == NULL) |
1139 | if (sack->env == NULL) |
1144 | { /* if it's on ground,open it also */ |
1140 | { /* if it's on ground,open it also */ |
1145 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1141 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1146 | apply_container (op, sack); |
1142 | apply_container (op, sack); |
1147 | return 1; |
1143 | return 1; |
1148 | } |
1144 | } |
1149 | } |
1145 | } |
1150 | } |
1146 | } |
|
|
1147 | |
1151 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1148 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1149 | |
1152 | if (op->contr) |
1150 | if (op->contr) |
1153 | op->contr->socket.update_look = 1; |
1151 | op->contr->ns->floorbox_update (); |
|
|
1152 | |
1154 | return 1; |
1153 | return 1; |
1155 | } |
1154 | } |
1156 | |
1155 | |
1157 | /** |
1156 | /** |
1158 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
1157 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
… | |
… | |
1176 | if (op->type != PLAYER) |
1175 | if (op->type != PLAYER) |
1177 | return 0; /* This might change */ |
1176 | return 0; /* This might change */ |
1178 | |
1177 | |
1179 | if (sack == NULL || sack->type != CONTAINER) |
1178 | if (sack == NULL || sack->type != CONTAINER) |
1180 | { |
1179 | { |
1181 | LOG (llevError, "esrv_apply_container: %s is not container!\n", &sack->name); |
1180 | LOG (llevError, "esrv_apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1182 | return 0; |
1181 | return 0; |
1183 | } |
1182 | } |
1184 | |
1183 | |
1185 | /* If we have a currently open container, then it needs to be closed in all cases |
1184 | /* If we have a currently open container, then it needs to be closed in all cases |
1186 | * if we are opening this one up. We then fall through if appropriate for |
1185 | * if we are opening this one up. We then fall through if appropriate for |
… | |
… | |
1346 | |
1345 | |
1347 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1346 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1348 | { |
1347 | { |
1349 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1348 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1350 | |
1349 | |
1351 | remove_ob (tmp); |
1350 | tmp->remove (); |
1352 | |
1351 | |
1353 | if (i == -1) |
1352 | if (i == -1) |
1354 | i = 0; |
1353 | i = 0; |
1355 | |
1354 | |
1356 | tmp->map = op->map; |
1355 | tmp->map = op->map; |
… | |
… | |
1420 | { |
1419 | { |
1421 | LOG (llevError, "Internal shop-mat problem.\n"); |
1420 | LOG (llevError, "Internal shop-mat problem.\n"); |
1422 | } |
1421 | } |
1423 | else |
1422 | else |
1424 | { |
1423 | { |
1425 | remove_ob (op); |
1424 | op->remove (); |
1426 | op->x += freearr_x[i]; |
1425 | op->x += freearr_x[i]; |
1427 | op->y += freearr_y[i]; |
1426 | op->y += freearr_y[i]; |
1428 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1427 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1429 | } |
1428 | } |
1430 | } |
1429 | } |
… | |
… | |
1789 | |
1788 | |
1790 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1789 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1791 | { |
1790 | { |
1792 | /*exp_gain *= 2; because they just identified it too */ |
1791 | /*exp_gain *= 2; because they just identified it too */ |
1793 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1792 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
|
|
1793 | |
1794 | /* If in a container, update how it looks */ |
1794 | /* If in a container, update how it looks */ |
1795 | if (tmp->env) |
1795 | if (tmp->env) |
1796 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1796 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1797 | else |
1797 | else |
1798 | op->contr->socket.update_look = 1; |
1798 | op->contr->ns->floorbox_update (); |
1799 | } |
1799 | } |
|
|
1800 | |
1800 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1801 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1801 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1802 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1802 | } |
1803 | } |
1803 | } |
1804 | } |
1804 | |
1805 | |
… | |
… | |
1853 | } |
1854 | } |
1854 | return; |
1855 | return; |
1855 | } |
1856 | } |
1856 | |
1857 | |
1857 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1858 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1858 | tmp = get_object (); |
1859 | tmp = spell->clone (); |
1859 | copy_object (spell, tmp); |
|
|
1860 | insert_ob_in_ob (tmp, op); |
1860 | insert_ob_in_ob (tmp, op); |
1861 | |
1861 | |
1862 | if (special_prayer) |
1862 | if (special_prayer) |
1863 | { |
|
|
1864 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1863 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1865 | } |
|
|
1866 | |
1864 | |
1867 | esrv_add_spells (op->contr, tmp); |
1865 | esrv_add_spells (op->contr, tmp); |
1868 | } |
1866 | } |
1869 | |
1867 | |
1870 | /** |
1868 | /** |
… | |
… | |
1887 | } |
1885 | } |
1888 | |
1886 | |
1889 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1887 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1890 | player_unready_range_ob (op->contr, spob); |
1888 | player_unready_range_ob (op->contr, spob); |
1891 | esrv_remove_spell (op->contr, spob); |
1889 | esrv_remove_spell (op->contr, spob); |
1892 | remove_ob (spob); |
1890 | spob->destroy (); |
1893 | free_object (spob); |
|
|
1894 | } |
1891 | } |
1895 | |
1892 | |
1896 | /** |
1893 | /** |
1897 | * Handles player applying a spellbook. |
1894 | * Handles player applying a spellbook. |
1898 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
1895 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
… | |
… | |
1936 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1933 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1937 | return; |
1934 | return; |
1938 | } |
1935 | } |
1939 | |
1936 | |
1940 | spell = tmp->inv; |
1937 | spell = tmp->inv; |
|
|
1938 | |
1941 | if (!spell) |
1939 | if (!spell) |
1942 | { |
1940 | { |
1943 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1941 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1944 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1942 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1945 | return; |
1943 | return; |
1946 | } |
1944 | } |
1947 | if (spell->level > (skop->level + 10)) |
1945 | |
|
|
1946 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1948 | { |
1947 | { |
1949 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1948 | new_draw_info (NDI_UNIQUE, 0, op, "It is too hard to read at your level: You are unable to decipher the strange symbols."); |
1950 | return; |
1949 | return; |
1951 | } |
1950 | } |
1952 | |
1951 | |
1953 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1952 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1954 | |
1953 | |
1955 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1954 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1956 | { |
1955 | { |
1957 | identify (tmp); |
1956 | identify (tmp); |
|
|
1957 | |
1958 | if (tmp->env) |
1958 | if (tmp->env) |
1959 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1959 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1960 | else |
1960 | else |
1961 | op->contr->socket.update_look = 1; |
1961 | op->contr->ns->floorbox_update (); |
1962 | } |
1962 | } |
1963 | |
1963 | |
1964 | /* I removed the check for special_prayer_mark here - it didn't make |
1964 | /* I removed the check for special_prayer_mark here - it didn't make |
1965 | * a lot of sense - special prayers are not found in spellbooks, and |
1965 | * a lot of sense - special prayers are not found in spellbooks, and |
1966 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1966 | * if the player doesn't know the spell, doesn't make a lot of sense that |
… | |
… | |
2082 | */ |
2082 | */ |
2083 | static void |
2083 | static void |
2084 | apply_treasure (object *op, object *tmp) |
2084 | apply_treasure (object *op, object *tmp) |
2085 | { |
2085 | { |
2086 | object *treas; |
2086 | object *treas; |
2087 | tag_t tmp_tag = tmp->count, op_tag = op->count; |
|
|
2088 | |
2087 | |
2089 | |
2088 | |
2090 | /* Nice side effect of new treasure creation method is that the treasure |
2089 | /* Nice side effect of new treasure creation method is that the treasure |
2091 | * for the chest is done when the chest is created, and put into the chest |
2090 | * for the chest is done when the chest is created, and put into the chest |
2092 | * inventory. So that when the chest burns up, the items still exist. Also |
2091 | * inventory. So that when the chest burns up, the items still exist. Also |
… | |
… | |
2103 | } |
2102 | } |
2104 | while (tmp->inv) |
2103 | while (tmp->inv) |
2105 | { |
2104 | { |
2106 | treas = tmp->inv; |
2105 | treas = tmp->inv; |
2107 | |
2106 | |
2108 | remove_ob (treas); |
2107 | treas->remove (); |
2109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2108 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2110 | |
2109 | |
2111 | treas->x = op->x; |
2110 | treas->x = op->x; |
2112 | treas->y = op->y; |
2111 | treas->y = op->y; |
2113 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2112 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2114 | |
2113 | |
2115 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2114 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2116 | spring_trap (treas, op); |
2115 | spring_trap (treas, op); |
|
|
2116 | |
2117 | /* If either player or container was destroyed, no need to do |
2117 | /* If either player or container was destroyed, no need to do |
2118 | * further processing. I think this should be enclused with |
2118 | * further processing. I think this should be enclused with |
2119 | * spring trap above, as I don't think there is otherwise |
2119 | * spring trap above, as I don't think there is otherwise |
2120 | * any way for the treasure chest or player to get killed |
2120 | * any way for the treasure chest or player to get killed |
2121 | */ |
2121 | */ |
2122 | if (was_destroyed (op, op_tag) || was_destroyed (tmp, tmp_tag)) |
2122 | if (op->destroyed () || tmp->destroyed ()) |
2123 | break; |
2123 | break; |
2124 | } |
2124 | } |
2125 | |
2125 | |
2126 | if (!was_destroyed (tmp, tmp_tag) && tmp->inv == NULL) |
2126 | if (!tmp->destroyed () && tmp->inv == NULL) |
2127 | decrease_ob (tmp); |
2127 | decrease_ob (tmp); |
2128 | |
2128 | |
2129 | } |
2129 | } |
2130 | |
2130 | |
2131 | /** |
2131 | /** |
… | |
… | |
2326 | |
2326 | |
2327 | if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) |
2327 | if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) |
2328 | { |
2328 | { |
2329 | /* resistance increased! */ |
2329 | /* resistance increased! */ |
2330 | skin->resist[i]++; |
2330 | skin->resist[i]++; |
2331 | fix_player (op); |
2331 | op->update_stats (); |
2332 | |
2332 | |
2333 | sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]); |
2333 | sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]); |
2334 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, buf); |
2334 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, buf); |
2335 | } |
2335 | } |
2336 | |
2336 | |
… | |
… | |
2355 | } |
2355 | } |
2356 | } |
2356 | } |
2357 | return 1; |
2357 | return 1; |
2358 | } |
2358 | } |
2359 | |
2359 | |
2360 | static void |
|
|
2361 | apply_savebed (object *pl) |
|
|
2362 | { |
|
|
2363 | #ifndef COZY_SERVER |
|
|
2364 | if (!pl->contr->name_changed || !pl->stats.exp) |
|
|
2365 | { |
|
|
2366 | new_draw_info (NDI_UNIQUE, 0, pl, "You don't deserve to save your character yet."); |
|
|
2367 | return; |
|
|
2368 | } |
|
|
2369 | #endif |
|
|
2370 | INVOKE_PLAYER (LOGOUT, pl->contr); |
|
|
2371 | /* Need to call terminate_all_pets() before we remove the player ob */ |
|
|
2372 | terminate_all_pets (pl); |
|
|
2373 | remove_ob (pl); |
|
|
2374 | pl->direction = 0; |
|
|
2375 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
|
|
2376 | |
|
|
2377 | /* update respawn position */ |
|
|
2378 | strcpy (pl->contr->savebed_map, pl->map->path); |
|
|
2379 | pl->contr->bed_x = pl->x; |
|
|
2380 | pl->contr->bed_y = pl->y; |
|
|
2381 | |
|
|
2382 | strcpy (pl->contr->killer, "left"); |
|
|
2383 | check_score (pl); /* Always check score */ |
|
|
2384 | (void) save_player (pl, 0); |
|
|
2385 | pl->map->players--; |
|
|
2386 | #if MAP_MAXTIMEOUT |
|
|
2387 | MAP_SWAP_TIME (pl->map) = MAP_TIMEOUT (pl->map); |
|
|
2388 | #endif |
|
|
2389 | play_again (pl); |
|
|
2390 | pl->speed = 0; |
|
|
2391 | update_ob_speed (pl); |
|
|
2392 | } |
|
|
2393 | |
|
|
2394 | /** |
2360 | /** |
2395 | * Handles applying an improve armor scroll. |
2361 | * Handles applying an improve armor scroll. |
2396 | * Does some sanity checks, then calls improve_armour. |
2362 | * Does some sanity checks, then calls improve_armour. |
2397 | */ |
2363 | */ |
2398 | static void |
2364 | static void |
… | |
… | |
2403 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
2369 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
2404 | { |
2370 | { |
2405 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); |
2371 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); |
2406 | return; |
2372 | return; |
2407 | } |
2373 | } |
|
|
2374 | |
2408 | armor = find_marked_object (op); |
2375 | armor = find_marked_object (op); |
|
|
2376 | |
2409 | if (!armor) |
2377 | if (!armor) |
2410 | { |
2378 | { |
2411 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); |
2379 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); |
2412 | return; |
2380 | return; |
2413 | } |
2381 | } |
|
|
2382 | |
2414 | if (armor->type != ARMOUR |
2383 | if (armor->type != ARMOUR |
2415 | && armor->type != CLOAK |
2384 | && armor->type != CLOAK |
2416 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2385 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2417 | { |
2386 | { |
2418 | new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n"); |
2387 | new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n"); |
… | |
… | |
2420 | } |
2389 | } |
2421 | |
2390 | |
2422 | new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment."); |
2391 | new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment."); |
2423 | improve_armour (op, tmp, armor); |
2392 | improve_armour (op, tmp, armor); |
2424 | } |
2393 | } |
2425 | |
|
|
2426 | |
2394 | |
2427 | extern void |
2395 | extern void |
2428 | apply_poison (object *op, object *tmp) |
2396 | apply_poison (object *op, object *tmp) |
2429 | { |
2397 | { |
2430 | if (op->type == PLAYER) |
2398 | if (op->type == PLAYER) |
… | |
… | |
2446 | /** |
2414 | /** |
2447 | * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2415 | * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2448 | * A valid 2 way exit means: |
2416 | * A valid 2 way exit means: |
2449 | * -You can come back (there is another exit at the other side) |
2417 | * -You can come back (there is another exit at the other side) |
2450 | * -You are |
2418 | * -You are |
2451 | * ° the owner of the exit |
2419 | * ° the owner of the exit |
2452 | * ° or in the same party as the owner |
2420 | * ° or in the same party as the owner |
2453 | * |
2421 | * |
2454 | * Note: a owner in a 2 way exit is saved as the owner's name |
2422 | * Note: a owner in a 2 way exit is saved as the owner's name |
2455 | * in the field exit->name cause the field exit->owner doesn't |
2423 | * in the field exit->name cause the field exit->owner doesn't |
2456 | * survive in the swapping (in fact the whole exit doesn't survive). |
2424 | * survive in the swapping (in fact the whole exit doesn't survive). |
2457 | */ |
2425 | */ |
… | |
… | |
2459 | is_legal_2ways_exit (object *op, object *exit) |
2427 | is_legal_2ways_exit (object *op, object *exit) |
2460 | { |
2428 | { |
2461 | object *tmp; |
2429 | object *tmp; |
2462 | object *exit_owner; |
2430 | object *exit_owner; |
2463 | player *pp; |
2431 | player *pp; |
2464 | mapstruct *exitmap; |
2432 | maptile *exitmap; |
2465 | |
2433 | |
2466 | if (exit->stats.exp != 1) |
2434 | if (exit->stats.exp != 1) |
2467 | return 1; /*This is not a 2 way, so it is legal */ |
2435 | return 1; /*This is not a 2 way, so it is legal */ |
2468 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2436 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2469 | return 0; /* This is a reset town portal */ |
2437 | return 0; /* This is a reset town portal */ |
… | |
… | |
2474 | exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE); |
2442 | exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE); |
2475 | else |
2443 | else |
2476 | exitmap = ready_map_name (EXIT_PATH (exit), 0); |
2444 | exitmap = ready_map_name (EXIT_PATH (exit), 0); |
2477 | if (exitmap) |
2445 | if (exitmap) |
2478 | { |
2446 | { |
2479 | tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit)); |
2447 | tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit)); |
2480 | if (!tmp) |
2448 | if (!tmp) |
2481 | return 0; |
2449 | return 0; |
2482 | for ((tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) |
2450 | for ((tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) |
2483 | { |
2451 | { |
2484 | if (tmp->type != EXIT) |
2452 | if (tmp->type != EXIT) |
2485 | continue; /*Not an exit */ |
2453 | continue; /*Not an exit */ |
2486 | if (!EXIT_PATH (tmp)) |
2454 | if (!EXIT_PATH (tmp)) |
2487 | continue; /*Not a valid exit */ |
2455 | continue; /*Not a valid exit */ |
… | |
… | |
2551 | { |
2519 | { |
2552 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
2520 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
2553 | return 1; |
2521 | return 1; |
2554 | } |
2522 | } |
2555 | else |
2523 | else |
2556 | { |
|
|
2557 | return 0; /* monsters just skip unpaid items */ |
2524 | return 0; /* monsters just skip unpaid items */ |
2558 | } |
|
|
2559 | } |
2525 | } |
2560 | |
2526 | |
2561 | if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op))) |
2527 | if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op))) |
2562 | return RESULT_INT (0); |
2528 | return RESULT_INT (0); |
2563 | |
2529 | |
2564 | switch (tmp->type) |
2530 | switch (tmp->type) |
2565 | { |
2531 | { |
2566 | |
|
|
2567 | case CF_HANDLE: |
2532 | case CF_HANDLE: |
2568 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2533 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2569 | play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); |
2534 | play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); |
2570 | tmp->value = tmp->value ? 0 : 1; |
2535 | tmp->value = tmp->value ? 0 : 1; |
2571 | SET_ANIMATION (tmp, tmp->value); |
2536 | SET_ANIMATION (tmp, tmp->value); |
… | |
… | |
2699 | case POISON: |
2664 | case POISON: |
2700 | apply_poison (op, tmp); |
2665 | apply_poison (op, tmp); |
2701 | return 1; |
2666 | return 1; |
2702 | |
2667 | |
2703 | case SAVEBED: |
2668 | case SAVEBED: |
2704 | if (op->type == PLAYER) |
|
|
2705 | { |
|
|
2706 | apply_savebed (op); |
|
|
2707 | return 1; |
2669 | return 1; |
2708 | } |
|
|
2709 | else |
|
|
2710 | { |
|
|
2711 | return 0; |
|
|
2712 | } |
|
|
2713 | |
2670 | |
2714 | case ARMOUR_IMPROVER: |
2671 | case ARMOUR_IMPROVER: |
2715 | if (op->type == PLAYER) |
2672 | if (op->type == PLAYER) |
2716 | { |
2673 | { |
2717 | apply_armour_improver (op, tmp); |
2674 | apply_armour_improver (op, tmp); |
2718 | return 1; |
2675 | return 1; |
2719 | } |
2676 | } |
2720 | else |
2677 | else |
2721 | { |
|
|
2722 | return 0; |
2678 | return 0; |
2723 | } |
|
|
2724 | |
2679 | |
2725 | case WEAPON_IMPROVER: |
2680 | case WEAPON_IMPROVER: |
2726 | (void) check_improve_weapon (op, tmp); |
2681 | (void) check_improve_weapon (op, tmp); |
2727 | return 1; |
2682 | return 1; |
2728 | |
2683 | |
… | |
… | |
2808 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2763 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2809 | { |
2764 | { |
2810 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2765 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2811 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!"); |
2766 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!"); |
2812 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2767 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2813 | remove_ob (op); |
2768 | op->destroy (); |
2814 | free_object (op); |
|
|
2815 | return 1; |
2769 | return 1; |
2816 | } |
2770 | } |
2817 | |
2771 | |
2818 | pl->contr->last_used = op; |
2772 | pl->contr->last_used = op; |
2819 | pl->contr->last_used_id = op->count; |
|
|
2820 | |
2773 | |
2821 | tmp = manual_apply (pl, op, aflag); |
2774 | tmp = manual_apply (pl, op, aflag); |
2822 | if (!quiet) |
2775 | if (!quiet) |
2823 | { |
2776 | { |
2824 | if (tmp == 0) |
2777 | if (tmp == 0) |
… | |
… | |
2946 | tmp2->map = op->map; |
2899 | tmp2->map = op->map; |
2947 | tmp2->below = op->below; |
2900 | tmp2->below = op->below; |
2948 | tmp2->above = op->above; |
2901 | tmp2->above = op->above; |
2949 | tmp2->stats.food = op->stats.food; |
2902 | tmp2->stats.food = op->stats.food; |
2950 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2903 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
|
|
2904 | |
2951 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2905 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2952 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2906 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
|
|
2907 | |
2953 | if (who->type == PLAYER) |
2908 | if (who->type == PLAYER) |
2954 | esrv_del_item (who->contr, (tag_t) op->count); |
2909 | esrv_del_item (who->contr, op->count); |
2955 | remove_ob (op); |
2910 | |
2956 | free_object (op); |
2911 | op->destroy (); |
2957 | insert_ob_in_ob (tmp2, who); |
2912 | insert_ob_in_ob (tmp2, who); |
2958 | fix_player (who); |
2913 | who->update_stats (); |
2959 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2914 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2960 | { |
2915 | { |
2961 | if (who->type == PLAYER) |
2916 | if (who->type == PLAYER) |
2962 | { |
2917 | { |
2963 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2918 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
… | |
… | |
2996 | default: |
2951 | default: |
2997 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2952 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2998 | break; |
2953 | break; |
2999 | } |
2954 | } |
3000 | |
2955 | |
3001 | fix_player (who); |
2956 | who->update_stats (); |
3002 | |
2957 | |
3003 | if (!(aflags & AP_NO_MERGE)) |
2958 | if (!(aflags & AP_NO_MERGE)) |
3004 | { |
2959 | { |
3005 | object *tmp; |
2960 | object *tmp; |
3006 | |
|
|
3007 | tag_t del_tag = op->count; |
|
|
3008 | |
2961 | |
3009 | tmp = merge_ob (op, NULL); |
2962 | tmp = merge_ob (op, NULL); |
3010 | if (who->type == PLAYER) |
2963 | if (who->type == PLAYER) |
3011 | { |
2964 | { |
3012 | if (tmp) |
2965 | if (tmp) |
3013 | { /* it was merged */ |
2966 | { /* it was merged */ |
3014 | esrv_del_item (who->contr, del_tag); |
2967 | esrv_del_item (who->contr, op->count); |
3015 | op = tmp; |
2968 | op = tmp; |
3016 | } |
2969 | } |
|
|
2970 | |
3017 | esrv_send_item (who, op); |
2971 | esrv_send_item (who, op); |
3018 | } |
2972 | } |
3019 | } |
2973 | } |
3020 | return 0; |
2974 | return 0; |
3021 | } |
2975 | } |
… | |
… | |
3485 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3439 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3486 | insert_ob_in_ob (tmp2, who); |
3440 | insert_ob_in_ob (tmp2, who); |
3487 | |
3441 | |
3488 | /* Remove the old lantern */ |
3442 | /* Remove the old lantern */ |
3489 | if (who->type == PLAYER) |
3443 | if (who->type == PLAYER) |
3490 | esrv_del_item (who->contr, (tag_t) op->count); |
3444 | esrv_del_item (who->contr, op->count); |
3491 | remove_ob (op); |
3445 | |
3492 | free_object (op); |
3446 | op->destroy (); |
3493 | |
3447 | |
3494 | /* insert the portion that was split off */ |
3448 | /* insert the portion that was split off */ |
3495 | if (tmp != NULL) |
3449 | if (tmp != NULL) |
3496 | { |
3450 | { |
3497 | (void) insert_ob_in_ob (tmp, who); |
3451 | (void) insert_ob_in_ob (tmp, who); |
3498 | if (who->type == PLAYER) |
3452 | if (who->type == PLAYER) |
3499 | esrv_send_item (who, tmp); |
3453 | esrv_send_item (who, tmp); |
3500 | } |
3454 | } |
3501 | fix_player (who); |
3455 | who->update_stats (); |
3502 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3456 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3503 | { |
3457 | { |
3504 | if (who->type == PLAYER) |
3458 | if (who->type == PLAYER) |
3505 | { |
3459 | { |
3506 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3460 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
… | |
… | |
3603 | SET_FLAG (op, FLAG_APPLIED); |
3557 | SET_FLAG (op, FLAG_APPLIED); |
3604 | |
3558 | |
3605 | if (tmp != NULL) |
3559 | if (tmp != NULL) |
3606 | tmp = insert_ob_in_ob (tmp, who); |
3560 | tmp = insert_ob_in_ob (tmp, who); |
3607 | |
3561 | |
3608 | fix_player (who); |
3562 | who->update_stats (); |
3609 | |
3563 | |
3610 | /* We exclude spell casting objects. The fire code will set the |
3564 | /* We exclude spell casting objects. The fire code will set the |
3611 | * been applied flag when they are used - until that point, |
3565 | * been applied flag when they are used - until that point, |
3612 | * you don't know anything about them. |
3566 | * you don't know anything about them. |
3613 | */ |
3567 | */ |
… | |
… | |
3653 | int i; |
3607 | int i; |
3654 | |
3608 | |
3655 | switch (op->type) |
3609 | switch (op->type) |
3656 | { |
3610 | { |
3657 | case SHOP_FLOOR: |
3611 | case SHOP_FLOOR: |
3658 | if (!HAS_RANDOM_ITEMS (op)) |
3612 | if (!op->has_random_items ()) |
3659 | return 0; |
3613 | return 0; |
|
|
3614 | |
3660 | do |
3615 | do |
3661 | { |
3616 | { |
3662 | i = 10; /* let's give it 10 tries */ |
3617 | i = 10; /* let's give it 10 tries */ |
3663 | while ((tmp = generate_treasure (op->randomitems, |
3618 | while ((tmp = generate_treasure (op->randomitems, |
3664 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3619 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3665 | if (tmp == NULL) |
3620 | if (tmp == NULL) |
3666 | return 0; |
3621 | return 0; |
3667 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3622 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3668 | { |
3623 | { |
3669 | free_object (tmp); |
3624 | tmp->destroy (); |
3670 | tmp = NULL; |
3625 | tmp = NULL; |
3671 | } |
3626 | } |
3672 | } |
3627 | } |
3673 | while (!tmp); |
3628 | while (!tmp); |
|
|
3629 | |
3674 | tmp->x = op->x; |
3630 | tmp->x = op->x; |
3675 | tmp->y = op->y; |
3631 | tmp->y = op->y; |
3676 | SET_FLAG (tmp, FLAG_UNPAID); |
3632 | SET_FLAG (tmp, FLAG_UNPAID); |
3677 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3633 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3678 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3634 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
… | |
… | |
3680 | break; |
3636 | break; |
3681 | |
3637 | |
3682 | case TREASURE: |
3638 | case TREASURE: |
3683 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3639 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3684 | return 0; |
3640 | return 0; |
|
|
3641 | |
3685 | while ((op->stats.hp--) > 0) |
3642 | while ((op->stats.hp--) > 0) |
3686 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3643 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3687 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3644 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3688 | |
3645 | |
3689 | /* If we generated an object and put it in this object inventory, |
3646 | /* If we generated an object and put it in this object inventory, |
… | |
… | |
3692 | * that is put inside other objects. |
3649 | * that is put inside other objects. |
3693 | */ |
3650 | */ |
3694 | for (tmp = op->inv; tmp; tmp = tmp2) |
3651 | for (tmp = op->inv; tmp; tmp = tmp2) |
3695 | { |
3652 | { |
3696 | tmp2 = tmp->below; |
3653 | tmp2 = tmp->below; |
3697 | remove_ob (tmp); |
3654 | tmp->remove (); |
|
|
3655 | |
3698 | if (op->env) |
3656 | if (op->env) |
3699 | insert_ob_in_ob (tmp, op->env); |
3657 | insert_ob_in_ob (tmp, op->env); |
3700 | else |
3658 | else |
3701 | free_object (tmp); |
3659 | tmp->destroy (); |
3702 | } |
3660 | } |
3703 | remove_ob (op); |
3661 | |
3704 | free_object (op); |
3662 | op->destroy (); |
3705 | break; |
3663 | break; |
3706 | } |
3664 | } |
3707 | return tmp ? 1 : 0; |
3665 | return tmp ? 1 : 0; |
3708 | } |
3666 | } |
3709 | |
3667 | |
… | |
… | |
3712 | * when an original map is loaded) and performs special actions for |
3670 | * when an original map is loaded) and performs special actions for |
3713 | * certain objects (most initialization of chests and creation of |
3671 | * certain objects (most initialization of chests and creation of |
3714 | * treasures and stuff). Calls auto_apply if appropriate. |
3672 | * treasures and stuff). Calls auto_apply if appropriate. |
3715 | */ |
3673 | */ |
3716 | void |
3674 | void |
3717 | fix_auto_apply (mapstruct *m) |
3675 | fix_auto_apply (maptile *m) |
3718 | { |
3676 | { |
3719 | object *tmp, *above = NULL; |
3677 | object *tmp, *above = NULL; |
3720 | int x, y; |
3678 | int x, y; |
3721 | |
3679 | |
3722 | if (m == NULL) |
3680 | if (m == NULL) |
3723 | return; |
3681 | return; |
3724 | |
3682 | |
3725 | for (x = 0; x < MAP_WIDTH (m); x++) |
3683 | for (x = 0; x < MAP_WIDTH (m); x++) |
3726 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3684 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3727 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) |
3685 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) |
3728 | { |
3686 | { |
3729 | above = tmp->above; |
3687 | above = tmp->above; |
3730 | |
3688 | |
3731 | if (tmp->inv) |
3689 | if (tmp->inv) |
3732 | { |
3690 | { |
… | |
… | |
3736 | { |
3694 | { |
3737 | invnext = invtmp->below; |
3695 | invnext = invtmp->below; |
3738 | |
3696 | |
3739 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3697 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3740 | auto_apply (invtmp); |
3698 | auto_apply (invtmp); |
3741 | else if (invtmp->type == TREASURE && HAS_RANDOM_ITEMS (invtmp)) |
3699 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3742 | { |
3700 | { |
3743 | while ((invtmp->stats.hp--) > 0) |
3701 | while ((invtmp->stats.hp--) > 0) |
3744 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3702 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3745 | |
3703 | |
3746 | invtmp->randomitems = NULL; |
3704 | invtmp->randomitems = NULL; |
3747 | } |
3705 | } |
3748 | else if (invtmp && invtmp->arch |
3706 | else if (invtmp && invtmp->arch |
3749 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && HAS_RANDOM_ITEMS (invtmp)) |
3707 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3750 | { |
3708 | { |
3751 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3709 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3752 | /* Need to clear this so that we never try to create |
3710 | /* Need to clear this so that we never try to create |
3753 | * treasure again for this object |
3711 | * treasure again for this object |
3754 | */ |
3712 | */ |
… | |
… | |
3771 | |
3729 | |
3772 | } |
3730 | } |
3773 | |
3731 | |
3774 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3732 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3775 | auto_apply (tmp); |
3733 | auto_apply (tmp); |
3776 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && HAS_RANDOM_ITEMS (tmp)) |
3734 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3777 | { |
3735 | { |
3778 | while ((tmp->stats.hp--) > 0) |
3736 | while ((tmp->stats.hp--) > 0) |
3779 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3737 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3780 | tmp->randomitems = NULL; |
3738 | tmp->randomitems = NULL; |
3781 | } |
3739 | } |
… | |
… | |
3796 | * This is a problem for the above objects, because they have counters |
3754 | * This is a problem for the above objects, because they have counters |
3797 | * which say how many times to make the treasure. |
3755 | * which say how many times to make the treasure. |
3798 | */ |
3756 | */ |
3799 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3757 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3800 | && tmp->type != TREASURE && tmp->type != SPELL |
3758 | && tmp->type != TREASURE && tmp->type != SPELL |
3801 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && HAS_RANDOM_ITEMS (tmp)) |
3759 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) |
3802 | { |
3760 | { |
3803 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3761 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3804 | tmp->randomitems = NULL; |
3762 | tmp->randomitems = NULL; |
3805 | } |
3763 | } |
3806 | } |
3764 | } |
3807 | |
3765 | |
3808 | for (x = 0; x < MAP_WIDTH (m); x++) |
3766 | for (x = 0; x < MAP_WIDTH (m); x++) |
3809 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3767 | for (y = 0; y < MAP_HEIGHT (m); y++) |
3810 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
3768 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
3811 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3769 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3812 | check_trigger (tmp, tmp->above); |
3770 | check_trigger (tmp, tmp->above); |
3813 | } |
3771 | } |
3814 | |
3772 | |
3815 | /** |
3773 | /** |
… | |
… | |
3845 | { |
3803 | { |
3846 | force->resist[i] = food->resist[i] / 2; |
3804 | force->resist[i] = food->resist[i] / 2; |
3847 | did_one = 1; |
3805 | did_one = 1; |
3848 | } |
3806 | } |
3849 | } |
3807 | } |
|
|
3808 | |
3850 | if (did_one) |
3809 | if (did_one) |
3851 | { |
3810 | { |
3852 | force->speed = 0.1; |
3811 | force->speed = 0.1; |
3853 | update_ob_speed (force); |
3812 | update_ob_speed (force); |
3854 | /* bigger morsel of food = longer effect time */ |
3813 | /* bigger morsel of food = longer effect time */ |
3855 | force->stats.food = food->stats.food / 5; |
3814 | force->duration = food->stats.food / 5; |
3856 | SET_FLAG (force, FLAG_IS_USED_UP); |
|
|
3857 | SET_FLAG (force, FLAG_APPLIED); |
3815 | SET_FLAG (force, FLAG_APPLIED); |
3858 | change_abil (who, force); |
3816 | change_abil (who, force); |
3859 | insert_ob_in_ob (force, who); |
3817 | insert_ob_in_ob (force, who); |
3860 | } |
3818 | } |
3861 | else |
3819 | else |
3862 | { |
3820 | force->destroy (); |
3863 | free_object (force); |
|
|
3864 | } |
|
|
3865 | |
3821 | |
3866 | /* check for hp, sp change */ |
3822 | /* check for hp, sp change */ |
3867 | if (food->stats.hp != 0) |
3823 | if (food->stats.hp != 0) |
3868 | { |
3824 | { |
3869 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3825 | if (QUERY_FLAG (food, FLAG_CURSED)) |
… | |
… | |
3895 | new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); |
3851 | new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); |
3896 | who->stats.sp += food->stats.sp; |
3852 | who->stats.sp += food->stats.sp; |
3897 | /* place limit on max sp from food? */ |
3853 | /* place limit on max sp from food? */ |
3898 | } |
3854 | } |
3899 | } |
3855 | } |
3900 | fix_player (who); |
3856 | who->update_stats (); |
3901 | } |
3857 | } |
3902 | |
|
|
3903 | |
3858 | |
3904 | /** |
3859 | /** |
3905 | * Designed primarily to light torches/lanterns/etc. |
3860 | * Designed primarily to light torches/lanterns/etc. |
3906 | * Also burns up burnable material too. First object in the inventory is |
3861 | * Also burns up burnable material too. First object in the inventory is |
3907 | * the selected object to "burn". -b.t. |
3862 | * the selected object to "burn". -b.t. |
3908 | */ |
3863 | */ |
3909 | |
|
|
3910 | void |
3864 | void |
3911 | apply_lighter (object *who, object *lighter) |
3865 | apply_lighter (object *who, object *lighter) |
3912 | { |
3866 | { |
3913 | object *item; |
3867 | object *item; |
3914 | int is_player_env = 0; |
3868 | int is_player_env = 0; |
3915 | uint32 nrof; |
|
|
3916 | tag_t count; |
|
|
3917 | char item_name[MAX_BUF]; |
|
|
3918 | |
3869 | |
3919 | item = find_marked_object (who); |
3870 | item = find_marked_object (who); |
3920 | if (item) |
3871 | if (item) |
3921 | { |
3872 | { |
3922 | if (lighter->last_eat && lighter->stats.food) |
3873 | if (lighter->last_eat && lighter->stats.food) |
3923 | { /* lighter gets used up */ |
3874 | { /* lighter gets used up */ |
3924 | /* Split multiple lighters if they're being used up. Otherwise * |
3875 | /* Split multiple lighters if they're being used up. Otherwise * |
3925 | * one charge from each would be used up. --DAMN */ |
3876 | * one charge from each would be used up. --DAMN */ |
3926 | if (lighter->nrof > 1) |
3877 | if (lighter->nrof > 1) |
3927 | { |
3878 | { |
3928 | object *oneLighter = get_object (); |
3879 | object *oneLighter = lighter->clone (); |
3929 | |
3880 | |
3930 | copy_object (lighter, oneLighter); |
|
|
3931 | lighter->nrof -= 1; |
3881 | lighter->nrof -= 1; |
3932 | oneLighter->nrof = 1; |
3882 | oneLighter->nrof = 1; |
3933 | oneLighter->stats.food--; |
3883 | oneLighter->stats.food--; |
3934 | esrv_send_item (who, lighter); |
3884 | esrv_send_item (who, lighter); |
3935 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3885 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3936 | esrv_send_item (who, oneLighter); |
3886 | esrv_send_item (who, oneLighter); |
3937 | } |
3887 | } |
3938 | else |
3888 | else |
3939 | { |
|
|
3940 | lighter->stats.food--; |
3889 | lighter->stats.food--; |
3941 | } |
|
|
3942 | |
|
|
3943 | } |
3890 | } |
3944 | else if (lighter->last_eat) |
3891 | else if (lighter->last_eat) |
3945 | { /* no charges left in lighter */ |
3892 | { /* no charges left in lighter */ |
3946 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); |
3893 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); |
3947 | return; |
3894 | return; |
3948 | } |
3895 | } |
|
|
3896 | |
3949 | /* Perhaps we should split what we are trying to light on fire? |
3897 | /* Perhaps we should split what we are trying to light on fire? |
3950 | * I can't see many times when you would want to light multiple |
3898 | * I can't see many times when you would want to light multiple |
3951 | * objects at once. |
3899 | * objects at once. |
3952 | */ |
3900 | */ |
3953 | nrof = item->nrof; |
3901 | |
3954 | count = item->count; |
|
|
3955 | /* If the item is destroyed, we don't have a valid pointer to the |
|
|
3956 | * name object, so make a copy so the message we print out makes |
|
|
3957 | * some sense. |
|
|
3958 | */ |
|
|
3959 | strcpy (item_name, item->name); |
|
|
3960 | if (who == is_player_inv (item)) |
3902 | if (who == item->in_player ()) |
3961 | is_player_env = 1; |
3903 | is_player_env = 1; |
3962 | |
3904 | |
3963 | save_throw_object (item, AT_FIRE, who); |
3905 | save_throw_object (item, AT_FIRE, who); |
3964 | /* Change to check count and not freed, since the object pointer |
3906 | |
3965 | * may have gotten recycled |
3907 | if (item->destroyed ()) |
3966 | */ |
3908 | { |
3967 | if ((nrof != item->nrof) || (count != item->count)) |
|
|
3968 | { |
|
|
3969 | new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); |
3909 | new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name); |
3970 | /* Need to update the player so that the players glow radius |
3910 | /* Need to update the player so that the players glow radius |
3971 | * gets changed. |
3911 | * gets changed. |
3972 | */ |
3912 | */ |
3973 | if (is_player_env) |
3913 | if (is_player_env) |
3974 | fix_player (who); |
3914 | who->update_stats (); |
3975 | } |
3915 | } |
3976 | else |
3916 | else |
3977 | { |
|
|
3978 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); |
3917 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); |
3979 | } |
|
|
3980 | |
|
|
3981 | } |
3918 | } |
3982 | else /* nothing to light */ |
3919 | else /* nothing to light */ |
3983 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3920 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3984 | |
3921 | |
3985 | } |
3922 | } |
… | |
… | |
3999 | object *tmp; |
3936 | object *tmp; |
4000 | |
3937 | |
4001 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3938 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
4002 | tmp = get_archetype (SPELL_WONDER); |
3939 | tmp = get_archetype (SPELL_WONDER); |
4003 | cast_wonder (op, op, 0, tmp); |
3940 | cast_wonder (op, op, 0, tmp); |
4004 | free_object (tmp); |
3941 | tmp->destroy (); |
4005 | } |
3942 | } |
4006 | else if (failure <= -15 && failure > -35) |
3943 | else if (failure <= -15 && failure > -35) |
4007 | { /* drain mana */ |
3944 | { /* drain mana */ |
4008 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
3945 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
4009 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3946 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
… | |
… | |
4032 | object *tmp; |
3969 | object *tmp; |
4033 | |
3970 | |
4034 | tmp = get_archetype (LOOSE_MANA); |
3971 | tmp = get_archetype (LOOSE_MANA); |
4035 | cast_magic_storm (op, tmp, power); |
3972 | cast_magic_storm (op, tmp, power); |
4036 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
3973 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4037 | free_object (tmp); |
3974 | tmp->destroy (); |
4038 | } |
3975 | } |
4039 | } |
3976 | } |
4040 | } |
3977 | } |
4041 | |
3978 | |
4042 | void |
3979 | void |
… | |
… | |
4205 | if (!new_item) |
4142 | if (!new_item) |
4206 | { |
4143 | { |
4207 | new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); |
4144 | new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); |
4208 | return; |
4145 | return; |
4209 | } |
4146 | } |
|
|
4147 | |
4210 | new_item->nrof = yield; |
4148 | new_item->nrof = yield; |
4211 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4149 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4212 | insert_ob_in_ob (new_item, pl); |
4150 | insert_ob_in_ob (new_item, pl); |
4213 | esrv_send_inventory (pl, pl); |
4151 | esrv_send_inventory (pl, pl); |
4214 | /* Eat up one item */ |
4152 | /* Eat up one item */ |