-+-+-+-+-+-+-+-+ START OF PART 66 -+-+-+-+-+-+-+-+ X`09 if (k == 0) /* clear player's spot, but don't put wall there */ X`09`09replace_spot(i, j, 1); X`09 else if (k < 13) X`09`09replace_spot(i, j, randint(6)); X`09 else if (k < 16) X`09`09replace_spot(i, j, randint(9)); X`09 `7D X `7D X msg_print("There is a searing blast of light!"); X py.flags.blind += 10 + randint(10); X`7D X X X/* Enchants a plus onto an item.`09`09`09-RAK-`09*/ Xint enchant(plusses, limit) Xint16 *plusses; Xint16 limit; /* maximum bonus allowed; usually 10, but weapon's maximum dama Vge X`09`09when enchanting melee weapons to damage */ X`7B X register int chance, res; X `20 X if (limit <= 0) /* avoid randint(0) call */ X return(FALSE); X chance = 0; X res = FALSE; X if (*plusses > 0) X `7B X chance = *plusses; X if (randint(100) == 1) /* very rarely allow enchantment over limit */ X`09chance = randint(chance) - 1; X `7D X if (randint(limit) > chance) X `7B X *plusses += 1; X res = TRUE; X `7D X return(res); X`7D X X X/* Removes curses from items in inventory`09`09-RAK-`09*/ Xint remove_curse() X`7B X register int i, result; X register inven_type *i_ptr; X#ifdef ATARIST_MWC X int32u holder = TR_CURSED; X#endif X X result = FALSE; X for (i = INVEN_WIELD; i <= INVEN_OUTER; i++) X `7B X i_ptr = &inventory`5Bi`5D; X#ifdef ATARIST_MWC X if (holder & i_ptr->flags) X#else X if (TR_CURSED & i_ptr->flags) X#endif X`09`7B X#ifdef ATARIST_MWC X`09 i_ptr->flags &= `7Eholder; X#else X`09 i_ptr->flags &= `7ETR_CURSED; X#endif X`09 calc_bonuses(); X`09 result = TRUE; X`09`7D X `7D X return(result); X`7D X X X/* Restores any drained experience`09`09`09-RAK-`09*/ Xint restore_level() X`7B X register int restore; X register struct misc *m_ptr; X X restore = FALSE; X m_ptr = &py.misc; X if (m_ptr->max_exp > m_ptr->exp) X `7B X restore = TRUE; X msg_print("You feel your life energies returning."); X /* this while loop is not redundant, ptr_exp may reduce the exp level V */ X while (m_ptr->exp < m_ptr->max_exp) X`09`7B X`09 m_ptr->exp = m_ptr->max_exp; X`09 prt_experience(); X`09`7D X `7D X return(restore); X`7D $ CALL UNPACK SPELLS.C;1 320380657 $ create 'f' X/* source/staffs.c: staff code X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X#include "config.h" X#include "constant.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#include X#else X#include X#endif X X X/* Use a staff.`09`09`09`09`09-RAK-`09*/ Xvoid use() X`7B X int32u i; X int j, k, item_val, chance, y, x; X register int ident; X register struct misc *m_ptr; X register inven_type *i_ptr; X X free_turn_flag = TRUE; X if (inven_ctr == 0) X msg_print("But you are not carrying anything."); X else if (!find_range(TV_STAFF, TV_NEVER, &j, &k)) X msg_print("You are not carrying any staffs."); X else if (get_item(&item_val, "Use which staff?", j, k, CNIL, CNIL)) X `7B X i_ptr = &inventory`5Bitem_val`5D; X free_turn_flag = FALSE; X m_ptr = &py.misc; X chance = m_ptr->save + stat_adj(A_INT) - (int)i_ptr->level - 5 X`09+ (class_level_adj`5Bm_ptr->pclass`5D`5BCLA_DEVICE`5D * m_ptr->lev / 3); X if (py.flags.confused > 0) X`09chance = chance / 2; X if ((chance < USE_DEVICE) && (randint(USE_DEVICE - chance + 1) == 1)) X`09chance = USE_DEVICE; /* Give everyone a slight chance */ X if (chance <= 0)`09chance = 1; X if (randint(chance) < USE_DEVICE) X`09msg_print("You failed to use the staff properly."); X else if (i_ptr->p1 > 0) X`09`7B X`09 i = i_ptr->flags; X`09 ident = FALSE; X`09 (i_ptr->p1)--; X`09 while (i != 0) X`09 `7B X`09 j = bit_pos(&i) + 1; X`09 /* Staffs.`09`09`09`09*/ X`09 switch(j) X`09`09`7B X`09`09case 1: X`09`09 ident = light_area(char_row, char_col); X`09`09 break; X`09`09case 2: X`09`09 ident = detect_sdoor(); X`09`09 break; X`09`09case 3: X`09`09 ident = detect_trap(); X`09`09 break; X`09`09case 4: X`09`09 ident = detect_treasure(); X`09`09 break; X`09`09case 5: X`09`09 ident = detect_object(); X`09`09 break; X`09`09case 6: X`09`09 teleport(100); X`09`09 ident = TRUE; X`09`09 break; X`09`09case 7: X`09`09 ident = TRUE; X`09`09 earthquake(); X`09`09 break; X`09`09case 8: X`09`09 ident = FALSE; X`09`09 for (k = 0; k < randint(4); k++) X`09`09 `7B X`09`09 y = char_row; X`09`09 x = char_col; X`09`09 ident `7C= summon_monster(&y, &x, FALSE); X`09`09 `7D X`09`09 break; X`09`09case 10: X`09`09 ident = TRUE; X`09`09 destroy_area(char_row, char_col); X`09`09 break; X`09`09case 11: X`09`09 ident = TRUE; X`09`09 starlite(char_row, char_col); X`09`09 break; X`09`09case 12: X`09`09 ident = speed_monsters(1); X`09`09 break; X`09`09case 13: X`09`09 ident = speed_monsters(-1); X`09`09 break; X`09`09case 14: X`09`09 ident = sleep_monsters2(); X`09`09 break; X`09`09case 15: X`09`09 ident = hp_player(randint(8)); X`09`09 break; X`09`09case 16: X`09`09 ident = detect_invisible(); X`09`09 break; X`09`09case 17: X`09`09 if (py.flags.fast == 0) X`09`09 ident = TRUE; X`09`09 py.flags.fast += randint(30) + 15; X`09`09 break; X`09`09case 18: X`09`09 if (py.flags.slow == 0) X`09`09 ident = TRUE; X`09`09 py.flags.slow += randint(30) + 15; X`09`09 break; X`09`09case 19: X`09`09 ident = mass_poly(); X`09`09 break; X`09`09case 20: X`09`09 if (remove_curse()) X`09`09 `7B X`09`09 if (py.flags.blind < 1) X`09`09`09msg_print("The staff glows blue for a moment.."); X`09`09 ident = TRUE; X`09`09 `7D X`09`09 break; X`09`09case 21: X`09`09 ident = detect_evil(); X`09`09 break; X`09`09case 22: X`09`09 if ((cure_blindness()) `7C`7C (cure_poison()) `7C`7C X`09`09 (cure_confusion())) X`09`09 ident = TRUE; X`09`09 break; X`09`09case 23: X`09`09 ident = dispel_creature(CD_EVIL, 60); X`09`09 break; X`09`09case 25: X`09`09 ident = unlight_area(char_row, char_col); X`09`09 break; X`09`09case 32: X`09`09 /* store bought flag */ X`09`09 break; X`09`09default: X`09`09 msg_print("Internal error in staffs()"); X`09`09 break; X`09`09`7D X`09 /* End of staff actions.`09`09*/ X`09 `7D X`09 if (ident) X`09 `7B X`09 if (!known1_p(i_ptr)) X`09`09`7B X`09`09 m_ptr = &py.misc; X`09`09 /* round half-way case up */ X`09`09 m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / X`09`09 m_ptr->lev; X`09`09 prt_experience(); X X`09`09 identify(&item_val); X`09`09 i_ptr = &inventory`5Bitem_val`5D; X`09`09`7D X`09 `7D X`09 else if (!known1_p(i_ptr)) X`09 sample (i_ptr); X`09 desc_charges(item_val); X`09`7D X else X`09`7B X`09 msg_print("The staff has no charges left."); X`09 if (!known2_p(i_ptr)) X`09 add_inscribe(i_ptr, ID_EMPTY); X`09`7D X `7D X`7D $ CALL UNPACK STAFFS.C;1 439580624 $ create 'f' X/* source/store1.c: store code, updating store inventory, pricing objects X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X#include "config.h" X#include "constant.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#ifndef ATARIST_MWC X#include X#endif X#else X#include X#endif X X#if defined(LINT_ARGS) Xstatic void insert_store(int, int, int32, struct inven_type *); Xstatic void store_create(int); X#else Xstatic void insert_store(); Xstatic void store_create(); X#endif X X X/* Returns the value for any given object`09`09-RAK-`09*/ Xint32 item_value(i_ptr) Xregister inven_type *i_ptr; X`7B X register int32 value; X X value = i_ptr->cost; X /* don't purchase known cursed items */ X if (i_ptr->ident & ID_DAMD) X value = 0; X else if (((i_ptr->tval >= TV_BOW) && (i_ptr->tval <= TV_SWORD)) `7C`7C X`09 ((i_ptr->tval >= TV_BOOTS) && (i_ptr->tval <= TV_SOFT_ARMOR))) X `7B`09/* Weapons and armor`09*/ X if (!known2_p(i_ptr)) X`09value = object_list`5Bi_ptr->index`5D.cost; X else if ((i_ptr->tval >= TV_BOW) && (i_ptr->tval <= TV_SWORD)) X`09`7B X`09 if (i_ptr->tohit < 0) X`09 value = 0; X`09 else if (i_ptr->todam < 0) X`09 value = 0; X`09 else if (i_ptr->toac < 0) X`09 value = 0; X`09 else X`09 value = i_ptr->cost+(i_ptr->tohit+i_ptr->todam+i_ptr->toac)*100; X`09`7D X else X`09`7B X`09 if (i_ptr->toac < 0) X`09 value = 0; X`09 else X`09 value = i_ptr->cost+i_ptr->toac*100; X`09`7D X `7D X else if ((i_ptr->tval >= TV_SLING_AMMO) && (i_ptr->tval <= TV_SPIKE)) X `7B`09/* Ammo`09`09`09*/ X if (!known2_p(i_ptr)) X`09value = object_list`5Bi_ptr->index`5D.cost; X else X`09`7B X`09 if (i_ptr->tohit < 0) X`09 value = 0; X`09 else if (i_ptr->todam < 0) X`09 value = 0; X`09 else if (i_ptr->toac < 0) X`09 value = 0; X`09 else X`09 /* use 5, because missiles generally appear in groups of 20, X`09 so 20 * 5 == 100, which is comparable to weapon bonus above */ X`09 value = i_ptr->cost+(i_ptr->tohit+i_ptr->todam+i_ptr->toac)*5; X`09`7D X `7D X else if ((i_ptr->tval == TV_SCROLL1) `7C`7C (i_ptr->tval == TV_SCROLL2) `7 VC`7C X`09 (i_ptr->tval == TV_POTION1) `7C`7C (i_ptr->tval == TV_POTION2)) X `7B`09/* Potions, Scrolls, and Food`09*/ X if (!known1_p(i_ptr)) X`09value = 20; X `7D X else if (i_ptr->tval == TV_FOOD) X `7B X if ((i_ptr->subval < (ITEM_SINGLE_STACK_MIN + MAX_MUSH)) X`09 && !known1_p(i_ptr)) X`09value = 1; X `7D X else if ((i_ptr->tval == TV_AMULET) `7C`7C (i_ptr->tval == TV_RING)) X `7B`09/* Rings and amulets`09*/ X if (!known1_p(i_ptr)) X`09/* player does not know what type of ring/amulet this is */ X`09value = 45; X else if (!known2_p(i_ptr)) X`09/* player knows what type of ring, but does not know whether it is X`09 cursed or not, if refuse to buy cursed objects here, then X`09 player can use this to 'identify' cursed objects */ X`09value = object_list`5Bi_ptr->index`5D.cost; X `7D X else if ((i_ptr->tval == TV_STAFF) `7C`7C (i_ptr->tval == TV_WAND)) X `7B`09/* Wands and staffs*/ X if (!known1_p(i_ptr)) X`09`7B X`09 if (i_ptr->tval == TV_WAND) X`09 value = 50; X`09 else X`09 value = 70; X`09`7D X else if (known2_p(i_ptr)) X`09value = i_ptr->cost + (i_ptr->cost / 20) * i_ptr->p1; X `7D X /* picks and shovels */ X else if (i_ptr->tval == TV_DIGGING) X `7B X if (!known2_p(i_ptr)) X`09value = object_list`5Bi_ptr->index`5D.cost; X else X`09`7B X`09 if (i_ptr->p1 < 0) X`09 value = 0; X`09 else X`09 `7B X`09 /* some digging tools start with non-zero p1 values, so only X`09`09 multiply the plusses by 100, make sure result is positive */ X`09 value = i_ptr->cost X`09`09+ (i_ptr->p1 - object_list`5Bi_ptr->index`5D.p1) * 100; X`09 if (value < 0) X`09`09value = 0; X`09 `7D X`09`7D X `7D X /* multiply value by number of items if it is a group stack item */ X if (i_ptr->subval > ITEM_GROUP_MIN) /* do not include torches here */ X value = value * i_ptr->number; X return(value); X`7D X X X/* Asking price for an item`09`09`09`09-RAK-`09*/ Xint32 sell_price(snum, max_sell, min_sell, item) Xint snum; Xint32 *max_sell, *min_sell; Xinven_type *item; X`7B X register int32 i; X register store_type *s_ptr; X X s_ptr = &store`5Bsnum`5D; X i = item_value(item); X /* check item->cost in case it is cursed, check i in case it is damaged */ X if ((item->cost > 0) && (i > 0)) X `7B X i = i * rgold_adj`5Bowners`5Bs_ptr->owner`5D.owner_race`5D`5Bpy.misc.p Vrace`5D / 100; X if (i < 1) i = 1; X *max_sell = i * owners`5Bs_ptr->owner`5D.max_inflate / 100; X *min_sell = i * owners`5Bs_ptr->owner`5D.min_inflate / 100; X if (min_sell > max_sell)`09min_sell = max_sell; X return(i); X `7D X else X /* don't let the item get into the store inventory */ X return(0); X`7D X X X/* Check to see if he will be carrying too many objects`09-RAK-`09*/ Xint store_check_num(t_ptr, store_num) Xinven_type *t_ptr; Xint store_num; X`7B X register int store_check, i; X register store_type *s_ptr; X register inven_type *i_ptr; X X store_check = FALSE; X s_ptr = &store`5Bstore_num`5D; X if (s_ptr->store_ctr < STORE_INVEN_MAX) X store_check = TRUE; X else if (t_ptr->subval >= ITEM_SINGLE_STACK_MIN) X for (i = 0; i < s_ptr->store_ctr; i++) X `7B X`09i_ptr = &s_ptr->store_inven`5Bi`5D.sitem; X`09/* note: items with subval of gte ITEM_SINGLE_STACK_MAX only stack X`09 if their subvals match */ X`09if (i_ptr->tval == t_ptr->tval && i_ptr->subval == t_ptr->subval X`09 && ((int)i_ptr->number + (int)t_ptr->number < 256) X`09 && (t_ptr->subval < ITEM_GROUP_MIN X`09`09`7C`7C (i_ptr->p1 == t_ptr->p1))) X`09 store_check = TRUE; X `7D X return(store_check); X`7D X X X/* Insert INVEN_MAX at given location`09*/ Xstatic void insert_store(store_num, pos, icost, i_ptr) Xregister int pos; Xint store_num; Xint32 icost; Xinven_type *i_ptr; X`7B X register int i; X register store_type *s_ptr; X X s_ptr = &store`5Bstore_num`5D; X for (i = s_ptr->store_ctr-1; i >= pos; i--) X s_ptr->store_inven`5Bi+1`5D = s_ptr->store_inven`5Bi`5D; X s_ptr->store_inven`5Bpos`5D.sitem = *i_ptr; X s_ptr->store_inven`5Bpos`5D.scost = -icost; X s_ptr->store_ctr++; X`7D X X X/* Add the item in INVEN_MAX to stores inventory.`09-RAK-`09*/ Xvoid store_carry(store_num, ipos, t_ptr) Xint store_num; Xint *ipos; Xinven_type *t_ptr; X`7B X int item_num, item_val, flag; X register int typ, subt; X int32 icost, dummy; X register inven_type *i_ptr; X register store_type *s_ptr; X X *ipos = -1; X if (sell_price(store_num, &icost, &dummy, t_ptr) > 0) X `7B X s_ptr = &store`5Bstore_num`5D; X item_val = 0; X item_num = t_ptr->number; X flag = FALSE; X typ = t_ptr->tval; X subt = t_ptr->subval; X do X`09`7B +-+-+-+-+-+-+-+- END OF PART 66 +-+-+-+-+-+-+-+-