Example #1
0
static bool _create_arrows(void)
{
    int             item, slot;
    object_type  forge;

    item_tester_hook = _create_ammo_p;
    if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) 
        return FALSE;

    object_prep(&forge, lookup_kind(TV_ARROW, m_bonus(1, p_ptr->lev)+ 1));
    forge.number = (byte)rand_range(5, 10);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");
    if (item >= 0)
    {
        inven_item_increase(item, -1);
        inven_item_describe(item);
        inven_item_optimize(item);
    }
    else
    {
        floor_item_increase(0 - item, -1);
        floor_item_describe(0 - item);
        floor_item_optimize(0 - item);
    }

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);
    return TRUE;
}
Example #2
0
/*
 * Carry an object and delete it.
 */
static void py_pickup_aux(int o_idx, bool domsg)
{
	int slot, quiver_slot = 0;

	char o_name[80];
	object_type *o_ptr = object_byid(o_idx);

	/* Carry the object */
	slot = inven_carry(p_ptr, o_ptr);

	/* Handle errors (paranoia) */
	if (slot < 0) return;

	/* If we have picked up ammo which matches something in the quiver, note
	 * that it so that we can wield it later (and suppress pick up message) */
	if (obj_is_ammo(o_ptr)) 
	{
		int i;
		for (i = QUIVER_START; i < QUIVER_END; i++) 
		{
			if (!p_ptr->inventory[i].kind) continue;
			if (!object_similar(&p_ptr->inventory[i], o_ptr,
				OSTACK_QUIVER)) continue;
			quiver_slot = i;
			break;
		}
	}

	/* Get the new object */
	o_ptr = &p_ptr->inventory[slot];

	/* Set squelch status */
	p_ptr->notice |= PN_SQUELCH;

	/* Automatically sense artifacts */
	object_notice_artifact(o_ptr);

	/* Optionally, display a message */
	if (domsg && !quiver_slot)
	{
		/* Describe the object */
		object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

		/* Message */
		msg("You have %s (%c).", o_name, index_to_label(slot));
	}

	/* Update object_idx if necessary */
	if (p_ptr->object_idx == (0 - o_idx))
	{
		track_object(slot);
	}

	/* Delete the object */
	delete_object_idx(o_idx);

	/* If we have a quiver slot that this ammo matches, use it */
	if (quiver_slot) wield_item(o_ptr, slot, quiver_slot);
}
Example #3
0
void _blood_pool_spell(int cmd, variant *res)
{
    switch (cmd)
    {
    case SPELL_NAME:
        var_set_string(res, "Blood Pool");
        break;
    case SPELL_DESC:
        var_set_string(res, "Creates a macabre Potion of Healing made of your own blood.");
        break;
    case SPELL_SPOIL_DESC:
        var_set_string(res, "Create a potion of blood. Player is limited to 30 such potions, and may neither "
                                "drop, throw nor sell them. Quaffing a potion of blood heals 100hp and cures "
                                "blindness, confusion, poison and stuns.");
        break;
    case SPELL_CAST:
    {
        object_type forge;
        int ct = _count_blood_potions();

        if (ct >= 30)
        {
            msg_print("You have too many blood potions at the moment. Why not drink some?");
            var_set_bool(res, FALSE);
            return;
        }

        msg_print("You feel light headed.");
        object_prep(&forge, lookup_kind(TV_POTION, SV_POTION_BLOOD));

        /* We can't just drop potions on the ground, or the user can spam the spell! */
        if (!inven_carry_okay(&forge))
        {
            msg_print("Your pack is full!  The potion goes sour ...");
            object_prep(&forge, lookup_kind(TV_POTION, SV_POTION_SALT_WATER));
            drop_near(&forge, -1, py, px);
        }
        else
        {
            inven_carry(&forge);
            msg_print("You store your blood for future use.");
        }
        var_set_bool(res, TRUE);
        break;
    }
    default:
        default_spell(cmd, res);
        break;
    }
}
Example #4
0
/**
 * Move an object from a floor pile to the player's gear
 */
static void player_pickup_aux(struct object *obj, bool domsg)
{
	/* Confirm the object can be picked up*/
	if (!inven_carry_okay(obj))
		quit_fmt("Failed pickup of %s", obj->kind->name);

	/* Set ignore status */
	player->upkeep->notice |= PN_IGNORE;

	/* Automatically sense artifacts */
	object_sense_artifact(obj);

	/* Log artifacts if found */
	if (obj->artifact)
		history_add_artifact(obj->artifact, object_is_known(obj), TRUE);

	/* Carry the object */
	square_excise_object(cave, player->py, player->px, obj);
	inven_carry(player, obj, domsg);
}
Example #5
0
static bool _create_shots(void)
{
    int         x, y, dir, slot;
    cave_type  *c_ptr;
    object_type forge;

    if (!get_rep_dir(&dir, FALSE)) 
        return FALSE;

    y = py + ddy[dir];
    x = px + ddx[dir];
    c_ptr = &cave[y][x];

    if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_CAN_DIG))
    {
        msg_print("You need pile of rubble.");
        return FALSE;
    }

    if (!cave_have_flag_grid(c_ptr, FF_CAN_DIG) || !cave_have_flag_grid(c_ptr, FF_HURT_ROCK))
    {
        msg_print("You failed to make ammo.");
        return FALSE;
    }

    object_prep(&forge, lookup_kind(TV_SHOT, m_bonus(1, p_ptr->lev) + 1));
    forge.number = (byte)rand_range(15,30);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);

    cave_alter_feat(y, x, FF_HURT_ROCK);
    p_ptr->update |= PU_FLOW;
    return TRUE;
}
Example #6
0
bool quest_poison_quest_hook(char *fmt)
{
	object_type forge, *q_ptr;
	s32b q_idx;

	q_idx = get_next_arg(fmt);

	if (q_idx != QUEST_POISON) return FALSE;

	q_ptr = &forge;
	object_prep(q_ptr, lookup_kind(TV_POTION2, SV_POTION2_CURE_WATER));
	q_ptr->number = 99;
	object_aware(q_ptr);
	object_known(q_ptr);
	q_ptr->ident |= IDENT_STOREB;
	q_ptr->note = quark_add("quest");
	(void)inven_carry(q_ptr, FALSE);

	del_hook(HOOK_INIT_QUEST, quest_poison_quest_hook);
	process_hooks_restart = TRUE;

	return FALSE;
}
Example #7
0
static bool _create_bolts(void)
{
    int             item, slot;
    object_type  forge;

    item_tester_hook = _create_ammo_p;
    if (!get_item(&item, "Convert which item? ", "You have no item to convert.", USE_INVEN | USE_FLOOR)) 
        return FALSE;

    /* Note: You won't ever get Steel Bolts this way since I:18:1 is shared with 
       by Bolts and Steel Bolts and lookup_kind() picks the first match in k_info.txt.
       However, getting Steel from Bones/Junk would be a bit odd anyway ... */
    object_prep(&forge, lookup_kind(TV_BOLT, m_bonus(1, p_ptr->lev)+ 1));
    forge.number = (byte)rand_range(4, 8);
    apply_magic(&forge, p_ptr->lev, AM_NO_FIXED_ART);
    obj_identify(&forge);
    forge.discount = 99;

    msg_print("You make some ammo.");
    if (item >= 0)
    {
        inven_item_increase(item, -1);
        inven_item_describe(item);
        inven_item_optimize(item);
    }
    else
    {
        floor_item_increase(0 - item, -1);
        floor_item_describe(0 - item);
        floor_item_optimize(0 - item);
    }

    slot = inven_carry(&forge);
    if (slot >= 0) 
        autopick_alter_item(slot, FALSE);
    return TRUE;
}
Example #8
0
/**
 * Carry an object and delete it.
 */
