Esempio n. 1
0
void
pack_report(object *obj, int print_message, char *message)
{
    /* Notify the user */

    if (print_message)
    {
        if (!terse)
            addmsg(message);

        msg("(%c%c) %s.", obj->o_type, print_letters[get_ident(obj)],
            inv_name(obj, !terse));
    }

    if (obj->o_type == ARTIFACT)
    {
        has_artifact |= (1 << obj->o_which);
        picked_artifact |= (1 << obj->o_which);

        if (!(obj->ar_flags & ISUSED))
        {
            obj->ar_flags |= ISUSED;
            pstats.s_exp += arts[obj->o_which].ar_worth / 10;
            check_level();
        }
    }

    updpack();

    return;
}
Esempio n. 2
0
void
chg_str(int amt, int both, int lost)
{
    int           ring_str; /* ring strengths */
    struct stats *ptr;      /* for speed */

    ptr = &pstats;

    ring_str = ring_value(R_ADDSTR) + (on(player, POWERSTR) ? 10 : 0) +
               (on(player, SUPERHERO) ? 10 : 0);

    ptr->s_str -= ring_str;
    ptr->s_str += amt;

    if (ptr->s_str < 3)
    {
        ptr->s_str = 3;
        lost = FALSE;
    }
    else if (ptr->s_str > 25)
        ptr->s_str = 25;

    if (both)
        max_stats.s_str = ptr->s_str;

    if (lost)
        lost_str -= amt;

    ptr->s_str += ring_str;

    if (ptr->s_str < 0)
        ptr->s_str = 0;

    updpack();
}
Esempio n. 3
0
void
rem_pack(struct object *obj_p)
{
    cur_null(obj_p);    /* check for current stuff */
    pop_bag(&pack, obj_p);
    updpack();
    return;      /* tell caller an item has been removed */
}
Esempio n. 4
0
void
ring_off(void)
{
    struct object   *obj;
    struct linked_list  *item;

    if (cur_ring[LEFT_1] == NULL && cur_ring[LEFT_2] == NULL &&
        cur_ring[LEFT_3] == NULL && cur_ring[LEFT_4] == NULL &&
        cur_ring[LEFT_5] == NULL &&
        cur_ring[RIGHT_1] == NULL && cur_ring[RIGHT_2] == NULL &&
        cur_ring[RIGHT_3] == NULL && cur_ring[RIGHT_4] == NULL &&
        cur_ring[RIGHT_5] == NULL)
    {
        msg("You aren't wearing any rings.");
        return;
    }
    else if ((item = get_item("remove", RING)) == NULL)
        return;

    mpos = 0;
    obj = OBJPTR(item);

    if ((obj = OBJPTR(item)) == NULL)
        msg("You are not wearing that!");

    if (dropcheck(obj))
    {
        switch (obj->o_which)
        {
            case R_SEEINVIS:
                msg("Your eyes stop tingling.");
                break;

            case R_CARRYING:
                updpack();
                break;

            case R_LEVITATION:
                msg("You float gently to the ground.");
                break;

            case R_LIGHT:
                if (roomin(hero) != NULL)
                {
                    light(&hero);
                    mvwaddch(cw, hero.y, hero.x, PLAYER);
                }
                break;

            case R_TRUESEE:
                msg("Your sensory perceptions return to normal.");
                break;
        }

        msg("Was wearing %s.", inv_name(obj, LOWERCASE));
    }
}
Esempio n. 5
0
/* 
 * del_pack:
 *	Take something out of the hero's pack
 */
void del_pack(struct linked_list *what)
{
	struct object *op;

	op = OBJPTR(what);
	cur_null(op);		/* check for current stuff */
	if (op->o_count > 1) {
		op->o_count--;
	}
	else {
		detach(pack,what);
		discard(what);
	}
	updpack();
}
fuse
res_strength(fuse_arg *arg)
{
    NOOP(arg);

    if (lost_str)
    {
        chg_str(lost_str, FALSE, FALSE);
        lost_str = 0;
    }
    else
        pstats.s_str = max_stats.s_str + ring_value(R_ADDSTR) +
            (on(player, POWERSTR) ? 10 : 0) +
            (on(player, SUPERHERO) ? 10 : 0);

    updpack();
}
/*
 * res_strength:
 *	Restore player's strength
 */
