• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ drop_near函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中drop_near函数的典型用法代码示例。如果您正苦于以下问题:C++ drop_near函数的具体用法?C++ drop_near怎么用?C++ drop_near使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了drop_near函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wiz_create_item_subaction

bool wiz_create_item_subaction(menu_type *m, const ui_event *e, int oid)
{
	object_kind **choices = menu_priv(m);
	object_kind *kind = choices[oid];

	object_type *i_ptr;
	object_type object_type_body;

	if (e->type != EVT_SELECT)
		return TRUE;


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

	/* Create the item */
	object_prep(i_ptr, kind, p_ptr->depth, RANDOMISE);

	/* Apply magic (no messages, no artifacts) */
	apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);

	/* Mark as cheat, and where created */
	i_ptr->origin = ORIGIN_CHEAT;
	i_ptr->origin_depth = p_ptr->depth;

	if (kind->tval == TV_GOLD)
		make_gold(i_ptr, p_ptr->depth, kind->sval);

	/* Drop the object from heaven */
	drop_near(cave, i_ptr, 0, p_ptr->py, p_ptr->px, TRUE);

	return FALSE;
}
开发者ID:mtadd,项目名称:angband,代码行数:33,代码来源:wizard.c


示例2: _rune_of_elemental_protection_spell

static void _rune_of_elemental_protection_spell(int cmd, variant *res)
{
	switch (cmd)
	{
	case SPELL_NAME:
		var_set_string(res, "Rune of Protection");
		break;
	case SPELL_DESC:
		var_set_string(res, "Creates a standalone rune. As long as you have this rune in your inventory, your inventory items are 50% less likely to be destroyed by elemental attacks.");
		break;
	case SPELL_CAST:
	{
		object_type forge;

		object_prep(&forge, lookup_kind(TV_RUNE, SV_RUNE));
		rune_add(&forge, RUNE_ELEMENTAL_PROTECTION, FALSE);
		drop_near(&forge, -1, py, px);

		var_set_bool(res, TRUE);
		break;
	}
	default:
		_rune_default_spell(cmd, res);
		break;
	}
}
开发者ID:erikbroo,项目名称:chengband,代码行数:26,代码来源:rune_knight.c


示例3: wiz_create_artifact

/*
 * Create the artifact with the specified number
 */
static void wiz_create_artifact(int a_idx)
{
	object_type *i_ptr;
	object_type object_type_body;
	int k_idx;

	artifact_type *a_ptr = &a_info[a_idx];

	/* Ignore "empty" artifacts */
	if (!a_ptr->name) return;

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

	/* Wipe the object */
	object_wipe(i_ptr);

	/* Acquire the "kind" index */
	k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);

	/* Oops */
	if (!k_idx) return;

	/* Create the artifact */
	object_prep(i_ptr, &k_info[k_idx], a_ptr->alloc_min, RANDOMISE);

	/* Save the name */
	i_ptr->name1 = a_idx;

	/* Extract the fields */
	i_ptr->pval = a_ptr->pval;
	i_ptr->ac = a_ptr->ac;
	i_ptr->dd = a_ptr->dd;
	i_ptr->ds = a_ptr->ds;
	i_ptr->to_a = a_ptr->to_a;
	i_ptr->to_h = a_ptr->to_h;
	i_ptr->to_d = a_ptr->to_d;
	i_ptr->weight = a_ptr->weight;

	/* Hack -- extract the "cursed" flags */
	if (cursed_p(a_ptr))
	{
		bitflag curse_flags[OF_SIZE];
		of_copy(curse_flags, a_ptr->flags);
		flags_mask(curse_flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
		of_union(i_ptr->flags, curse_flags);
	}

	/* Mark that the artifact has been created. */
	a_ptr->created = TRUE;

	/* Mark as cheat */
	i_ptr->origin = ORIGIN_CHEAT;

	/* Drop the artifact from heaven */
	drop_near(i_ptr, 0, p_ptr->py, p_ptr->px, TRUE);

	/* All done */
	msg_print("Allocated.");
}
开发者ID:NickMcConnell,项目名称:RePosBand,代码行数:63,代码来源:wizard.c


