Example #1
0
int opentin(void)
{
    if (!carried(tin.tin))     // perhaps it was stolen?
	return 0;	       // %% probably we should use tinoid
    if (tin.usedtime++ >= 50) {
	pline("You give up your attempt to open the tin.");
	return 0;
    }
    if (tin.usedtime < tin.reqtime)
	return 1;	       // still busy

    pline("You succeed in opening the tin.");
    useup(tin.tin);
    unsigned r = rn2(2 * ArraySize(c_tintxts));
    if (r < ArraySize(c_tintxts)) {
	pline(c_tintxts[r].txt);
	lesshungry(c_tintxts[r].nut);
	if (r == 1) {	       // SALMON
	    Glib = rnd(15);
	    pline("Eating salmon made your fingers very slippery.");
	}
    } else {
	pline("It contains spinach - this makes you feel like Popeye!");
	lesshungry(600);
	if (_u.ustr < 118)
	    _u.ustr += rnd(((_u.ustr < 17) ? 19 : 118) - _u.ustr);
	if (_u.ustr > _u.ustrmax)
	    _u.ustrmax = _u.ustr;
	_wflags.botl = 1;
    }
    return 0;
}
Example #2
0
opentin(){
	register int r;

	if(!carried(tin.tin))		/* perhaps it was stolen? */
		return(0);		/* %% probably we should use tinoid */
	if(tin.usedtime++ >= 50) {
		pline("You give up your attempt to open the tin.");
		return(0);
	}
	if(tin.usedtime < tin.reqtime)
		return(1);		/* still busy */

	pline("You succeed in opening the tin.");
	useup(tin.tin);
	r = rn2(2*TTSZ);
	if(r < TTSZ){
	    pline(tintxts[r].txt);
	    lesshungry(tintxts[r].nut);
	    if(r == 1)	/* SALMON */ {
		Glib = rnd(15);
		pline("Eating salmon made your fingers very slippery.");
	    }
	} else {
	    pline("It contains spinach - this makes you feel like Popeye!");
	    lesshungry(600);
	    if(u.ustr < 118)
		u.ustr += rnd( ((u.ustr < 17) ? 19 : 118) - u.ustr);
	    if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
	    flags.botl = 1;
	}
	return(0);
}
Example #3
0
int doeat(void)
{
    struct obj *otmp;
    int tmp;

    // Is there some food (probably a heavy corpse) here on the ground?
    if (!Levitation)
	for (otmp = _level->objects; otmp; otmp = otmp->nobj) {
	    if (otmp->ox == _u.ux && otmp->oy == _u.uy && otmp->olet == FOOD_SYM) {
		pline("There %s %s here; eat %s? [ny] ", (otmp->quan == 1) ? "is" : "are", doname(otmp), (otmp->quan == 1) ? "it" : "one");
		if (readchar() == 'y') {
		    if (otmp->quan != 1)
			(void) splitobj(otmp, 1);
		    freeobj(otmp);
		    otmp = addinv(otmp);
		    addtobill(otmp);
		    goto gotit;
		}
	    }
	}
    otmp = getobj("%", "eat");
    if (!otmp)
	return 0;
  gotit:
    if (otmp->otyp == TIN) {
	if (uwep) {
	    switch (uwep->otyp) {
		case CAN_OPENER:
		    tmp = 1;
		    break;
		case DAGGER:
		    tmp = 3;
		    break;
		case PICK_AXE:
		case AXE:
		    tmp = 6;
		    break;
		default:
		    goto no_opener;
	    }
	    pline("Using your %s you try to open the tin.", aobjnam(uwep, NULL));
	} else {
	  no_opener:
	    pline("It is not so easy to open this tin.");
	    if (Glib) {
		pline("The tin slips out of your hands.");
		if (otmp->quan > 1) {
		    struct obj *obj;

		    obj = splitobj(otmp, 1);
		    if (otmp == uwep)
			setuwep(obj);
		}
		dropx(otmp);
		return 1;
	    }
	    tmp = 10 + rn2(1 + 500 / ((int) (_u.ulevel + _u.ustr)));
	}
	tin.reqtime = tmp;
	tin.usedtime = 0;
	tin.tin = otmp;
	occupation = opentin;
	occtxt = "opening the tin";
	return 1;
    }
    const struct objclass* ftmp = &c_Objects[otmp->otyp];
    multi = -ftmp->oc_delay;
    if (otmp->otyp >= CORPSE && eatcorpse(otmp))
	goto eatx;
    if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
	pline("Blecch!  Rotten food!");
	if (!rn2(4)) {
	    pline("You feel rather light headed.");
	    Confusion += d(2, 4);
	} else if (!rn2(4) && !Blind) {
	    pline("Everything suddenly goes dark.");
	    Blind = d(2, 10);
	    seeoff(0);
	} else if (!rn2(3)) {
	    if (Blind)
		pline("The world spins and you slap against the floor.");
	    else
		pline("The world spins and goes dark.");
	    nomul(-rnd(10));
	    nomovemsg = "You are conscious again.";
	}
	lesshungry(ftmp->nutrition / 4);
    } else {
	if (_u.uhunger >= 1500) {
	    pline("You choke over your food.");
	    pline("You die...");
	    killer = ftmp->oc_name;
	    done("choked");
	}
	switch (otmp->otyp) {
	    case FOOD_RATION:
		if (_u.uhunger <= 200)
		    pline("That food really hit the spot!");
		else if (_u.uhunger <= 700)
		    pline("That satiated your stomach!");
		else {
		    pline("You're having a hard time getting all that food down.");
		    multi -= 2;
		}
		lesshungry(ftmp->nutrition);
		if (multi < 0)
		    nomovemsg = "You finished your meal.";
		break;
	    case TRIPE_RATION:
		pline("Yak - dog food!");
		more_experienced(1, 0);
		_wflags.botl = 1;
		if (rn2(2)) {
		    pline("You vomit.");
		    morehungry(20);
		    if (Sick) {
			Sick = 0;	// David Neves
			pline("What a relief!");
		    }
		} else
		    lesshungry(ftmp->nutrition);
		break;
	    default:
		if (otmp->otyp >= CORPSE)
		    pline("That %s tasted terrible!", ftmp->oc_name);
		else
		    pline("That %s was delicious!", ftmp->oc_name);
		lesshungry(ftmp->nutrition);
		if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
		    Confusion = 2;
		else if (otmp->otyp == FORTUNE_COOKIE) {
		    if (Blind) {
			pline("This cookie has a scrap of paper inside!");
			pline("What a pity, that you cannot read it!");
		    } else
			print_rumor();
		} else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
		    // This stuff seems to be VERY healthy!
		    if (_u.ustrmax < 118)
			++_u.ustrmax;
		    if (_u.ustr < _u.ustrmax)
			++_u.ustr;
		    _u.uhp += rnd(20);
		    if (_u.uhp > _u.uhpmax) {
			if (!rn2(17))
			    ++_u.uhpmax;
			_u.uhp = _u.uhpmax;
		    }
		    heal_legs();
		}
		break;
	}
    }
  eatx:
    if (multi < 0 && !nomovemsg) {
	static char msgbuf[BUFSZ];
	sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name);
	nomovemsg = msgbuf;
    }
    useup(otmp);
    return 1;
}
Example #4
0
int
dodrink()
{
	struct obj *otmp,*objs;
	struct monst *mtmp;
	int unkn = 0, nothing = 0;

	otmp = getobj("!", "drink");
	if(!otmp) return(0);
	if(!strcmp(objects[otmp->otyp].oc_descr, "smoky") && !rn2(13)) {
		ghost_from_bottle();
		goto use_it;
	}
	switch(otmp->otyp){
	case POT_RESTORE_STRENGTH:
		unkn++;
		pline("Wow!  This makes you feel great!");
		if(u.ustr < u.ustrmax) {
			u.ustr = u.ustrmax;
			flags.botl = 1;
		}
		break;
	case POT_BOOZE:
		unkn++;
		pline("Ooph!  This tastes like liquid fire!");
		Confusion += d(3,8);
		/* the whiskey makes us feel better */
		if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey");
		if(!rn2(4)) {
			pline("You pass out.");
			multi = -rnd(15);
			nomovemsg = "You awake with a headache.";
		}
		break;
	case POT_INVISIBILITY:
		if(Invis || See_invisible)
		  nothing++;
		else {
		  if(!Blind)
		    pline("Gee!  All of a sudden, you can't see yourself.");
		  else
		    pline("You feel rather airy."), unkn++;
		  newsym(u.ux,u.uy);
		}
		Invis += rn1(15,31);
		break;
	case POT_FRUIT_JUICE:
		pline("This tastes like fruit juice.");
		lesshungry(20);
		break;
	case POT_HEALING:
		pline("You begin to feel better.");
		flags.botl = 1;
		u.uhp += rnd(10);
		if(u.uhp > u.uhpmax)
			u.uhp = ++u.uhpmax;
		if(Blind) Blind = 1;	/* see on next move */
		if(Sick) Sick = 0;
		break;
	case POT_PARALYSIS:
		if(Levitation)
			pline("You are motionlessly suspended.");
		else
			pline("Your feet are frozen to the floor!");
		nomul(-(rn1(10,25)));
		break;
	case POT_MONSTER_DETECTION:
		if(!fmon) {
			strange_feeling(otmp, "You feel threatened.");
			return(1);
		} else {
			cls();
			for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
				if(mtmp->mx > 0)
				at(mtmp->mx,mtmp->my,mtmp->data->mlet);
			prme();
			pline("You sense the presence of monsters.");
			more();
			docrt();
		}
		break;
	case POT_OBJECT_DETECTION:
		if(!fobj) {
			strange_feeling(otmp, "You feel a pull downward.");
			return(1);
		} else {
		    for(objs = fobj; objs; objs = objs->nobj)
			if(objs->ox != u.ux || objs->oy != u.uy)
				goto outobjmap;
		    pline("You sense the presence of objects close nearby.");
		    break;
		outobjmap:
			cls();
			for(objs = fobj; objs; objs = objs->nobj)
				at(objs->ox,objs->oy,objs->olet);
			prme();
			pline("You sense the presence of objects.");
			more();
			docrt();
		}
		break;
	case POT_SICKNESS:
		pline("Yech! This stuff tastes like poison.");
		if(Poison_resistance)
    pline("(But in fact it was biologically contaminated orange juice.)");
		losestr(rn1(4,3));
		losehp(rnd(10), "contaminated potion");
		break;
	case POT_CONFUSION:
		if(!Confusion)
			pline("Huh, What?  Where am I?");
		else
			nothing++;
		Confusion += rn1(7,16);
		break;
	case POT_GAIN_STRENGTH:
		pline("Wow do you feel strong!");
		if(u.ustr >= 118) break;	/* > 118 is impossible */
		if(u.ustr > 17) u.ustr += rnd(118-u.ustr);
		else u.ustr++;
		if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
		flags.botl = 1;
		break;
	case POT_SPEED:
		if(Wounded_legs) {
			heal_legs();
			unkn++;
			break;
		}
		if(!(Fast & ~INTRINSIC))
			pline("You are suddenly moving much faster.");
		else
			pline("Your legs get new energy."), unkn++;
		Fast += rn1(10,100);
		break;
	case POT_BLINDNESS:
		if(!Blind)
			pline("A cloud of darkness falls upon you.");
		else
			nothing++;
		Blind += rn1(100,250);
		seeoff(0);
		break;
	case POT_GAIN_LEVEL: 
		pluslvl();
		break;
	case POT_EXTRA_HEALING:
		pline("You feel much better.");
		flags.botl = 1;
		u.uhp += d(2,20)+1;
		if(u.uhp > u.uhpmax)
			u.uhp = (u.uhpmax += 2);
		if(Blind) Blind = 1;
		if(Sick) Sick = 0;
		break;
	case POT_LEVITATION:
		if(!Levitation)
			float_up();
		else
			nothing++;
		Levitation += rnd(100);
		u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
		break;
	default:
		impossible("What a funny potion! (%u)", otmp->otyp);
		return(0);
	}
	if(nothing) {
	    unkn++;
	    pline("You have a peculiar feeling for a moment, then it passes.");
	}
	if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
		if(!unkn) {
			objects[otmp->otyp].oc_name_known = 1;
			more_experienced(0,10);
		} else if(!objects[otmp->otyp].oc_uname)
			docall(otmp);
	}
