Mercurial > hg > early-roguelike
comparison arogue7/encumb.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 | f9ef86cf22b2 |
comparison
equal
deleted
inserted
replaced
| 124:d10fc4a065ac | 125:adfa37e67084 |
|---|---|
| 1 /* | |
| 2 * encumb.c - Stuff to do with encumberence | |
| 3 * | |
| 4 * Advanced Rogue | |
| 5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T | |
| 6 * All rights reserved. | |
| 7 * | |
| 8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
| 9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 13 */ | |
| 14 | |
| 15 /* | |
| 16 * Stuff to do with encumberence | |
| 17 * | |
| 18 */ | |
| 19 | |
| 20 #include "curses.h" | |
| 21 #include "rogue.h" | |
| 22 | |
| 23 /* | |
| 24 * updpack: | |
| 25 * Update his pack weight and adjust fooduse accordingly | |
| 26 */ | |
| 27 updpack(getmax, tp) | |
| 28 int getmax; | |
| 29 struct thing *tp; | |
| 30 { | |
| 31 | |
| 32 reg int topcarry, curcarry; | |
| 33 | |
| 34 if (getmax) | |
| 35 tp->t_stats.s_carry = totalenc(tp); /* get total encumb */ | |
| 36 curcarry = packweight(tp); /* get pack weight */ | |
| 37 | |
| 38 /* Only update food use for the player (for now) */ | |
| 39 if (tp == &player) { | |
| 40 topcarry = tp->t_stats.s_carry / 5; /* 20% of total carry */ | |
| 41 if(curcarry > 4 * topcarry) { | |
| 42 if(rnd(100) < 80) | |
| 43 foodlev = 3; /* > 80% of pack */ | |
| 44 } else if(curcarry > 3 * topcarry) { | |
| 45 if(rnd(100) < 60) | |
| 46 foodlev = 2; /* > 60% of pack */ | |
| 47 } else | |
| 48 foodlev = 1; /* <= 60% of pack */ | |
| 49 } | |
| 50 tp->t_stats.s_pack = curcarry; /* update pack weight */ | |
| 51 } | |
| 52 | |
| 53 | |
| 54 /* | |
| 55 * packweight: | |
| 56 * Get the total weight of the hero's pack | |
| 57 */ | |
| 58 packweight(tp) | |
| 59 register struct thing *tp; | |
| 60 { | |
| 61 reg struct object *obj; | |
| 62 reg struct linked_list *pc; | |
| 63 reg int weight; | |
| 64 | |
| 65 weight = 0; | |
| 66 for (pc = tp->t_pack ; pc != NULL ; pc = next(pc)) { | |
| 67 obj = OBJPTR(pc); | |
| 68 weight += itemweight(obj); | |
| 69 } | |
| 70 if (weight < 0) /* in case of amulet */ | |
| 71 weight = 0; | |
| 72 | |
| 73 /* If this is the player, is he wearing a ring of carrying? */ | |
| 74 if (tp == &player && ISWEARING(R_CARRY)) { | |
| 75 register int temp, i; | |
| 76 | |
| 77 temp = 0; | |
| 78 for (i=0; i<NUM_FINGERS; i++) { | |
| 79 if (cur_ring[i]->o_which == R_CARRY) { | |
| 80 if (cur_ring[i]->o_flags & ISCURSED) temp--; | |
| 81 else temp++; | |
| 82 } | |
| 83 } | |
| 84 weight -= (temp * weight) / 4; | |
| 85 } | |
| 86 | |
| 87 return(weight); | |
| 88 } | |
| 89 | |
| 90 | |
| 91 /* | |
| 92 * itemweight: | |
| 93 * Get the weight of an object | |
| 94 */ | |
| 95 itemweight(wh) | |
| 96 reg struct object *wh; | |
| 97 { | |
| 98 reg int weight; | |
| 99 reg int ac; | |
| 100 | |
| 101 weight = wh->o_weight; /* get base weight */ | |
| 102 switch(wh->o_type) { | |
| 103 case ARMOR: | |
| 104 /* | |
| 105 * subtract 10% for each enchantment | |
| 106 * this will add weight for negative items | |
| 107 */ | |
| 108 ac = armors[wh->o_which].a_class - wh->o_ac; | |
| 109 weight = ((weight*10) - (weight*ac)) / 10; | |
| 110 if (weight < 0) weight = 0; | |
| 111 when WEAPON: | |
| 112 if ((wh->o_hplus + wh->o_dplus) > 0) | |
| 113 weight /= 2; | |
| 114 } | |
| 115 if(wh->o_flags & ISCURSED) | |
| 116 weight += weight / 5; /* 20% more for cursed */ | |
| 117 weight *= wh->o_count; | |
| 118 return(weight); | |
| 119 } | |
| 120 | |
| 121 | |
| 122 /* | |
| 123 * playenc: | |
| 124 * Get hero's carrying ability above norm | |
| 125 */ | |
| 126 playenc(tp) | |
| 127 register struct thing *tp; | |
| 128 { | |
| 129 register int strength; | |
| 130 | |
| 131 if (tp == &player) strength = str_compute(); | |
| 132 else strength = tp->t_stats.s_str; | |
| 133 | |
| 134 return ((strength-8)*50); | |
| 135 } | |
| 136 | |
| 137 | |
| 138 /* | |
| 139 * totalenc: | |
| 140 * Get total weight that the hero can carry | |
| 141 */ | |
| 142 totalenc(tp) | |
| 143 register struct thing *tp; | |
| 144 { | |
| 145 reg int wtotal; | |
| 146 | |
| 147 wtotal = NORMENCB + playenc(tp); | |
| 148 if (tp == &player) switch(hungry_state) { | |
| 149 case F_SATIATED: | |
| 150 case F_OKAY: | |
| 151 case F_HUNGRY: ; /* no change */ | |
| 152 when F_WEAK: wtotal -= wtotal / 10; /* 10% off weak */ | |
| 153 when F_FAINT: wtotal /= 2; /* 50% off faint */ | |
| 154 } | |
| 155 return(wtotal); | |
| 156 } | |
| 157 | |
| 158 | |
| 159 | |
| 160 /* | |
| 161 * whgtchk: | |
| 162 * See if the hero can carry his pack | |
| 163 */ | |
| 164 | |
| 165 wghtchk() | |
| 166 { | |
| 167 reg int dropchk, err = TRUE; | |
| 168 reg char ch; | |
| 169 int wghtchk(); | |
| 170 | |
| 171 inwhgt = TRUE; | |
| 172 if (pstats.s_pack > pstats.s_carry) { | |
| 173 ch = CCHAR( mvwinch(stdscr, hero.y, hero.x) ); | |
| 174 if((ch != FLOOR && ch != PASSAGE)) { | |
| 175 extinguish(wghtchk); | |
| 176 fuse(wghtchk,TRUE,1,AFTER); | |
| 177 inwhgt = FALSE; | |
| 178 return; | |
| 179 } | |
| 180 extinguish(wghtchk); | |
| 181 msg("Your pack is too heavy for you"); | |
| 182 do { | |
| 183 dropchk = drop(NULL); | |
| 184 if(dropchk == 0) { | |
| 185 mpos = 0; | |
| 186 msg("You must drop something"); | |
| 187 } | |
| 188 if(dropchk == TRUE) | |
| 189 err = FALSE; | |
| 190 } while(err); | |
| 191 } | |
| 192 inwhgt = FALSE; | |
| 193 } | |
| 194 | |
| 195 | |
| 196 /* | |
| 197 * hitweight: | |
| 198 * Gets the fighting ability according to current weight | |
| 199 * This returns a +1 hit for light pack weight | |
| 200 * 0 hit for medium pack weight | |
| 201 * -1 hit for heavy pack weight | |
| 202 */ | |
| 203 | |
| 204 hitweight() | |
| 205 { | |
| 206 return(2 - foodlev); | |
| 207 } |