示例4: wiz_test_kind

/*
 * Create lots of items.
 */
static void wiz_test_kind(int tval)
{
	int py = p_ptr->py;
	int px = p_ptr->px;
	int sval;

	object_type object_type_body;
	object_type *i_ptr = &object_type_body;

	for (sval = 0; sval < 255; sval++)
	{
		object_kind *kind = lookup_kind(tval, sval);
		if (!kind) continue;

		/* Create the item */
		object_prep(i_ptr, kind, p_ptr->depth, RANDOMISE);

		/* Apply magic (no messages, no artifacts) */
		apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);

		/* Mark as cheat, and where created */
		i_ptr->origin = ORIGIN_CHEAT;
		i_ptr->origin_depth = p_ptr->depth;

		if (tval == TV_GOLD)
			make_gold(i_ptr, p_ptr->depth, sval);

		/* Drop the object from heaven */
		drop_near(cave, i_ptr, 0, py, px, TRUE);
	}

	msg("Done.");
}
开发者ID:mtadd,项目名称:angband,代码行数:36,代码来源:wizard.c


示例5: _rune_of_good_fortune_spell

static void _rune_of_good_fortune_spell(int cmd, variant *res)
{
	switch (cmd)
	{
	case SPELL_NAME:
		var_set_string(res, "Rune of Good Fortune");
		break;
	case SPELL_DESC:
		var_set_string(res, "Creates a standalone rune. As long as you have this rune in your inventory, you gain the effects of White Aura mutation.");
		break;
	case SPELL_CAST:
	{
		object_type forge;

		object_prep(&forge, lookup_kind(TV_RUNE, SV_RUNE));
		rune_add(&forge, RUNE_GOOD_FORTUNE, FALSE);
		drop_near(&forge, -1, py, px);

		var_set_bool(res, TRUE);
		break;
	}
	default:
		_rune_default_spell(cmd, res);
		break;
	}
}
开发者ID:erikbroo,项目名称:chengband,代码行数:26,代码来源:rune_knight.c


示例6: wiz_create_item_aux

/*
 * Auxilliary Wizard routine for creating objects
 *
 * Hack -- this routine always makes a "dungeon object", and applies
 * magic to it, and attempts to decline cursed items. XXX XXX XXX
 */
static void wiz_create_item_aux(int k_idx)
{
	int py = p_ptr->py;
	int px = p_ptr->px;
		
	object_type *i_ptr;
	object_type object_type_body;
		
	/* Get local object */
	i_ptr = &object_type_body;
	
	/* Create the item */
	object_prep(i_ptr, k_idx);
		
	/* Apply magic (no messages, no artefacts) */
	apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE, FALSE);
	
	// apply the autoinscription (if any)
	apply_autoinscription(i_ptr);
	
	if (i_ptr->tval == TV_ARROW) i_ptr->number = 24;
	
	/* Drop the object from heaven */
	drop_near(i_ptr, -1, py, px);
}
开发者ID:MarvinPA,项目名称:mpa-sil,代码行数:31,代码来源:wizard2.c


示例7: drop_near

void WizardModeDialog::wiz_mass_create_items(void)
{
    int i;
    object_type object_type_body;

    object_type *i_ptr;

    this->accept();

    for(i=0; i < 25; i++)
    {
        /* Get local object */
        i_ptr = &object_type_body;

        /* Wipe the object */
        i_ptr->object_wipe();

        /* Make a object (if possible) */
        if (!make_object(i_ptr, FALSE, FALSE, DROP_TYPE_UNTHEMED, FALSE)) continue;

        /* Drop the object */
        drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);
    }

}
开发者ID:nppangband,项目名称:NPPAngband_QT,代码行数:25,代码来源:wizard_mode.cpp


示例8: wiz_create_item