extern void py_pickup_aux(int o_idx, bool msg)
{
    int slot, quiver_slot = 0;

    char o_name[120];
    object_type *o_ptr = &o_list[o_idx];
    object_type *i_ptr = &p_ptr->inventory[INVEN_LIGHT];
    bitflag f[OF_SIZE], obvious_mask[OF_SIZE];


    flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);
    of_copy(f, o_ptr->flags_obj);
    
    /* Carry the object */
    slot = inven_carry(p_ptr, o_ptr);

    /* Handle errors (paranoia) */
    if (slot < 0) return;

    /* If we have picked up ammo which matches something in the quiver, note
     * that it so that we can wield it later (and suppress pick up message) */
    if (obj_is_quiver_obj(o_ptr)) 
    {
	int i;
	for (i = QUIVER_START; i < QUIVER_END; i++) 
	{
	    if (!p_ptr->inventory[i].k_idx) continue;
	    if (!object_similar(&p_ptr->inventory[i], o_ptr,
				OSTACK_QUIVER)) continue;
	    quiver_slot = i;
	    break;
	}
    }

    /* Get the object again */
    o_ptr = &p_ptr->inventory[slot];

    /* Set squelch status */
    p_ptr->notice |= PN_SQUELCH;

    /* Stone of Lore gives id on pickup */
    if (!object_known_p(o_ptr)) {
	if (i_ptr->sval == SV_STONE_LORE)
	    identify_object(o_ptr);

	/* Otherwise pseudo-ID */
	else {
	    bool heavy = FALSE;
	    int feel;

	    /* Heavy sensing */
	    heavy = (player_has(PF_PSEUDO_ID_HEAVY));

	    /* Type of feeling */
	    feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));

	    /* We have "felt" it */
	    o_ptr->ident |= (IDENT_SENSE);

	    /* Inscribe it textually */
	    o_ptr->feel = feel;

	    /* Set squelch flag as appropriate */
	    p_ptr->notice |= PN_SQUELCH;
	}
    }

    /* Log artifacts if found */
    if (artifact_p(o_ptr))
	history_add_artifact(o_ptr->name1, object_is_known(o_ptr), TRUE);

    /* Notice dice and other obvious stuff */
    notice_other(IF_DD_DS, slot + 1);
    (void) of_inter(f, obvious_mask);
    of_union(o_ptr->id_obj, f);

    /* Average things are average */
    if ((o_ptr->feel == FEEL_AVERAGE) && (is_weapon(o_ptr) || is_armour(o_ptr))){
	notice_other(IF_AC, slot + 1);
	notice_other(IF_TO_A, slot + 1);
	notice_other(IF_TO_H, slot + 1);
	notice_other(IF_TO_D, slot + 1);
    }

    /* Recalculate the bonuses */
    p_ptr->update |= (PU_BONUS);

    /* Optionally, display a message */
    if (msg && !quiver_slot)
    {
	/* Describe the object */
	object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg_format("You have %s (%c).", o_name, index_to_label(slot));
    }


    /* Delete the object */
    delete_object_idx(o_idx);

    /* If we have a quiver slot that this item matches, use it */
    if (quiver_slot) wield_item(o_ptr, slot, quiver_slot);
}
Example #9
0
/*
 * Activate (zap) a Rod
 *
 * Unstack fully charged rods as needed.
 *
 * Hack -- rods of perception/banishment can be "cancelled"
 * All rods can be cancelled at the "Direction?" prompt
 */