void
res_strength(void)
{

    /* If lost_str is non-zero, restore that amount of strength,
     * else all of it 
     */
    if (lost_str) {
	chg_str(lost_str, FALSE, FALSE);
	lost_str = 0;
    }

    /* Otherwise, put player at the maximum strength */
    else {
	pstats.s_str = max_stats.s_str + ring_value(R_ADDSTR) + 
		(on(player, POWERSTR) ? 10 : 0) +
		(on(player, SUPERHERO) ? 10 : 0);
    }

    updpack(TRUE);
}
Esempio n. 8
0
void
eat(void)
{
    struct object   *obj;
    int amount;
    float scale = (float) (LINES * COLS) / (25.0F * 80.0F);

    if ((obj = get_object(pack, "eat", FOOD, NULL)) == NULL)
        return;

    switch (obj->o_which)
    {
    case FD_RATION:
        amount = (int)(scale * (HUNGERTIME + rnd(400) - 200));

        if (rnd(100) > 70)
        {
            msg("Yuk, this food tastes awful.");
            pstats.s_exp++;
            check_level();
        }
        else
            msg("Yum, that tasted good.");
        break;

    case FD_FRUIT:
        amount = (int)(scale * (200 + rnd(HUNGERTIME)));
        msg("My, that was a yummy %s.", fruit);
        break;

    case FD_CRAM:
        amount = (int)(scale * (rnd(HUNGERTIME / 2) + 600));
        msg("The cram tastes dry in your mouth.");
        break;

    case FD_CAKES:
        amount = (int)(scale * ((HUNGERTIME / 3) + rnd(600)));
        msg("Yum, the honey cakes tasted good.");
        break;

    case FD_LEMBA:
        amount = (int)(scale * ((HUNGERTIME / 2) + rnd(900)));
        quaff(&player, P_HEALING, ISNORMAL);
        break;

    case FD_MIRUVOR:
        amount = (int)(scale * ((HUNGERTIME / 3) + rnd(500)));
        quaff(&player, P_HEALING, ISNORMAL);
        quaff(&player, P_RESTORE, ISNORMAL);
        break;

    default:
        msg("What a strange thing to eat!");
        amount = (int)(scale * HUNGERTIME);
    }

    food_left += amount;

    if (obj->o_flags & ISBLESSED)
    {
        food_left += 2 * amount;
        msg("You have a tingling feeling in your mouth.");
    }
    else if (food_left > scale * STOMACHSIZE)
    {
        food_left = (int)(scale * STOMACHSIZE);
        msg("You feel satiated and too full to move.");
        no_command = HOLDTIME;
    }

    hungry_state = F_OK;
    updpack();

    if (obj == cur_weapon)
        cur_weapon = NULL;

    if (--obj->o_count <= 0) /* Remove this pack entry if last of food */
        discard_pack(obj);
}
daemon
stomach(daemon_arg *arg)
{
    int oldfood, old_hunger;
    int amount;
    int power_scale;

    NOOP(arg);

    old_hunger = hungry_state;

    if (food_left <= 0)
    {
        /* the hero is fainting */

        if (no_command || rnd(100) > 20)
            return;

        no_command = rnd(8) + 4;
        running = FALSE;
        count = 0;
        hungry_state = F_FAINT;
        feed_me(hungry_state);
    }
    else
    {
        oldfood = food_left;

        amount = ring_eat(LEFT_1) + ring_eat(LEFT_2) +
            ring_eat(LEFT_3) + ring_eat(LEFT_4) +
            ring_eat(RIGHT_1) + ring_eat(RIGHT_2) +
            ring_eat(RIGHT_3) + ring_eat(RIGHT_4) +
            foodlev;

        if (on(player, SUPEREAT))   /* artifact or regeneration munchies */
            amount *= 2;

        if (on(player, POWEREAT))  /* Used an artifact power */
        {
            amount += 40;
            turn_off(player, POWEREAT);
        }

        power_scale = (on(player, POWERDEXT) + on(player, POWERSTR) +
            on(player, POWERWISDOM) + on(player, POWERINTEL) +
            on(player, POWERCONST) + 1);

        food_left -= amount * power_scale;

        if (food_left < MORETIME && oldfood >= MORETIME)
        {
            hungry_state = F_WEAK;
            running = FALSE;
            feed_me(hungry_state);
        }
        else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
        {
            hungry_state = F_HUNGRY;
            running = FALSE;
            feed_me(hungry_state);
        }
    }

    if (old_hunger != hungry_state)
        updpack();

    wghtchk(NULL);
}
/*
 * missile:
 *	Fire a missile in a given direction
 */