/*!
 * @brief 任意のベースアイテム生成のメインルーチン /
 * Wizard routine for creating objects		-RAK-
 * @return なし
 * @details
 * Heavily modified to allow magification and artifactification  -Bernd-
 *
 * Note that wizards cannot create objects on top of other objects.
 *
 * Hack -- this routine always makes a "dungeon object", and applies
 * magic to it, and attempts to decline cursed items.
 */
static void wiz_create_item(void)
{
	object_type	forge;
	object_type *q_ptr;

	int k_idx;


	/* Save the screen */
	screen_save();

	/* Get object base type */
	k_idx = wiz_create_itemtype();

	/* Restore the screen */
	screen_load();


	/* Return if failed */
	if (!k_idx) return;

	if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
	{
		int i;

		/* Artifactify */
		for (i = 1; i < max_a_idx; i++)
		{
			/* Ignore incorrect tval */
			if (a_info[i].tval != k_info[k_idx].tval) continue;

			/* Ignore incorrect sval */
			if (a_info[i].sval != k_info[k_idx].sval) continue;

			/* Create this artifact */
			(void)create_named_art(i, p_ptr->y, p_ptr->x);

			/* All done */
			msg_print("Allocated(INSTA_ART).");

			return;
		}
	}

	/* Get local object */
	q_ptr = &forge;

	/* Create the item */
	object_prep(q_ptr, k_idx);

	/* Apply magic */
	apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);

	/* Drop the object from heaven */
	(void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);

	/* All done */
	msg_print("Allocated.");
}
开发者ID:naota,项目名称:hengband,代码行数:71,代码来源:wizard2.c


示例9: chest_death

/**
 * Allocate objects upon opening a chest
 *
 * Disperse treasures from the given chest, centered at (x,y).
 *
 * Small chests often contain "gold", while Large chests always contain
 * items.  Wooden chests contain 2 items, Iron chests contain 4 items,
 * and Steel chests contain 6 items.  The "value" of the items in a
 * chest is based on the level on which the chest is generated.
 *
 * Judgment of size and construction of chests is currently made from the name.
 */
static void chest_death(int y, int x, struct object *chest)
{
	int number, value;

	bool tiny;

	struct object *treasure;

	/* Small chests often hold "gold" */
	tiny = strstr(chest->kind->name, "Small") ? TRUE : FALSE;

	/* Determine how much to drop (see above) */
	if (strstr(chest->kind->name, "wooden"))
		number = 2;
	else if (strstr(chest->kind->name, "iron"))
		number = 4;
	else if (strstr(chest->kind->name, "steel"))
		number = 6;
	else
		number = 2 * (randint1(3));

	/* Zero pval means empty chest */
	if (!chest->pval) number = 0;

	/* Determine the "value" of the items */
	value = chest->origin_depth - 10 + 2 * chest->sval;
	if (value < 1)
		value = 1;

	/* Drop some objects (non-chests) */
	for (; number > 0; --number) {
		/* Small chests often drop gold */
		if (tiny && (randint0(100) < 75))
			treasure = make_gold(value, "any");

		/* Otherwise drop an item, as long as it isn't a chest */
		else {
			treasure = make_object(cave, value, FALSE, FALSE, FALSE, NULL, 0);
			if (!treasure) continue;
			if (tval_is_chest(treasure)) {
				mem_free(treasure);
				continue;
			}
		}

		/* Record origin */
		treasure->origin = ORIGIN_CHEST;
		treasure->origin_depth = chest->origin_depth;

		/* Drop it in the dungeon */
		drop_near(cave, treasure, 0, y, x, TRUE);
	}

	/* Empty */
	chest->pval = 0;

	/* Known */
	object_notice_everything(chest);
}
开发者ID:NickMcConnell,项目名称:FirstAgeAngband,代码行数:71,代码来源:obj-chest.c


示例10: monster_death