void do_cmd_zap_rod(void)
{
	int item;
	bool ident;
	object_type *o_ptr;
	cptr q, s;


	/* Restrict choices to rods */
	item_tester_tval = TV_ROD;

	/* Get an item */
	q = "Zap which rod? ";
	s = "You have no rod to zap.";
	if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;

	/* Get the item (in the pack) */
	if (item >= 0)
	{
		o_ptr = &inventory[item];
	}

	/* Get the item (on the floor) */
	else
	{
		o_ptr = &o_list[0 - item];
	}


	/* Mega-Hack -- refuse to zap a pile from the ground */
	if ((item < 0) && (o_ptr->number > 1))
	{
		msg_print("You must first pick up the rods.");
		return;
	}

	/* Zap the rod */
	if (!use_object(o_ptr, &ident)) return;

	/* Combine / Reorder the pack (later) */
	p_ptr->notice |= (PN_COMBINE | PN_REORDER);

	/* Tried the object */
	object_tried(o_ptr);

	/* Successfully determined the object function */
	if (ident && !object_aware_p(o_ptr))
	{
		/* Object level */
		int lev = k_info[o_ptr->k_idx].level;

		object_aware(o_ptr);
		gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev);
	}

	/* Window stuff */
	p_ptr->window |= (PW_INVEN | PW_EQUIP);

	/* XXX Hack -- unstack if necessary */
	if ((item >= 0) && (o_ptr->number > 1) && (o_ptr->pval > 0))
	{
		object_type *i_ptr;
		object_type object_type_body;

		/* Get local object */
		i_ptr = &object_type_body;

		/* Obtain a local object */
		object_copy(i_ptr, o_ptr);

		/* Modify quantity */
		i_ptr->number = 1;

		/* Restore "charge" */
		o_ptr->pval = 0;

		/* Unstack the used item */
		o_ptr->number--;
		p_ptr->total_weight -= i_ptr->weight;
		item = inven_carry(i_ptr);

		/* Message */
		msg_print("You unstack your rod.");
	}
}
Example #10
0
// Select an artifact from a list and place it in the player's inventory
MakeArtifactDialog::MakeArtifactDialog(void)
{
    int i;
    QPointer<QVBoxLayout> vlay = new QVBoxLayout;
    art_choice = new QComboBox;
    object_type object_type_body;
    object_type *i_ptr = &object_type_body;


    QPointer<QLabel>  obj_label = new QLabel(QString("<b><big>Please select an artifact:</big></b>"));
    obj_label->setAlignment(Qt::AlignCenter);

    vlay->addWidget(obj_label);
    vlay->addStretch();

    connect(art_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(update_art_choice(int)));

    QPointer<QPushButton> close_button = new QPushButton(tr("&Close"));
    connect(close_button, SIGNAL(clicked()), this, SLOT(close()));

    int count = 0;
    art_num = 0;

    for (i = 1; i < z_info->art_norm_max; i++)
    {
        artifact_type *a_ptr = &a_info[i];

        /* Skip "empty" items */
        if (a_ptr->tval + a_ptr->sval == 0) continue;

        art_choice->addItem(QString("%1") .arg(i));

        art_choice->setItemText(count++, get_artifact_display_name(i));
    }

    vlay->addWidget(art_choice);
    vlay->addStretch();
    vlay->addWidget(close_button);

    setLayout(vlay);

    setWindowTitle(tr("Make Artifact"));
    this->exec();

    // find the artifact
    count = 0;
    for (i = 1; i < z_info->art_norm_max; i++)
    {
        artifact_type *a_ptr = &a_info[i];

        /* Skip "empty" items */
        if (a_ptr->tval + a_ptr->sval == 0) continue;

        // Found the match
        if (count == art_num) break;
        count++;
    }

    i_ptr->object_wipe();
    if (!wiz_alloc_artifact(i_ptr, i))
    {

     return;
    }
    object_history(i_ptr, ORIGIN_CHEAT, 0);
    identify_object(i_ptr, true);
    if(inven_carry(i_ptr) < 0)
    {
        drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
    }
}
Example #11
0
bool quest_poison_gen_hook(char *fmt)
{
	int cy = 1, cx = 1, x, y, try = 10000, r_idx;
	bool (*old_get_mon_num_hook)(int r_idx);

	if (cquest.status != QUEST_STATUS_TAKEN) return FALSE;
	if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0]) return FALSE;
	if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1]) return FALSE;
	if (p_ptr->wild_mode) return FALSE;

	/* Find a good position */
	while (try)
	{
		/* Get a random spot */
		cy = randint(cur_hgt - 24) + 22;
		cx = randint(cur_wid - 34) + 32;

		/* Is it a good spot ? */
		if (cave_empty_bold(cy, cx)) break;

		/* One less try */
		try--;
	}

	/* Place the baddies */

	/* Backup the old hook */
	old_get_mon_num_hook = get_mon_num_hook;

	/* Require "okay" monsters */
	get_mon_num_hook = create_molds_hook;

	/* Prepare allocation table */
	get_mon_num_prep();

	/* Pick a monster, using the level calculation */
	for (x = cx - 25; x <= cx + 25; x++)
		for (y = cy - 25; y <= cy + 25; y++)
		{
			if (!in_bounds(y, x)) continue;

			if (distance(cy, cx, y, x) > 25) continue;

			if (magik(80) && ((cave[y][x].feat == FEAT_DEEP_WATER) || (cave[y][x].feat == FEAT_SHAL_WATER))) cave_set_feat(y, x, FEAT_TAINTED_WATER);

			if (distance(cy, cx, y, x) > 10) continue;

			if (magik(60))
			{
				int m_idx;

				r_idx = get_mon_num(30);
				m_idx = place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY);

				/* Sometimes make it up some levels */
				if (magik(80) && m_idx)
				{
					monster_type *m_ptr = &m_list[m_idx];

					if (m_ptr->level < p_ptr->lev)
					{
						m_ptr->exp = MONSTER_EXP(m_ptr->level + randint(p_ptr->lev - m_ptr->level));
						monster_check_experience(m_idx, TRUE);
					}
				}
			}
		}

	/* Reset restriction */
	get_mon_num_hook = old_get_mon_num_hook;

	/* Prepare allocation table */
	get_mon_num_prep();

	return FALSE;
}
bool quest_poison_finish_hook(char *fmt)
{
	object_type forge, *q_ptr;
	s32b q_idx;

	q_idx = get_next_arg(fmt);

	if (q_idx != QUEST_POISON) return FALSE;

	c_put_str(TERM_YELLOW, "The water is clean again! Thank you so much.", 8, 0);
	c_put_str(TERM_YELLOW, "The beautiful Mallorns are safe. Take this as a proof of our gratitude.", 9, 0);

	q_ptr = &forge;
	object_prep(q_ptr, lookup_kind(TV_DRAG_ARMOR, SV_DRAGON_BLUE));
	q_ptr->found = OBJ_FOUND_REWARD;
	q_ptr->number = 1;
	q_ptr->name2 = EGO_ELVENKIND;
	apply_magic(q_ptr, 1, FALSE, FALSE, FALSE);
	object_aware(q_ptr);
	object_known(q_ptr);
	q_ptr->ident |= IDENT_STOREB;
	(void)inven_carry(q_ptr, FALSE);

	/* Continue the plot */
	*(quest[q_idx].plot) = QUEST_NULL;

	del_hook(HOOK_QUEST_FINISH, quest_poison_finish_hook);
	process_hooks_restart = TRUE;

	return TRUE;
}
Example #12
0
/*
 * Init players with some belongings
 *
 * Having an item identifies it and makes the player "aware" of its purpose.
 */
