📄 object.c
字号:
percent = get_rand(0, 91); obj->what_is = SCROL; if (percent <= 5) { obj->which_kind = PROTECT_ARMOR; } else if (percent <= 10) { obj->which_kind = HOLD_MONSTER; } else if (percent <= 20) { obj->which_kind = CREATE_MONSTER; } else if (percent <= 35) { obj->which_kind = IDENTIFY; } else if (percent <= 43) { obj->which_kind = TELEPORT; } else if (percent <= 50) { obj->which_kind = SLEEP; } else if (percent <= 55) { obj->which_kind = SCARE_MONSTER; } else if (percent <= 64) { obj->which_kind = REMOVE_CURSE; } else if (percent <= 69) { obj->which_kind = ENCH_ARMOR; } else if (percent <= 74) { obj->which_kind = ENCH_WEAPON; } else if (percent <= 80) { obj->which_kind = AGGRAVATE_MONSTER; } else if (percent <= 86) { obj->which_kind = CON_MON; } else { obj->which_kind = MAGIC_MAPPING; }}gr_potion(obj)object *obj;{ short percent; percent = get_rand(1, 118); obj->what_is = POTION; if (percent <= 5) { obj->which_kind = RAISE_LEVEL; } else if (percent <= 15) { obj->which_kind = DETECT_OBJECTS; } else if (percent <= 25) { obj->which_kind = DETECT_MONSTER; } else if (percent <= 35) { obj->which_kind = INCREASE_STRENGTH; } else if (percent <= 45) { obj->which_kind = RESTORE_STRENGTH; } else if (percent <= 55) { obj->which_kind = HEALING; } else if (percent <= 65) { obj->which_kind = EXTRA_HEALING; } else if (percent <= 75) { obj->which_kind = BLINDNESS; } else if (percent <= 85) { obj->which_kind = HALLUCINATION; } else if (percent <= 95) { obj->which_kind = CONFUSION; } else if (percent <= 105) { obj->which_kind = POISON; } else if (percent <= 110) { obj->which_kind = LEVITATION; } else if (percent <= 114) { obj->which_kind = HASTE_SELF; } else { obj->which_kind = SEE_INVISIBLE; }}gr_weapon(obj, assign_wk)object *obj;int assign_wk;{ short percent; short i; short blessing, increment; obj->what_is = WEAPON; if (assign_wk) { obj->which_kind = get_rand(0, (WEAPONS - 1)); } if ((obj->which_kind == ARROW) || (obj->which_kind == DAGGER) || (obj->which_kind == SHURIKEN) | (obj->which_kind == DART)) { obj->quantity = get_rand(3, 15); obj->quiver = get_rand(0, 126); } else { obj->quantity = 1; } obj->hit_enchant = obj->d_enchant = 0; percent = get_rand(1, 96); blessing = get_rand(1, 3); if (percent <= 16) { increment = 1; } else if (percent <= 32) { increment = -1; obj->is_cursed = 1; } if (percent <= 32) { for (i = 0; i < blessing; i++) { if (coin_toss()) { obj->hit_enchant += increment; } else { obj->d_enchant += increment; } } } switch(obj->which_kind) { case BOW: case DART: obj->damage = "1d1"; break; case ARROW: obj->damage = "1d2"; break; case DAGGER: obj->damage = "1d3"; break; case SHURIKEN: obj->damage = "1d4"; break; case MACE: obj->damage = "2d3"; break; case LONG_SWORD: obj->damage = "3d4"; break; case TWO_HANDED_SWORD: obj->damage = "4d5"; break; }}gr_armor(obj)object *obj;{ short percent; short blessing; obj->what_is = ARMOR; obj->which_kind = get_rand(0, (ARMORS - 1)); obj->class = obj->which_kind + 2; if ((obj->which_kind == PLATE) || (obj->which_kind == SPLINT)) { obj->class--; } obj->is_protected = 0; obj->d_enchant = 0; percent = get_rand(1, 100); blessing = get_rand(1, 3); if (percent <= 16) { obj->is_cursed = 1; obj->d_enchant -= blessing; } else if (percent <= 33) { obj->d_enchant += blessing; }}gr_wand(obj)object *obj;{ obj->what_is = WAND; obj->which_kind = get_rand(0, (WANDS - 1)); obj->class = get_rand(3, 7);}get_food(obj, force_ration)object *obj;boolean force_ration;{ obj->what_is = FOOD; if (force_ration || rand_percent(80)) { obj->which_kind = RATION; } else { obj->which_kind = FRUIT; }}put_stairs(){ short row, col; gr_row_col(&row, &col, (FLOOR | TUNNEL)); dungeon[row][col] |= STAIRS;}get_armor_class(obj)object *obj;{ if (obj) { return(obj->class + obj->d_enchant); } return(0);}object *alloc_object(){ object *obj; if (free_list) { obj = free_list; free_list = free_list->next_object; } else if (!(obj = (object *) md_malloc(sizeof(object)))) { message("cannot allocate object, saving game", 0); save_into_file(error_file); } obj->quantity = 1; obj->ichar = 'L'; obj->picked_up = obj->is_cursed = 0; obj->in_use_flags = NOT_USED; obj->identified = UNIDENTIFIED; obj->damage = "1d1"; return(obj);}free_object(obj)object *obj;{ obj->next_object = free_list; free_list = obj;}make_party(){ short n; party_room = gr_room(); n = rand_percent(99) ? party_objects(party_room) : 11; if (rand_percent(99)) { party_monsters(party_room, n); }}show_objects(){ object *obj; short mc, rc, row, col; object *monster; obj = level_objects.next_object; while (obj) { row = obj->row; col = obj->col; rc = get_mask_char(obj->what_is); if (dungeon[row][col] & MONSTER) { if (monster = object_at(&level_monsters, row, col)) { monster->trail_char = rc; } } mc = mvinch(row, col); if (((mc < 'A') || (mc > 'Z')) && ((row != rogue.row) || (col != rogue.col))) { mvaddch(row, col, rc); } obj = obj->next_object; } monster = level_monsters.next_object; while (monster) { if (monster->m_flags & IMITATES) { mvaddch(monster->row, monster->col, (int) monster->disguise); } monster = monster->next_monster; }}put_amulet(){ object *obj; obj = alloc_object(); obj->what_is = AMULET; rand_place(obj);}rand_place(obj)object *obj;{ short row, col; gr_row_col(&row, &col, (FLOOR | TUNNEL)); place_at(obj, row, col);}c_object_for_wizard(){ short ch, max, wk; object *obj; char buf[80]; if (pack_count((object *) 0) >= MAX_PACK_COUNT) { message("pack full", 0); return; } message("type of object?", 0); while (r_index("!?:)]=/,\033", (ch = rgetchar()), 0) == -1) { sound_bell(); } check_message(); if (ch == '\033') { return; } obj = alloc_object(); switch(ch) { case '!': obj->what_is = POTION; max = POTIONS - 1; break; case '?': obj->what_is = SCROL; max = SCROLS - 1; break; case ',': obj->what_is = AMULET; break; case ':': get_food(obj, 0); break; case ')': gr_weapon(obj, 0); max = WEAPONS - 1; break; case ']': gr_armor(obj); max = ARMORS - 1; break; case '/': gr_wand(obj); max = WANDS - 1; break; case '=': max = RINGS - 1; obj->what_is = RING; break; } if ((ch != ',') && (ch != ':')) {GIL: if (get_input_line("which kind?", "", buf, "", 0, 1)) { wk = get_number(buf); if ((wk >= 0) && (wk <= max)) { obj->which_kind = (unsigned short) wk; if (obj->what_is == RING) { gr_ring(obj, 0); } } else { sound_bell(); goto GIL; } } else { free_object(obj); return; } } get_desc(obj, buf); message(buf, 0); (void) add_to_pack(obj, &rogue.pack, 1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -