Annotation of early-roguelike/xrogue/eat.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: eat.c - Functions for dealing with digestion
! 3:
! 4: XRogue: Expeditions into the Dungeons of Doom
! 5: Copyright (C) 1991 Robert Pietkivitch
! 6: All rights reserved.
! 7:
! 8: Based on "Advanced Rogue"
! 9: Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
! 10: All rights reserved.
! 11:
! 12: Based on "Rogue: Exploring the Dungeons of Doom"
! 13: Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
! 14: All rights reserved.
! 15:
! 16: See the file LICENSE.TXT for full copyright and licensing information.
! 17: */
! 18:
! 19: #include <curses.h>
! 20: #include "rogue.h"
! 21:
! 22: /*
! 23: * eat:
! 24: * He wants to eat something, so let him try
! 25: */
! 26:
! 27: void
! 28: eat(void)
! 29: {
! 30: register struct linked_list *item;
! 31: int which;
! 32: unsigned long temp;
! 33:
! 34: if (player.t_action != C_EAT) {
! 35: if ((item = get_item(pack, "eat", FOOD, FALSE, FALSE)) == NULL)
! 36: return;
! 37:
! 38: player.t_using = item; /* Remember what it is */
! 39: player.t_action = C_EAT; /* We are eating */
! 40: which = (OBJPTR(item))->o_which;
! 41: player.t_no_move = max(foods[which].mi_food/100, 1) * movement(&player);
! 42: return;
! 43: }
! 44:
! 45: /* We have waited our time, let's eat the food */
! 46: item = player.t_using;
! 47: player.t_using = NULL;
! 48: player.t_action = A_NIL;
! 49:
! 50: which = (OBJPTR(item))->o_which;
! 51: if ((food_left += foods[which].mi_food) > STOMACHSIZE)
! 52: food_left = STOMACHSIZE;
! 53: del_pack(item);
! 54: if (hungry_state == F_SATIATED && food_left == STOMACHSIZE && rnd(4) == 1) {
! 55: pstats.s_hpt = -1;
! 56: msg ("Cough! Ack! You choke on all that food and die! --More--");
! 57: wait_for(' ');
! 58: death(D_FOOD_CHOKE);
! 59: }
! 60: if (food_left >= STOMACHSIZE-MORETIME) {
! 61: hungry_state = F_SATIATED;
! 62: msg ("You have trouble getting that food down!");
! 63: msg ("Your stomach feels like it's about to burst!");
! 64: }
! 65: else if (which != E_SLIMEMOLD) {
! 66: hungry_state = F_OKAY;
! 67: switch (rnd(10)) {
! 68: case 0: msg("Yuck, what a foul tasting %s! ", foods[which].mi_name);
! 69: when 1: msg("Mmmm, what a tasty %s. ", foods[which].mi_name);
! 70: when 2: msg("Wow, what a scrumptious %s! ", foods[which].mi_name);
! 71: when 3: msg("Hmmm, %s heaven! ", foods[which].mi_name);
! 72: when 4: msg("You've eaten better %s. ", foods[which].mi_name);
! 73: when 5: msg("You smack your lips ");
! 74: when 6: msg("Yum-yum-yum ");
! 75: when 7: msg("Gulp! ");
! 76: when 8: msg("Your tongue flips out! ");
! 77: when 9: msg("You lick your chin ");
! 78: }
! 79: }
! 80: updpack(TRUE, &player);
! 81: switch(which) {
! 82: case E_WHORTLEBERRY: /* add 1 to intelligence */
! 83: (*add_abil[A_INTELLIGENCE])(1);
! 84: when E_SWEETSOP: /* add 1 to strength */
! 85: case E_SOURSOP: /* add 1 to strength */
! 86: (*add_abil[A_STRENGTH])(1);
! 87: when E_SAPODILLA: /* add 1 to wisdom */
! 88: (*add_abil[A_WISDOM])(1);
! 89: when E_APPLE: /* add 1 to dexterity */
! 90: (*add_abil[A_DEXTERITY])(1);
! 91: when E_PRICKLEY: /* add 1 to constitution */
! 92: (*add_abil[A_CONSTITUTION])(1);
! 93: when E_PEACH: /* add 1 to charisma */
! 94: (*add_abil[A_CHARISMA])(1);
! 95: when E_PITANGA: /* add 1 hit point */
! 96: max_stats.s_hpt++;
! 97: pstats.s_hpt = max_stats.s_hpt;
! 98: msg("You feel a bit tougher now. ");
! 99: when E_HAGBERRY: /* armor class */
! 100: case E_JABOTICABA: /* armor class */
! 101: pstats.s_arm--;
! 102: msg("Your skin feels more resilient now. ");
! 103: when E_STRAWBERRY: /* add 10% experience points */
! 104: case E_RAMBUTAN: /* add 10% experience points */
! 105: temp = pstats.s_exp/100 + 10;
! 106: pstats.s_exp += temp;
! 107: msg("You feel slightly more experienced now. ");
! 108: check_level();
! 109: when E_DEWBERRY: /* encourage him to do more magic */
! 110: if (chant_time > 0) {
! 111: chant_time -= 80;
! 112: if (chant_time < 0)
! 113: chant_time = 0;
! 114: msg("You feel you have more chant ability. ");
! 115: }
! 116: if (pray_time > 0) {
! 117: pray_time -= 80;
! 118: if (pray_time < 0)
! 119: pray_time = 0;
! 120: msg("You feel you have more prayer ability. ");
! 121: }
! 122: if (spell_power > 0) {
! 123: spell_power -= 80;
! 124: if (spell_power < 0)
! 125: spell_power = 0;
! 126: msg("You feel you have more spell casting ability. ");
! 127: }
! 128: when E_CANDLEBERRY: /* cure him */
! 129: if (on(player, HASINFEST) ||
! 130: on(player, HASDISEASE)||
! 131: on(player, DOROT)) {
! 132: if (on(player, HASDISEASE)) {
! 133: extinguish(cure_disease);
! 134: cure_disease();
! 135: }
! 136: if (on(player, HASINFEST)) {
! 137: msg("You feel yourself improving. ");
! 138: turn_off(player, HASINFEST);
! 139: infest_dam = 0;
! 140: }
! 141: if (on(player, DOROT)) {
! 142: msg("You feel your skin returning to normal. ");
! 143: turn_off(player, DOROT);
! 144: }
! 145: }
! 146: when E_SLIMEMOLD: /* monster food */
! 147: msg("The slime-mold quivers around in your mouth. ");
! 148: player.t_no_move = 3*movement(&player);
! 149: if (off(player, HASDISEASE)) {
! 150: if (ISWEARING(R_HEALTH) || player.t_ctype == C_PALADIN ||
! 151: player.t_ctype == C_RANGER) {
! 152: msg("You feel lousy. ");
! 153: }
! 154: else {
! 155: turn_on(player, HASDISEASE);
! 156: fuse(cure_disease, NULL, roll(HEALTIME,SICKTIME),AFTER);
! 157: msg("You become ill. ");
! 158: }
! 159: }
! 160: pstats.s_const -= rnd(2)+1;
! 161: if (pstats.s_const <= 3) pstats.s_const = 3;
! 162:
! 163: otherwise: /* not all the foods have to do something */
! 164: break;
! 165: }
! 166: }
! 167:
CVSweb