static void player_outfit(void)
{
	int i, slot, inven_slot;
	const start_item *e_ptr;
	object_type *i_ptr;
	object_type object_type_body;
	object_type *o_ptr;
	
	time_t c;       // time variables
	struct tm *tp;  //

	/* Hack -- Give the player his equipment */
	for (i = 0; i < MAX_START_ITEMS; i++)
	{
		/* Access the item */
		e_ptr = &(rp_ptr->start_items[i]);

		/* Get local object */
		i_ptr = &object_type_body;

		/* Hack	-- Give the player an object */
		if (e_ptr->tval > 0)
		{
			/* Get the object_kind */
			s16b k_idx = lookup_kind(e_ptr->tval, e_ptr->sval);

			/* Valid item? */
			if (!k_idx) continue;

			/* Prepare the item */
			object_prep(i_ptr, k_idx);
			i_ptr->number = (byte)rand_range(e_ptr->min, e_ptr->max);

			//object_aware(i_ptr);
			//object_known(i_ptr);
		}

		/* Check the slot */
		slot = wield_slot(i_ptr);
		
		/* give light sources a duration */
		if (slot == INVEN_LITE)
		{
			i_ptr->timeout = 2000;
		}

		/*put it in the inventory*/
		inven_slot = inven_carry(i_ptr);

		/*if player can wield an item, do so*/
		if (slot >= INVEN_WIELD)
		{
			/* Get the wield slot */
			o_ptr = &inventory[slot];

			/* Wear the new stuff */
			object_copy(o_ptr, i_ptr);

			/* Modify quantity */
			o_ptr->number = 1;

			/* Decrease the item */
			inven_item_increase(inven_slot, -1);
			inven_item_optimize(inven_slot);

			/* Increment the equip counter by hand */
			p_ptr->equip_cnt++;
		}

		/*Bugfix:  So we don't get duplicate objects*/
		object_wipe (i_ptr);

	}

	// Christmas presents:
	
	/* Make sure it is Dec 24-26 */
	c = time((time_t *)0);
	tp = localtime(&c);
	if ((tp->tm_mon == 11) && (tp->tm_mday >= 20) && (tp->tm_mday <= 31))
	{
		/* Get local object */
		i_ptr = &object_type_body;
		
		/* Get the object_kind */
		s16b k_idx = lookup_kind(TV_CHEST, SV_CHEST_PRESENT);
		
		/* Prepare the item */
		object_prep(i_ptr, k_idx);
		i_ptr->number = 1;
		i_ptr->pval = -20;
		
		//object_aware(i_ptr);
		//object_known(i_ptr);
		
		/*put it in the inventory*/
		inven_slot = inven_carry(i_ptr);
	}


	/* Recalculate bonuses */
	p_ptr->update |= (PU_BONUS);

	/* Recalculate mana */
	p_ptr->update |= (PU_MANA);

	/* Window stuff */
	p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER_0);

	p_ptr->redraw |= (PR_EQUIPPY | PR_RESIST);;
}
Example #13
0
File: cmd3.c Project: fph/mortsil
void prise_silmaril(void)
{
	object_type   *o_ptr;
	object_type   *w_ptr;
	artefact_type *a_ptr;

	object_type object_type_body;

	cptr freed_msg = NULL; // default to soothe compiler warnings

	bool freed = FALSE;

	int slot = 0;
	
	int dam = 0;
	int prt = 0;
	int net_dam = 0;
	int prt_percent = 0;
	int hit_result = 0;
	int crit_bonus_dice = 0;
	int pd = 0;
	int noise = 0;
	u32b dummy_noticed_flag;
	
	int mds = p_ptr->mds;
	int attack_mod = p_ptr->skill_use[S_MEL];

	char o_name[80];

	// the Crown is on the ground
	o_ptr = &o_list[cave_o_idx[p_ptr->py][p_ptr->px]];
				
	switch (o_ptr->name1)
	{
		case ART_MORGOTH_3:
		{
			pd = 15;
			noise = 5;
			freed_msg = "You have freed a Silmaril!";
			break;
		}
		case ART_MORGOTH_2:
		{
			pd = 25;
			noise = 10;
						
			if (p_ptr->crown_shatter)	freed_msg = "The fates be damned! You free a second Silmaril.";
			else						freed_msg = "You free a second Silmaril.";
			
			break;
		}
		case ART_MORGOTH_1:
		{
			pd = 30;
			noise = 15;
			
			freed_msg = "You free the final Silmaril. You have a very bad feeling about this.";
			
			msg_print("Looking into the hallowed light of the final Silmaril, you are filled with a strange dread.");
			if (!get_check("Are you sure you wish to proceed? ")) return;
			
			break;
		}
	}
	
	/* Get the weapon */
	w_ptr = &inventory[INVEN_WIELD];

	// undo rapid attack penalties
	if (p_ptr->active_ability[S_MEL][MEL_RAPID_ATTACK])
	{
		// undo strength adjustment to the attack
		mds = total_mds(w_ptr, 0);
		
		// undo the dexterity adjustment to the attack
		attack_mod += 3;
	}
	
	/* Test for hit */
	hit_result = hit_roll(attack_mod, 0, PLAYER, NULL, TRUE);
	
	/* Make some noise */
	stealth_score -= noise;
	
	// Determine damage
	if (hit_result > 0)
	{
		crit_bonus_dice = crit_bonus(hit_result, w_ptr->weight, &r_info[R_IDX_MORGOTH], S_MEL, FALSE);
		
		dam = damroll(p_ptr->mdd + crit_bonus_dice, mds);
		prt = damroll(pd, 4);
		
		prt_percent = prt_after_sharpness(w_ptr, &dummy_noticed_flag);
		prt = (prt * prt_percent) / 100;
		net_dam = dam - prt;
		
		/* No negative damage */
		if (net_dam < 0) net_dam = 0;
		
		//update_combat_rolls1b(PLAYER, TRUE);
		update_combat_rolls2(p_ptr->mdd + crit_bonus_dice, mds, dam, pd, 4, prt, prt_percent, GF_HURT, TRUE);
	}
	
	
	// if you succeed in prising out a Silmaril...
	if (net_dam > 0)
	{
		freed = TRUE;
		
		switch (o_ptr->name1)
		{
			case ART_MORGOTH_3:
			{
				break;
			}
			case ART_MORGOTH_2:
			{
				if (!p_ptr->crown_shatter && one_in_(2))
				{
					shatter_weapon(2);
					freed = FALSE;
				}
				break;
			}
			case ART_MORGOTH_1:
			{
				if (!p_ptr->crown_shatter)
				{
					shatter_weapon(3);
					freed = FALSE;
				}
				else
				{
					p_ptr->cursed = TRUE;
				}
				break;
			}
		}
		
		if (freed)
		{
			// change its type to that of the crown with one less silmaril
			o_ptr->name1--;
			
			// get the details of this new crown
			a_ptr = &a_info[o_ptr->name1];
			
			// modify the existing crown
			object_into_artefact(o_ptr, a_ptr);
			
			// report success
			msg_print(freed_msg);
			
			// Get new local object
			o_ptr = &object_type_body;
			
			// Make Silmaril
			object_prep(o_ptr, lookup_kind(TV_LIGHT, SV_LIGHT_SILMARIL));
			
			// Get it
			slot = inven_carry(o_ptr);

			/* Get the object again */
			o_ptr = &inventory[slot];
			
			/* Describe the object */
			object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3);
			
			/* Message */
			msg_format("You have %s (%c).", o_name, index_to_label(slot));

			// Break the truce (always)
			break_truce(TRUE);
		
			// add a note to the notes file
			do_cmd_note("Cut a Silmaril from Morgoth's crown", p_ptr->depth);
		}
	}
	
	// if you fail to prise out a Silmaril...
	else
	{
		msg_print("Try though you might, you were unable to free a Silmaril.");
		msg_print("Perhaps you should try again or use a different weapon.");

		if (pd == 15) msg_print("(The combat rolls window shows what is happening.)");

		// Break the truce if creatures see
		break_truce(FALSE);
	}

	// check for taking of final Silmaril
	if ((pd == 30) && freed)
	{
		msg_print("Until you escape you must now roll twice for every skill check, taking the worse result each time.");
		msg_print("You hear a cry of veangance echo through the iron hells.");
		wake_all_monsters(0);
	}
}
Example #14
0
File: cmd3.c Project: fph/mortsil
/*
 * Refill the player's lamp (from the pack or floor)
 */
