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

Annotation of early-roguelike/rogue3/daemons.c, Revision 1.1

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

CVSweb