-+-+-+-+-+-+-+-+ START OF PART 49 -+-+-+-+-+-+-+-+ X`09hour`09: integer; X`09sec`09: integer) : string; X var X`09out`09: string; X`09min`09: integer; X begin X min := trunc(sec * 0.15); X writev(out,hour:2,':',min:2); X insert_str(out,' ','0'); X insert_str(out,' ','0'); X time_string := out; X end; X X X`09`7B Return the difference of two time records`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D procedure time_diff( X`09a`09: game_time_type; X`09b`09: game_time_type; X`09var c`09: game_time_type); X begin X if (a.secs < b.secs) then X`09begin X`09 a.secs := a.secs + 400; X`09 a.hour := a.hour - 1; X`09end; X c.secs := a.secs - b.secs; X if (a.hour < b.hour) then X`09begin X`09 a.hour := a.hour + 24; X`09 a.day := a.day - 1; X`09end; X c.hour := a.hour - b.hour; X if (a.day < b.day) then X`09begin X`09 a.day := a.day + 28; X`09 a.month := a.month - 1; X`09end; X c.day := a.day - b.day; X if (a.month < b.month) then X`09begin X`09 a.month := a.month + 13; X`09 a.year := a.year - 1; X`09end; X c.month := a.month - b.month; X c.year := a.year - b.year; X end; X X X`09`7B Add days to the current date`09`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D procedure add_days( X`09`09`09`09var ti`09: game_time_type; X`09`09`09`09d`09: integer); X begin X with ti do X`09begin X`09 day := day + d; X`09 month := month + (day-1) div 28; X`09 day := (day-1) mod 28 + 1; X`09 year := year + (month-1) div 13; X`09 month := (month-1) mod 13 + 1; X`09end; X end; X X X`09`7B Return string with entire date/time`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function full_date_string(time : game_time_ty Vpe) : string; X var X`09out,out2`09: string; X`09pos`09`09: integer; X begin X out := day_of_week_string(time.day,10); X pos := index(out,' '); X if (pos > 0) then X`09out := substr(out,1,pos-1); X with time do X`09writev(out2,out,', ',month_string(month),' the ', X`09`09 place_string(day),', ',time_string(hour,secs)); X full_date_string := out2; X end; X X X`09`7B Advance the game clock by one 'second'`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D procedure adv_time(flag : boolean); X begin X`09with py.misc.cur_age do X`09 begin X`09 secs := secs + 1; X`09 if (secs > 399) then X`09 begin X`09 hour := hour + 1; X`09 secs := 0; X`09 if (hour = 24) then X`09 begin X`09`09day := day + 1; X`09`09hour := 0; X`09`09if (day = 29) then X`09`09 begin X`09`09 month := month + 1; X`09`09 day := 1; X`09`09 if (month = 14) then X`09`09 begin X`09`09 month := 1; X`09`09 year := year + 1; X`09`09 end; X`09`09 end; X`09 end; X`09 end; X`09 if (flag) and ((secs mod 100) = 0) then X`09 begin X`09`09prt_hp; X`09`09if is_magii then prt_mana; X`09`09prt_time; X`09 end; X`09 end; X end; X X X`09`7B Return string for how long character has been playing`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function play_time(t : time_type) : string; X var X`09out,out2`09: string; X begin X`09with t do X`09 begin X`09 writev(out,hours:2,':',minutes:2,':',seconds:2,'.',hundredths:2); X`09 insert_str(out,' ','0'); X`09 insert_str(out,' ','0'); X`09 insert_str(out,' ','0'); X`09 insert_str(out,' ','0'); X`09 writev(out2,days:1,' days and ',out,' hours.'); X`09 if (days = 1) then insert_str(out,'days','day'); X`09 end; X`09play_time := out2; X end; X X X`09`7B Add two time_types together`09`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D procedure add_play_time( X`09`09var res`09: time_type; X`09`09add`09: time_type); X begin X`09with res do X`09 begin X`09 days := days + add.days; X`09 hours := hours + add.hours; X`09 minutes := minutes + add.minutes; X`09 seconds := seconds + add.seconds; X`09 hundredths := hundredths + add.hundredths; X`09 if hundredths > 100 then X`09 begin X`09`09hundredths := hundredths - 100; X`09`09seconds := seconds + 1; X`09 end; X`09 if seconds > 60 then X`09 begin X`09`09seconds := seconds - 60; X`09`09minutes := minutes + 1; X`09 end; X`09 if minutes > 60 then X`09 begin X`09`09minutes := minutes - 60; X`09`09hours := hours + 1; X`09 end; X`09 if hours > 24 then X`09 begin X`09`09hours := hours - 24; X`09`09days := days + 1; X`09 end; X`09 end; X end; X X X`09`7B Return string for the age of the character`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function show_char_age : string; X var X`09dif`09: game_time_type; X`09out`09: string; X begin X`09time_diff(py.misc.cur_age,py.misc.birth,dif); X`09with dif do X`09 begin X`09 writev(out,'You are ',year:1,' years, ',month:1,' months, ',day:1, X`09`09 ' days, and ',time_string(hour,secs),' hours old.'); X`09 if (year = 1) then insert_str(out,'years','year'); X`09 if (month = 1) then insert_str(out,'months','month'); X`09 if (day = 1) then insert_str(out,'days','day'); X`09 end; X`09show_char_age := out; X end; X X X`09`7B Return current time in the game`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function show_current_time : string; X var X`09current_time`09: quad_type; X`09out`09`09: vtype; X begin X`09sys$gettim(current_time); X`09sys$asctim(out.length,out.body,current_time); X`09show_current_time := out; X end; X X `5Bexternal`5D procedure sub_quadtime(a,b,c : `5Breference`5D quad_type) V; extern; X `20 X`09`7B Return string for amount of play time`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function show_play_time : string; X var X`09tim`09`09`09: time_type; X`09current_time,delta_time`09: quad_type; X begin X`09sys$gettim(current_time); X`09sub_quadtime(current_time,start_time,delta_time); X`09sys$numtim(tim,delta_time); X`09add_play_time(tim,py.misc.play_tm); X`09show_play_time := play_time(tim); X end; X X X`09`7B Return description about the contents of a bag`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function bag_descrip(bag : treas_ptr) : strin Vg; X var X`09count,wgt`09: integer; X`09ptr`09`09: treas_ptr; X`09out,out2`09: string; X begin X`09if (bag`5E.next = nil) or (bag`5E.next`5E.is_in = false) then X`09 bag_descrip := ' (empty)' X`09else X`09 begin X`09 ptr := bag`5E.next; X`09 count := 0; X`09 wgt := 0; X`09 while (ptr <> nil) and (ptr`5E.is_in) do X`09 begin X`09`09count := count + ptr`5E.data.number; X`09`09wgt := wgt + ptr`5E.data.weight * ptr`5E.data.number; X`09`09ptr := ptr`5E.next; X`09 end; X`09 writev(out,' (',trunc(wgt * 100 / bag`5E.data.p1):1,'% full, containi Vng ',count:1,' item'); X`09 if (count <> 1) then out := out + 's'; X`09 bag_descrip := out + ')'; X`09 end; X end; X X`5Bglobal,psect(misc2$code)`5D function squish_stat(this : integer) : bytein Vt; X begin X`09if (this > 250) then squish_stat := 250 X`09else if (this < 0) then squish_stat := 0 X`09else squish_stat := this X end; X X X`09`7B Increases a stat by one randomized level`09`09-RAK-`09`7D X`5Bglobal,psect(misc2$code)`5D function in_statp(stat : byteint) : byteint; X begin X if (stat < 150) then X`09in_statp := 10 X else if (stat < 220) then X`09in_statp := randint(25) X else if (stat < 240) then X`09in_statp := randint(10) X else if (stat < 250) then X`09in_statp := 1 X else X`09in_statp := 0 X end; X X X`09`7B Decreases a stat by one randomized level`09`09-RAK-`09`7D X`5Bglobal,psect(misc2$code)`5D function de_statp(stat : byteint) : byteint; X var duh : byteint; X begin X if (stat < 11) then X`09de_statp := stat X else if (stat < 151) then X`09de_statp := 10 X else if (stat < 241) then X`09begin X`09 duh := randint(10) + 5; X`09 if (stat - duh < 150) then duh := stat - 150; X`09 de_statp := duh X`09end X else X`09de_statp := randint(3); X end; X X X X X`09`7B Returns a character's adjustment to hit.`09`09-JWT-`09`7D X`5Bglobal,psect(misc2$code)`5D function tohit_adj : integer; X var X`09total`09`09`09: integer; X begin X with py.stat do X begin X`09if`09(c`5Bdx`5D < 10) then total := -3 X`09else if (c`5Bdx`5D < 30) then total := -2 X`09else if (c`5Bdx`5D < 50) then total := -1 X`09else if (c`5Bdx`5D < 130) then total := 0 X`09else if (c`5Bdx`5D < 140) then total := 1 X`09else if (c`5Bdx`5D < 150) then total := 2 X`09else if (c`5Bdx`5D < 201) then total := 3 X`09else if (c`5Bdx`5D < 250) then total := 4 X`09else`09`09`09 total := 5; X`09if`09(c`5Bsr`5D < 10) then total := total - 3 X`09else if (c`5Bsr`5D < 20) then total := total - 2 X`09else if (c`5Bsr`5D < 40) then total := total - 1 X`09else if (c`5Bsr`5D < 150) then total := total + 0 X`09else if (c`5Bsr`5D < 226) then total := total + 1 X`09else if (c`5Bsr`5D < 241) then total := total + 2 X`09else if (c`5Bsr`5D < 249) then total := total + 3 X`09else`09`09`09 total := total + 4; X end; X tohit_adj := total; X end; X X X`09`7B Returns a character's adjustment to armor class`09-JWT-`09`7D X`5Bglobal,psect(misc2$code)`5D function toac_adj : integer; X begin X with py.stat do X if (c`5Bdx`5D <`0910) then toac_adj := -4 X else if (c`5Bdx`5D <`0920) then toac_adj := -3 X else if (c`5Bdx`5D <`0930) then toac_adj := -2 X else if (c`5Bdx`5D <`0940) then toac_adj := -1 X else if (c`5Bdx`5D < 120) then toac_adj := 0 X else if (c`5Bdx`5D < 150) then toac_adj := 1 X else if (c`5Bdx`5D < 191) then toac_adj := 2 X else if (c`5Bdx`5D < 226) then toac_adj := 3 X else if (c`5Bdx`5D < 249) then toac_adj := 4 X else`09`09`09 toac_adj := 5 X end; X X X`09`7B Returns a character's adjustment to disarm`09`09-RAK-`09`7D X`5Bglobal,psect(misc2$code)`5D function todis_adj : integer; X begin X with py.stat do X if (c`5Bdx`5D <`0910) then todis_adj := -8 X else if (c`5Bdx`5D <`0920) then todis_adj := -6 X else if (c`5Bdx`5D <`0930) then todis_adj := -4 X else if (c`5Bdx`5D <`0940) then todis_adj := -2 X else if (c`5Bdx`5D <`0950) then todis_adj := -1 X else if (c`5Bdx`5D < 100) then todis_adj := 0 X else if (c`5Bdx`5D < 130) then todis_adj := 1 X else if (c`5Bdx`5D < 150) then todis_adj := 2 X else if (c`5Bdx`5D < 191) then todis_adj := 4 X else if (c`5Bdx`5D < 226) then todis_adj := 5 X else if (c`5Bdx`5D < 249) then todis_adj := 6 X else`09`09`09 todis_adj := 8 X end; X X X`09`7B Returns a character's adjustment to damage`09`09-JWT-`09`7D X`5Bglobal,psect(misc2$code)`5D function todam_adj : integer; X begin X with py.stat do X if (c`5Bsr`5D <`0910) then todam_adj := -2 X else if (c`5Bsr`5D <`0920) then todam_adj := -1 X else if (c`5Bsr`5D < 130) then todam_adj := 0 X else if (c`5Bsr`5D < 140) then todam_adj := 1 X else if (c`5Bsr`5D < 150) then todam_adj := 2 X else if (c`5Bsr`5D < 226) then todam_adj := 3 X else if (c`5Bsr`5D < 241) then todam_adj := 4 X else if (c`5Bsr`5D < 249) then todam_adj := 5 X else`09`09`09todam_adj := 6; X end; X X`09`7B Returns a rating of x depending on y`09`09`09-JWT-`09`7D X`5Bglobal,psect(create$code)`5D function likert(x,y : integer) : btype; X begin X`09if (trunc(x/y) < -3) then X`09 likert := 'Very Bad' X`09else X`09 case trunc(x/y) of X`09 -3,-2,-1`09: likert := 'Very Bad'; X`09 0,1`09`09: likert := 'Bad'; X`09 2`09`09: likert := 'Poor'; X`09 3,4`09`09: likert := 'Fair'; X`09 5`09`09: likert := 'Good'; X`09 6`09`09: likert := 'Very Good'; X`09 7,8`09`09: likert := 'Superb'; X`09 otherwise`09 likert := 'Excellent'; X`09 end X end; X X X`09`7B Builds passwords`09`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(setup$code)`5D procedure bpswd; X var X`09`09i1`09`09: integer; X begin X`09seed := wdata`5B1,0`5D; X`09`7Bfor i1 := 1 to 12 do`7D X `7Blesser op password`7D X`09 password1 := 'fragrance';`7Bchr( uxor(wdata`5B1,i1`5D,randint(255)) );` V7D X`09seed := wdata`5B2,0`5D; X`09`7Bfor i1 := 1 to 12 do`7D X `7Bfull op password`7D X`09 password2 := 'mopwillow';`7Bchr( uxor(wdata`5B2,i1`5D,randint(255)) );` V7D X`09seed := get_seed; X end; X X`09`7B Determine character's sex`09`09`09`09-DCJ-`09`7D X`5Bglobal,psect(misc4$code)`5D function characters_sex : byteint ; X`09begin X X`09 characters_sex := trunc((index(sex_type,py.misc.sex)+5)/6) ; X X`09end ; X X X`09`7B Determine character's maximum allowable weight`09-DCJ-`09`7D X`5Bglobal,psect(misc4$code)`5D function max_allowable_weight : wordint ; X`09begin X X`09 case characters_sex of X`09 female`09: X`09`09max_allowable_weight := race`5Bpy.misc.prace`5D.f_b_wt + X`09`09`09`09`094*race`5Bpy.misc.prace`5D.f_m_wt ; X`09 male`09: X`09`09max_allowable_weight := race`5Bpy.misc.prace`5D.m_b_wt + X`09`09`09`09`094*race`5Bpy.misc.prace`5D.m_m_wt ; X`09 end ; X X`09end ; X X`09`7B Determine character's minimum allowable weight`09-DCJ-`09`7D X`5Bglobal,psect(misc4$code)`5D function min_allowable_weight : wordint ; X`09begin X X`09 case characters_sex of X`09 female`09: X`09`09min_allowable_weight := race`5Bpy.misc.prace`5D.f_b_wt - X`09`09`09`09`094*race`5Bpy.misc.prace`5D.f_m_wt ; X`09 male`09: X`09`09min_allowable_weight := race`5Bpy.misc.prace`5D.m_b_wt - X`09`09`09`09`094*race`5Bpy.misc.prace`5D.m_m_wt ; X`09 end ; X X`09end ; X X`09`7B Computes current weight limit`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D function weight_limit : integer; X var X`09weight_cap`09: integer; X begin X`09weight_cap:=(py.stat.c`5Bsr`5D+30)*player_weight_cap + py.misc.wt; X`09if (weight_cap > 3000) then weight_cap := 3000; X`09weight_cap := weight_cap + py.misc.xtr_wgt; X`09weight_limit := weight_cap; X end; X X X`09`7B Pick up some money`09`09`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc4$code)`5D function money_carry : treas_ptr; X begin X`09money_carry := inven_temp; X`09with py.misc do X`09 with inven_temp`5E.data do X`09 begin X`09 money`5Blevel`5D := money`5Blevel`5D + number; X`09 reset_total_cash; X`09 inven_weight := inven_weight + number * weight; X`09 end; X`09prt_gold; X`09prt_weight; +-+-+-+-+-+-+-+- END OF PART 49 +-+-+-+-+-+-+-+-