void do_cmd_refuel_lamp(object_type *default_o_ptr, int default_item)
{
	int item;

	object_type *o_ptr;
	object_type *j_ptr;

	cptr q, s;

	// use specified item if possible
	if (default_o_ptr != NULL)
	{
		o_ptr = default_o_ptr;
		item = default_item;
	}
	/* Get an item */
	else
	{
		/* Restrict the choices */
		item_tester_hook = item_tester_refuel_lantern;

		/* Get an item */
		q = "Refill with which source of oil? ";
		s = "You have no sources of oil.";
		if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;

		/* Get the item (in the pack) */
		if (item >= 0)
		{
			o_ptr = &inventory[item];
		}

		/* Get the item (on the floor) */
		else
		{
			o_ptr = &o_list[0 - item];
		}
	}

	/* Take a turn */
	p_ptr->energy_use = 100;

	// store the action type
	p_ptr->previous_action[0] = ACTION_MISC;
		
	/* Get the lantern */
	j_ptr = &inventory[INVEN_LITE];

	/* Refuel from a latern */
	if (o_ptr->sval == SV_LIGHT_LANTERN)
	{
	  j_ptr->timeout += o_ptr->timeout;
	}
	/* Refuel from a flask */
	else
	{
	  j_ptr->timeout += o_ptr->pval;
	}

	/* Message */
	msg_print("You fuel your lamp.");

	/* Comment */
	if (j_ptr->timeout >= FUEL_LAMP)
	{
		j_ptr->timeout = FUEL_LAMP;
		msg_print("Your lamp is full.");
	}

	/* Refilled from a latern */
	if (o_ptr->sval == SV_LIGHT_LANTERN)
	{
		/* Unstack if necessary */
		if (o_ptr->number > 1)
		{
			object_type *i_ptr;
			object_type object_type_body;

			/* Get local object */
			i_ptr = &object_type_body;

			/* Obtain a local object */
			object_copy(i_ptr, o_ptr);

			/* Modify quantity */
			i_ptr->number = 1;

			/* Remove fuel */
			i_ptr->timeout = 0;

			/* Unstack the used item */
			o_ptr->number--;

			/* Carry or drop */
			if (item >= 0)
				item = inven_carry(i_ptr);
			else
				drop_near(i_ptr, 0, p_ptr->py, p_ptr->px);
		}

		/* Empty a single latern */
		else
		{
			/* No more fuel */
			o_ptr->timeout = 0;
		}


		/* Combine / Reorder the pack (later) */
		p_ptr->notice |= (PN_COMBINE | PN_REORDER);

		/* Window stuff */
		p_ptr->window |= (PW_INVEN);
	}

	/* Refilled from a flask */
	else
	{
		/* Decrease the item (from the pack) */
		if (item >= 0)
		{
			inven_item_increase(item, -1);
			inven_item_describe(item);
			inven_item_optimize(item);
		}

		/* Decrease the item (from the floor) */
		else
		{
			floor_item_increase(0 - item, -1);
			floor_item_describe(0 - item);
			floor_item_optimize(0 - item);
		}

	}

	/* Window stuff */
	p_ptr->window |= (PW_EQUIP);
	
	// get another chance to identify the lamp
	ident_on_wield(j_ptr);
}
Example #15
0
void WizardModeDialog::wiz_winners_kit(void)
{
    if (!character_dungeon) return;

    if (game_mode == GAME_NPPMORIA)
    {
        // Make 2 rings of speed
        int k_idx = lookup_kind(TV_RING, SV_RING_SPEED);
        object_type object_type_body;
        object_type *i_ptr = &object_type_body;
        i_ptr->object_wipe();
        if (k_idx)
        {
            object_prep(i_ptr, k_idx);
            apply_magic(i_ptr, k_info[k_idx].k_level, FALSE, TRUE, TRUE, TRUE);
            i_ptr->number = 2;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        //Give an amulet of the magi;
        k_idx = lookup_kind(TV_AMULET, SV_AMULET_THE_MAGI);
        if (k_idx)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            apply_magic(i_ptr, k_info[k_idx].k_level, FALSE, TRUE, TRUE, TRUE);
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        //boots of speed
        k_idx = lookup_kind(TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS);
        int ego_num = lookup_ego(TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS, "speed");
        if (k_idx && ego_num)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            i_ptr->ego_num = ego_num;
            a_m_aux_2(i_ptr, k_info[k_idx].k_level, 2);
            apply_ego_item_magic(i_ptr, k_info[k_idx].k_level);
            i_ptr->to_a = 25;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        // Robe of Resistance
        k_idx = lookup_kind(TV_SOFT_ARMOR, SV_ROBE);
        ego_num = lookup_ego(TV_SOFT_ARMOR, SV_ROBE, "resistance");
        if (k_idx && ego_num)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            i_ptr->ego_num = ego_num;
            a_m_aux_2(i_ptr, k_info[k_idx].k_level, 2);
            apply_ego_item_magic(i_ptr, k_info[k_idx].k_level);
            i_ptr->to_a = 25;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        // super-charged holy avenger dagger
        k_idx = lookup_kind(TV_SWORD, SV_DAGGER);
        ego_num = lookup_ego(TV_SWORD, SV_DAGGER, "holy avenger");
        if (k_idx && ego_num)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            i_ptr->ego_num = ego_num;
            a_m_aux_1(i_ptr, k_info[k_idx].k_level, 2);
            apply_ego_item_magic(i_ptr, k_info[k_idx].k_level);
            i_ptr->to_a = i_ptr->to_h = i_ptr->to_d = 25;
            i_ptr->dd = i_ptr->ds = 9;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        // crown of the magi
        k_idx = lookup_kind(TV_CROWN, SV_SILVER_CROWN);
        ego_num = lookup_ego(TV_CROWN, SV_SILVER_CROWN, "magi");
        if (k_idx && ego_num)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            i_ptr->ego_num = ego_num;
            a_m_aux_2(i_ptr, k_info[k_idx].k_level, 2);
            apply_ego_item_magic(i_ptr, k_info[k_idx].k_level);
            i_ptr->to_a = 25;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        // super charged gloves of slaying
        k_idx = lookup_kind(TV_GLOVES, SV_SET_OF_LEATHER_GLOVES);
        ego_num = lookup_ego(TV_GLOVES, SV_SET_OF_LEATHER_GLOVES, "slaying");
        if (k_idx && ego_num)
        {
            i_ptr->object_wipe();
            object_prep(i_ptr, k_idx);
            i_ptr->ego_num = ego_num;
            a_m_aux_2(i_ptr, k_info[k_idx].k_level, 2);
            apply_ego_item_magic(i_ptr, k_info[k_idx].k_level);
            i_ptr->to_a = i_ptr->to_h = i_ptr->to_d = 25;
            i_ptr->mark_fully_known(TRUE);
            object_history(i_ptr, ORIGIN_CHEAT, 0);
            if(inven_carry(i_ptr) < 0)
            {
                drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
            }
        }
        //finally the Phial
        if (TRUE)
        {
            i_ptr->object_wipe();
            if (wiz_alloc_artifact(i_ptr, 1))
            {
                object_history(i_ptr, ORIGIN_CHEAT, 0);
                identify_object(i_ptr, true);
                if(inven_carry(i_ptr) < 0)
                {
                    drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
                }
            }
        }

        handle_stuff();
        this->accept();
        return;

    }

    else if (game_mode != GAME_NPPANGBAND) return;

    int artis[] = {
        47,     // RINGIL
        124,    // CUBRAGOL
        13,     // NARYA
        14,     // NENYA
        10,     // ELESSAR
        12,     // GEM OF AMON SUL
        38,     // BLADETUNDER
        113,    // COLANNON
        33,     // THORIN
        110,    // NUMENOR
        129,    // CAMBELEG
        127,    // FEANOR
        0
    };

    object_type obj;
    object_type *o_ptr = &obj;

    for (int i = 0; artis[i]; i++)
    {
        o_ptr->object_wipe();
        if (!wiz_alloc_artifact(o_ptr, artis[i])) continue;
        object_history(o_ptr, ORIGIN_CHEAT, 0);
        identify_object(o_ptr, true);
        if (inven_carry(o_ptr) < 0)
        {
            drop_near(o_ptr, -1, p_ptr->py, p_ptr->px);
        }
        QString name = object_desc(o_ptr, ODESC_PREFIX | ODESC_FULL);
        message("Allocated " + name);
    }

    //Some amazing ammo;
    int k_idx = lookup_kind(TV_BOLT, SV_AMMO_MITHRIL);
    int ego_num = lookup_ego(TV_BOLT, SV_AMMO_MITHRIL, "holy might");
    if (k_idx && ego_num)
    {
        o_ptr->object_wipe();
        object_prep(o_ptr, k_idx);
        o_ptr->ego_num = ego_num;
        a_m_aux_1(o_ptr, k_info[k_idx].k_level, 2);
        apply_ego_item_magic(o_ptr, k_info[k_idx].k_level);
        o_ptr->to_h = 99;
        o_ptr->to_d = 99;
        o_ptr->dd = 25;
        o_ptr->ds = 25;
        o_ptr->number = 99;
        o_ptr->mark_fully_known(TRUE);
        object_history(o_ptr, ORIGIN_CHEAT, 0);
        if(inven_carry(o_ptr) < 0)
        {
            drop_near(o_ptr, -1, p_ptr->py, p_ptr->px);
        }
    }

    handle_stuff();

    this->accept();
}
Example #16
0
// Select an artifact from a list and place it in the player's inventory.
// Note that dragon armor comes out doesn't work too well, since it
// is always make into an ego item.
MakeObjectDialog::MakeObjectDialog(void)
{
    int i;
    QPointer<QVBoxLayout> vlay = new QVBoxLayout;
    obj_choice = new QComboBox;
    object_type object_type_body;
    object_type *i_ptr = &object_type_body;


    QPointer<QLabel>  obj_label = new QLabel(QString("<b><big>Please select an object:</big></b>"));
    obj_label->setAlignment(Qt::AlignCenter);

    vlay->addWidget(obj_label);
    vlay->addStretch();

    connect(obj_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(update_obj_choice(int)));

    QPointer<QPushButton> close_button = new QPushButton(tr("&Close"));
    connect(close_button, SIGNAL(clicked()), this, SLOT(close()));

    int count = 0;
    obj_num = 0;

    for (i = 1; i < z_info->k_max; i++)
    {
        object_kind *k_ptr = &k_info[i];

        /* Skip "empty" items */
        if (k_ptr->k_name.isEmpty()) continue;
        // Skip artifact templates
        if (k_ptr->k_flags3 & (TR3_INSTA_ART)) continue;
        // Skip gold
        if (k_ptr->tval == TV_GOLD) continue;

        obj_choice->addItem(QString("%1") .arg(i));

        obj_choice->setItemText(count++, get_object_display_name(i));
    }

    vlay->addWidget(obj_choice);
    vlay->addStretch();
    vlay->addWidget(close_button);

    setLayout(vlay);

    setWindowTitle(tr("Make Object"));
    this->exec();

    // find the object
    count = 0;
    for (i = 1; i < z_info->k_max; i++)
    {
        object_kind *k_ptr = &k_info[i];

        /* Skip "empty" items */
        if (k_ptr->k_name.isEmpty()) continue;
        // Skip artifact templates
        if (k_ptr->k_flags3 & (TR3_INSTA_ART)) continue;
        // Skip gold
        if (k_ptr->tval == TV_GOLD) continue;

        // Found the match
        if (count == obj_num) break;
        count++;
    }

    //  This is necessary to keep the game from freezing on dragon armor
    object_level = k_info[i].k_level;

    i_ptr->object_wipe();
    object_prep(i_ptr, i);
    apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE, FALSE);
    object_history(i_ptr, ORIGIN_CHEAT, 0);
    identify_object(i_ptr, true);
    if(inven_carry(i_ptr) < 0)
    {
        drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
    }

    object_level = p_ptr->depth;
}
Example #17
0
/**
 * Wield or wear a single item from the pack or floor
 */
