Mercurial > hg > early-roguelike
comparison arogue5/encumb.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 09 Aug 2012 22:58:48 +0000 |
| parents | |
| children | 56e748983fa8 |
comparison
equal
deleted
inserted
replaced
| 62:0ef99244acb8 | 63:0ed67132cf10 |
|---|---|
| 1 /* | |
| 2 * Stuff to do with encumberence | |
| 3 * | |
| 4 * Advanced Rogue | |
| 5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
| 6 * All rights reserved. | |
| 7 * | |
| 8 * Based on "Super-Rogue" | |
| 9 * Copyright (C) 1984 Robert D. Kindelberger | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 13 */ | |
| 14 | |
| 15 #include "curses.h" | |
| 16 #include "rogue.h" | |
| 17 | |
| 18 /* | |
| 19 * updpack: | |
| 20 * Update his pack weight and adjust fooduse accordingly | |
| 21 */ | |
| 22 updpack(getmax) | |
| 23 int getmax; | |
| 24 { | |
| 25 | |
| 26 reg int topcarry, curcarry; | |
| 27 | |
| 28 if (getmax) | |
| 29 pstats.s_carry = totalenc(); /* get total encumb */ | |
| 30 curcarry = packweight(); /* get pack weight */ | |
| 31 topcarry = pstats.s_carry / 5; /* 20% of total carry */ | |
| 32 if(curcarry > 4 * topcarry) { | |
| 33 if(rnd(100) < 80) | |
| 34 foodlev = 3; /* > 80% of pack */ | |
| 35 } else if(curcarry > 3 * topcarry) { | |
| 36 if(rnd(100) < 60) | |
| 37 foodlev = 2; /* > 60% of pack */ | |
| 38 } else | |
| 39 foodlev = 1; /* <= 60% of pack */ | |
| 40 pstats.s_pack = curcarry; /* update pack weight */ | |
| 41 } | |
| 42 | |
| 43 | |
| 44 /* | |
| 45 * packweight: | |
| 46 * Get the total weight of the hero's pack | |
| 47 */ | |
| 48 packweight() | |
| 49 { | |
| 50 reg struct object *obj; | |
| 51 reg struct linked_list *pc; | |
| 52 reg int weight; | |
| 53 | |
| 54 weight = 0; | |
| 55 for(pc = pack ; pc != NULL ; pc = next(pc)) { | |
| 56 obj = OBJPTR(pc); | |
| 57 weight += itemweight(obj); | |
| 58 } | |
| 59 if(weight < 0) /* in case of amulet */ | |
| 60 weight = 0; | |
| 61 if(ISWEARING(R_HEAVY)) | |
| 62 weight += weight / 4; | |
| 63 return(weight); | |
| 64 } | |
| 65 | |
| 66 | |
| 67 /* | |
| 68 * itemweight: | |
| 69 * Get the weight of an object | |
| 70 */ | |
| 71 itemweight(wh) | |
| 72 reg struct object *wh; | |
| 73 { | |
| 74 reg int weight; | |
| 75 reg int ac; | |
| 76 | |
| 77 weight = wh->o_weight; /* get base weight */ | |
| 78 switch(wh->o_type) { | |
| 79 case ARMOR: | |
| 80 /* | |
| 81 * subtract 10% for each enchantment | |
| 82 * this will add weight for negative items | |
| 83 */ | |
| 84 ac = armors[wh->o_which].a_class - wh->o_ac; | |
| 85 weight = ((weight*10) - (weight*ac)) / 10; | |
| 86 if (weight < 0) weight = 0; | |
| 87 when WEAPON: | |
| 88 if ((wh->o_hplus + wh->o_dplus) > 0) | |
| 89 weight /= 2; | |
| 90 } | |
| 91 if(wh->o_flags & ISCURSED) | |
| 92 weight += weight / 5; /* 20% more for cursed */ | |
| 93 weight *= wh->o_count; | |
| 94 return(weight); | |
| 95 } | |
| 96 | |
| 97 | |
| 98 /* | |
| 99 * playenc: | |
| 100 * Get hero's carrying ability above norm | |
| 101 */ | |
| 102 playenc() | |
| 103 { | |
| 104 return ((str_compute()-8)*50); | |
| 105 } | |
| 106 | |
| 107 | |
| 108 /* | |
| 109 * totalenc: | |
| 110 * Get total weight that the hero can carry | |
| 111 */ | |
| 112 totalenc() | |
| 113 { | |
| 114 reg int wtotal; | |
| 115 | |
| 116 wtotal = NORMENCB + playenc(); | |
| 117 switch(hungry_state) { | |
| 118 case F_OKAY: | |
| 119 case F_HUNGRY: ; /* no change */ | |
| 120 when F_WEAK: wtotal -= wtotal / 10; /* 10% off weak */ | |
| 121 when F_FAINT: wtotal /= 2; /* 50% off faint */ | |
| 122 } | |
| 123 return(wtotal); | |
| 124 } | |
| 125 | |
| 126 | |
| 127 | |
| 128 /* | |
| 129 * whgtchk: | |
| 130 * See if the hero can carry his pack | |
| 131 */ | |
| 132 | |
| 133 wghtchk() | |
| 134 { | |
| 135 reg int dropchk, err = TRUE; | |
| 136 reg char ch; | |
| 137 int wghtchk(); | |
| 138 | |
| 139 inwhgt = TRUE; | |
| 140 if (pstats.s_pack > pstats.s_carry) { | |
| 141 ch = CCHAR( mvwinch(stdscr, hero.y, hero.x) ); | |
| 142 if((ch != FLOOR && ch != PASSAGE)) { | |
| 143 extinguish(wghtchk); | |
| 144 fuse(wghtchk,TRUE,1,AFTER); | |
| 145 inwhgt = FALSE; | |
| 146 return; | |
| 147 } | |
| 148 extinguish(wghtchk); | |
| 149 msg("Your pack is too heavy for you"); | |
| 150 do { | |
| 151 dropchk = drop(NULL); | |
| 152 if(dropchk == FALSE) { | |
| 153 mpos = 0; | |
| 154 msg("You must drop something"); | |
| 155 } | |
| 156 if(dropchk == TRUE) | |
| 157 err = FALSE; | |
| 158 } while(err); | |
| 159 } | |
| 160 inwhgt = FALSE; | |
| 161 } | |
| 162 | |
| 163 | |
| 164 /* | |
| 165 * hitweight: | |
| 166 * Gets the fighting ability according to current weight | |
| 167 * This returns a +1 hit for light pack weight | |
| 168 * 0 hit for medium pack weight | |
| 169 * -1 hit for heavy pack weight | |
| 170 */ | |
| 171 | |
| 172 hitweight() | |
| 173 { | |
| 174 return(2 - foodlev); | |
| 175 } |
