Mercurial > hg > early-roguelike
diff arogue7/wizard.c @ 125:adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
| author | John "Elwin" Edwards |
|---|---|
| date | Fri, 08 May 2015 15:24:40 -0400 |
| parents | |
| children | b786053d2f37 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arogue7/wizard.c Fri May 08 15:24:40 2015 -0400 @@ -0,0 +1,696 @@ +/* + * wizard.c - Special wizard commands + * + * Advanced Rogue + * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T + * All rights reserved. + * + * Based on "Rogue: Exploring the Dungeons of Doom" + * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +/* + * Special wizard commands (some of which are also non-wizard commands + * under strange circumstances) + */ + +#include "curses.h" +#include <ctype.h> +#include "rogue.h" +#ifdef PC7300 +#include "menu.h" +#endif + + +/* + * create_obj: + * Create any object for wizard, scroll, magician, or cleric + */ +create_obj(prompt, which_item, which_type) +bool prompt; +int which_item, which_type; +{ + reg struct linked_list *item; + reg struct object *obj; + reg int wh; + reg char ch, newitem, newtype, whc, msz, *pt; + WINDOW *thiswin; + + thiswin = cw; + if (prompt) { + bool nogood = TRUE; + + thiswin = hw; + wclear(hw); + wprintw(hw,"Item\t\t\tKey\n\n"); + wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_RING].mi_name,RING, + things[TYP_STICK].mi_name,STICK); + wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_POTION].mi_name,POTION, + things[TYP_SCROLL].mi_name,SCROLL); + wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_ARMOR].mi_name,ARMOR, + things[TYP_WEAPON].mi_name,WEAPON); + wprintw(hw,"%s\t%c\n",things[TYP_MM].mi_name,MM); + wprintw(hw,"%s\t\t\t%c\n",things[TYP_FOOD].mi_name,FOOD); + if (wizard) { + wprintw(hw,"%s\t\t%c\n",things[TYP_RELIC].mi_name,RELIC); + waddstr(hw,"monster\t\t\tm"); + } + wprintw(hw,"\n\nWhat do you want to create? "); + draw(hw); + do { + ch = wgetch(hw); + if (ch == ESCAPE) { + restscr(cw); + return; + } + switch (ch) { + case RING: + case STICK: + case POTION: + case SCROLL: + case ARMOR: + case WEAPON: + case FOOD: + case MM: + nogood = FALSE; + break; + case RELIC: + case 'm': + if (wizard) + nogood = FALSE; + break; + default: + nogood = TRUE; + } + } while (nogood); + newitem = ch; + } + else + newitem = which_item; + + pt = "those"; + msz = 0; + if(newitem == 'm') { + /* make monster and be done with it */ + wh = makemonster(TRUE, "Creation", "create"); + if (wh > 0) { + creat_mons (&player, wh, TRUE); + light(&hero); + } + return; + } + if(newitem == GOLD) + pt = "gold"; + /* else if(isatrap(newitem)) + pt = "traps"; + */ + switch(newitem) { + case POTION: whc = TYP_POTION; msz = MAXPOTIONS; + when SCROLL: whc = TYP_SCROLL; msz = MAXSCROLLS; + when WEAPON: whc = TYP_WEAPON; msz = MAXWEAPONS; + when ARMOR: whc = TYP_ARMOR; msz = MAXARMORS; + when RING: whc = TYP_RING; msz = MAXRINGS; + when STICK: whc = TYP_STICK; msz = MAXSTICKS; + when MM: whc = TYP_MM; msz = MAXMM; + when RELIC: whc = TYP_RELIC; msz = MAXRELIC; + when FOOD: whc = TYP_FOOD; msz = MAXFOODS; + otherwise: + if (thiswin == hw) + restscr(cw); + mpos = 0; + msg("Even wizards can't create %s !!",pt); + return; + } + if(msz == 1) { /* if only one type of item */ + ch = 'a'; + } + else if (prompt) { + register struct magic_item *wmi; + char wmn; + register int ii; + int old_prob; + + mpos = 0; + wmi = NULL; + wmn = 0; + switch(newitem) { + case POTION: wmi = &p_magic[0]; + when SCROLL: wmi = &s_magic[0]; + when RING: wmi = &r_magic[0]; + when STICK: wmi = &ws_magic[0]; + when MM: wmi = &m_magic[0]; + when RELIC: wmi = &rel_magic[0]; + when FOOD: wmi = &foods[0]; + when WEAPON: wmn = 1; + when ARMOR: wmn = 2; + } + wclear(hw); + thiswin = hw; + if (wmi != NULL) { + ii = old_prob = 0; + while (ii < msz) { + if(wmi->mi_prob == old_prob && wizard == FALSE) { + msz--; /* can't make a unique item */ + } + else { + mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a'); + waddstr(hw,") "); + waddstr(hw,wmi->mi_name); + ii++; + } + old_prob = wmi->mi_prob; + wmi++; + } + } + else if (wmn != 0) { + for(ii = 0 ; ii < msz ; ii++) { + mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a'); + waddstr(hw,") "); + if(wmn == 1) + waddstr(hw,weaps[ii].w_name); + else + waddstr(hw,armors[ii].a_name); + } + } + sprintf(prbuf,"Which %s? ",things[whc].mi_name); + mvwaddstr(hw,lines - 1, 0, prbuf); + draw(hw); + do { + ch = wgetch(hw); + if (ch == ESCAPE) { + restscr(cw); + msg(""); + return; + } + } until (isalpha(ch)); + if (thiswin == hw) /* restore screen if need be */ + restscr(cw); + newtype = tolower(ch) - 'a'; + if(newtype < 0 || newtype >= msz) { /* if an illegal value */ + mpos = 0; + msg("There is no such %s",things[whc].mi_name); + return; + } + } + else + newtype = which_type; + item = new_item(sizeof *obj); /* get some memory */ + obj = OBJPTR(item); + obj->o_type = newitem; /* store the new items */ + obj->o_mark[0] = '\0'; + obj->o_which = newtype; + obj->o_group = 0; + obj->contents = NULL; + obj->o_count = 1; + obj->o_flags = 0; + obj->o_dplus = obj->o_hplus = 0; + obj->o_weight = 0; + wh = obj->o_which; + mpos = 0; + if (!wizard) /* users get 0 to +3 */ + whc = rnd(4); + else /* wizard gets to choose */ + whc = getbless(); + if (whc < 0) + obj->o_flags |= ISCURSED; + switch (obj->o_type) { + case WEAPON: + case ARMOR: + if (obj->o_type == WEAPON) { + init_weapon(obj, wh); + obj->o_hplus += whc; + obj->o_dplus += whc; + } + else { /* armor here */ + obj->o_weight = armors[wh].a_wght; + obj->o_ac = armors[wh].a_class - whc; + } + when RING: + if (whc > 1 && r_magic[wh].mi_bless != 0) + obj->o_flags |= ISBLESSED; + r_know[wh] = TRUE; + switch(wh) { + case R_ADDSTR: + case R_ADDWISDOM: + case R_ADDINTEL: + case R_PROTECT: + case R_ADDHIT: + case R_ADDDAM: + case R_DIGEST: + obj->o_ac = whc + 1; + break; + default: + obj->o_ac = 0; + } + obj->o_weight = things[TYP_RING].mi_wght; + when MM: + if (whc > 1 && m_magic[wh].mi_bless != 0) + obj->o_flags |= ISBLESSED; + m_know[wh] = TRUE; + switch(wh) { + case MM_JUG: + switch(rnd(11)) { + case 0: obj->o_ac = P_PHASE; + when 1: obj->o_ac = P_CLEAR; + when 2: obj->o_ac = P_SEEINVIS; + when 3: obj->o_ac = P_HEALING; + when 4: obj->o_ac = P_MFIND; + when 5: obj->o_ac = P_TFIND; + when 6: obj->o_ac = P_HASTE; + when 7: obj->o_ac = P_RESTORE; + when 8: obj->o_ac = P_FLY; + when 9: obj->o_ac = P_SKILL; + when 10:obj->o_ac = P_FFIND; + } + when MM_OPEN: + case MM_HUNGER: + case MM_DRUMS: + case MM_DISAPPEAR: + case MM_CHOKE: + case MM_KEOGHTOM: + if (whc < 0) + whc = -whc; /* these cannot be negative */ + obj->o_ac = (whc + 1) * 5; + break; + when MM_BRACERS: + obj->o_ac = whc * 2 + 1; + when MM_DISP: + obj->o_ac = 2; + when MM_PROTECT: + obj->o_ac = whc; + when MM_SKILLS: + if (wizard && whc != 0) + obj->o_ac = rnd(NUM_CHARTYPES-1); + else + obj->o_ac = player.t_ctype; + otherwise: + obj->o_ac = 0; + } + obj->o_weight = things[TYP_MM].mi_wght; + when STICK: + if (whc > 1 && ws_magic[wh].mi_bless != 0) + obj->o_flags |= ISBLESSED; + ws_know[wh] = TRUE; + fix_stick(obj); + when SCROLL: + if (whc > 1 && s_magic[wh].mi_bless != 0) + obj->o_flags |= ISBLESSED; + obj->o_weight = things[TYP_SCROLL].mi_wght; + s_know[wh] = TRUE; + when POTION: + if (whc > 1 && p_magic[wh].mi_bless != 0) + obj->o_flags |= ISBLESSED; + obj->o_weight = things[TYP_POTION].mi_wght; + if (wh == P_ABIL) obj->o_kind = rnd(NUMABILITIES); + p_know[wh] = TRUE; + when RELIC: + obj->o_weight = things[TYP_RELIC].mi_wght; + switch (obj->o_which) { + case QUILL_NAGROM: obj->o_charges = QUILLCHARGES; + when EMORI_CLOAK: obj->o_charges = 1;
