-+-+-+-+-+-+-+-+ START OF PART 7 -+-+-+-+-+-+-+-+ X begin X`09clear(14,1); X`09with py.misc do X`09 begin X`09 xbth := bth + lev*bth_lev_adj + ptohit*bth_plus_adj; X`09 xbthb := bthb + lev*bth_lev_adj + ptohit*bth_plus_adj; X`09 xfos := 27 - fos; X`09 if (xfos < 0) then xfos := 0; X`09 xsrh := srh + spell_adj(iq); X`09 xstl := stl; X`09 xdis := disarm + lev + 2*todis_adj + spell_adj(iq); X`09 xsave := save + lev + spell_adj(ws); X`09 xdev := save + lev + spell_adj(iq); X`09 xswm := py.flags.swim + 4; X`09 xrep := 6 + rep div 25; X`09 writev(xinfra,py.flags.see_infra*10:1,' feet'); X`09 end; X`09prt('(Miscellaneous Abilities)',16,24); X`09put_buffer('Fighting : '+likert(xbth ,12) ,17, 2); X`09put_buffer('Bows/Throw : '+likert(xbthb,12) ,18, 2); X`09put_buffer('Saving Throw: '+likert(xsave, 6) ,19, 2); X`09put_buffer('Stealth : '+likert(xstl , 1) ,17,27); X`09put_buffer('Disarming : '+likert(xdis , 8) ,18,27); X`09put_buffer('Magic Device: '+likert(xdev , 7) ,19,27); X`09put_buffer('Perception : '+likert(xfos , 3) ,17,52); X`09put_buffer('Searching : '+likert(xsrh , 6) ,18,52); X`09put_buffer('Infra-Vision: '+xinfra,`09 19,52); X`09put_buffer('Swimming : '+likert(xswm , 1) ,20,52); X`09put_buffer('Reputation : '+likert(xrep , 1) ,20, 2); X end; X X`09`7B Used to display the character on the screen.`09`09-RAK-`09`7D X`5Bglobal,psect(create$code)`5D procedure display_char; X var X`09dummy`09: char; X begin X`09put_character; X`09put_misc1; X`09put_stats; X`09put_misc2; X`09put_misc3; X end; X X`09`7B Gets a name for the character`09`09`09`09-JWT-`09`7D X`5Bglobal,psect(create$code)`5D procedure get_name; X begin X prt('Enter your player''s name `5Bpress when finished`5D',22 V,3); X get_string(py.misc.name,3,15,24); X clear(21,1); X end; X X`09`7B Chances the name of the character`09`09`09-JWT-`09`7D X`5Bglobal,psect(create$code)`5D procedure change_name; X var X`09c`09: char; X`09flag`09: boolean; X begin X flag := false; X display_char; X repeat X`09prt('hange character name. to continue.',22,3); X`09inkey(c); X`09case ord(c) of X`09 99`09`09: get_name; X`09 0,3,25,26,27`09: flag := true; X`09 otherwise; X`09end; X until (flag); X end; X X`5Bglobal,psect(create$code)`5D procedure create_character; X X var X X`09printed_once, X `09minning`09`09: boolean; X`09try_count`09: integer; X`09tstat`09`09: stat_set; X`09best,user,max_r`09: stat_s_type; X`09best_min`09: integer; X X function old_stat(new_guy : integer) : byteint; X begin X`09if (new_guy<150) then X`09 old_stat := (squish_stat(new_guy) + 30) div 10 X`09else X`09 old_stat := squish_stat(new_guy) - 132; X end; X X function new_stat(old_guy : integer) : byteint; X begin X`09if (old_guy<18) then X`09 new_stat := squish_stat(old_guy*10-30) X`09else X`09 new_stat := squish_stat(old_guy+132) X end; X X X`09`7B Get minimum stats the character wants`09`09`09-DMF-`09`7D X procedure get_minimums; X var X`09temp`09: integer; X`09yes_no`09: string; X X X function get_min_stat (prompt : string; max : byteint) : integer; X var X`09tmp_str`09: string; X`09abil`09: integer; X`09perc`09: integer; X`09out_str`09: string; X begin X`09 if (max = 250) then X`09 writev(out_str,'Min ',prompt,' (racial max 18/00) : ') X`09 else if (max > 150) then X`09 writev(out_str,'Min ',prompt,' (racial max 18/',(max-150):1,') : ') X`09 else X`09 writev(out_str,'Min ',prompt,' (racial max ',old_stat(max):1,') : '); X`09 prt(out_str,1,1); X`09 abil := 0; X`09 get_string(tmp_str,1,length(out_str)+1,10); X`09 if (index(tmp_str,'/') > 0) then X`09 begin X`09 insert_str(tmp_str,'/',' '); X`09 readv(tmp_str,abil,perc,error:=continue); X`09 if (abil = 18) then X`09 if (perc = 0) then X`09 abil := 250 X`09 else X`09 abil := 150 + perc X`09 end X`09 else X`09 begin X`09 readv(tmp_str,abil,error:=continue); X`09 if (abil < 3) then abil := 3 X`09 else if (abil > 18) then abil := 18; X`09 abil := new_stat(abil) X`09 end; X`09 get_min_stat := abil; X end; X X begin X prt('Do you wish to try for minimum statistics? ',1,1); X if (get_string(yes_no,1,44,1)) then X`09case yes_no`5B1`5D of X`09 'y','Y' : X begin X minning := true; X user`5Bsr`5D := get_min_stat('STR',max_r`5Bsr`5D); X user`5Biq`5D := get_min_stat('INT',max_r`5Biq`5D); X user`5Bws`5D := get_min_stat('WIS',max_r`5Bws`5D); X user`5Bdx`5D := get_min_stat('DEX',max_r`5Bdx`5D); X user`5Bcn`5D := get_min_stat('CON',max_r`5Bcn`5D); X user`5Bca`5D := get_min_stat('CHR',max_r`5Bca`5D); X prt('Printing Stats...',1,1); X prt_6_stats(user,3,65); X end; X`09 otherwise ; X`09end; X erase_line(1,1); X end; X X X`09`7B Generates character's stats`09`09`09`09-JWT-`09`7D X function get_stat : integer; X var X`09i`09: integer; X begin X i := randint(4) + randint(4) + randint(4) + 5; X get_stat := (i-3)*10; X end; X X X`09`7B Changes stats by given amount`09`09`09`09-JWT-`09`7D X function change_stat(cur_stat,amount : integer) : integer; X var X`09i : integer; X begin X if (amount < 0) then X`09for i := -1 downto amount do X`09 cur_stat := cur_stat - squish_stat(de_statp(cur_stat)) X else X`09for i := 1 to amount do X`09 cur_stat := cur_stat + squish_stat(in_statp(cur_stat)); X change_stat := cur_stat; X end; X X X function max_in_statp(stat : byteint) : byteint; X begin X if (stat < 150) then X`09stat := stat + 10 X else if (stat < 220) then X`09stat := stat + 25 X else if (stat < 240) then X`09stat := stat + 10 X else if (stat < 250) then X`09stat := stat + 1; X max_in_statp := stat; X end; X X X function max_de_statp(stat : byteint) : byteint; X begin X if (stat < 11) then X`09stat := 0 X else if (stat < 151) then X`09stat := stat - 10 X else if (stat < 241) then X`09begin X`09 stat := stat - 6; X`09 if (stat < 150) then stat := 150; X`09end X else X`09stat := stat - 1; X max_de_statp := stat; X end; X X X function max_stat(cur_stat,amount : integer) : integer; X var X`09i : integer; X begin X if (amount < 0) then X`09for i := -1 downto amount do X`09 cur_stat := max_de_statp(cur_stat) X else X`09for i := 1 to amount do X`09 cur_stat := max_in_statp(cur_stat); X max_stat := cur_stat; X end; X X X`09`7B Allows player to select a race`09`09`09-JWT-`09`7D X function choose_race : boolean; X var X`09i2,i3,i4,i5`09`09: integer; X`09s`09`09`09: char; X`09exit_flag`09`09: boolean; X begin X i2 := 1; X i3 := 1; X i4 := 3; X i5 := 22; X clear(21,1); X prt('Choose a race (? for Help):',21,3); X repeat X`09put_buffer (chr(i3+96)+') '+race`5Bi2`5D.trace,i5,i4); X`09i3 := i3 + 1; X`09i4 := i4 + 15; X`09if (i4 > 70) then X`09 begin X`09 i4 := 3; X`09 i5 := i5 + 1 X`09 end; X`09i2 := i2 + 1 X until (i2 > max_races); X py.misc.race := ''; X put_buffer('',21,30); X exit_flag := false; X repeat X`09inkey_flush(s); X`09i2 := index('abcdefghijklmnopqrstuvwxyz',s); X`09if ((i2 <= max_races) and (i2 >= 1)) then X`09 begin X`09 py.misc.prace := i2; X`09 py.misc.race := race`5Bi2`5D.trace; X`09 exit_flag := true; X`09 choose_race := true; X`09 put_buffer(py.misc.race,4,15); X`09 end X`09else if (s = '?') then X`09 begin X`09 moria_help('Character Races'); X`09 exit_flag := true; X`09 choose_race := false; X`09 end; X until (exit_flag); X end; X X procedure print_try_count; X var X`09out_str`09: string; X begin X writev(out_str,'Try = ',try_count:10); X put_buffer(out_str,21,60); X put_qio; X end; X X function next_best_stats(this : stat_s_type) : integer; X var X`09below,below_sum`09: integer; X`09tstat`09`09: stat_set; X begin X below_sum := 0; X for tstat := sr to ca do X`09if (this`5Btstat`5D < user`5Btstat`5D) then begin X`09 below := user`5Btstat`5D - this`5Btstat`5D; X`09 below_sum := below_sum + ((below*(below+1)) div 2); X`09end; X if (below_sum < best_min) then X`09begin X`09 for tstat := sr to ca do X`09 best`5Btstat`5D := this`5Btstat`5D; X`09 next_best_stats := below_sum; X`09end X else X`09next_best_stats := best_min; X end; X X function satisfied : boolean; X`09forward; X X`09`7B What does it take to satisfy the guy?!`09`09-KRC-`09`7D X function satisfied; X var X`09s`09: char; X`09tstat`09: stat_set; X begin X if not(minning) then X begin X if not printed_once then X`09 begin X`09 clear(21,1); X`09 put_misc1; X`09 put_stats; X`09 prt( 'Press to reroll, any other key to continue:', 21, 3 ); X`09 printed_once := true; X`09 end X else X`09 begin X`09 upd_misc1; X`09 upd_stats; X`09 prt( '', 21, 51 ); X`09 end; X inkey_flush(s); X`09satisfied := (ord(s) <> 10); X end X else X`09begin X`09 if not printed_once then X`09 begin X`09 clear(21,1); X`09 prt('Press any key to give up (10000 rolls max): ',21,3); X`09 printed_once := true; X`09 end; X`09 best_min := next_best_stats(py.stat.p); X`09 try_count := try_count + 1; X`09 if (try_count mod 250) = 0 then print_try_count; X`09 inkey_delay(s,0); X`09 if ((s <> null) or (try_count = 10000)) then X`09 begin X`09 minning := false; X`09 printed_once := false; X`09 for tstat := sr to ca do begin X`09`09py.stat.p`5Btstat`5D := best`5Btstat`5D; X`09`09py.stat.c`5Btstat`5D := best`5Btstat`5D; X`09 end; X`09 satisfied := satisfied; X`09 end X`09 else X`09 begin X`09 satisfied := (best_min = 0); X`09 if (best_min = 0) then X`09`09begin X`09`09 put_misc1; X `09`09 put_stats; X`09`09end; X`09 end; X`09end; X end; X X`09`7B Get the statistics for this bozo`09`09`09-KRC-`09`7D X procedure get_stats; X var tstat : stat_set; X begin X with py do X`09with race`5Bmisc.prace`5D do X`09 begin X`09 for tstat := sr to ca do X`09 begin X`09`09stat.p`5Btstat`5D := change_stat(get_stat,adj`5Btstat`5D); X`09`09stat.c`5Btstat`5D := stat.p`5Btstat`5D;`09`09 X`09 end; X`09 misc.rep:= 0; X`09 misc.srh := srh; X`09 misc.bth := bth; X`09 misc.bthb := bthb; X`09 misc.fos := fos; X`09 misc.stl := stl; X`09 misc.save := bsav; X`09 misc.hitdie := bhitdie; X`09 misc.lev := 1; X`09 misc.ptodam := todam_adj; X`09 misc.ptohit := tohit_adj; X`09 misc.ptoac := 0; X`09 misc.pac := toac_adj; X`09 misc.expfact:= b_exp; X`09 flags.see_infra := infra; X`09 flags.swim`09:= swim; X`09 end; X end; X X`09`7B Will print the history of a character`09`09`09-JWT-`09`7D X procedure print_history; X var X`09i1`09`09: integer; X begin X clear(14,1); X put_buffer('Character Background',14,28); X for i1 := 1 to 5 do X`09put_buffer(py.misc.history`5Bi1`5D,i1+14,5) X end; X X X`09`7B Get the racial history, determines social class`09-RAK-`09`7D X`09`7B Assumtions:`09Each race has init history beginning at `09`7D X`09`7B`09`09(race-1)*3+1`09`09`09`09`09`7D X`09`7B`09`09All history parts are in ascending order`09`7D X procedure get_history; X var X`09hist_ptr,cur_ptr,test_roll`09: integer; X`09start_pos,end_pos,cur_len`09: integer; X`09line_ctr,new_start,social_class`09: integer; X`09history_block`09`09`09: varying `5B400`5D of char; X`09flag`09`09`09`09: boolean; X begin X`09`7B Get a block of history text`09`09`09`09`7D X hist_ptr := (py.misc.prace-1)*3 + 1; X history_block := ''; X social_class := randint(4); X cur_ptr := 0; X repeat X`09flag := false; X`09repeat X`09 cur_ptr := cur_ptr + 1; X`09 if (background`5Bcur_ptr`5D.chart = hist_ptr) then X`09 begin X`09 test_roll := randint(100); X`09 while (test_roll > background`5Bcur_ptr`5D.roll) do X`09`09cur_ptr := cur_ptr + 1; X`09 with background`5Bcur_ptr`5D do X`09`09begin X`09`09 history_block := history_block + info; X`09`09 social_class := social_class + bonus; X`09`09 if (hist_ptr > next) then cur_ptr := 0; X`09`09 hist_ptr := next; X`09`09end; X`09 flag := true; X`09 end; X`09until(flag); X until(hist_ptr < 1); X`09`7B Process block of history text for pretty output`09`7D X start_pos := 1; X end_pos := length(history_block); X line_ctr := 1; X flag := false; X while (history_block`5Bend_pos`5D = ' ') do X`09end_pos := end_pos - 1; X repeat X`09while (history_block`5Bstart_pos`5D = ' ') do X`09 start_pos := start_pos + 1; X`09cur_len := end_pos - start_pos + 1; X`09if (cur_len > 70) then`20 X`09 begin; X`09 cur_len := 70; X`09 while (history_block`5Bstart_pos+cur_len-1`5D <> ' ') do X`09 cur_len := cur_len - 1; X`09 new_start := start_pos + cur_len; X`09 while (history_block`5Bstart_pos+cur_len-1`5D = ' ') do X`09 cur_len := cur_len - 1; X`09 end X`09else X`09 flag := true; X`09py.misc.history`5Bline_ctr`5D := substr(history_block,start_pos,cur_len); X`09line_ctr := line_ctr + 1; X`09start_pos := new_start; X until(flag); X for line_ctr := line_ctr to 5 do py.misc.history`5Bline_ctr`5D := ''; X`09`7B Compute social class for player`09`09`09`7D X if (social_class > 100) then`20 X`09social_class := 100 X else if(social_class < 1) then X`09social_class := 1; X py.misc.rep := 50 - social_class; X py.misc.sc := social_class; X end; X X X`09`7B Gets the character's sex`09`09`09`09-JWT-`09`7D X function get_sex : boolean; X var X`09s `09`09`09: char; X`09exit_flag`09`09: boolean; X begin X if (py.misc.prace = 10) then begin X`09py.misc.sex := 'Female'; X`09get_sex := true; X`09exit_flag := true; X`09prt(py.misc.sex,5,15); X end X else begin X py.misc.sex := ''; X clear(21,1); X prt('Choose a sex (? for Help):',21,3); X prt('m) Male f) Female',22,3); X prt('',21,29); X repeat +-+-+-+-+-+-+-+- END OF PART 7 +-+-+-+-+-+-+-+-