… | |
… | |
206 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
206 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
207 | return 0; |
207 | return 0; |
208 | } |
208 | } |
209 | |
209 | |
210 | if (op->type == PLAYER) |
210 | if (op->type == PLAYER) |
211 | { |
|
|
212 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
211 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
213 | identify (tmp); |
212 | identify (tmp); |
214 | } |
|
|
215 | |
213 | |
216 | handle_apply_yield (tmp); |
214 | handle_apply_yield (tmp); |
217 | |
215 | |
218 | /* Potion of restoration - only for players */ |
216 | /* Potion of restoration - only for players */ |
219 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
217 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
… | |
… | |
226 | drain_stat (op); |
224 | drain_stat (op); |
227 | fix_player (op); |
225 | fix_player (op); |
228 | decrease_ob (tmp); |
226 | decrease_ob (tmp); |
229 | return 1; |
227 | return 1; |
230 | } |
228 | } |
|
|
229 | |
231 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
230 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
232 | { |
231 | { |
233 | LOG (llevError, "Could not find archetype depletion\n"); |
232 | LOG (llevError, "Could not find archetype depletion\n"); |
234 | return 0; |
233 | return 0; |
235 | } |
234 | } |
236 | depl = present_arch_in_ob (at, op); |
235 | depl = present_arch_in_ob (at, op); |
|
|
236 | |
237 | if (depl != NULL) |
237 | if (depl != NULL) |
238 | { |
238 | { |
239 | for (i = 0; i < NUM_STATS; i++) |
239 | for (i = 0; i < NUM_STATS; i++) |
240 | if (get_attr_value (&depl->stats, i)) |
240 | if (get_attr_value (&depl->stats, i)) |
241 | { |
|
|
242 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
241 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
243 | } |
242 | |
244 | remove_ob (depl); |
243 | depl->destroy (); |
245 | free_object (depl); |
|
|
246 | fix_player (op); |
244 | fix_player (op); |
247 | } |
245 | } |
248 | else |
246 | else |
249 | new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); |
247 | new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); |
250 | |
248 | |
… | |
… | |
253 | } |
251 | } |
254 | |
252 | |
255 | /* improvement potion - only for players */ |
253 | /* improvement potion - only for players */ |
256 | if (op->type == PLAYER && tmp->attacktype & AT_GODPOWER) |
254 | if (op->type == PLAYER && tmp->attacktype & AT_GODPOWER) |
257 | { |
255 | { |
258 | |
|
|
259 | for (i = 1; i < MIN (11, op->level); i++) |
256 | for (i = 1; i < MIN (11, op->level); i++) |
260 | { |
257 | { |
261 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
258 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
262 | { |
259 | { |
263 | if (op->contr->levhp[i] != 1) |
260 | if (op->contr->levhp[i] != 1) |
… | |
… | |
293 | op->contr->levgrace[i] = 3; |
290 | op->contr->levgrace[i] = 3; |
294 | break; |
291 | break; |
295 | } |
292 | } |
296 | } |
293 | } |
297 | } |
294 | } |
|
|
295 | |
298 | /* Just makes checking easier */ |
296 | /* Just makes checking easier */ |
299 | if (i < MIN (11, op->level)) |
297 | if (i < MIN (11, op->level)) |
300 | got_one = 1; |
298 | got_one = 1; |
|
|
299 | |
301 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
300 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
302 | { |
301 | { |
303 | if (got_one) |
302 | if (got_one) |
304 | { |
303 | { |
305 | fix_player (op); |
304 | fix_player (op); |
… | |
… | |
318 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); |
317 | new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); |
319 | } |
318 | } |
320 | else |
319 | else |
321 | new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); |
320 | new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); |
322 | } |
321 | } |
|
|
322 | |
323 | decrease_ob (tmp); |
323 | decrease_ob (tmp); |
324 | return 1; |
324 | return 1; |
325 | } |
325 | } |
326 | |
326 | |
327 | |
327 | |
… | |
… | |
952 | price_in = nr * CONV_NEED (converter) * item->value; |
952 | price_in = nr * CONV_NEED (converter) * item->value; |
953 | } |
953 | } |
954 | else |
954 | else |
955 | { |
955 | { |
956 | price_in = item->value; |
956 | price_in = item->value; |
957 | remove_ob (item); |
957 | item->destroy (); |
958 | free_object (item); |
|
|
959 | } |
958 | } |
960 | } |
959 | } |
961 | |
960 | |
962 | if (converter->inv != NULL) |
961 | if (converter->inv != NULL) |
963 | { |
962 | { |
… | |
… | |
1027 | if (op->type != PLAYER) |
1026 | if (op->type != PLAYER) |
1028 | return 0; /* This might change */ |
1027 | return 0; /* This might change */ |
1029 | |
1028 | |
1030 | if (sack == NULL || sack->type != CONTAINER) |
1029 | if (sack == NULL || sack->type != CONTAINER) |
1031 | { |
1030 | { |
1032 | LOG (llevError, "apply_container: %s is not container!\n", &sack->name); |
1031 | LOG (llevError, "apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1033 | return 0; |
1032 | return 0; |
1034 | } |
1033 | } |
1035 | op->contr->last_used = NULL; |
1034 | op->contr->last_used = NULL; |
1036 | op->contr->last_used_id = 0; |
1035 | op->contr->last_used_id = 0; |
1037 | |
1036 | |
… | |
… | |
1076 | } |
1075 | } |
1077 | else |
1076 | else |
1078 | { |
1077 | { |
1079 | sack->move_off = 0; |
1078 | sack->move_off = 0; |
1080 | tmp = sack->inv; |
1079 | tmp = sack->inv; |
|
|
1080 | |
1081 | if (tmp && tmp->type == CLOSE_CON) |
1081 | if (tmp && tmp->type == CLOSE_CON) |
1082 | { |
1082 | tmp->destroy (); |
1083 | remove_ob (tmp); |
|
|
1084 | free_object (tmp); |
|
|
1085 | } |
|
|
1086 | } |
1083 | } |
1087 | } |
1084 | } |
1088 | } |
1085 | } |
1089 | |
1086 | |
1090 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1087 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
… | |
… | |
1176 | if (op->type != PLAYER) |
1173 | if (op->type != PLAYER) |
1177 | return 0; /* This might change */ |
1174 | return 0; /* This might change */ |
1178 | |
1175 | |
1179 | if (sack == NULL || sack->type != CONTAINER) |
1176 | if (sack == NULL || sack->type != CONTAINER) |
1180 | { |
1177 | { |
1181 | LOG (llevError, "esrv_apply_container: %s is not container!\n", &sack->name); |
1178 | LOG (llevError, "esrv_apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1182 | return 0; |
1179 | return 0; |
1183 | } |
1180 | } |
1184 | |
1181 | |
1185 | /* If we have a currently open container, then it needs to be closed in all cases |
1182 | /* 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 |
1183 | * if we are opening this one up. We then fall through if appropriate for |
… | |
… | |
1346 | |
1343 | |
1347 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1344 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1348 | { |
1345 | { |
1349 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1346 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1350 | |
1347 | |
1351 | remove_ob (tmp); |
1348 | tmp->remove (); |
1352 | |
1349 | |
1353 | if (i == -1) |
1350 | if (i == -1) |
1354 | i = 0; |
1351 | i = 0; |
1355 | |
1352 | |
1356 | tmp->map = op->map; |
1353 | tmp->map = op->map; |
… | |
… | |
1420 | { |
1417 | { |
1421 | LOG (llevError, "Internal shop-mat problem.\n"); |
1418 | LOG (llevError, "Internal shop-mat problem.\n"); |
1422 | } |
1419 | } |
1423 | else |
1420 | else |
1424 | { |
1421 | { |
1425 | remove_ob (op); |
1422 | op->remove (); |
1426 | op->x += freearr_x[i]; |
1423 | op->x += freearr_x[i]; |
1427 | op->y += freearr_y[i]; |
1424 | op->y += freearr_y[i]; |
1428 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1425 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1429 | } |
1426 | } |
1430 | } |
1427 | } |
… | |
… | |
1853 | } |
1850 | } |
1854 | return; |
1851 | return; |
1855 | } |
1852 | } |
1856 | |
1853 | |
1857 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1854 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1858 | tmp = get_object (); |
1855 | tmp = spell->clone (); |
1859 | copy_object (spell, tmp); |
|
|
1860 | insert_ob_in_ob (tmp, op); |
1856 | insert_ob_in_ob (tmp, op); |
1861 | |
1857 | |
1862 | if (special_prayer) |
1858 | if (special_prayer) |
1863 | { |
|
|
1864 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1859 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1865 | } |
|
|
1866 | |
1860 | |
1867 | esrv_add_spells (op->contr, tmp); |
1861 | esrv_add_spells (op->contr, tmp); |
1868 | } |
1862 | } |
1869 | |
1863 | |
1870 | /** |
1864 | /** |
… | |
… | |
1887 | } |
1881 | } |
1888 | |
1882 | |
1889 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1883 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1890 | player_unready_range_ob (op->contr, spob); |
1884 | player_unready_range_ob (op->contr, spob); |
1891 | esrv_remove_spell (op->contr, spob); |
1885 | esrv_remove_spell (op->contr, spob); |
1892 | remove_ob (spob); |
1886 | spob->destroy (); |
1893 | free_object (spob); |
|
|
1894 | } |
1887 | } |
1895 | |
1888 | |
1896 | /** |
1889 | /** |
1897 | * Handles player applying a spellbook. |
1890 | * Handles player applying a spellbook. |
1898 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
1891 | * 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."); |
1929 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1937 | return; |
1930 | return; |
1938 | } |
1931 | } |
1939 | |
1932 | |
1940 | spell = tmp->inv; |
1933 | spell = tmp->inv; |
|
|
1934 | |
1941 | if (!spell) |
1935 | if (!spell) |
1942 | { |
1936 | { |
1943 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1937 | 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."); |
1938 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1945 | return; |
1939 | return; |
1946 | } |
1940 | } |
1947 | |
1941 | |
1948 | if (spell->level > (skop->level + 10)) |
1942 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1949 | { |
1943 | { |
1950 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1944 | new_draw_info (NDI_UNIQUE, 0, op, "It is too hard to read at your level: You are unable to decipher the strange symbols."); |
1951 | return; |
1945 | return; |
1952 | } |
1946 | } |
1953 | |
1947 | |
1954 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1948 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1955 | |
1949 | |
… | |
… | |
2103 | } |
2097 | } |
2104 | while (tmp->inv) |
2098 | while (tmp->inv) |
2105 | { |
2099 | { |
2106 | treas = tmp->inv; |
2100 | treas = tmp->inv; |
2107 | |
2101 | |
2108 | remove_ob (treas); |
2102 | treas->remove (); |
2109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2103 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2110 | |
2104 | |
2111 | treas->x = op->x; |
2105 | treas->x = op->x; |
2112 | treas->y = op->y; |
2106 | treas->y = op->y; |
2113 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2107 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2114 | |
2108 | |
2115 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2109 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2116 | spring_trap (treas, op); |
2110 | spring_trap (treas, op); |
|
|
2111 | |
2117 | /* If either player or container was destroyed, no need to do |
2112 | /* If either player or container was destroyed, no need to do |
2118 | * further processing. I think this should be enclused with |
2113 | * further processing. I think this should be enclused with |
2119 | * spring trap above, as I don't think there is otherwise |
2114 | * spring trap above, as I don't think there is otherwise |
2120 | * any way for the treasure chest or player to get killed |
2115 | * any way for the treasure chest or player to get killed |
2121 | */ |
2116 | */ |
… | |
… | |
2368 | } |
2363 | } |
2369 | #endif |
2364 | #endif |
2370 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2365 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2371 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2366 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2372 | terminate_all_pets (pl); |
2367 | terminate_all_pets (pl); |
2373 | remove_ob (pl); |
2368 | pl->remove (); |
2374 | pl->direction = 0; |
2369 | pl->direction = 0; |
2375 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2370 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2376 | |
2371 | |
2377 | /* update respawn position */ |
2372 | /* update respawn position */ |
2378 | strcpy (pl->contr->savebed_map, pl->map->path); |
2373 | strcpy (pl->contr->savebed_map, pl->map->path); |
… | |
… | |
2808 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2803 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2809 | { |
2804 | { |
2810 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2805 | 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!"); |
2806 | 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."); |
2807 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2813 | remove_ob (op); |
2808 | op->destroy (); |
2814 | free_object (op); |
|
|
2815 | return 1; |
2809 | return 1; |
2816 | } |
2810 | } |
2817 | |
2811 | |
2818 | pl->contr->last_used = op; |
2812 | pl->contr->last_used = op; |
2819 | pl->contr->last_used_id = op->count; |
2813 | pl->contr->last_used_id = op->count; |
… | |
… | |
2953 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2947 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2954 | |
2948 | |
2955 | if (who->type == PLAYER) |
2949 | if (who->type == PLAYER) |
2956 | esrv_del_item (who->contr, op->count); |
2950 | esrv_del_item (who->contr, op->count); |
2957 | |
2951 | |
2958 | remove_ob (op); |
2952 | op->destroy (); |
2959 | free_object (op); |
|
|
2960 | insert_ob_in_ob (tmp2, who); |
2953 | insert_ob_in_ob (tmp2, who); |
2961 | fix_player (who); |
2954 | fix_player (who); |
2962 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2955 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2963 | { |
2956 | { |
2964 | if (who->type == PLAYER) |
2957 | if (who->type == PLAYER) |
… | |
… | |
3489 | |
3482 | |
3490 | /* Remove the old lantern */ |
3483 | /* Remove the old lantern */ |
3491 | if (who->type == PLAYER) |
3484 | if (who->type == PLAYER) |
3492 | esrv_del_item (who->contr, op->count); |
3485 | esrv_del_item (who->contr, op->count); |
3493 | |
3486 | |
3494 | remove_ob (op); |
3487 | op->destroy (); |
3495 | free_object (op); |
|
|
3496 | |
3488 | |
3497 | /* insert the portion that was split off */ |
3489 | /* insert the portion that was split off */ |
3498 | if (tmp != NULL) |
3490 | if (tmp != NULL) |
3499 | { |
3491 | { |
3500 | (void) insert_ob_in_ob (tmp, who); |
3492 | (void) insert_ob_in_ob (tmp, who); |
… | |
… | |
3658 | switch (op->type) |
3650 | switch (op->type) |
3659 | { |
3651 | { |
3660 | case SHOP_FLOOR: |
3652 | case SHOP_FLOOR: |
3661 | if (!HAS_RANDOM_ITEMS (op)) |
3653 | if (!HAS_RANDOM_ITEMS (op)) |
3662 | return 0; |
3654 | return 0; |
|
|
3655 | |
3663 | do |
3656 | do |
3664 | { |
3657 | { |
3665 | i = 10; /* let's give it 10 tries */ |
3658 | i = 10; /* let's give it 10 tries */ |
3666 | while ((tmp = generate_treasure (op->randomitems, |
3659 | while ((tmp = generate_treasure (op->randomitems, |
3667 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3660 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3668 | if (tmp == NULL) |
3661 | if (tmp == NULL) |
3669 | return 0; |
3662 | return 0; |
3670 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3663 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3671 | { |
3664 | { |
3672 | free_object (tmp); |
3665 | tmp->destroy (); |
3673 | tmp = NULL; |
3666 | tmp = NULL; |
3674 | } |
3667 | } |
3675 | } |
3668 | } |
3676 | while (!tmp); |
3669 | while (!tmp); |
|
|
3670 | |
3677 | tmp->x = op->x; |
3671 | tmp->x = op->x; |
3678 | tmp->y = op->y; |
3672 | tmp->y = op->y; |
3679 | SET_FLAG (tmp, FLAG_UNPAID); |
3673 | SET_FLAG (tmp, FLAG_UNPAID); |
3680 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3674 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3681 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3675 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
… | |
… | |
3683 | break; |
3677 | break; |
3684 | |
3678 | |
3685 | case TREASURE: |
3679 | case TREASURE: |
3686 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3680 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3687 | return 0; |
3681 | return 0; |
|
|
3682 | |
3688 | while ((op->stats.hp--) > 0) |
3683 | while ((op->stats.hp--) > 0) |
3689 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3684 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3690 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3685 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3691 | |
3686 | |
3692 | /* If we generated an object and put it in this object inventory, |
3687 | /* If we generated an object and put it in this object inventory, |
… | |
… | |
3695 | * that is put inside other objects. |
3690 | * that is put inside other objects. |
3696 | */ |
3691 | */ |
3697 | for (tmp = op->inv; tmp; tmp = tmp2) |
3692 | for (tmp = op->inv; tmp; tmp = tmp2) |
3698 | { |
3693 | { |
3699 | tmp2 = tmp->below; |
3694 | tmp2 = tmp->below; |
3700 | remove_ob (tmp); |
3695 | tmp->remove (); |
|
|
3696 | |
3701 | if (op->env) |
3697 | if (op->env) |
3702 | insert_ob_in_ob (tmp, op->env); |
3698 | insert_ob_in_ob (tmp, op->env); |
3703 | else |
3699 | else |
3704 | free_object (tmp); |
3700 | tmp->destroy (); |
3705 | } |
3701 | } |
3706 | remove_ob (op); |
3702 | |
3707 | free_object (op); |
3703 | op->destroy (); |
3708 | break; |
3704 | break; |
3709 | } |
3705 | } |
3710 | return tmp ? 1 : 0; |
3706 | return tmp ? 1 : 0; |
3711 | } |
3707 | } |
3712 | |
3708 | |
… | |
… | |
3860 | SET_FLAG (force, FLAG_APPLIED); |
3856 | SET_FLAG (force, FLAG_APPLIED); |
3861 | change_abil (who, force); |
3857 | change_abil (who, force); |
3862 | insert_ob_in_ob (force, who); |
3858 | insert_ob_in_ob (force, who); |
3863 | } |
3859 | } |
3864 | else |
3860 | else |
3865 | { |
3861 | force->destroy (); |
3866 | free_object (force); |
|
|
3867 | } |
|
|
3868 | |
3862 | |
3869 | /* check for hp, sp change */ |
3863 | /* check for hp, sp change */ |
3870 | if (food->stats.hp != 0) |
3864 | if (food->stats.hp != 0) |
3871 | { |
3865 | { |
3872 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3866 | if (QUERY_FLAG (food, FLAG_CURSED)) |
… | |
… | |
3924 | { /* lighter gets used up */ |
3918 | { /* lighter gets used up */ |
3925 | /* Split multiple lighters if they're being used up. Otherwise * |
3919 | /* Split multiple lighters if they're being used up. Otherwise * |
3926 | * one charge from each would be used up. --DAMN */ |
3920 | * one charge from each would be used up. --DAMN */ |
3927 | if (lighter->nrof > 1) |
3921 | if (lighter->nrof > 1) |
3928 | { |
3922 | { |
3929 | object *oneLighter = get_object (); |
3923 | object *oneLighter = lighter->clone (); |
3930 | |
3924 | |
3931 | copy_object (lighter, oneLighter); |
|
|
3932 | lighter->nrof -= 1; |
3925 | lighter->nrof -= 1; |
3933 | oneLighter->nrof = 1; |
3926 | oneLighter->nrof = 1; |
3934 | oneLighter->stats.food--; |
3927 | oneLighter->stats.food--; |
3935 | esrv_send_item (who, lighter); |
3928 | esrv_send_item (who, lighter); |
3936 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3929 | oneLighter = insert_ob_in_ob (oneLighter, who); |
… | |
… | |
3992 | object *tmp; |
3985 | object *tmp; |
3993 | |
3986 | |
3994 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3987 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3995 | tmp = get_archetype (SPELL_WONDER); |
3988 | tmp = get_archetype (SPELL_WONDER); |
3996 | cast_wonder (op, op, 0, tmp); |
3989 | cast_wonder (op, op, 0, tmp); |
3997 | free_object (tmp); |
3990 | tmp->destroy (); |
3998 | } |
3991 | } |
3999 | else if (failure <= -15 && failure > -35) |
3992 | else if (failure <= -15 && failure > -35) |
4000 | { /* drain mana */ |
3993 | { /* drain mana */ |
4001 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
3994 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
4002 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3995 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
… | |
… | |
4025 | object *tmp; |
4018 | object *tmp; |
4026 | |
4019 | |
4027 | tmp = get_archetype (LOOSE_MANA); |
4020 | tmp = get_archetype (LOOSE_MANA); |
4028 | cast_magic_storm (op, tmp, power); |
4021 | cast_magic_storm (op, tmp, power); |
4029 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4022 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4030 | free_object (tmp); |
4023 | tmp->destroy (); |
4031 | } |
4024 | } |
4032 | } |
4025 | } |
4033 | } |
4026 | } |
4034 | |
4027 | |
4035 | void |
4028 | void |