void
missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp)
{
	register struct object *obj ;
	register struct linked_list *nitem ;

	/*
	* Get which thing we are hurling
	*/
	if (item == NULL) {
		return ;
	}
	obj = (struct object *) ldata(item) ;
	if (!dropcheck(obj) || is_current(obj)) {
		return ;
	}
	/*
	* Get rid of the thing. If it is a non-multiple item object, or
	* if it is the last thing, just drop it. Otherwise, create a new
	* item with a count of one.
	*/
	if (obj->o_count < 2) {
		detach(tp->t_pack, item) ;
		if (tp->t_pack == pack) {
			inpack-- ;
			freeletter(item);
		}
	} else {
		obj->o_count-- ;
		nitem = (struct linked_list *) new_item(sizeof *obj) ;
		obj = (struct object *) ldata(nitem) ;
		*obj = *((struct object *) ldata(item)) ;
		obj->o_count = 1 ;
		item = nitem ;
	}
	if (obj->o_type == ARTIFACT)
		has_artifact &= ~(1 << obj->o_which);
	if (obj->o_type == SCROLL && obj->o_which == S_SCARE) {
		if (obj->o_flags & ISBLESSED)
		    obj->o_flags &= ~ISBLESSED;
		else 
		    obj->o_flags |= ISCURSED;
	}
	updpack (FALSE);
	do_motion(obj, ydelta, xdelta, tp) ;
	/*
	* AHA! Here it has hit something. If it is a wall or a door,
	* or if it misses (combat) the monster, put it on the floor
	*/
	if (!hit_monster(unc(obj->o_pos), obj, tp)) {
		if (obj->o_type == WEAPON && obj->o_which == GRENADE) {
			register struct room *rp;
            static coord fpos;

            msg("BOOOM!");
            aggravate();
            rp = roomin(&obj->o_pos);
            if (ntraps + 1 < MAXTRAPS + MAXTRAPS &&
					fallpos(&obj->o_pos, &fpos, TRUE)) {
				mvaddch(fpos.y, fpos.x, TRAPDOOR);
                traps[ntraps].tr_type = TRAPDOOR;
                traps[ntraps].tr_flags = ISFOUND;
                traps[ntraps].tr_show = TRAPDOOR;
                traps[ntraps].tr_pos.y = fpos.y;
                traps[ntraps++].tr_pos.x = fpos.x;
                light(&hero);
            }
            discard(item);
        }
	    else if (obj->o_flags & ISLOST) {
		if (obj->o_type == WEAPON)
		    addmsg("The %s", weaps[obj->o_which].w_name);
		else
		    addmsg(inv_name(obj, TRUE));
		msg(" vanishes in a puff of greasy smoke.");
		discard(item);
	    }
	    else {
		if (fall(item, TRUE))
		if (obj->o_flags & CANRETURN)
		    msg("You have %s.", inv_name(obj, TRUE));
	    }
	}
	else if (obj->o_flags & ISOWNED) {
		add_pack(item, TRUE);
		msg("You have %s.", inv_name(obj, TRUE));
	}
	mvwaddch(cw, hero.y, hero.x, PLAYER) ;
}
Esempio n. 11
0
void
ring_on(void)
{
    struct object   *obj;
    struct linked_list  *item;
    int ring;
    char buf[2 * LINELEN];

    if ((item = get_item("put on", RING)) == NULL)
        return;

    obj = OBJPTR(item);

    if (obj->o_type != RING)
    {
        msg("You can't put that on!");
        return;
    }

    /* find out which hand to put it on */

    if (is_current(obj))
    {
        msg("Already wearing that!");
        return;
    }

    if (cur_ring[LEFT_1] == NULL)
        ring = LEFT_1;
    else if (cur_ring[LEFT_2] == NULL)
        ring = LEFT_2;
    else if (cur_ring[LEFT_3] == NULL)
        ring = LEFT_3;
    else if (cur_ring[LEFT_4] == NULL)
        ring = LEFT_4;
    else if (cur_ring[LEFT_5] == NULL)
        ring = LEFT_5;
    else if (cur_ring[RIGHT_1] == NULL)
        ring = RIGHT_1;
    else if (cur_ring[RIGHT_2] == NULL)
        ring = RIGHT_2;
    else if (cur_ring[RIGHT_3] == NULL)
        ring = RIGHT_3;
    else if (cur_ring[RIGHT_4] == NULL)
        ring = RIGHT_4;
    else if (cur_ring[RIGHT_5] == NULL)
        ring = RIGHT_5;
    else
    {
        msg("You already have on ten rings.");
        return;
    }

    cur_ring[ring] = obj;

    /* Calculate the effect it has on the poor guy. */

    switch (obj->o_which)
    {
        case R_ADDSTR:
            pstats.s_str += obj->o_ac;
            break;
        case R_ADDHIT:
            pstats.s_dext += obj->o_ac;
            break;
        case R_ADDINTEL:
            pstats.s_intel += obj->o_ac;
            break;
        case R_ADDWISDOM:
            pstats.s_wisdom += obj->o_ac;
            break;
        case R_FREEDOM:
            turn_off(player, ISHELD);
            hold_count = 0;
            break;
        case R_TRUESEE:
            if (off(player, PERMBLIND))
            {
                turn_on(player, CANTRUESEE);
                msg("You become more aware of your surroundings.");
                sight(NULL);
                light(&hero);
                mvwaddch(cw, hero.y, hero.x, PLAYER);
            }
            break;

        case R_SEEINVIS:
            if (off(player, PERMBLIND))
            {
                turn_on(player, CANTRUESEE);
                msg("Your eyes begin to tingle.");
                sight(NULL);
                light(&hero);
                mvwaddch(cw, hero.y, hero.x, PLAYER);
            }
            break;

        case R_AGGR:
            aggravate();
            break;

        case R_CARRYING:
            updpack();
            break;

        case R_LEVITATION:
            msg("You begin to float in the air!");
            break;

        case R_LIGHT:
            if (roomin(hero) != NULL)
            {
                light(&hero);
                mvwaddch(cw, hero.y, hero.x, PLAYER);
            }
    }

    status(FALSE);

    if (know_items[TYP_RING][obj->o_which] &&
        guess_items[TYP_RING][obj->o_which])
    {
        mem_free(guess_items[TYP_RING][obj->o_which]);
        guess_items[TYP_RING][obj->o_which] = NULL;
    }
    else if (!know_items[TYP_RING][obj->o_which] &&
         askme &&
         (obj->o_flags & ISKNOW) == 0 &&
         guess_items[TYP_RING][obj->o_which] == NULL)
    {
        mpos = 0;
        msg("What do you want to call it? ");

        if (get_string(buf, cw) == NORM)
        {
            guess_items[TYP_RING][obj->o_which] =
                new_alloc(strlen(buf) + 1);
            strcpy(guess_items[TYP_RING][obj->o_which], buf);
        }
        msg("");
    }
}
Esempio n. 12
0
/*
 * add_pack:
 * Pick up an object and add it to the pack.  If the argument
 * is non-null use it as the linked_list pointer instead of
 * getting it off the ground.
 */