/**
 * Handles the "death" of a monster.
 *
 * Disperses treasures carried by the monster centered at the monster location.
 * Note that objects dropped may disappear in crowded rooms.
 *
 * Checks for "Quest" completion when a quest monster is killed.
 *
 * Note that only the player can induce "monster_death()" on Uniques.
 * Thus (for now) all Quest monsters should be Uniques.
 *
 * If `stats` is true, then we skip updating the monster memory. This is
 * used by stats-generation code, for efficiency.
 */
void monster_death(struct monster *mon, bool stats)
{
	int dump_item = 0;
	int dump_gold = 0;
	struct object *obj = mon->held_obj;

	bool visible = (mflag_has(mon->mflag, MFLAG_VISIBLE) ||
					rf_has(mon->race->flags, RF_UNIQUE));

	/* Delete any mimicked objects */
	if (mon->mimicked_obj)
		object_delete(&mon->mimicked_obj);

	/* Drop objects being carried */
	while (obj) {
		struct object *next = obj->next;

		/* Object no longer held */
		obj->held_m_idx = 0;
		pile_excise(&mon->held_obj, obj);

		/* Count it and drop it - refactor once origin is a bitflag */
		if (!stats) {
			if (tval_is_money(obj) && (obj->origin != ORIGIN_STOLEN))
				dump_gold++;
			else if (!tval_is_money(obj) && ((obj->origin == ORIGIN_DROP)
					|| (obj->origin == ORIGIN_DROP_PIT)
					|| (obj->origin == ORIGIN_DROP_VAULT)
					|| (obj->origin == ORIGIN_DROP_SUMMON)
					|| (obj->origin == ORIGIN_DROP_SPECIAL)
					|| (obj->origin == ORIGIN_DROP_BREED)
					|| (obj->origin == ORIGIN_DROP_POLY)
					|| (obj->origin == ORIGIN_DROP_WIZARD)))
				dump_item++;
		}

		/* Change origin if monster is invisible, unless we're in stats mode */
		if (!visible && !stats)
			obj->origin = ORIGIN_DROP_UNKNOWN;

		drop_near(cave, obj, 0, mon->fy, mon->fx, true);
		obj = next;
	}

	/* Forget objects */
	mon->held_obj = NULL;

	/* Take note of any dropped treasure */
	if (visible && (dump_item || dump_gold))
		lore_treasure(mon, dump_item, dump_gold);

	/* Update monster list window */
	player->upkeep->redraw |= PR_MONLIST;

	/* Check if we finished a quest */
	quest_check(mon);
}
开发者ID:CrypticGator,项目名称:angband,代码行数:71,代码来源:mon-make.c


示例11: mon_drop_chosen_objects

/*
 * Helper function for monster_death -
 * Intended only to drop Morgoth's special artifacts
 */
static void mon_drop_chosen_objects(monster_type *m_ptr)
{
	object_type *i_ptr;
	object_type object_type_body;

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

	/* Mega-Hack -- Prepare to make "Grond" */
	object_prep(i_ptr, lookup_kind(TV_HAFTED, SV_GROND));

	/* Mega-Hack -- Mark this item as "Grond" */
	i_ptr->art_num = ART_GROND;

	/* Mega-Hack -- Actually create "Grond" */
	apply_magic(i_ptr, -1, TRUE, TRUE, TRUE, FALSE);

	/* Remember history */
	object_history(i_ptr, ORIGIN_MORGOTH, 0);

	/* Drop it in the dungeon */
	drop_near(i_ptr, -1, m_ptr->fy, m_ptr->fx);

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

	/* Mega-Hack -- Prepare to make "Morgoth's crown" */
	object_prep(i_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));

	/* Mega-Hack -- Mark this item as "Morgoth" */
	i_ptr->art_num = ART_MORGOTH;

	/* Mega-Hack -- Actually create "Morgoth" */
	apply_magic(i_ptr, -1, TRUE, TRUE, TRUE, FALSE);

	/* Remember history */
	object_history(i_ptr, ORIGIN_MORGOTH, 0);

	/* Drop it in the dungeon */
	drop_near(i_ptr, -1, m_ptr->fy, m_ptr->fx);
}
开发者ID:NickMcConnell,项目名称:NPPAngband,代码行数:45,代码来源:xtra2.c