void inven_wield(struct object *obj, int slot)
{
	struct object *wielded, *old = player->body.slots[slot].obj;

	const char *fmt;
	char o_name[80];

	/* Increase equipment counter if empty slot */
	if (old == NULL)
		player->upkeep->equip_cnt++;

	/* Take a turn */
	player->upkeep->energy_use = z_info->move_energy;

	/* Split off a new object if necessary */
	if (obj->number > 1) {
		/* Split off a new single object */
		wielded = object_split(obj, 1);

		/* If it's a gear object, give the split item a list entry */
		if (pile_contains(player->gear, obj)) {
			wielded->next = obj->next;
			obj->next = wielded;
			wielded->prev = obj;
			if (wielded->next)
				(wielded->next)->prev = wielded;
		}
	} else
		wielded = obj;

	/* Carry floor items, don't allow combining */
	if (square_holds_object(cave, player->py, player->px, wielded)) {
		square_excise_object(cave, player->py, player->px, wielded);
		inven_carry(player, wielded, FALSE, FALSE);
	}

	/* Wear the new stuff */
	player->body.slots[slot].obj = wielded;

	/* Do any ID-on-wield */
	object_notice_on_wield(wielded);

	/* Where is the item now */
	if (tval_is_melee_weapon(wielded))
		fmt = "You are wielding %s (%c).";
	else if (wielded->tval == TV_BOW)
		fmt = "You are shooting with %s (%c).";
	else if (tval_is_light(wielded))
		fmt = "Your light source is %s (%c).";
	else
		fmt = "You are wearing %s (%c).";

	/* Describe the result */
	object_desc(o_name, sizeof(o_name), wielded, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msgt(MSG_WIELD, fmt, o_name, I2A(slot));

	/* Cursed! */
	if (cursed_p(wielded->flags)) {
		/* Warn the player */
		msgt(MSG_CURSED, "Oops! It feels deathly cold!");

		/* Sense the object */
		object_notice_curses(wielded);
	}

	/* See if we have to overflow the pack */
	combine_pack();
	pack_overflow(old);

	/* Recalculate bonuses, torch, mana, gear */
	player->upkeep->notice |= (PN_IGNORE);
	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->redraw |= (PR_INVEN | PR_EQUIP | PR_ARMOR);
	player->upkeep->redraw |= (PR_STATS | PR_HP | PR_MANA | PR_SPEED);

	/* Disable repeats */
	cmd_disable_repeat();
}
Example #18
0
/*
 * Use a staff
 *
 * One charge of one staff disappears.
 *
 * Hack -- staffs of identify can be "cancelled".
 */
void do_cmd_use_staff(void)
{
	int item, chance, lev;

	bool ident;
	
	object_type *o_ptr;

	bool use_charge;

	cptr q, s;


	/* Restrict choices to staves */
	item_tester_tval = TV_STAFF;

	/* Get an item */
	q = "Use which staff? ";
	s = "You have no staff to use.";
	if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;

	/* Get the item (in the pack) */
	if (item >= 0)
	{
		o_ptr = &inventory[item];
	}

	/* Get the item (on the floor) */
	else
	{
		o_ptr = &o_list[0 - item];
	}


	/* Mega-Hack -- refuse to use a pile from the ground */
	if ((item < 0) && (o_ptr->number > 1))
	{
		msg_print("You must first pick up the staffs.");
		return;
	}


	/* Take a turn */
	p_ptr->energy_use = 100;

	/* Not identified yet */
	ident = FALSE;

	/* Extract the item level */
	lev = k_info[o_ptr->k_idx].level;

	/* Base chance of success */
	chance = p_ptr->skill_dev;

	/* Confusion hurts skill */
	if (p_ptr->confused) chance = chance / 2;

	/* High level objects are harder */
	chance = chance - ((lev > 50) ? 50 : lev);

	/* Give everyone a (slight) chance */
	if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
	{
		chance = USE_DEVICE;
	}

	/* Roll for usage */
	if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE))
	{
		if (flush_failure) flush();
		msg_print("You failed to use the staff properly.");
		return;
	}

	/* Notice empty staffs */
	if (o_ptr->pval <= 0)
	{
		if (flush_failure) flush();
		msg_print("The staff has no charges left.");
		o_ptr->ident |= (IDENT_EMPTY);
		p_ptr->notice |= (PN_COMBINE | PN_REORDER);
		p_ptr->window |= (PW_INVEN);
		return;
	}


	/* Sound */
	sound(MSG_ZAP);


	/* Use the staff */
	use_charge = use_object(o_ptr, &ident);


	/* Combine / Reorder the pack (later) */
	p_ptr->notice |= (PN_COMBINE | PN_REORDER);

	/* Tried the item */
	object_tried(o_ptr);

	/* An identification was made */
	if (ident && !object_aware_p(o_ptr))
	{
		object_aware(o_ptr);
		gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev);
	}

	/* Window stuff */
	p_ptr->window |= (PW_INVEN | PW_EQUIP);


	/* Hack -- some uses are "free" */
	if (!use_charge) return;


	/* Use a single charge */
	o_ptr->pval--;

	/* XXX Hack -- unstack if necessary */
	if ((item >= 0) && (o_ptr->number > 1))
	{
		object_type *i_ptr;
		object_type object_type_body;

		/* Get local object */
		i_ptr = &object_type_body;

		/* Obtain a local object */
		object_copy(i_ptr, o_ptr);

		/* Modify quantity */
		i_ptr->number = 1;

		/* Restore the charges */
		o_ptr->pval++;

		/* Unstack the used item */
		o_ptr->number--;
		p_ptr->total_weight -= i_ptr->weight;
		item = inven_carry(i_ptr);

		/* Message */
		msg_print("You unstack your staff.");
	}

	/* Describe charges in the pack */
	if (item >= 0)
	{
		inven_item_charges(item);
	}

	/* Describe charges on the floor */
	else
	{
		floor_item_charges(0 - item);
	}
}
Example #19
0
static void refill_lamp(object_type *j_ptr, object_type *o_ptr, int item)
{
	/* Refuel */
	j_ptr->timeout += o_ptr->timeout ? o_ptr->timeout : o_ptr->pval[DEFAULT_PVAL];

	/* Message */
	msg("You fuel your lamp.");

	/* Comment */
	if (j_ptr->timeout >= FUEL_LAMP)
	{
		j_ptr->timeout = FUEL_LAMP;
		msg("Your lamp is full.");
	}

	/* Refilled from a lantern */
	if (o_ptr->sval == SV_LIGHT_LANTERN)
	{
		/* Unstack if necessary */
		if (o_ptr->number > 1)
		{
			object_type *i_ptr;
			object_type object_type_body;

			/* Get local object */
			i_ptr = &object_type_body;

			/* Obtain a local object */
			object_copy(i_ptr, o_ptr);

			/* Modify quantity */
			i_ptr->number = 1;

			/* Remove fuel */
			i_ptr->timeout = 0;

			/* Unstack the used item */
			o_ptr->number--;
			p_ptr->total_weight -= i_ptr->weight;

			/* Carry or drop */
			if (item >= 0)
				item = inven_carry(p_ptr, i_ptr);
			else
				drop_near(cave, i_ptr, 0, p_ptr->py, p_ptr->px, FALSE);
		}

		/* Empty a single lantern */
		else
		{
			/* No more fuel */
			o_ptr->timeout = 0;
		}

		/* Combine / Reorder the pack (later) */
		p_ptr->notice |= (PN_COMBINE | PN_REORDER);

		/* Redraw stuff */
		p_ptr->redraw |= (PR_INVEN);
	}

	/* Refilled from a flask */
	else
	{
		/* Decrease the item (from the pack) */
		if (item >= 0)
		{
			inven_item_increase(item, -1);
			inven_item_describe(item);
			inven_item_optimize(item);
		}

		/* Decrease the item (from the floor) */
		else
		{
			floor_item_increase(0 - item, -1);
			floor_item_describe(0 - item);
			floor_item_optimize(0 - item);
		}
	}

	/* Recalculate torch */
	p_ptr->update |= (PU_TORCH);

	/* Redraw stuff */
	p_ptr->redraw |= (PR_EQUIP);
}
Example #20
0
/*
 * Aim a wand (from the pack or floor).
 *
 * Use a single charge from a single item.
 * Handle "unstacking" in a logical manner.
 *
 * For simplicity, you cannot use a stack of items from the
 * ground.  This would require too much nasty code.
 *
 * There are no wands which can "destroy" themselves, in the inventory
 * or on the ground, so we can ignore this possibility.  Note that this
 * required giving "wand of wonder" the ability to ignore destruction
 * by electric balls.
 *
 * All wands can be "cancelled" at the "Direction?" prompt for free.
 *
 * Note that the basic "bolt" wands do slightly less damage than the
 * basic "bolt" rods, but the basic "ball" wands do the same damage
 * as the basic "ball" rods.
 */
