本文整理汇总了C++中drop_near函数的典型用法代码示例。如果您正苦于以下问题:C++ drop_near函数的具体用法?C++ drop_near怎么用?C++ drop_near使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_near函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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.");
}
示例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.");
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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.");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}