示例12: pack_overflow

/**
 * Overflow an item from the pack, if it is overfull.
 */
void pack_overflow(struct object *obj)
{
	int i;
	char o_name[80];
	bool artifact = false;

	if (!pack_is_overfull()) return;

	/* Disturbing */
	disturb(player, 0);

	/* Warning */
	msg("Your pack overflows!");

	/* Get the last proper item */
	for (i = 1; i <= z_info->pack_size; i++)
		if (!player->upkeep->inven[i])
			break;

	/* Drop the last inventory item unless requested otherwise */
	if (!obj) {
		obj = player->upkeep->inven[i - 1];
	}

	/* Rule out weirdness (like pack full, but inventory empty) */
	assert(obj != NULL);

	/* Describe */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);
	if (obj->artifact) {
		artifact = true;
	}

	/* Message */
	msg("You drop %s.", o_name);

	/* Excise the object and drop it (carefully) near the player */
	gear_excise_object(obj);
	drop_near(cave, &obj, 0, player->py, player->px, false);

	/* Describe */
	if (artifact)
		msg("You no longer have the %s.", o_name);
	else
		msg("You no longer have %s.", o_name);

	/* Notice, update, redraw */
	if (player->upkeep->notice) notice_stuff(player);
	if (player->upkeep->update) update_stuff(player);
	if (player->upkeep->redraw) redraw_stuff(player);
}
开发者ID:fe051,项目名称:angband,代码行数:54,代码来源:obj-gear.c


示例13: pack_overflow

/**
 * Overflow an item from the pack, if it is overfull.
 */
void pack_overflow(void)
{
	int i;
	struct object *obj = NULL;
	char o_name[80];

	if (!pack_is_overfull()) return;

	/* Disturbing */
	disturb(player, 0);

	/* Warning */
	msg("Your pack overflows!");

	/* Find the last inventory item */
	for (i = 1; i <= z_info->pack_size; i++)
		if (!player->upkeep->inven[i])
			break;

	/* Last object was the previous index */
	obj = player->upkeep->inven[i - 1];

	/* Rule out weirdness (like pack full, but inventory empty) */
	assert(obj != NULL);

	/* Describe */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg("You drop %s (%c).", o_name, I2A(i - 1));

	/* Excise the object and drop it (carefully) near the player */
	gear_excise_object(obj);
	drop_near(cave, obj, 0, player->py, player->px, FALSE);

	/* Describe */
	if (obj->artifact)
		msg("You no longer have the %s (%c).", o_name, I2A(i - 1));
	else
		msg("You no longer have %s (%c).", o_name, I2A(i - 1));

	/* Notice stuff (if needed) */
	if (player->upkeep->notice) notice_stuff(player->upkeep);

	/* Update stuff (if needed) */
	if (player->upkeep->update) update_stuff(player->upkeep);

	/* Redraw stuff (if needed) */
	if (player->upkeep->redraw) redraw_stuff(player->upkeep);
}
开发者ID:tingley,项目名称:angband,代码行数:53,代码来源:obj-gear.c


示例14: _blood_pool_spell

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;
    }
}
开发者ID:bamhamcity,项目名称:lessxpcb,代码行数:50,代码来源:blood_knight.c


示例15: push_object

/**
 * This will push objects off a square.
 *
 * The methodology is to load all objects on the square into a queue. Replace
 * the previous square with a type that does not allow for objects. Drop the
 * objects. Last, put the square back to its original type.
 */
