Annotation of researchv10no/games/rogue/daemons.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * All the daemon and fuse functions are in here
        !             3:  *
        !             4:  * @(#)daemons.c       3.7 (Berkeley) 6/15/81
        !             5:  */
        !             6: 
        !             7: #include <curses.h>
        !             8: #include "rogue.h"
        !             9: 
        !            10: /*
        !            11:  * doctor:
        !            12:  *     A healing daemon that restors hit points after rest
        !            13:  */
        !            14: 
        !            15: doctor()
        !            16: {
        !            17:     register int lv, ohp;
        !            18: 
        !            19:     lv = pstats.s_lvl;
        !            20:     ohp = pstats.s_hpt;
        !            21:     quiet++;
        !            22:     if (lv < 8)
        !            23:     {
        !            24:        if (quiet > 20 - lv*2)
        !            25:            pstats.s_hpt++;
        !            26:     }
        !            27:     else
        !            28:        if (quiet >= 3)
        !            29:            pstats.s_hpt += rnd(lv - 7)+1;
        !            30:     if (ISRING(LEFT, R_REGEN))
        !            31:        pstats.s_hpt++;
        !            32:     if (ISRING(RIGHT, R_REGEN))
        !            33:        pstats.s_hpt++;
        !            34:     if (ohp != pstats.s_hpt)
        !            35:     {
        !            36:        if (pstats.s_hpt > max_hp)
        !            37:            pstats.s_hpt = max_hp;
        !            38:        quiet = 0;
        !            39:     }
        !            40: }
        !            41: 
        !            42: /*
        !            43:  * Swander:
        !            44:  *     Called when it is time to start rolling for wandering monsters
        !            45:  */
        !            46: 
        !            47: swander()
        !            48: {
        !            49:     daemon(rollwand, 0, BEFORE);
        !            50: }
        !            51: 
        !            52: /*
        !            53:  * rollwand:
        !            54:  *     Called to roll to see if a wandering monster starts up
        !            55:  */
        !            56: 
        !            57: rollwand()
        !            58: {
        !            59:     static int between = 0;
        !            60: 
        !            61:     if (++between >= 4)
        !            62:     {
        !            63:        if (roll(1, 6) == 4)
        !            64:        {
        !            65:            wanderer();
        !            66:            kill_daemon(rollwand);
        !            67:            fuse(swander, 0, WANDERTIME, BEFORE);
        !            68:        }
        !            69:        between = 0;
        !            70:     }
        !            71: }
        !            72: 
        !            73: /*
        !            74:  * unconfuse:
        !            75:  *     Release the poor player from his confusion
        !            76:  */
        !            77: 
        !            78: unconfuse()
        !            79: {
        !            80:     player.t_flags &= ~ISHUH;
        !            81:     msg("You feel less confused now");
        !            82: }
        !            83: 
        !            84: 
        !            85: /*
        !            86:  * unsee:
        !            87:  *     He lost his see invisible power
        !            88:  */
        !            89: 
        !            90: unsee()
        !            91: {
        !            92:     player.t_flags &= ~CANSEE;
        !            93: }
        !            94: 
        !            95: /*
        !            96:  * sight:
        !            97:  *     He gets his sight back
        !            98:  */
        !            99: 
        !           100: sight()
        !           101: {
        !           102:     if (on(player, ISBLIND))
        !           103:     {
        !           104:        extinguish(sight);
        !           105:        player.t_flags &= ~ISBLIND;
        !           106:        light(&hero);
        !           107:        msg("The veil of darkness lifts");
        !           108:     }
        !           109: }
        !           110: 
        !           111: /*
        !           112:  * nohaste:
        !           113:  *     End the hasting
        !           114:  */
        !           115: 
        !           116: nohaste()
        !           117: {
        !           118:     player.t_flags &= ~ISHASTE;
        !           119:     msg("You feel yourself slowing down.");
        !           120: }
        !           121: 
        !           122: /*
        !           123:  * digest the hero's food
        !           124:  */
        !           125: stomach()
        !           126: {
        !           127:     register int oldfood;
        !           128: 
        !           129:     if (food_left <= 0)
        !           130:     {
        !           131:        /*
        !           132:         * the hero is fainting
        !           133:         */
        !           134:        if (no_command || rnd(100) > 20)
        !           135:            return;
        !           136:        no_command = rnd(8)+4;
        !           137:        if (!terse)
        !           138:            addmsg("You feel too weak from lack of food.  ");
        !           139:        msg("You faint");
        !           140:        running = FALSE;
        !           141:        count = 0;
        !           142:        hungry_state = 3;
        !           143:     }
        !           144:     else
        !           145:     {
        !           146:        oldfood = food_left;
        !           147:        food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet;
        !           148: 
        !           149:        if (food_left < MORETIME && oldfood >= MORETIME)
        !           150:        {
        !           151:            msg("You are starting to feel weak");
        !           152:            hungry_state = 2;
        !           153:        }
        !           154:        else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
        !           155:        {
        !           156:            if (!terse)
        !           157:                msg("You are starting to get hungry");
        !           158:            else
        !           159:                msg("Getting hungry");
        !           160:            hungry_state = 1;
        !           161:        }
        !           162:     }
        !           163: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.