… | |
… | |
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 | |
1036 | op->contr->last_used_id = 0; |
1035 | op->contr->last_used = 0; |
1037 | |
1036 | |
1038 | if (sack->env != op) |
1037 | if (sack->env != op) |
1039 | { |
1038 | { |
1040 | if (sack->other_arch == NULL || sack->env != NULL) |
1039 | if (sack->other_arch == NULL || sack->env != NULL) |
1041 | { |
1040 | { |
1042 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1041 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1043 | return 1; |
1042 | return 1; |
1044 | } |
1043 | } |
|
|
1044 | |
1045 | /* It's on the ground, the problems begin */ |
1045 | /* It's on the ground, the problems begin */ |
1046 | if (op->container != sack) |
1046 | if (op->container != sack) |
1047 | { |
1047 | { |
1048 | /* it's closed OR some player has opened it */ |
1048 | /* it's closed OR some player has opened it */ |
1049 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1049 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
… | |
… | |
1076 | } |
1076 | } |
1077 | else |
1077 | else |
1078 | { |
1078 | { |
1079 | sack->move_off = 0; |
1079 | sack->move_off = 0; |
1080 | tmp = sack->inv; |
1080 | tmp = sack->inv; |
|
|
1081 | |
1081 | if (tmp && tmp->type == CLOSE_CON) |
1082 | if (tmp && tmp->type == CLOSE_CON) |
1082 | { |
1083 | tmp->destroy (); |
1083 | remove_ob (tmp); |
|
|
1084 | free_object (tmp); |
|
|
1085 | } |
|
|
1086 | } |
1084 | } |
1087 | } |
1085 | } |
1088 | } |
1086 | } |
1089 | |
1087 | |
1090 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1088 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
… | |
… | |
1146 | apply_container (op, sack); |
1144 | apply_container (op, sack); |
1147 | return 1; |
1145 | return 1; |
1148 | } |
1146 | } |
1149 | } |
1147 | } |
1150 | } |
1148 | } |
|
|
1149 | |
1151 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1150 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1151 | |
1152 | if (op->contr) |
1152 | if (op->contr) |
1153 | op->contr->socket.update_look = 1; |
1153 | op->contr->socket->floorbox_update (); |
|
|
1154 | |
1154 | return 1; |
1155 | return 1; |
1155 | } |
1156 | } |
1156 | |
1157 | |
1157 | /** |
1158 | /** |
1158 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
1159 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
… | |
… | |
1176 | if (op->type != PLAYER) |
1177 | if (op->type != PLAYER) |
1177 | return 0; /* This might change */ |
1178 | return 0; /* This might change */ |
1178 | |
1179 | |
1179 | if (sack == NULL || sack->type != CONTAINER) |
1180 | if (sack == NULL || sack->type != CONTAINER) |
1180 | { |
1181 | { |
1181 | LOG (llevError, "esrv_apply_container: %s is not container!\n", &sack->name); |
1182 | LOG (llevError, "esrv_apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1182 | return 0; |
1183 | return 0; |
1183 | } |
1184 | } |
1184 | |
1185 | |
1185 | /* If we have a currently open container, then it needs to be closed in all cases |
1186 | /* 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 |
1187 | * if we are opening this one up. We then fall through if appropriate for |
… | |
… | |
1346 | |
1347 | |
1347 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1348 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1348 | { |
1349 | { |
1349 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1350 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1350 | |
1351 | |
1351 | remove_ob (tmp); |
1352 | tmp->remove (); |
1352 | |
1353 | |
1353 | if (i == -1) |
1354 | if (i == -1) |
1354 | i = 0; |
1355 | i = 0; |
1355 | |
1356 | |
1356 | tmp->map = op->map; |
1357 | tmp->map = op->map; |
… | |
… | |
1420 | { |
1421 | { |
1421 | LOG (llevError, "Internal shop-mat problem.\n"); |
1422 | LOG (llevError, "Internal shop-mat problem.\n"); |
1422 | } |
1423 | } |
1423 | else |
1424 | else |
1424 | { |
1425 | { |
1425 | remove_ob (op); |
1426 | op->remove (); |
1426 | op->x += freearr_x[i]; |
1427 | op->x += freearr_x[i]; |
1427 | op->y += freearr_y[i]; |
1428 | op->y += freearr_y[i]; |
1428 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1429 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
1429 | } |
1430 | } |
1430 | } |
1431 | } |
… | |
… | |
1789 | |
1790 | |
1790 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1791 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1791 | { |
1792 | { |
1792 | /*exp_gain *= 2; because they just identified it too */ |
1793 | /*exp_gain *= 2; because they just identified it too */ |
1793 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1794 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
|
|
1795 | |
1794 | /* If in a container, update how it looks */ |
1796 | /* If in a container, update how it looks */ |
1795 | if (tmp->env) |
1797 | if (tmp->env) |
1796 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1798 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1797 | else |
1799 | else |
1798 | op->contr->socket.update_look = 1; |
1800 | op->contr->socket->floorbox_update (); |
1799 | } |
1801 | } |
|
|
1802 | |
1800 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1803 | 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 */ |
1804 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1802 | } |
1805 | } |
1803 | } |
1806 | } |
1804 | |
1807 | |
… | |
… | |
1853 | } |
1856 | } |
1854 | return; |
1857 | return; |
1855 | } |
1858 | } |
1856 | |
1859 | |
1857 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1860 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1858 | tmp = get_object (); |
1861 | tmp = spell->clone (); |
1859 | copy_object (spell, tmp); |
|
|
1860 | insert_ob_in_ob (tmp, op); |
1862 | insert_ob_in_ob (tmp, op); |
1861 | |
1863 | |
1862 | if (special_prayer) |
1864 | if (special_prayer) |
1863 | { |
|
|
1864 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1865 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1865 | } |
|
|
1866 | |
1866 | |
1867 | esrv_add_spells (op->contr, tmp); |
1867 | esrv_add_spells (op->contr, tmp); |
1868 | } |
1868 | } |
1869 | |
1869 | |
1870 | /** |
1870 | /** |
… | |
… | |
1887 | } |
1887 | } |
1888 | |
1888 | |
1889 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1889 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1890 | player_unready_range_ob (op->contr, spob); |
1890 | player_unready_range_ob (op->contr, spob); |
1891 | esrv_remove_spell (op->contr, spob); |
1891 | esrv_remove_spell (op->contr, spob); |
1892 | remove_ob (spob); |
1892 | spob->destroy (); |
1893 | free_object (spob); |
|
|
1894 | } |
1893 | } |
1895 | |
1894 | |
1896 | /** |
1895 | /** |
1897 | * Handles player applying a spellbook. |
1896 | * Handles player applying a spellbook. |
1898 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
1897 | * Checks whether player has knowledge of required skill, doesn't already know the spell, |
… | |
… | |
1955 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1954 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1956 | |
1955 | |
1957 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1956 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1958 | { |
1957 | { |
1959 | identify (tmp); |
1958 | identify (tmp); |
|
|
1959 | |
1960 | if (tmp->env) |
1960 | if (tmp->env) |
1961 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1961 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1962 | else |
1962 | else |
1963 | op->contr->socket.update_look = 1; |
1963 | op->contr->socket->floorbox_update (); |
1964 | } |
1964 | } |
1965 | |
1965 | |
1966 | /* I removed the check for special_prayer_mark here - it didn't make |
1966 | /* I removed the check for special_prayer_mark here - it didn't make |
1967 | * a lot of sense - special prayers are not found in spellbooks, and |
1967 | * a lot of sense - special prayers are not found in spellbooks, and |
1968 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1968 | * if the player doesn't know the spell, doesn't make a lot of sense that |
… | |
… | |
2104 | } |
2104 | } |
2105 | while (tmp->inv) |
2105 | while (tmp->inv) |
2106 | { |
2106 | { |
2107 | treas = tmp->inv; |
2107 | treas = tmp->inv; |
2108 | |
2108 | |
2109 | remove_ob (treas); |
2109 | treas->remove (); |
2110 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2110 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
2111 | |
2111 | |
2112 | treas->x = op->x; |
2112 | treas->x = op->x; |
2113 | treas->y = op->y; |
2113 | treas->y = op->y; |
2114 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2114 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2115 | |
2115 | |
2116 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2116 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2117 | spring_trap (treas, op); |
2117 | spring_trap (treas, op); |
|
|
2118 | |
2118 | /* If either player or container was destroyed, no need to do |
2119 | /* If either player or container was destroyed, no need to do |
2119 | * further processing. I think this should be enclused with |
2120 | * further processing. I think this should be enclused with |
2120 | * spring trap above, as I don't think there is otherwise |
2121 | * spring trap above, as I don't think there is otherwise |
2121 | * any way for the treasure chest or player to get killed |
2122 | * any way for the treasure chest or player to get killed |
2122 | */ |
2123 | */ |
… | |
… | |
2369 | } |
2370 | } |
2370 | #endif |
2371 | #endif |
2371 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2372 | INVOKE_PLAYER (LOGOUT, pl->contr); |
2372 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2373 | /* Need to call terminate_all_pets() before we remove the player ob */ |
2373 | terminate_all_pets (pl); |
2374 | terminate_all_pets (pl); |
2374 | remove_ob (pl); |
2375 | pl->remove (); |
2375 | pl->direction = 0; |
2376 | pl->direction = 0; |
2376 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2377 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, pl, "%s leaves the game.", &pl->name); |
2377 | |
2378 | |
2378 | /* update respawn position */ |
2379 | /* update respawn position */ |
2379 | strcpy (pl->contr->savebed_map, pl->map->path); |
2380 | strcpy (pl->contr->savebed_map, pl->map->path); |
… | |
… | |
2809 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2810 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
2810 | { |
2811 | { |
2811 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2812 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
2812 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!"); |
2813 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!"); |
2813 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2814 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
2814 | remove_ob (op); |
2815 | op->destroy (); |
2815 | free_object (op); |
|
|
2816 | return 1; |
2816 | return 1; |
2817 | } |
2817 | } |
2818 | |
2818 | |
2819 | pl->contr->last_used = op; |
2819 | pl->contr->last_used = op; |
2820 | pl->contr->last_used_id = op->count; |
|
|
2821 | |
2820 | |
2822 | tmp = manual_apply (pl, op, aflag); |
2821 | tmp = manual_apply (pl, op, aflag); |
2823 | if (!quiet) |
2822 | if (!quiet) |
2824 | { |
2823 | { |
2825 | if (tmp == 0) |
2824 | if (tmp == 0) |
… | |
… | |
2954 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2953 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2955 | |
2954 | |
2956 | if (who->type == PLAYER) |
2955 | if (who->type == PLAYER) |
2957 | esrv_del_item (who->contr, op->count); |
2956 | esrv_del_item (who->contr, op->count); |
2958 | |
2957 | |
2959 | remove_ob (op); |
2958 | op->destroy (); |
2960 | free_object (op); |
|
|
2961 | insert_ob_in_ob (tmp2, who); |
2959 | insert_ob_in_ob (tmp2, who); |
2962 | fix_player (who); |
2960 | fix_player (who); |
2963 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2961 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2964 | { |
2962 | { |
2965 | if (who->type == PLAYER) |
2963 | if (who->type == PLAYER) |
… | |
… | |
3490 | |
3488 | |
3491 | /* Remove the old lantern */ |
3489 | /* Remove the old lantern */ |
3492 | if (who->type == PLAYER) |
3490 | if (who->type == PLAYER) |
3493 | esrv_del_item (who->contr, op->count); |
3491 | esrv_del_item (who->contr, op->count); |
3494 | |
3492 | |
3495 | remove_ob (op); |
3493 | op->destroy (); |
3496 | free_object (op); |
|
|
3497 | |
3494 | |
3498 | /* insert the portion that was split off */ |
3495 | /* insert the portion that was split off */ |
3499 | if (tmp != NULL) |
3496 | if (tmp != NULL) |
3500 | { |
3497 | { |
3501 | (void) insert_ob_in_ob (tmp, who); |
3498 | (void) insert_ob_in_ob (tmp, who); |
… | |
… | |
3657 | int i; |
3654 | int i; |
3658 | |
3655 | |
3659 | switch (op->type) |
3656 | switch (op->type) |
3660 | { |
3657 | { |
3661 | case SHOP_FLOOR: |
3658 | case SHOP_FLOOR: |
3662 | if (!HAS_RANDOM_ITEMS (op)) |
3659 | if (!op->has_random_items ()) |
3663 | return 0; |
3660 | return 0; |
|
|
3661 | |
3664 | do |
3662 | do |
3665 | { |
3663 | { |
3666 | i = 10; /* let's give it 10 tries */ |
3664 | i = 10; /* let's give it 10 tries */ |
3667 | while ((tmp = generate_treasure (op->randomitems, |
3665 | while ((tmp = generate_treasure (op->randomitems, |
3668 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3666 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3669 | if (tmp == NULL) |
3667 | if (tmp == NULL) |
3670 | return 0; |
3668 | return 0; |
3671 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3669 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3672 | { |
3670 | { |
3673 | free_object (tmp); |
3671 | tmp->destroy (); |
3674 | tmp = NULL; |
3672 | tmp = NULL; |
3675 | } |
3673 | } |
3676 | } |
3674 | } |
3677 | while (!tmp); |
3675 | while (!tmp); |
|
|
3676 | |
3678 | tmp->x = op->x; |
3677 | tmp->x = op->x; |
3679 | tmp->y = op->y; |
3678 | tmp->y = op->y; |
3680 | SET_FLAG (tmp, FLAG_UNPAID); |
3679 | SET_FLAG (tmp, FLAG_UNPAID); |
3681 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3680 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3682 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3681 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
… | |
… | |
3684 | break; |
3683 | break; |
3685 | |
3684 | |
3686 | case TREASURE: |
3685 | case TREASURE: |
3687 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3686 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3688 | return 0; |
3687 | return 0; |
|
|
3688 | |
3689 | while ((op->stats.hp--) > 0) |
3689 | while ((op->stats.hp--) > 0) |
3690 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3690 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3691 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3691 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3692 | |
3692 | |
3693 | /* If we generated an object and put it in this object inventory, |
3693 | /* If we generated an object and put it in this object inventory, |
… | |
… | |
3696 | * that is put inside other objects. |
3696 | * that is put inside other objects. |
3697 | */ |
3697 | */ |
3698 | for (tmp = op->inv; tmp; tmp = tmp2) |
3698 | for (tmp = op->inv; tmp; tmp = tmp2) |
3699 | { |
3699 | { |
3700 | tmp2 = tmp->below; |
3700 | tmp2 = tmp->below; |
3701 | remove_ob (tmp); |
3701 | tmp->remove (); |
|
|
3702 | |
3702 | if (op->env) |
3703 | if (op->env) |
3703 | insert_ob_in_ob (tmp, op->env); |
3704 | insert_ob_in_ob (tmp, op->env); |
3704 | else |
3705 | else |
3705 | free_object (tmp); |
3706 | tmp->destroy (); |
3706 | } |
3707 | } |
3707 | remove_ob (op); |
3708 | |
3708 | free_object (op); |
3709 | op->destroy (); |
3709 | break; |
3710 | break; |
3710 | } |
3711 | } |
3711 | return tmp ? 1 : 0; |
3712 | return tmp ? 1 : 0; |
3712 | } |
3713 | } |
3713 | |
3714 | |
… | |
… | |
3740 | { |
3741 | { |
3741 | invnext = invtmp->below; |
3742 | invnext = invtmp->below; |
3742 | |
3743 | |
3743 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3744 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3744 | auto_apply (invtmp); |
3745 | auto_apply (invtmp); |
3745 | else if (invtmp->type == TREASURE && HAS_RANDOM_ITEMS (invtmp)) |
3746 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3746 | { |
3747 | { |
3747 | while ((invtmp->stats.hp--) > 0) |
3748 | while ((invtmp->stats.hp--) > 0) |
3748 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3749 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3749 | |
3750 | |
3750 | invtmp->randomitems = NULL; |
3751 | invtmp->randomitems = NULL; |
3751 | } |
3752 | } |
3752 | else if (invtmp && invtmp->arch |
3753 | else if (invtmp && invtmp->arch |
3753 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && HAS_RANDOM_ITEMS (invtmp)) |
3754 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3754 | { |
3755 | { |
3755 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3756 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3756 | /* Need to clear this so that we never try to create |
3757 | /* Need to clear this so that we never try to create |
3757 | * treasure again for this object |
3758 | * treasure again for this object |
3758 | */ |
3759 | */ |
… | |
… | |
3775 | |
3776 | |
3776 | } |
3777 | } |
3777 | |
3778 | |
3778 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3779 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3779 | auto_apply (tmp); |
3780 | auto_apply (tmp); |
3780 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && HAS_RANDOM_ITEMS (tmp)) |
3781 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3781 | { |
3782 | { |
3782 | while ((tmp->stats.hp--) > 0) |
3783 | while ((tmp->stats.hp--) > 0) |
3783 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3784 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3784 | tmp->randomitems = NULL; |
3785 | tmp->randomitems = NULL; |
3785 | } |
3786 | } |
… | |
… | |
3800 | * This is a problem for the above objects, because they have counters |
3801 | * This is a problem for the above objects, because they have counters |
3801 | * which say how many times to make the treasure. |
3802 | * which say how many times to make the treasure. |
3802 | */ |
3803 | */ |
3803 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3804 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3804 | && tmp->type != TREASURE && tmp->type != SPELL |
3805 | && tmp->type != TREASURE && tmp->type != SPELL |
3805 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && HAS_RANDOM_ITEMS (tmp)) |
3806 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) |
3806 | { |
3807 | { |
3807 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3808 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3808 | tmp->randomitems = NULL; |
3809 | tmp->randomitems = NULL; |
3809 | } |
3810 | } |
3810 | } |
3811 | } |
… | |
… | |
3861 | SET_FLAG (force, FLAG_APPLIED); |
3862 | SET_FLAG (force, FLAG_APPLIED); |
3862 | change_abil (who, force); |
3863 | change_abil (who, force); |
3863 | insert_ob_in_ob (force, who); |
3864 | insert_ob_in_ob (force, who); |
3864 | } |
3865 | } |
3865 | else |
3866 | else |
3866 | { |
3867 | force->destroy (); |
3867 | free_object (force); |
|
|
3868 | } |
|
|
3869 | |
3868 | |
3870 | /* check for hp, sp change */ |
3869 | /* check for hp, sp change */ |
3871 | if (food->stats.hp != 0) |
3870 | if (food->stats.hp != 0) |
3872 | { |
3871 | { |
3873 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3872 | if (QUERY_FLAG (food, FLAG_CURSED)) |
… | |
… | |
3925 | { /* lighter gets used up */ |
3924 | { /* lighter gets used up */ |
3926 | /* Split multiple lighters if they're being used up. Otherwise * |
3925 | /* Split multiple lighters if they're being used up. Otherwise * |
3927 | * one charge from each would be used up. --DAMN */ |
3926 | * one charge from each would be used up. --DAMN */ |
3928 | if (lighter->nrof > 1) |
3927 | if (lighter->nrof > 1) |
3929 | { |
3928 | { |
3930 | object *oneLighter = get_object (); |
3929 | object *oneLighter = lighter->clone (); |
3931 | |
3930 | |
3932 | copy_object (lighter, oneLighter); |
|
|
3933 | lighter->nrof -= 1; |
3931 | lighter->nrof -= 1; |
3934 | oneLighter->nrof = 1; |
3932 | oneLighter->nrof = 1; |
3935 | oneLighter->stats.food--; |
3933 | oneLighter->stats.food--; |
3936 | esrv_send_item (who, lighter); |
3934 | esrv_send_item (who, lighter); |
3937 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3935 | oneLighter = insert_ob_in_ob (oneLighter, who); |
… | |
… | |
3993 | object *tmp; |
3991 | object *tmp; |
3994 | |
3992 | |
3995 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3993 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3996 | tmp = get_archetype (SPELL_WONDER); |
3994 | tmp = get_archetype (SPELL_WONDER); |
3997 | cast_wonder (op, op, 0, tmp); |
3995 | cast_wonder (op, op, 0, tmp); |
3998 | free_object (tmp); |
3996 | tmp->destroy (); |
3999 | } |
3997 | } |
4000 | else if (failure <= -15 && failure > -35) |
3998 | else if (failure <= -15 && failure > -35) |
4001 | { /* drain mana */ |
3999 | { /* drain mana */ |
4002 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
4000 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
4003 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
4001 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
… | |
… | |
4026 | object *tmp; |
4024 | object *tmp; |
4027 | |
4025 | |
4028 | tmp = get_archetype (LOOSE_MANA); |
4026 | tmp = get_archetype (LOOSE_MANA); |
4029 | cast_magic_storm (op, tmp, power); |
4027 | cast_magic_storm (op, tmp, power); |
4030 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4028 | new_draw_info (NDI_UNIQUE, 0, op, "You unlease uncontrolled mana!"); |
4031 | free_object (tmp); |
4029 | tmp->destroy (); |
4032 | } |
4030 | } |
4033 | } |
4031 | } |
4034 | } |
4032 | } |
4035 | |
4033 | |
4036 | void |
4034 | void |