void do_cmd_aim_wand(void)
{
	int item, lev;

	bool ident;

	object_type *o_ptr;

	cptr q, s;


	/* Restrict choices to wands */
	item_tester_tval = TV_WAND;

	/* Get an item */
	q = "Aim which wand? ";
	s = "You have no wand to aim.";
	if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;

	/* Get the item (in the pack) */
	if (item >= 0)
	{
		o_ptr = &inventory[item];
	}

	/* Get the item (on the floor) */
	else
	{
		o_ptr = &o_list[0 - item];
	}


	/* Mega-Hack -- refuse to aim a pile from the ground */
	if ((item < 0) && (o_ptr->number > 1))
	{
		msg_print("You must first pick up the wands.");
		return;
	}


	/* Aim the wand */
	if (!use_object(o_ptr, &ident)) return;


	/* Combine / Reorder the pack (later) */
	p_ptr->notice |= (PN_COMBINE | PN_REORDER);

	/* Mark it as tried */
	object_tried(o_ptr);

	/* Object level */
	lev = k_info[o_ptr->k_idx].level;

	/* Apply identification */
	if (ident && !object_aware_p(o_ptr))
	{
		object_aware(o_ptr);
		gain_exp((lev + (p_ptr->lev / 2)) / p_ptr->lev);
	}

	/* Window stuff */
	p_ptr->window |= (PW_INVEN | PW_EQUIP);


	/* Use a single charge */
	o_ptr->pval--;

	/* Hack -- unstack if necessary */
	if ((item >= 0) && (o_ptr->number > 1))
	{
		object_type *i_ptr;
		object_type object_type_body;

		/* Get local object */
		i_ptr = &object_type_body;

		/* Obtain a local object */
		object_copy(i_ptr, o_ptr);

		/* Modify quantity */
		i_ptr->number = 1;

		/* Restore the charges */
		o_ptr->pval++;

		/* Unstack the used item */
		o_ptr->number--;
		p_ptr->total_weight -= i_ptr->weight;
		item = inven_carry(i_ptr);

		/* Message */
		msg_print("You unstack your wand.");
	}

	/* Describe the charges in the pack */
	if (item >= 0)
	{
		inven_item_charges(item);
	}

	/* Describe the charges on the floor */
	else
	{
		floor_item_charges(0 - item);
	}
}
Example #21
0
/**
 * Wield or wear a single item from the pack or floor
 */