bool add_pack(struct linked_list *item,bool silent)
{
	struct linked_list *ip, *lp;
	struct object *obj, *op;
	bool from_floor;
	char delchar;

	if (player.t_room == NULL)
		delchar = PASSAGE;
	else
		delchar = FLOOR;
	if (item == NULL) {
		from_floor = TRUE;
		if ((item = find_obj(hero.y, hero.x)) == NULL) {
			mpos = 0;
			msg("That object must have been an illusion.");
			mvaddch(hero.y, hero.x, delchar);
			return FALSE;
		}
		/*
		 * Check for scare monster scrolls
		 */
		obj = OBJPTR(item);
		if (obj->o_type == SCROLL && obj->o_which == S_SCARE) {
			if (o_on(obj,ISFOUND)) {
				msg("The scroll turns to dust as you pick it up.");
				detach(lvl_obj, item);
				discard(item);
				mvaddch(hero.y, hero.x, delchar);	
				return FALSE;
			}
		}
	}
	else
		from_floor = FALSE;
	obj = OBJPTR(item);
	/*
	 * See if this guy can carry any more weight
	 */
	if (itemweight(obj) + him->s_pack > him->s_carry) {
		msg("You can't carry that %s.", obj->o_typname);
		return FALSE;
	}
	/*
	 * Check if there is room
	 */
	if (packvol + obj->o_vol > V_PACK) {
		msg("That %s won't fit in your pack.", obj->o_typname);
		return FALSE;
	}
	if (from_floor) {
		detach(lvl_obj, item);
		mvaddch(hero.y, hero.x, delchar);
	}
	item->l_prev = NULL;
	item->l_next = NULL;
	setoflg(obj, ISFOUND);
	/*
	 * start looking thru pack to find the start of items
	 * with the same type.
	 */
	lp = pack;
	for (ip = pack; ip != NULL; ip = next(ip)) {
		op = OBJPTR(ip);
		/*
		 * If we find a matching type then quit.
		 */
		if (op->o_type == obj->o_type)
			break;
		if (next(ip) != NULL)
			lp = next(lp);		/* update "previous" entry */
	}
	/*
	 * If the pack was empty, just stick the item in it.
	 */
	if (pack == NULL) {
		pack = item;
		item->l_prev = NULL;
	}
	/*
	 * If we looked thru the pack, but could not find an
	 * item of the same type, then stick it at the end,
	 * unless it was food, then put it in front.
	 */
	else if (ip == NULL) {
		if (obj->o_type == FOOD) {	/* insert food at front */
			item->l_next = pack;
			pack->l_prev = item;
			pack = item;
			item->l_prev = NULL;
		}
		else {						/* insert other stuff at back */
			lp->l_next = item;
			item->l_prev = lp;
		}
	}
	/*
	 * Here, we found at least one item of the same type.
	 * Look thru these items to see if there is one of the
	 * same group. If so, increment the count and throw the
	 * new item away. If not, stick it at the end of the
	 * items with the same type. Also keep all similar
	 * objects near each other, like all identify scrolls, etc.
	 */
	else {
		struct linked_list **save;

		while (ip != NULL && op->o_type == obj->o_type) {
			if (op->o_group == obj->o_group) {
				if (op->o_flags == obj->o_flags) {
					op->o_count++;
					discard(item);
					item = ip;
					goto picked_up;
				}
				else {
					goto around;
				}
			}
			if (op->o_which == obj->o_which) {
				if (obj->o_type == FOOD)
					ip = next(ip);
				break;
			}
around:
			ip = next(ip);
			if (ip != NULL) {
				op = OBJPTR(ip);
				lp = next(lp);
			}
		}
		/*
		 * If inserting into last of group at end of pack,
		 * just tack on the end.
		 */
		if (ip == NULL) {
			lp->l_next = item;
			item->l_prev = lp;
		}
		/*
		 * Insert into the last of a group of objects
		 * not at the end of the pack.
		 */
		else {
			save = &((ip->l_prev)->l_next);
			item->l_next = ip;
			item->l_prev = ip->l_prev;
			ip->l_prev = item;
			*save = item;
		}
	}
picked_up:
	obj = OBJPTR(item);
	if (!silent)
		msg("%s (%c)",inv_name(obj,FALSE),pack_char(obj));
	if (obj->o_type == AMULET)
		amulet = TRUE;
	updpack();				/* new pack weight & volume */
	return TRUE;
}
/*
 * digest the hero's food
 */
