Beispiel #1
0
/*
 * Start a corpse decay or revive timer.
 * This takes the age of the corpse into consideration as of 3.4.0.
 */
void
start_corpse_timeout(struct obj *body)
{
    long when; 		/* rot away when this old */
    long corpse_age;	/* age of corpse          */
    int rot_adjust;
    short action;

#define TAINT_AGE (50L)		/* age when corpses go bad */
#define TROLL_REVIVE_CHANCE 37	/* 1/37 chance for 50 turns ~ 75% chance */
#define ROT_AGE (250L)		/* age when corpses rot away */

    /* lizards and lichen don't rot or revive */
    if (body->corpsenm == PM_LIZARD || body->corpsenm == PM_LICHEN) return;

    action = ROT_CORPSE;		/* default action: rot away */
    rot_adjust = in_mklev ? 25 : 10;	/* give some variation */
    corpse_age = monstermoves - body->age;
    if (corpse_age > ROT_AGE)
        when = rot_adjust;
    else
        when = ROT_AGE - corpse_age;
    when += (long)(rnz(rot_adjust) - rot_adjust);

    if (is_rider(&mons[body->corpsenm])) {
        /*
         * Riders always revive.  They have a 1/3 chance per turn
         * of reviving after 12 turns.  Always revive by 500.
         */
        action = REVIVE_MON;
        for (when = 12L; when < 500L; when++)
            if (!rn2(3)) break;

    } else if (mons[body->corpsenm].mlet == S_TROLL && !body->norevive) {
        long age;
        struct monst *mtmp = get_mtraits(body, FALSE);
        if (mtmp && !mtmp->mcan) {
            for (age = 2; age <= TAINT_AGE; age++)
                if (!rn2(TROLL_REVIVE_CHANCE)) {	/* troll revives */
                    action = REVIVE_MON;
                    when = age;
                    break;
                }
        }
    }

    if (body->norevive) body->norevive = 0;
    (void) start_timer(when, TIMER_OBJECT, action, (genericptr_t)body);
}
Beispiel #2
0
static int arti_invoke(struct obj *obj)
{
    const struct artifact *oart = get_artifact(obj);

    if (!oart || !oart->inv_prop) {
        if (obj->oclass == WAND_CLASS)
            return do_break_wand(obj);
        else if (obj->oclass == GEM_CLASS || obj->oclass == TOOL_CLASS)
            return dorub(obj);
	else if (obj->otyp == CRYSTAL_BALL)
	    use_crystal_ball(obj);
	else
	    pline("Nothing happens.");
	return 1;
    }

    if (oart->inv_prop > LAST_PROP) {
	/* It's a special power, not "just" a property */
	if (obj->age > moves) {
	    /* the artifact is tired :-) */
	    pline("You feel that %s %s ignoring you.",
		     the(xname(obj)), otense(obj, "are"));
	    /* and just got more so; patience is essential... */
	    obj->age += (long) dice(3,10);
	    return 1;
	}
	obj->age = moves + rnz(100);

	switch(oart->inv_prop) {
	case TAMING: {
	    struct obj pseudo;
	    boolean unused_known;

	    pseudo = zeroobj;	/* neither cursed nor blessed */
	    pseudo.otyp = SCR_TAMING;
	    seffects(&pseudo, &unused_known);
	    break;
	  }
	case HEALING: {
	    int healamt = (u.uhpmax + 1 - u.uhp) / 2;
	    long creamed = (long)u.ucreamed;

	    if (Upolyd) healamt = (u.mhmax + 1 - u.mh) / 2;
	    if (healamt || Sick || Slimed || Blinded > creamed)
		pline("You feel better.");
	    else
		goto nothing_special;
	    if (healamt > 0) {
		if (Upolyd) u.mh += healamt;
		else u.uhp += healamt;
	    }
	    if (Sick) make_sick(0L,NULL,FALSE,SICK_ALL);
	    if (Slimed) Slimed = 0L;
	    if (Blinded > creamed) make_blinded(creamed, FALSE);
	    iflags.botl = 1;
	    break;
	  }
	case ENERGY_BOOST: {
	    int epboost = (u.uenmax + 1 - u.uen) / 2;
	    if (epboost > 120) epboost = 120;		/* arbitrary */
	    else if (epboost < 12) epboost = u.uenmax - u.uen;
	    if (epboost) {
		pline("You feel re-energized.");
		u.uen += epboost;
		iflags.botl = 1;
	    } else
		goto nothing_special;
	    break;
	  }
	case UNTRAP: {
	    if (!untrap(TRUE)) {
		obj->age = 0; /* don't charge for changing their mind */
		return 0;
	    }
	    break;
	  }
	case CHARGE_OBJ: {
	    struct obj *otmp = getobj(recharge_type, "charge");
	    boolean b_effect;

	    if (!otmp) {
		obj->age = 0;
		return 0;
	    }
	    b_effect = obj->blessed &&
		(Role_switch == oart->role || !oart->role);
	    recharge(otmp, b_effect ? 1 : obj->cursed ? -1 : 0);
	    update_inventory();
	    break;
	  }
	case LEV_TELE:
	    level_tele();
	    break;
	case CREATE_PORTAL: {
	    int i, num_ok_dungeons, last_ok_dungeon = 0;
	    d_level newlev;
	    extern int n_dgns; /* from dungeon.c */
	    struct nh_menuitem *items;
	    items = malloc(n_dgns * sizeof(struct nh_menuitem));

	    num_ok_dungeons = 0;
	    for (i = 0; i < n_dgns; i++) {
		if (!dungeons[i].dunlev_ureached)
		    continue;
		items[num_ok_dungeons].id = i+1;
		items[num_ok_dungeons].accel = 0;
		items[num_ok_dungeons].role = MI_NORMAL;
		items[num_ok_dungeons].selected = FALSE;
		strcpy(items[num_ok_dungeons].caption, dungeons[i].dname);
		num_ok_dungeons++;
		last_ok_dungeon = i;
	    }

	    if (num_ok_dungeons > 1) {
		/* more than one entry; display menu for choices */
		int n;
		int selected[1];

		n = display_menu(items, num_ok_dungeons, "Open a portal to which dungeon?", PICK_ONE, selected);
		free(items);
		if (n <= 0)
		    goto nothing_special;
		
		i = selected[0] - 1;
	    } else {
		free(items);
		i = last_ok_dungeon;	/* also first & only OK dungeon */
	    }

	    /*
	     * i is now index into dungeon structure for the new dungeon.
	     * Find the closest level in the given dungeon, open
	     * a use-once portal to that dungeon and go there.
	     * The closest level is either the entry or dunlev_ureached.
	     */
	    newlev.dnum = i;
	    if (dungeons[i].depth_start >= depth(&u.uz))
		newlev.dlevel = dungeons[i].entry_lev;
	    else
		newlev.dlevel = dungeons[i].dunlev_ureached;
	    if (u.uhave.amulet || In_endgame(&u.uz) || In_endgame(&newlev) ||
	       newlev.dnum == u.uz.dnum) {
		pline("You feel very disoriented for a moment.");
	    } else {
		if (!Blind) pline("You are surrounded by a shimmering sphere!");
		else pline("You feel weightless for a moment.");
		goto_level(&newlev, FALSE, FALSE, FALSE);
	    }
	    break;
	  }
	case ENLIGHTENING:
	    enlightenment(0);
	    break;
	case CREATE_AMMO: {
	    struct obj *otmp = mksobj(level, ARROW, TRUE, FALSE);

	    if (!otmp) goto nothing_special;
	    otmp->blessed = obj->blessed;
	    otmp->cursed = obj->cursed;
	    otmp->bknown = obj->bknown;
	    if (obj->blessed) {
		if (otmp->spe < 0) otmp->spe = 0;
		otmp->quan += rnd(10);
	    } else if (obj->cursed) {
		if (otmp->spe > 0) otmp->spe = 0;
	    } else
		otmp->quan += rnd(5);
	    otmp->owt = weight(otmp);
	    hold_another_object(otmp, "Suddenly %s out.", aobjnam(otmp, "fall"), NULL);
	    break;
	  }
	}
    } else {
	long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI),
	     iprop = u.uprops[oart->inv_prop].intrinsic;
	boolean on = (eprop & W_ARTI) != 0; /* true if invoked prop just set */

	if (on && obj->age > moves) {
	    /* the artifact is tired :-) */
	    u.uprops[oart->inv_prop].extrinsic ^= W_ARTI;
	    pline("You feel that %s %s ignoring you.",
		     the(xname(obj)), otense(obj, "are"));
	    /* can't just keep repeatedly trying */
	    obj->age += (long) dice(3,10);
	    return 1;
	} else if (!on) {
	    /* when turning off property, determine downtime */
	    /* arbitrary for now until we can tune this -dlc */
	    obj->age = moves + rnz(100);
	}

	if ((eprop & ~W_ARTI) || iprop) {
nothing_special:
	    /* you had the property from some other source too */
	    if (carried(obj))
		pline("You feel a surge of power, but nothing seems to happen.");
	    return 1;
	}
	switch(oart->inv_prop) {
	case CONFLICT:
	    if (on) pline("You feel like a rabble-rouser.");
	    else pline("You feel the tension decrease around you.");
	    break;
	case LEVITATION:
	    if (on) {
		float_up();
		spoteffects(FALSE);
	    } else float_down(I_SPECIAL|TIMEOUT, W_ARTI);
	    break;
	case INVIS:
	    if (BInvis || Blind) goto nothing_special;
	    newsym(u.ux, u.uy);
	    if (on)
		pline("Your body takes on a %s transparency...",
		     Hallucination ? "normal" : "strange");
	    else
		pline("Your body seems to unfade...");
	    break;
	}
    }

    return 1;
}