[BACK]Return to encumb.c CVS log [TXT][DIR] Up to [contributed] / early-roguelike / urogue

Annotation of early-roguelike/urogue/encumb.c, Revision 1.1

1.1     ! rubenllo    1: /*
        !             2:     encumb.c - Stuff to do with encumberance
        !             3:
        !             4:     UltraRogue: The Ultimate Adventure in the Dungeons of Doom
        !             5:     Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong
        !             6:     All rights reserved.
        !             7:
        !             8:     Based on "Advanced Rogue"
        !             9:     Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka
        !            10:     All rights reserved.
        !            11:
        !            12:     See the file LICENSE.TXT for full copyright and licensing information.
        !            13: */
        !            14:
        !            15: #include "rogue.h"
        !            16:
        !            17: /*
        !            18:     updpack()
        !            19:         Update his pack weight and adjust fooduse accordingly
        !            20: */
        !            21:
        !            22: void
        !            23: updpack(void)
        !            24: {
        !            25:     int curcarry = packweight();
        !            26:
        !            27:     pstats.s_carry = totalenc();    /* update max encumb */
        !            28:
        !            29:     if (is_carrying(TR_PURSE))
        !            30:         pstats.s_carry += 1000;
        !            31:
        !            32:     foodlev = 0;
        !            33:
        !            34:     switch ((curcarry * 5) / pstats.s_carry)   /* % of total capacity */
        !            35:     {
        !            36:         case 5:     /* 100 % */
        !            37:             foodlev++;
        !            38:
        !            39:         case 4:     /* 80 % */
        !            40:             if (rnd(100) < 80)
        !            41:                 foodlev++;
        !            42:
        !            43:         case 3:     /* 60 % */
        !            44:             if (rnd(100) < 60)
        !            45:                 foodlev++;
        !            46:
        !            47:         case 2:     /* 40 % */
        !            48:             if (rnd(100) < 40)
        !            49:                 foodlev++;
        !            50:
        !            51:         case 1:     /* 20 % */
        !            52:             if (rnd(100) < 20)
        !            53:                 foodlev++;
        !            54:
        !            55:         case 0:     /* 0 % */
        !            56:             foodlev++;
        !            57:     }
        !            58:
        !            59:     pstats.s_pack = curcarry;   /* update pack weight */
        !            60:
        !            61:     if (is_carrying(TR_PURSE))  /* makes pack lighter */
        !            62:         foodlev--;
        !            63: }
        !            64:
        !            65:
        !            66: /*
        !            67:     packweight()
        !            68:         Get the total weight of the hero's pack
        !            69: */
        !            70:
        !            71: int
        !            72: packweight(void)
        !            73: {
        !            74:     struct linked_list  *pc;
        !            75:     int weight = 0;
        !            76:
        !            77:     for (pc = pack; pc != NULL; pc = next(pc))
        !            78:     {
        !            79:         struct object   *obj = OBJPTR(pc);
        !            80:
        !            81:         weight += itemweight(obj) * obj->o_count;
        !            82:     }
        !            83:
        !            84:     if (weight < 0)     /* caused by artifacts or blessed items */
        !            85:         weight = 0;
        !            86:
        !            87:     return (weight);
        !            88: }
        !            89:
        !            90:
        !            91: /*
        !            92:     itemweight()
        !            93:         Get the weight of an object
        !            94: */
        !            95:
        !            96: int
        !            97: itemweight(struct object *wh)
        !            98: {
        !            99:     int weight = wh->o_weight;  /* get base weight */
        !           100:     int ac;
        !           101:
        !           102:     switch (wh->o_type)
        !           103:     {
        !           104:         case ARMOR:  /* 10% for each plus or minus*/
        !           105:             ac = armors[wh->o_which].a_class - wh->o_ac;
        !           106:             weight *= (10 - ac) / 10;
        !           107:             break;
        !           108:
        !           109:         case WEAPON:
        !           110:             if ((wh->o_hplus + wh->o_dplus) > 0)
        !           111:                 weight /= 2;
        !           112:     }
        !           113:
        !           114:     if (wh->o_flags & ISCURSED)
        !           115:         weight += weight / 2;   /* +50% for cursed */
        !           116:     else if (wh->o_flags & ISBLESSED)
        !           117:         weight -= weight / 5;   /* -20% for blessed */
        !           118:
        !           119:     if (weight < 0)
        !           120:         weight = 0;
        !           121:
        !           122:     return (weight);
        !           123: }
        !           124:
        !           125:
        !           126: /*
        !           127:     playenc()
        !           128:         Get hero's carrying ability above norm 50 units per point of STR
        !           129:         over 10, 300 units per plus on R_CARRYING 1000 units for TR_PURSE
        !           130: */
        !           131:
        !           132: int
        !           133: playenc(void)
        !           134: {
        !           135:     int ret_val = (pstats.s_str - 10) * 50;
        !           136:
        !           137:     if (is_wearing(R_CARRYING))
        !           138:         ret_val += ring_value(R_CARRYING) * 300;
        !           139:
        !           140:     return (ret_val);
        !           141: }
        !           142:
        !           143:
        !           144: /*
        !           145:     totalenc()
        !           146:         Get total weight that the hero can carry
        !           147: */
        !           148:
        !           149: int
        !           150: totalenc(void)
        !           151: {
        !           152:     int wtotal = 1400 + playenc();
        !           153:
        !           154:     switch (hungry_state)
        !           155:     {
        !           156:         case F_OK:
        !           157:         case F_HUNGRY: /* no change */
        !           158:             break;
        !           159:
        !           160:         case F_WEAK:
        !           161:             wtotal -= wtotal / 4;  /* 25% off weak */
        !           162:             break;
        !           163:
        !           164:         case F_FAINT:
        !           165:             wtotal /= 2;    /* 50% off faint */
        !           166:             break;
        !           167:     }
        !           168:
        !           169:     return (wtotal);
        !           170: }
        !           171:
        !           172:
        !           173: /*
        !           174:     hitweight()
        !           175:         Gets the fighting ability according to current weight This
        !           176:         returns a  +2 hit for very light pack weight, +1 hit
        !           177:         for light pack weight, 0 hit for medium pack weight, -1 hit for heavy
        !           178:         pack weight, -2 hit for very heavy pack weight
        !           179: */
        !           180:
        !           181: int
        !           182: hitweight(void)
        !           183: {
        !           184:     return(3 - foodlev);
        !           185: }

CVSweb