void
stomach(void)
{
    register int oldfood, old_hunger;
    register int amount;
    int power_scale;

    old_hunger = hungry_state;
    if (food_left <= 0)
    {
	/*
	 * the hero is fainting
	 */
	if (no_command || rnd(100) > 20)
	    return;
	no_command = rnd(8)+4;
	if (!terse)
	    addmsg("You feel too weak from lack of food.  ");
	msg("You faint.");
	running = FALSE;
	count = 0;
	hungry_state = F_FAINT;
    }
    else
    {
	oldfood = food_left;
	amount =	ring_eat(LEFT_1) + ring_eat(LEFT_2) +
			ring_eat(LEFT_3) + ring_eat(LEFT_4) +
	    		ring_eat(RIGHT_1) + ring_eat(RIGHT_2) +
			ring_eat(RIGHT_3) + ring_eat(RIGHT_4) + 
			foodlev;

	if (on(player, SUPEREAT))
	    amount *= 2;

	if (on(player, POWEREAT)) {
	    amount += 40;
	    turn_off(player, POWEREAT);
	}

	power_scale =	on(player, POWERDEXT) + on(player, POWERSTR) +
		on(player, POWERWISDOM) + on(player, POWERINTEL) +
		on(player, POWERCONST) + 1;

	food_left -= amount * power_scale;

	if (food_left < MORETIME && oldfood >= MORETIME)
	{
	    msg("You are starting to feel weak.");
	    hungry_state = F_WEAK;
	}
	else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
	{
	    msg(terse ? "Getting hungry." : "You are starting to get hungry.");
	    hungry_state = F_HUNGRY;
	}

    }
    if (old_hunger != hungry_state) 
	updpack(TRUE);
    wghtchk();
}
Esempio n. 14
0
/*
 * quaff:
 *	Let the hero drink a potion
 */