void push_object(int y, int x)
{
	/* Save the original terrain feature */
	struct feature *feat_old = square_feat(cave, y, x);

	struct object *obj = square_object(cave, y, x);

	struct queue *queue = q_new(z_info->floor_size);

	bool glyph = square_iswarded(cave, y, x);

	/* Push all objects on the square, stripped of pile info, into the queue */
	while (obj) {
		struct object *next = obj->next;
		q_push_ptr(queue, obj);

		/* Orphan the object */
		obj->next = NULL;
		obj->prev = NULL;
		obj->iy = 0;
		obj->ix = 0;

		/* Next object */
		obj = next;
	}

	/* Disassociate the objects from the square */
	cave->squares[y][x].obj = NULL;

	/* Set feature to an open door */
	square_force_floor(cave, y, x);
	square_add_door(cave, y, x, false);

	/* Drop objects back onto the floor */
	while (q_len(queue) > 0) {
		/* Take object from the queue */
		obj = q_pop_ptr(queue);

		/* Drop the object */
		drop_near(cave, &obj, 0, y, x, false);
	}

	/* Reset cave feature and rune if needed */
	square_set_feat(cave, y, x, feat_old->fidx);
	if (glyph)
		square_add_ward(cave, y, x);

	q_free(queue);
}
开发者ID:fizzix,项目名称:angband,代码行数:56,代码来源:obj-pile.c


示例16: wiz_create_artifact

/*
 * Create the artifact with the specified number
 */
static void wiz_create_artifact(int a_idx)
{
	object_type *i_ptr;
	object_type object_type_body;
	object_kind *kind;

	artifact_type *a_ptr = &a_info[a_idx];

	/* Ignore "empty" artifacts */
	if (!a_ptr->name) return;

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

	/* Wipe the object */
	object_wipe(i_ptr);

	/* Acquire the "kind" index */
	kind = lookup_kind(a_ptr->tval, a_ptr->sval);
	if (!kind)
		return;

	/* Create the artifact */
	object_prep(i_ptr, kind, a_ptr->alloc_min, RANDOMISE);

	/* Save the name */
	i_ptr->artifact = a_ptr;

	/* Extract the fields */
	copy_artifact_data(i_ptr, a_ptr);

	/* Mark that the artifact has been created. */
	a_ptr->created = TRUE;

	/* Mark as cheat */
	i_ptr->origin = ORIGIN_CHEAT;

	/* Drop the artifact from heaven */
	drop_near(cave, i_ptr, 0, p_ptr->py, p_ptr->px, TRUE);

	/* All done */
	msg("Allocated.");
	
	/* Redraw map */
	p_ptr->redraw |= (PR_MAP | PR_ITEMLIST);
	handle_stuff(p_ptr);
}
开发者ID:mtadd,项目名称:angband,代码行数:50,代码来源:wizard.c


示例17: acquirement

/**
 * Scatter some objects near the player
 */
void acquirement(int y1, int x1, int level, int num, bool great)
{
	struct object *nice_obj;

	/* Acquirement */
	while (num--) {
		/* Make a good (or great) object (if possible) */
		nice_obj = make_object(cave, level, true, great, true, NULL, 0);
		if (!nice_obj) continue;

		nice_obj->origin = ORIGIN_ACQUIRE;
		nice_obj->origin_depth = player->depth;

		/* Drop the object */
		drop_near(cave, nice_obj, 0, y1, x1, true);
	}
}
开发者ID:CrypticGator,项目名称:angband,代码行数:20,代码来源:obj-make.c


示例18: wiz_create_artifact

/*
 * Create the artifact with the specified number
 */
