… | |
… | |
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 = object::create (); |
1859 | copy_object (spell, tmp); |
1856 | spell->copy_to (tmp); |
1860 | insert_ob_in_ob (tmp, op); |
1857 | insert_ob_in_ob (tmp, op); |
1861 | |
1858 | |
1862 | if (special_prayer) |
1859 | if (special_prayer) |
1863 | { |
1860 | { |
1864 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1861 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
… | |
… | |
1887 | } |
1884 | } |
1888 | |
1885 | |
1889 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1886 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1890 | player_unready_range_ob (op->contr, spob); |
1887 | player_unready_range_ob (op->contr, spob); |
1891 | esrv_remove_spell (op->contr, spob); |
1888 | esrv_remove_spell (op->contr, spob); |
1892 | remove_ob (spob); |
1889 | spob->destroy (); |
1893 | free_object (spob); |
|
|
1894 | } |
1890 | } |
1895 | |
1891 | |
1896 | /** |
1892 | /** |
1897 | * Handles player applying a spellbook. |
1893 | * Handles player applying a spellbook. |
1898 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
1894 | * 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."); |
1932 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1937 | return; |
1933 | return; |
1938 | } |
1934 | } |
1939 | |
1935 | |
1940 | spell = tmp->inv; |
1936 | spell = tmp->inv; |
|
|
1937 | |
1941 | if (!spell) |
1938 | if (!spell) |
1942 | { |
1939 | { |
1943 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1940 | 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."); |
1941 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1945 | return; |
1942 | return; |
1946 | } |
1943 | } |
1947 | if (spell->level > (skop->level + 10)) |
1944 | |
|
|
1945 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1948 | { |
1946 | { |
1949 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1947 | 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; |
1948 | return; |
1951 | } |
1949 | } |
1952 | |
1950 | |
1953 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1951 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1954 | |
1952 | |
… | |
… | |
2082 | */ |
2080 | */ |
2083 | static void |
2081 | static void |
2084 | apply_treasure (object *op, object *tmp) |
2082 | apply_treasure (object *op, object *tmp) |
2085 | { |
2083 | { |
2086 | object *treas; |
2084 | object *treas; |
2087 | tag_t tmp_tag = tmp->count, op_tag = op->count; |
|
|
2088 | |
2085 | |
2089 | |
2086 | |
2090 | /* Nice side effect of new treasure creation method is that the treasure |
2087 | /* 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 |
2088 | * 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 |
2089 | * inventory. So that when the chest burns up, the items still exist. Also |
… | |
… | |
2103 | } |
2100 | } |
2104 | while (tmp->inv) |
2101 | while (tmp->inv) |
2105 | { |
2102 | { |
2106 | treas = tmp->inv; |
2103 | treas = tmp->inv; |
2107 | |
2104 | |
2108 | remove_ob (treas); |
2105 | treas->remove (); |
2109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2106 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2110 | |
2107 | |
2111 | treas->x = op->x; |
2108 | treas->x = op->x; |
2112 | treas->y = op->y; |
2109 | treas->y = op->y; |
2113 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2110 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2114 | |
2111 | |
2115 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2112 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2116 | spring_trap (treas, op); |
2113 | spring_trap (treas, op); |
|
|
2114 | |
2117 | /* If either player or container was destroyed, no need to do |
2115 | /* If either player or container was destroyed, no need to do |
2118 | * further processing. I think this should be enclused with |
2116 | * further processing. I think this should be enclused with |
2119 | * spring trap above, as I don't think there is otherwise |
2117 | * spring trap above, as I don't think there is otherwise |
2120 | * any way for the treasure chest or player to get killed |
2118 | * any way for the treasure chest or player to get killed |
2121 | */ |
2119 | */ |
2122 | if (was_destroyed (op, op_tag) || was_destroyed (tmp, tmp_tag)) |
2120 | if (op->destroyed () || tmp->destroyed ()) |
2123 | break; |
2121 | break; |
2124 | } |
2122 | } |
2125 | |
2123 | |
2126 | if (!was_destroyed (tmp, tmp_tag) && tmp->inv == NULL) |
2124 | if (!tmp->destroyed () && tmp->inv == NULL) |
2127 | decrease_ob (tmp); |
2125 | decrease_ob (tmp); |
2128 | |
2126 | |
2129 | } |
2127 | } |
2130 | |
2128 | |
2131 | /** |
2129 | /** |
… | |
… | |
2368 | } |
2366 | } |
2369 | #endif |
2367 | #endif |
2370 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2368 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2371 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2369 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2372 | terminate_all_pets (pl); |
2370 | terminate_all_pets (pl); |
2373 | remove_ob (pl); |
2371 | pl->remove (); |
2374 | pl->direction = 0; |
2372 | pl->direction = 0; |
2375 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2373 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2376 | |
2374 | |
2377 | /* update respawn position */ |
2375 | /* update respawn position */ |
2378 | strcpy (pl->contr->savebed_map, pl->map->path); |
2376 | strcpy (pl->contr->savebed_map, pl->map->path); |
… | |
… | |
2459 | is_legal_2ways_exit (object *op, object *exit) |
2457 | is_legal_2ways_exit (object *op, object *exit) |
2460 | { |
2458 | { |
2461 | object *tmp; |
2459 | object *tmp; |
2462 | object *exit_owner; |
2460 | object *exit_owner; |
2463 | player *pp; |
2461 | player *pp; |
2464 | mapstruct *exitmap; |
2462 | maptile *exitmap; |
2465 | |
2463 | |
2466 | if (exit->stats.exp != 1) |
2464 | if (exit->stats.exp != 1) |
2467 | return 1; /*This is not a 2 way, so it is legal */ |
2465 | return 1; /*This is not a 2 way, so it is legal */ |
2468 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2466 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2469 | return 0; /* This is a reset town portal */ |
2467 | return 0; /* This is a reset town portal */ |
… | |
… | |
2808 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2806 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2809 | { |
2807 | { |
2810 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2808 | 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!"); |
2809 | 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."); |
2810 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2813 | remove_ob (op); |
2811 | op->destroy (); |
2814 | free_object (op); |
|
|
2815 | return 1; |
2812 | return 1; |
2816 | } |
2813 | } |
2817 | |
2814 | |
2818 | pl->contr->last_used = op; |
2815 | pl->contr->last_used = op; |
2819 | pl->contr->last_used_id = op->count; |
2816 | pl->contr->last_used_id = op->count; |
… | |
… | |
2946 | tmp2->map = op->map; |
2943 | tmp2->map = op->map; |
2947 | tmp2->below = op->below; |
2944 | tmp2->below = op->below; |
2948 | tmp2->above = op->above; |
2945 | tmp2->above = op->above; |
2949 | tmp2->stats.food = op->stats.food; |
2946 | tmp2->stats.food = op->stats.food; |
2950 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2947 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
|
|
2948 | |
2951 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2949 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2952 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2950 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
|
|
2951 | |
2953 | if (who->type == PLAYER) |
2952 | if (who->type == PLAYER) |
2954 | esrv_del_item (who->contr, (tag_t) op->count); |
2953 | esrv_del_item (who->contr, op->count); |
2955 | remove_ob (op); |
2954 | |
2956 | free_object (op); |
2955 | op->destroy (); |
2957 | insert_ob_in_ob (tmp2, who); |
2956 | insert_ob_in_ob (tmp2, who); |
2958 | fix_player (who); |
2957 | fix_player (who); |
2959 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2958 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2960 | { |
2959 | { |
2961 | if (who->type == PLAYER) |
2960 | if (who->type == PLAYER) |
… | |
… | |
3002 | |
3001 | |
3003 | if (!(aflags & AP_NO_MERGE)) |
3002 | if (!(aflags & AP_NO_MERGE)) |
3004 | { |
3003 | { |
3005 | object *tmp; |
3004 | object *tmp; |
3006 | |
3005 | |
3007 | tag_t del_tag = op->count; |
|
|
3008 | |
|
|
3009 | tmp = merge_ob (op, NULL); |
3006 | tmp = merge_ob (op, NULL); |
3010 | if (who->type == PLAYER) |
3007 | if (who->type == PLAYER) |
3011 | { |
3008 | { |
3012 | if (tmp) |
3009 | if (tmp) |
3013 | { /* it was merged */ |
3010 | { /* it was merged */ |
3014 | esrv_del_item (who->contr, del_tag); |
3011 | esrv_del_item (who->contr, op->count); |
3015 | op = tmp; |
3012 | op = tmp; |
3016 | } |
3013 | } |
|
|
3014 | |
3017 | esrv_send_item (who, op); |
3015 | esrv_send_item (who, op); |
3018 | } |
3016 | } |
3019 | } |
3017 | } |
3020 | return 0; |
3018 | return 0; |
3021 | } |
3019 | } |
… | |
… | |
3485 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3483 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3486 | insert_ob_in_ob (tmp2, who); |
3484 | insert_ob_in_ob (tmp2, who); |
3487 | |
3485 | |
3488 | /* Remove the old lantern */ |
3486 | /* Remove the old lantern */ |
3489 | if (who->type == PLAYER) |
3487 | if (who->type == PLAYER) |
3490 | esrv_del_item (who->contr, (tag_t) op->count); |
3488 | esrv_del_item (who->contr, op->count); |
3491 | remove_ob (op); |
3489 | |
3492 | free_object (op); |
3490 | op->destroy (); |
3493 | |
3491 | |
3494 | /* insert the portion that was split off */ |
3492 | /* insert the portion that was split off */ |
3495 | if (tmp != NULL) |
3493 | if (tmp != NULL) |
3496 | { |
3494 | { |
3497 | (void) insert_ob_in_ob (tmp, who); |
3495 | (void) insert_ob_in_ob (tmp, who); |
… | |
… | |
3655 | switch (op->type) |
3653 | switch (op->type) |
3656 | { |
3654 | { |
3657 | case SHOP_FLOOR: |
3655 | case SHOP_FLOOR: |
3658 | if (!HAS_RANDOM_ITEMS (op)) |
3656 | if (!HAS_RANDOM_ITEMS (op)) |
3659 | return 0; |
3657 | return 0; |
|
|
3658 | |
3660 | do |
3659 | do |
3661 | { |
3660 | { |
3662 | i = 10; /* let's give it 10 tries */ |
3661 | i = 10; /* let's give it 10 tries */ |
3663 | while ((tmp = generate_treasure (op->randomitems, |
3662 | while ((tmp = generate_treasure (op->randomitems, |
3664 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3663 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3665 | if (tmp == NULL) |
3664 | if (tmp == NULL) |
3666 | return 0; |
3665 | return 0; |
3667 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3666 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3668 | { |
3667 | { |
3669 | free_object (tmp); |
3668 | tmp->destroy (); |
3670 | tmp = NULL; |
3669 | tmp = NULL; |
3671 | } |
3670 | } |
3672 | } |
3671 | } |
3673 | while (!tmp); |
3672 | while (!tmp); |
|
|
3673 | |
3674 | tmp->x = op->x; |
3674 | tmp->x = op->x; |
3675 | tmp->y = op->y; |
3675 | tmp->y = op->y; |
3676 | SET_FLAG (tmp, FLAG_UNPAID); |
3676 | SET_FLAG (tmp, FLAG_UNPAID); |
3677 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3677 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3678 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3678 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
… | |
… | |
3680 | break; |
3680 | break; |
3681 | |
3681 | |
3682 | case TREASURE: |
3682 | case TREASURE: |
3683 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3683 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3684 | return 0; |
3684 | return 0; |
|
|
3685 | |
3685 | while ((op->stats.hp--) > 0) |
3686 | while ((op->stats.hp--) > 0) |
3686 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3687 | 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); |
3688 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3688 | |
3689 | |
3689 | /* If we generated an object and put it in this object inventory, |
3690 | /* If we generated an object and put it in this object inventory, |
… | |
… | |
3692 | * that is put inside other objects. |
3693 | * that is put inside other objects. |
3693 | */ |
3694 | */ |
3694 | for (tmp = op->inv; tmp; tmp = tmp2) |
3695 | for (tmp = op->inv; tmp; tmp = tmp2) |
3695 | { |
3696 | { |
3696 | tmp2 = tmp->below; |
3697 | tmp2 = tmp->below; |
3697 | remove_ob (tmp); |
3698 | tmp->remove (); |
|
|
3699 | |
3698 | if (op->env) |
3700 | if (op->env) |
3699 | insert_ob_in_ob (tmp, op->env); |
3701 | insert_ob_in_ob (tmp, op->env); |
3700 | else |
3702 | else |
3701 | free_object (tmp); |
3703 | tmp->destroy (); |
3702 | } |
3704 | } |
3703 | remove_ob (op); |
3705 | |
3704 | free_object (op); |
3706 | op->destroy (); |
3705 | break; |
3707 | break; |
3706 | } |
3708 | } |
3707 | return tmp ? 1 : 0; |
3709 | return tmp ? 1 : 0; |
3708 | } |
3710 | } |
3709 | |
3711 | |
… | |
… | |
3712 | * when an original map is loaded) and performs special actions for |
3714 | * when an original map is loaded) and performs special actions for |
3713 | * certain objects (most initialization of chests and creation of |
3715 | * certain objects (most initialization of chests and creation of |
3714 | * treasures and stuff). Calls auto_apply if appropriate. |
3716 | * treasures and stuff). Calls auto_apply if appropriate. |
3715 | */ |
3717 | */ |
3716 | void |
3718 | void |
3717 | fix_auto_apply (mapstruct *m) |
3719 | fix_auto_apply (maptile *m) |
3718 | { |
3720 | { |
3719 | object *tmp, *above = NULL; |
3721 | object *tmp, *above = NULL; |
3720 | int x, y; |
3722 | int x, y; |
3721 | |
3723 | |
3722 | if (m == NULL) |
3724 | if (m == NULL) |
… | |
… | |
3857 | SET_FLAG (force, FLAG_APPLIED); |
3859 | SET_FLAG (force, FLAG_APPLIED); |
3858 | change_abil (who, force); |
3860 | change_abil (who, force); |
3859 | insert_ob_in_ob (force, who); |
3861 | insert_ob_in_ob (force, who); |
3860 | } |
3862 | } |
3861 | else |
3863 | else |
3862 | { |
3864 | force->destroy (); |
3863 | free_object (force); |
|
|
3864 | } |
|
|
3865 | |
3865 | |
3866 | /* check for hp, sp change */ |
3866 | /* check for hp, sp change */ |
3867 | if (food->stats.hp != 0) |
3867 | if (food->stats.hp != 0) |
3868 | { |
3868 | { |
3869 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3869 | if (QUERY_FLAG (food, FLAG_CURSED)) |
… | |
… | |
3910 | void |
3910 | void |
3911 | apply_lighter (object *who, object *lighter) |
3911 | apply_lighter (object *who, object *lighter) |
3912 | { |
3912 | { |
3913 | object *item; |
3913 | object *item; |
3914 | int is_player_env = 0; |
3914 | int is_player_env = 0; |
3915 | uint32 nrof; |
|
|
3916 | tag_t count; |
|
|
3917 | char item_name[MAX_BUF]; |
3915 | char item_name[MAX_BUF]; |
3918 | |
3916 | |
3919 | item = find_marked_object (who); |
3917 | item = find_marked_object (who); |
3920 | if (item) |
3918 | if (item) |
3921 | { |
3919 | { |
… | |
… | |
3923 | { /* lighter gets used up */ |
3921 | { /* lighter gets used up */ |
3924 | /* Split multiple lighters if they're being used up. Otherwise * |
3922 | /* Split multiple lighters if they're being used up. Otherwise * |
3925 | * one charge from each would be used up. --DAMN */ |
3923 | * one charge from each would be used up. --DAMN */ |
3926 | if (lighter->nrof > 1) |
3924 | if (lighter->nrof > 1) |
3927 | { |
3925 | { |
3928 | object *oneLighter = get_object (); |
3926 | object *oneLighter = object::create (); |
3929 | |
3927 | |
3930 | copy_object (lighter, oneLighter); |
3928 | lighter->copy_to (oneLighter); |
3931 | lighter->nrof -= 1; |
3929 | lighter->nrof -= 1; |
3932 | oneLighter->nrof = 1; |
3930 | oneLighter->nrof = 1; |
3933 | oneLighter->stats.food--; |
3931 | oneLighter->stats.food--; |
3934 | esrv_send_item (who, lighter); |
3932 | esrv_send_item (who, lighter); |
3935 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3933 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3936 | esrv_send_item (who, oneLighter); |
3934 | esrv_send_item (who, oneLighter); |
3937 | } |
3935 | } |
3938 | else |
3936 | else |
3939 | { |
|
|
3940 | lighter->stats.food--; |
3937 | lighter->stats.food--; |
3941 | } |
|
|
3942 | |
|
|
3943 | } |
3938 | } |
3944 | else if (lighter->last_eat) |
3939 | else if (lighter->last_eat) |
3945 | { /* no charges left in lighter */ |
3940 | { /* 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); |
3941 | 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; |
3942 | return; |
3948 | } |
3943 | } |
3949 | /* Perhaps we should split what we are trying to light on fire? |
3944 | /* 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 |
3945 | * I can't see many times when you would want to light multiple |
3951 | * objects at once. |
3946 | * objects at once. |
3952 | */ |
3947 | */ |
3953 | nrof = item->nrof; |
|
|
3954 | count = item->count; |
|
|
3955 | /* If the item is destroyed, we don't have a valid pointer to the |
3948 | /* 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 |
3949 | * name object, so make a copy so the message we print out makes |
3957 | * some sense. |
3950 | * some sense. |
3958 | */ |
3951 | */ |
3959 | strcpy (item_name, item->name); |
3952 | strcpy (item_name, item->name); |
… | |
… | |
3962 | |
3955 | |
3963 | save_throw_object (item, AT_FIRE, who); |
3956 | save_throw_object (item, AT_FIRE, who); |
3964 | /* Change to check count and not freed, since the object pointer |
3957 | /* Change to check count and not freed, since the object pointer |
3965 | * may have gotten recycled |
3958 | * may have gotten recycled |
3966 | */ |
3959 | */ |
3967 | if ((nrof != item->nrof) || (count != item->count)) |
3960 | if (item->destroyed ()) |
3968 | { |
3961 | { |
3969 | new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); |
3962 | 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 |
3963 | /* Need to update the player so that the players glow radius |
3971 | * gets changed. |
3964 | * gets changed. |
3972 | */ |
3965 | */ |
3973 | if (is_player_env) |
3966 | if (is_player_env) |
3974 | fix_player (who); |
3967 | fix_player (who); |
3975 | } |
3968 | } |
3976 | else |
3969 | 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); |
3970 | 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 | } |
3971 | } |
3982 | else /* nothing to light */ |
3972 | else /* nothing to light */ |
3983 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3973 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3984 | |
3974 | |
3985 | } |
3975 | } |
… | |
… | |
3999 | object *tmp; |
3989 | object *tmp; |
4000 | |
3990 | |
4001 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3991 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
4002 | tmp = get_archetype (SPELL_WONDER); |
3992 | tmp = get_archetype (SPELL_WONDER); |
4003 | cast_wonder (op, op, 0, tmp); |
3993 | cast_wonder (op, op, 0, tmp); |
4004 | free_object (tmp); |
3994 | tmp->destroy (); |
4005 | } |
3995 | } |
4006 | else if (failure <= -15 && failure > -35) |
3996 | else if (failure <= -15 && failure > -35) |
4007 | { /* drain mana */ |
3997 | { /* drain mana */ |
4008 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
3998 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
4009 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3999 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
… | |
… | |
4032 | object *tmp; |
4022 | object *tmp; |
4033 | |
4023 | |
4034 | tmp = get_archetype (LOOSE_MANA); |
4024 | tmp = get_archetype (LOOSE_MANA); |
4035 | cast_magic_storm (op, tmp, power); |
4025 | cast_magic_storm (op, tmp, power); |
4036 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4026 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4037 | free_object (tmp); |
4027 | tmp->destroy (); |
4038 | } |
4028 | } |
4039 | } |
4029 | } |
4040 | } |
4030 | } |
4041 | |
4031 | |
4042 | void |
4032 | void |
… | |
… | |
4205 | if (!new_item) |
4195 | if (!new_item) |
4206 | { |
4196 | { |
4207 | new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); |
4197 | new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); |
4208 | return; |
4198 | return; |
4209 | } |
4199 | } |
|
|
4200 | |
4210 | new_item->nrof = yield; |
4201 | new_item->nrof = yield; |
4211 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4202 | 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); |
4203 | insert_ob_in_ob (new_item, pl); |
4213 | esrv_send_inventory (pl, pl); |
4204 | esrv_send_inventory (pl, pl); |
4214 | /* Eat up one item */ |
4205 | /* Eat up one item */ |