int quaff()
{
	struct object *obj;
	struct linked_list *item, *titem;
	struct thing *th;
	int wh;
	char buf[LINLEN];
	bool bless, curse;

	/*
	 * Make certain that it is somethings that we want to drink
	 */
	if ((item = get_item("quaff", POTION)) == NULL)
		return 0;
	obj = OBJPTR(item);
	if (obj->o_type != POTION) {
		msg("That's undrinkable!");
		after = FALSE;
		return 0;
	}
	wh = obj->o_which;
	bless = o_on(obj, ISBLESS);
	curse = o_on(obj, ISCURSED);
	del_pack(item);		/* get rid of it */

	/*
	 * Calculate the effect it has on the poor guy.
	 */
	switch(wh) {
	case P_CONFUSE:
		if (!bless) {
			if (pl_on(ISINVINC))
				msg("You remain level-headed.");
			else {
				chg_abil(WIS,-1,TRUE);		/* confuse his mind */
				if (pl_off(ISHUH)) {
					msg("Wait, what's going on here. Huh? What? Who?");
					if (pl_on(ISHUH))
						lengthen(unconfuse,rnd(8)+HUHDURATION);
					else
						fuse(unconfuse,TRUE,rnd(8)+HUHDURATION);
					player.t_flags |= ISHUH;
				}
			}
			p_know[P_CONFUSE] = TRUE;
		}
	when P_POISON:
		if (!bless) {
			if (pl_off(ISINVINC) && !iswearing(R_SUSTSTR) &&
			  !iswearing(R_SUSAB)) {
				chg_abil(CON,-1,TRUE);		
				chg_abil(STR,-(rnd(3)+1),TRUE);
				msg("You feel very sick now.");
			}
			else
				msg("You feel momentarily sick.");
			p_know[P_POISON] = TRUE;
		}
	when P_HEALING:
		if (!curse) {
			heal_self(4, TRUE);
			msg("You begin to feel better.");
			if (!iswearing(R_SLOW))
				notslow(FALSE);
			sight(FALSE);
			p_know[P_HEALING] = TRUE;
		}
	when P_STRENGTH:
		if (!curse) {
			msg("You feel stronger, now.  What bulging muscles!");
			chg_abil(STR,1,TRUE);
			p_know[P_STRENGTH] = TRUE;
		}
	when P_MFIND:
		/*
		 * Potion of monster detection - find all monsters
		 */
		if (mlist != NULL && !curse) {
			dispmons();
			mpos = 0;
			msg("You begin to sense the presence of monsters--More--");
			p_know[P_MFIND] = TRUE;
			wait_for(cw,' ');
			msg("");		/* clear line */
		}
		else
			msg("You have a strange feeling for a moment, then it passes.");
	when P_TFIND:
		/*
		 * Potion of magic detection.  Show the potions and scrolls
		 */
		if (lvl_obj != NULL && !curse) {
			struct linked_list *mobj;
			struct object *tp;
			bool show;

			show = FALSE;
			wclear(hw);
			for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) {
				tp = OBJPTR(mobj);
				if (is_magic(tp)) {
					show = TRUE;
					mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
				}
			}
			for(titem = mlist; titem != NULL; titem = next(titem)) {
				struct linked_list *pitem;

				th = THINGPTR(titem);
				for(pitem=th->t_pack;pitem!=NULL;pitem=next(pitem)) {
					if (is_magic(ldata(pitem))) {
						show = TRUE;
						mvwaddch(hw,th->t_pos.y, th->t_pos.x, MAGIC);
					}
				}
			}
			if (show) {
				msg("You begin to sense the presence of magic.");
				overlay(hw,cw);
				p_know[P_TFIND] = TRUE;
				break;
			}
		}
		msg("You have a strange feeling for a moment, then it passes.");
	when P_PARALYZE:
		if (!bless) {
			if (pl_on(ISINVINC))
				msg("You feel numb for a moment.");
			else {
				msg("You can't move.");
				player.t_nocmd = HOLDTIME;
			}
			p_know[P_PARALYZE] = TRUE;
		}
	when P_SEEINVIS:
		if (!curse) {
			int invlen = roll(40,20);

			msg("This potion tastes like %s juice.", fruit);
			if (pl_off(CANSEE)) {
				player.t_flags |= CANSEE;
				fuse(unsee, TRUE, invlen);
				light(&hero);
			}
			else
				lengthen(unsee, invlen);
			sight(FALSE);
		}
	when P_RAISE:
		if (!curse) {
			msg("You suddenly feel much more skillful.");
			p_know[P_RAISE] = TRUE;
			chg_abil(DEX,1,TRUE);
			chg_abil(WIS,1,TRUE);
			chg_abil(CON,1,TRUE);
			raise_level();
		}
	when P_XHEAL:
		if (!curse) {
			heal_self(8, TRUE);
			if (rnd(100) < 50)
				chg_abil(CON,1,TRUE);
			msg("You begin to feel much better.");
			p_know[P_XHEAL] = TRUE;
			if (!iswearing(R_SLOW))
				notslow(FALSE);
			unconfuse();
			extinguish(unconfuse);
			sight(FALSE);
		}
	when P_HASTE:
		if (!curse) {
			add_haste(TRUE);
			msg("You feel yourself moving much faster.");
			p_know[P_HASTE] = TRUE;
		}
	when P_INVINC:
		if (!curse) {
			int time = rnd(400) + 350;

			msg("You feel invincible.");
			if (player.t_flags & ISINVINC)
				lengthen(notinvinc,time);
			else
				fuse(notinvinc,TRUE,time);
			player.t_flags |= ISINVINC;
			p_know[P_INVINC] = TRUE;
		}
	when P_SMART:
		if (!curse) {
			msg("You feel more perceptive.");
			p_know[P_SMART] = TRUE;
			chg_abil(WIS,1,TRUE);
		}
	when P_RESTORE:
		if (!curse) {
			msg("Hey, this tastes great. You feel warm all over.");
			him->s_re = max_stats.s_re;
			him->s_ef = max_stats.s_re;
			ringabil();				/* add in rings */
			updpack();				/* update weight */
			p_know[P_RESTORE] = TRUE;
			extinguish(rchg_str);	/* kill restore in from ulodyte */
		}
	when P_BLIND:
		if (!bless) {
			if (pl_on(ISINVINC))
				msg("The light dims for a moment.");
			else {
				chg_abil(WIS,-1,TRUE);
				msg("A cloak of darkness falls around you.");
				if (pl_off(ISBLIND)) {
					player.t_flags |= ISBLIND;
					fuse(sight, TRUE, rnd(400) + 450);
					light(&hero);
				}
			}
			p_know[P_BLIND] = TRUE;
		}
	when P_ETH:
		if (!curse) {
			int ethlen = roll(40,20);

			msg("You feel more vaporous.");
			if (pl_on(ISETHER))
				lengthen(noteth,ethlen);
			else
				fuse(noteth,TRUE,ethlen);
			player.t_flags |= ISETHER;
			p_know[P_ETH] = TRUE;
		}
	when P_NOP:
		msg("This potion tastes extremely dull.");
	when P_DEX:
		if (!curse) {
			chg_abil(DEX,1,TRUE);		/* increase dexterity */
			p_know[P_DEX] = TRUE;
			msg("You feel much more agile.");
		}
	when P_REGEN:
		if (!curse) {
			int reglen = rnd(450) + 450;

			if (pl_on(ISREGEN))
				lengthen(notregen, reglen);
			else
				fuse(notregen, TRUE, reglen);
			player.t_flags |= ISREGEN;
			msg("You feel yourself improved.");
			p_know[P_REGEN] = TRUE;
		}
	when P_DECREP:
	case P_SUPHERO: {
		int howmuch = rnd(3) + 1;

		if (wh == P_DECREP) {
			if (!bless) {
				if (iswearing(R_SUSAB) || pl_on(ISINVINC)) {
					msg("You feel momentarily woozy.");
					howmuch = 0;
				}
				else {
					msg("You feel crippled.");
					howmuch = -howmuch;
					if (!iswearing(R_SUSTSTR))
						chg_abil(STR,howmuch,TRUE);
				}
			}
			else
				howmuch = 0;
		}
		else {			/* potion of superhero */
			if (curse)
				howmuch = 0;
			msg("You feel invigorated.");
			chg_abil(STR,howmuch,TRUE);
		}
		chg_abil(CON,howmuch,TRUE);
		chg_abil(DEX,howmuch,TRUE);
		chg_abil(WIS,howmuch,TRUE);		/* change abilities */
		p_know[wh] = TRUE;
	}
	otherwise:
		msg("What an odd tasting potion!");
		return 0;
	}
	nochange = FALSE;
	if (p_know[wh] && p_guess[wh]) {
		free(p_guess[wh]);
		p_guess[wh] = NULL;
	}
	else if(!p_know[wh] && p_guess[wh] == NULL) {
		strcpy(buf, p_colors[wh]);
		msg(callit);
		if (get_str(buf, cw) == NORM) {
			p_guess[wh] = new(strlen(buf) + 1);
			strcpy(p_guess[wh], buf);
		}
Esempio n. 15
0
/*
 * ring_on:
 *	Put on a ring
 */
int ring_on()
{
  struct object *obj;
  struct linked_list *item;
  int ring, wh;
  char buf[LINLEN];
  bool okring;

  if (cur_ring[LEFT] != NULL && cur_ring[RIGHT] != NULL) {
    msg("Already wearing two rings.");
    after = FALSE;
    return 0;
  }
  /*
   * Make certain that it is somethings that we want to wear
   */
  if ((item = get_item("put on", RING)) == NULL)
    return 0;
  obj = OBJPTR(item);
  if (obj->o_type != RING) {
    msg("That won't fit on your finger.");
    return 0;
  }
  /*
   * find out which hand to put it on
   */
  if (is_current(obj))
    return 0;
  if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) {
    if ((ring = gethand(FALSE)) < 0)
      return 0;
  } else if (cur_ring[LEFT] == NULL)
    ring = LEFT;
  else
    ring = RIGHT;
  cur_ring[ring] = obj;
  wh = obj->o_which;
  /*
   * okring = FALSE when:
   * 1) ring is cursed and benefit = plus
   * 2) ring is blessed and benefit = minus
   */
  okring = !((obj->o_ac > 0 && o_on(obj, ISCURSED)) ||
             (obj->o_ac < 0 && o_on(obj, ISBLESS)));
  /*
   * Calculate the effect it has on the poor guy (if possible).
   */
  if (okring) {
    switch (wh) {
    case R_SPEED:
      if (--obj->o_ac < 0) {
        obj->o_ac = 0;
        setoflg(obj, ISCURSED);
      } else {
        add_haste(FALSE);
        msg("You find yourself moving must faster.");
      }
      when R_GIANT : /* to 24 */
                     him->s_ef.a_str = MAXSTR;
      when R_ADDSTR : chg_abil(STR, obj->o_ac, FROMRING);
      when R_KNOW : chg_abil(WIS, obj->o_ac, FROMRING);
      when R_DEX : chg_abil(DEX, obj->o_ac, FROMRING);
      when R_CONST : chg_abil(CON, obj->o_ac, FROMRING);
      when R_SEEINVIS : player.t_flags |= CANSEE;
      light(&hero);
      mvwaddch(cw, hero.y, hero.x, PLAYER);
      when R_AGGR : aggravate();
      when R_HEAVY : updpack(); /* new pack weight */
      when R_BLIND : r_know[R_BLIND] = TRUE;
      player.t_flags |= ISBLIND;
      look(FALSE);
      when R_SLOW : player.t_flags |= ISSLOW;
      when R_SAPEM : fuse(sapem, TRUE, 150);
      when R_LIGHT:
      {
        struct room *rop;

        r_know[R_LIGHT] = TRUE;
        if ((rop = player.t_room) != NULL) {
          rop->r_flags &= ~ISDARK;
          light(&hero);
          mvwaddch(cw, hero.y, hero.x, PLAYER);
        }
      }
    }
  }
  if (r_know[wh] && r_guess[wh]) {
    free(r_guess[wh]);
    r_guess[wh] = NULL;
  } else if (!r_know[wh] && r_guess[wh] == NULL) {
    mpos = 0;
    strcpy(buf, r_stones[wh]);
    msg(callit);
    if (get_str(buf, cw) == NORM) {
      r_guess[wh] = new (strlen(buf) + 1);
      strcpy(r_guess[wh], buf);
    }
Esempio n. 16
0
void
missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp)
{
    struct object   *obj;
    struct linked_list  *nitem;

    if (item == NULL)   /* Get which thing we are hurling */
        return;

    obj = OBJPTR(item);

    if (!dropcheck(obj) || is_current(obj))
        return;

    /*
     * Get rid of the thing. If it is a non-multiple item object, or if
     * it is the last thing, just drop it. Otherwise, create a new item
     * with a count of one.
    */

    if (obj->o_count < 2)
    {
        if (tp->t_pack == pack)
            rem_pack(obj);
        else
            detach(tp->t_pack, item);
    }
    else
    {
        obj->o_count--;
        nitem = (struct linked_list *) new_item(sizeof *obj);
        obj = OBJPTR(nitem);
        *obj = *(OBJPTR(item));
        obj->o_count = 1;
        item = nitem;
    }

    switch (obj->o_type)
    {
        case ARTIFACT:
            has_artifact &= ~(1 << obj->o_which);
            break;

        case SCROLL:
            if (obj->o_which == S_SCARE && obj->o_flags & ISBLESSED)
                obj->o_flags &= ~ISBLESSED;
            else
                obj->o_flags |= ISCURSED;
    }

    updpack();
    obj->o_pos = do_motion(obj->o_type, ydelta, xdelta, tp);

    /*
     * AHA! Here it has hit something. If it is a wall or a door, or if
     * it misses (combat) the monster, put it on the floor
     */

    if (!hit_monster(obj->o_pos.y, obj->o_pos.x, obj, tp))
    {
        if (obj->o_type == WEAPON && obj->o_which == GRENADE)
        {
            hearmsg("BOOOM!");
            aggravate();

            if (ntraps + 1 < 2 * MAXTRAPS &&
                fallpos(obj->o_pos, &traps[ntraps].tr_pos))
            {
                mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x,
                    TRAPDOOR);
                traps[ntraps].tr_type = TRAPDOOR;
                traps[ntraps].tr_flags = ISFOUND;
                traps[ntraps].tr_show = TRAPDOOR;
                ntraps++;
                light(&hero);
            }
            discard(item);
        }
        else if (obj->o_flags & ISLOST)
        {
            if (obj->o_type == WEAPON)
                addmsg("The %s", weaps[obj->o_which].w_name);
            else
                addmsg(inv_name(obj, LOWERCASE));

            msg(" vanishes in a puff of greasy smoke.");
            discard(item);
        }
        else
        {
            fall(&player, item, TRUE, TRUE);

            if (obj->o_flags & CANRETURN)
                msg("You have %s.", inv_name(obj, LOWERCASE));
        }
    }
    else if (obj->o_flags & ISOWNED)
    {
        add_pack(item, NOMESSAGE);
        msg("You have %s.", inv_name(obj, LOWERCASE));
    }

    mvwaddch(cw, hero.y, hero.x, PLAYER);
}
void
ring_on(void)
{
    register struct object *obj;
    register struct linked_list *item;
    register int ring;
    char buf[LINELEN];

    item = get_item("put on", RING);
    /*
     * Make certain that it is somethings that we want to wear
     */
    if (item == NULL)
	return;
    obj = (struct object *) ldata(item);
    if (obj->o_type != RING) {
	msg("You can't put that on!");
	return;
    }

    /*
     * find out which hand to put it on
     */
    if (is_current(obj))
	return;

    if      (cur_ring[LEFT_1] == NULL) ring = LEFT_1;
    else if (cur_ring[LEFT_2] == NULL) ring = LEFT_2;
    else if (cur_ring[LEFT_3] == NULL) ring = LEFT_3;
    else if (cur_ring[LEFT_4] == NULL) ring = LEFT_4;
    else if (cur_ring[RIGHT_1] == NULL) ring = RIGHT_1;
    else if (cur_ring[RIGHT_2] == NULL) ring = RIGHT_2;
    else if (cur_ring[RIGHT_3] == NULL) ring = RIGHT_3;
    else if (cur_ring[RIGHT_4] == NULL) ring = RIGHT_4;
    else
    {
	if (terse) 
	    msg("Wearing enough rings.");
	else
	    msg("You already have on eight rings.");
	return;
    }
    cur_ring[ring] = obj;

    /*
     * Calculate the effect it has on the poor guy.
     */
    switch (obj->o_which)
    {
	when R_ADDSTR:
	    pstats.s_str += obj->o_ac;
	when R_ADDHIT:
	    pstats.s_dext += obj->o_ac;
	when R_ADDINTEL:
	    pstats.s_intel += obj->o_ac;
	when R_ADDWISDOM:
	    pstats.s_wisdom += obj->o_ac;
	when R_SEEINVIS:
	    if (off(player, PERMBLIND)) {
		turn_on(player, CANSEE);
		msg("Your eyes begin to tingle.");
		sight();
		light(&hero);
		mvwaddch(cw, hero.y, hero.x, PLAYER);
	    }
	when R_AGGR:
	    aggravate();
	when R_CARRYING:
	    updpack(FALSE);
	when R_LEVITATION:
	    msg("You begin to float in the air!");
	when R_LIGHT: {
		if(roomin(&hero) != NULL) {
			light(&hero);
			mvwaddch(cw, hero.y, hero.x, PLAYER);
		}
	    }
    }
    status(FALSE);
    if (r_know[obj->o_which] && r_guess[obj->o_which])
    {
	free(r_guess[obj->o_which]);
	r_guess[obj->o_which] = NULL;
    }
    else if (!r_know[obj->o_which] && 
	     askme && 
	     (obj->o_flags & ISKNOW) == 0 &&
	     r_guess[obj->o_which] == NULL) {
	mpos = 0;
	msg(terse ? "Call it: " : "What do you want to call it? ");
	if (get_str(buf, msgw) == NORM)
	{
	    r_guess[obj->o_which] = new(strlen(buf) + 1);
	    strcpy(r_guess[obj->o_which], buf);
	}