void inven_wield(struct object *obj, int slot)
{
	struct object *wielded, *old = player->body.slots[slot].obj;

	const char *fmt;
	char o_name[80];
	bool dummy = false;

	/* Increase equipment counter if empty slot */
	if (old == NULL)
		player->upkeep->equip_cnt++;

	/* Take a turn */
	player->upkeep->energy_use = z_info->move_energy;

	/* It's either a gear object or a floor object */
	if (object_is_carried(player, obj)) {
		/* Split off a new object if necessary */
		if (obj->number > 1) {
			wielded = gear_object_for_use(obj, 1, false, &dummy);

			/* The new item needs new gear and known gear entries */
			wielded->next = obj->next;
			obj->next = wielded;
			wielded->prev = obj;
			if (wielded->next)
				(wielded->next)->prev = wielded;
			wielded->known->next = obj->known->next;
			obj->known->next = wielded->known;
			wielded->known->prev = obj->known;
			if (wielded->known->next)
				(wielded->known->next)->prev = wielded->known;
		} else {
			/* Just use the object directly */
			wielded = obj;
		}
	} else {
		/* Get a floor item and carry it */
		wielded = floor_object_for_use(obj, 1, false, &dummy);
		inven_carry(player, wielded, false, false);
	}

	/* Wear the new stuff */
	player->body.slots[slot].obj = wielded;

	/* Do any ID-on-wield */
	object_learn_on_wield(player, wielded);

	/* Where is the item now */
	if (tval_is_melee_weapon(wielded))
		fmt = "You are wielding %s (%c).";
	else if (wielded->tval == TV_BOW)
		fmt = "You are shooting with %s (%c).";
	else if (tval_is_light(wielded))
		fmt = "Your light source is %s (%c).";
	else
		fmt = "You are wearing %s (%c).";

	/* Describe the result */
	object_desc(o_name, sizeof(o_name), wielded, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msgt(MSG_WIELD, fmt, o_name, I2A(slot));

	/* Cursed! */
	if (wielded->curses) {
		/* Warn the player */
		msgt(MSG_CURSED, "Oops! It feels deathly cold!");
	}

	/* See if we have to overflow the pack */
	combine_pack();
	pack_overflow(old);

	/* Recalculate bonuses, torch, mana, gear */
	player->upkeep->notice |= (PN_IGNORE);
	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->redraw |= (PR_INVEN | PR_EQUIP | PR_ARMOR);
	player->upkeep->redraw |= (PR_STATS | PR_HP | PR_MANA | PR_SPEED);

	/* Disable repeats */
	cmd_disable_repeat();
}
Example #22
0
bool leprechaun_steal(int m_idx)
{
    bool result = FALSE;
    monster_type *m_ptr = &m_list[m_idx];
    monster_race *r_ptr = &r_info[m_ptr->r_idx];

    if ( !mon_save_p(m_ptr->r_idx, A_DEX) 
      || (MON_CSLEEP(m_ptr) && !mon_save_p(m_ptr->r_idx, A_DEX)))
    {
        object_type loot = {0};

        if (m_ptr->hold_o_idx && one_in_(2))
        {
            object_copy(&loot, &o_list[m_ptr->hold_o_idx]);
            delete_object_idx(m_ptr->hold_o_idx);
            loot.held_m_idx = 0;
        }
        else if (m_ptr->drop_ct > m_ptr->stolen_ct)
        {
            if (get_monster_drop(m_idx, &loot))
            {
                m_ptr->stolen_ct++;
                if (r_ptr->flags1 & RF1_UNIQUE)
                    r_ptr->stolen_ct++;
            }
        }

        if (!loot.k_idx)
        {
            msg_print("There is nothing to steal!");
        }
        else 
        {
            char o_name[MAX_NLEN];

            result = TRUE;
            object_desc(o_name, &loot, 0);
            if (mon_save_p(m_ptr->r_idx, A_DEX))
            {
                msg_format("Oops! You drop %s.", o_name);
                drop_near(&loot, -1, py, px);
            }
            else if (loot.tval == TV_GOLD)
            {
                msg_format("You steal %d gold pieces worth of %s.", (int)loot.pval, o_name);
                sound(SOUND_SELL);
                p_ptr->au += loot.pval;
                stats_on_gold_find(loot.pval);
                p_ptr->redraw |= (PR_GOLD);
                if (prace_is_(RACE_MON_LEPRECHAUN))
                    p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA);
            }
            else if (!inven_carry_okay(&loot))
            {
                msg_format("You have no room for %s.", o_name);
                drop_near(&loot, -1, py, px);
            }
            else
            {
                int slot = inven_carry(&loot);

                msg_format("You steal %s (%c).", o_name, index_to_label(slot));
                autopick_alter_item(slot, TRUE);
            }
        }
    }
    return result;
}