use_it:
	useup(otmp);
	return(1);
}
Example #5
0
// Note: this is a litte different, it will return true
// iff the action is COMPLETE, and false if there was no action OR
// the action is needing to finish up (after leaving SenseForm).
// So if (do_drink) the caller should exit invform _and_ tick,
// otherwise the caller should just exit invform.
// (exiting the invform occurs _before_ calling do_drink..)
// .. Ok, I've modified this again so that it lets the caller distinguish
// between "it worked" and "it worked and I popped up EngraveForm".
tri_val_t do_drink(obj_t *otmp)
{
  obj_t *objs;
  //  monst_t *mtmp;
  Boolean unkn = false, nothing = false, b;
  Short tmp;

  if (!otmp) return NO_OP;
  tmp = oc_descr_offset[otmp->otype];
  if (tmp >= 0 && (0 == StrNCompare("smoky", oc_descrs+tmp, 5)) && !rund(13)) {
    ghost_from_bottle();
    useup(otmp);
    return DONE;
  }
  switch(otmp->otype) {
  case POT_RESTORE_STRENGTH:
    unkn = true;
    message("Wow!  This makes you feel great!");
    if (you.ustr < you.ustrmax) {
      you.ustr = you.ustrmax;
      flags.botl |= BOTL_STR;
    }
    break;
  case POT_BOOZE:
    unkn = true;
    message("Ooph!  This tastes like liquid fire!");
    Confusion += dice(3,8);
    /* the whiskey makes us feel better */
    if (you.uhp < you.uhpmax) losehp(-1, "bottle of whiskey");
    if (!rund(4)) {
      tri_val_t t;
      //      Short coma;
      message("You pass out.");
      multi = -rnd(15);
      spin_multi("You awake with a headache.");
      //      coma = rnd(15); //
      //      do { tick(); } while (--coma > 0);
      //      message("You awake with a headache.");
      // // nomovemsg = "You awake with a headache.";
      t = finish_do_drink(otmp, nothing, unkn); //.... I guess....
      return (t==DONE ? NO_OP : t); // so that we don't take any _more_ turns
    }
    break;
  case POT_INVISIBILITY:
    if (Invis || See_invisible)
      nothing = true;
    else {
      if (!Blind)
	message("Gee!  All of a sudden, you can't see yourself.");
      else {
	message("You feel rather airy.");
	unkn = true;
      }
      newsym(you.ux,you.uy);
    }
    Invis += rund(15)+31;
    break;
  case POT_FRUIT_JUICE:
    message("This tastes like fruit juice.");
    lesshungry(20);
    break;
  case POT_HEALING:
    message("You begin to feel better.");
    you.uhp += rnd(10);
    if (you.uhp > you.uhpmax)
      you.uhp = ++you.uhpmax;
    if (Blind) Blind = 1;	/* you'll see again on the next move */
    if (Sick) Sick = 0;
    flags.botl |= BOTL_HP;
    break;
  case POT_PARALYSIS:
    if (Levitation)
      message("You are motionlessly suspended.");
    else
      message("Your feet are frozen to the floor!");
    nomul(-(rund(10)+25));
    break;
  case POT_MONSTER_DETECTION:
    if (!fmon) {
      b = strange_feeling(otmp, "You feel threatened.");
      return ((b) ? GO_ON : DONE);
    } else {
      sense_what = SENSE_MONSTERS;
      sense_by_what = otmp;
      sense_init_screen();
      FrmPopupForm(SenseForm);
      return GO_ON; // to postpone the tick!
    }
    break;
  case POT_OBJECT_DETECTION:
    if (!fobj) {
      b = strange_feeling(otmp, "You feel a pull downward.");
      return ((b) ? GO_ON : DONE);
    } else {
      for (objs = fobj; objs; objs = objs->nobj)
	if (objs->ox != you.ux || objs->oy != you.uy) {
	  sense_what = SENSE_OBJECTS;
	  sense_by_what = otmp;
	  sense_init_screen();
	  FrmPopupForm(SenseForm);
	  return GO_ON; // to postpone the tick!
	}
      message("You sense the presence of objects close nearby.");
      break;
    }
    break;
  case POT_SICKNESS:
    message("Yech! This stuff tastes like poison.");
    if (Poison_resistance)
      message("(But in fact it was biologically contaminated orange juice.)");
    losestr(rund(4)+3);
    losehp(rnd(10), "contaminated potion");
    flags.botl |= BOTL_STR;
    break;
  case POT_CONFUSION:
    if (!Confusion)
      message("Huh, What?  Where am I?");
    else
      nothing = true;
    Confusion += rund(7)+16;
    break;
  case POT_GAIN_STRENGTH:
    message("Wow do you feel strong!");
    if (you.ustr >= 118) break;	/* > 118 is impossible */
    if (you.ustr > 17) you.ustr += rnd(118-you.ustr);
    else you.ustr++;
    if (you.ustr > you.ustrmax) you.ustrmax = you.ustr;
    flags.botl |= BOTL_STR;
    break;
  case POT_SPEED:
    if (Wounded_legs) {
      heal_legs();
      unkn = true;
      break;
    }
    if (!(Fast & ~INTRINSIC))
      message("You are suddenly moving much faster.");
    else {
      message("Your legs get new energy.");
      unkn = true;
    }
    Fast += rund(10)+100;
    break;
  case POT_BLINDNESS:
    if (!Blind)
      message("A cloud of darkness falls upon you.");
    else
      nothing = true;
    Blind += rund(100)+250;
    seeoff(false);
    break;
  case POT_GAIN_LEVEL: 
    pluslvl();
    break;
  case POT_EXTRA_HEALING:
    message("You feel much better.");
    you.uhp += dice(2,20)+1;
    if (you.uhp > you.uhpmax)
      you.uhp = (you.uhpmax += 2);
    if (Blind) Blind = 1;
    if (Sick) Sick = 0;
    flags.botl |= BOTL_HP;
    break;
  case POT_LEVITATION:
    if (!Levitation)
      float_up();
    else
      nothing = true;
    Levitation += rnd(100);
    //    you.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down; // UNNEEDED,
    // it has been replaced by tweaking timeout.c to call float_down directly!
    break;
  default:
    StrPrintF(ScratchBuffer, "What a funny potion! (%u)", otmp->otype);
    message(ScratchBuffer);
    return NO_OP;
  }
  return finish_do_drink(otmp, nothing, unkn);
}