static void wiz_create_artifact(int a_idx)
{
	object_type *i_ptr;
	object_type object_type_body;
	int k_idx;

	artifact_type *a_ptr = &a_info[a_idx];

	/* Ignore "empty" artifacts */
	if (!a_ptr->name) return;

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

	/* Wipe the object */
	object_wipe(i_ptr);

	/* Acquire the "kind" index */
	k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);

	/* Oops */
	if (!k_idx) return;

	/* Create the artifact */
	object_prep(i_ptr, k_idx);

	/* Save the name */
	i_ptr->name1 = a_idx;

	/* Extract the fields */
	i_ptr->pval = a_ptr->pval;
	i_ptr->ac = a_ptr->ac;
	i_ptr->dd = a_ptr->dd;
	i_ptr->ds = a_ptr->ds;
	i_ptr->to_a = a_ptr->to_a;
	i_ptr->to_h = a_ptr->to_h;
	i_ptr->to_d = a_ptr->to_d;
	i_ptr->weight = a_ptr->weight;

	/* Drop the artifact from heaven */
	drop_near(i_ptr, -1, p_ptr->py, p_ptr->px);

	/* All done */
	msg_print("Allocated.");
}
开发者ID:BackupTheBerlios,项目名称:unangband-svn,代码行数:48,代码来源:wizard2.c


示例19: inven_drop

/**
 * Drop (some of) a non-cursed inventory/equipment item "near" the current
 * location
 *
 * There are two cases here - a single object or entire stack is being dropped,
 * or part of a stack is being split off and dropped
 */
void inven_drop(struct object *obj, int amt)
{
	int py = player->py;
	int px = player->px;
	struct object *dropped;

	char o_name[80];
	char label;

	/* Error check */
	if (amt <= 0)
		return;

	/* Check it is still held, in case there were two drop commands queued
	 * for this item.  This is in theory not ideal, but in practice should
	 * be safe. */
	if (!pile_contains(player->gear, obj))
		return;

	/* Get where the object is now */
	label = gear_to_label(obj);

	/* Not too many */
	if (amt > obj->number) amt = obj->number;

	/* Take off equipment */
	if (object_is_equipped(player->body, obj))
		inven_takeoff(obj);

	/* Get the object */
	dropped = gear_object_for_use(obj, amt, TRUE);

	/* Describe the dropped object */
	object_desc(o_name, sizeof(o_name), dropped, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg("You drop %s (%c).", o_name, label);

	/* Drop it near the player */
	drop_near(cave, dropped, 0, py, px, FALSE);

	event_signal(EVENT_INVENTORY);
	event_signal(EVENT_EQUIPMENT);
}
开发者ID:Daedelus01,项目名称:angband,代码行数:51,代码来源:obj-gear.c


示例20: chest_death

/**
 * Allocate objects upon opening a chest
 *
 * Disperse treasures from the given chest, centered at (x,y).
 *
 * Wooden chests contain 1 item, Iron chests contain 2 items,
 * and Steel chests contain 3 items.  Small chests now contain good items,
 * large chests great items, out of depth for the level on which the chest
 * is generated.
 *
 * Judgment of size and construction of chests is currently made from the name.
 */
static void chest_death(int y, int x, struct object *chest)
{
	int number, level;
	bool large = strstr(chest->kind->name, "Large") ? true : false;;

	/* Zero pval means empty chest */
	if (!chest->pval)
		return;

	/* Determine how much to drop (see above) */
	if (strstr(chest->kind->name, "wooden")) {
		number = 1;
	} else if (strstr(chest->kind->name, "iron")) {
		number = 2;
	} else if (strstr(chest->kind->name, "steel")) {
		number = 3;
	} else {
		number = randint1(3);
	}

	/* Drop some valuable objects (non-chests) */
	level = chest->origin_depth + 5;
	while (number > 0) {
		struct object *treasure;
		treasure = make_object(cave, level, true, large, false, NULL, 0);
		if (!treasure)
			continue;
		if (tval_is_chest(treasure)) {
			object_delete(&treasure);
			continue;
		}

		treasure->origin = ORIGIN_CHEST;
		treasure->origin_depth = chest->origin_depth;
		drop_near(cave, &treasure, 0, y, x, true);
		number--;
	}

	/* Chest is now empty */
	chest->pval = 0;
	chest->known->pval = 0;
}
开发者ID:BardurArantsson,项目名称:angband,代码行数:54,代码来源:obj-chest.c



注:本文中的drop_near函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ drop_nlink函数代码示例发布时间:2022-05-30
下一篇:
C++ drm_vblank_cleanup函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap