当前位置: 首页>>代码示例>>C++>>正文


C++ disturb函数代码示例

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


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

示例1: _set_current_r_idx

static void _set_current_r_idx(int r_idx)
{
    if (r_idx == p_ptr->current_r_idx)
        return;

    disturb(1, 0);
    if (r_idx == MON_MIMIC && p_ptr->current_r_idx)
        msg_format("You stop mimicking %s.", r_name + r_info[p_ptr->current_r_idx].name);
    possessor_set_current_r_idx(r_idx);
    if (r_idx != MON_MIMIC)
        msg_format("You start mimicking %s.", r_name + r_info[p_ptr->current_r_idx].name);
    /* Mimics shift forms often enough to be annoying if shapes
       have dramatically different body types (e.g. dragons vs humanoids).
       Inscribe gear with @mimic to autoequip on shifing. */
    equip_shuffle("@mimic1");
    equip_shuffle("@mimic2");
    equip_shuffle("@mimic3");
    equip_shuffle("@mimic4");
    equip_shuffle("@mimic");
}
开发者ID:bamhamcity,项目名称:lessxpcb,代码行数:20,代码来源:race_mimic.c

示例2: _cyber_move_player

static void _cyber_move_player(void)
{
    /* Cyberdemons move erratically (cf get_rep_dir()) and make a lot of noise */
    if (one_in_(66))
    {
        int i;

        cmsg_print(TERM_RED, "The dungeon trembles!");
        if (disturb_minor)
            disturb(0, 0);

        for (i = 1; i < m_max; i++)
        {
            monster_type *m_ptr = &m_list[i];

            if (!m_ptr->r_idx) continue;
            if (m_ptr->cdis < MAX_SIGHT * 2 && MON_CSLEEP(m_ptr))
                (void)set_monster_csleep(i, 0);
        }
    }
}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:21,代码来源:race_demon.c

示例3: wild_weapon_strike

void wild_weapon_strike(void)
{
    /* Note, if we get a counter slot first, then you can just regain what you lost.
       So getting the power first assures you are getting something new */
    int power = _get_random_power();
    int slot = _get_counter();
    int info = _find_type(power);

    if (info >= 0)
        _types[info].on_fn();

    p_ptr->wild_counters[slot].type = power;
    p_ptr->wild_counters[slot].counter = 2;

    if (info >= 0)
    {
        p_ptr->redraw |= _types[info].redraw_flags;
        p_ptr->update |= _types[info].update_flags;
        if (disturb_state) disturb(0, 0);
        handle_stuff();
    }
}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:22,代码来源:wild_realm.c

示例4: modify_panel

/*
 * Modify the current panel to the given coordinates, adjusting only to
 * ensure the coordinates are legal, and return TRUE if anything done.
 *
 * The town should never be scrolled around.
 *
 * Note that monsters are no longer affected in any way by panel changes.
 *
 * As a total hack, whenever the current panel changes, we assume that
 * the "overhead view" window should be updated.
 */
bool modify_panel(term *t, int wy, int wx)
{
	int dungeon_hgt = DUNGEON_HGT;
	int dungeon_wid = DUNGEON_WID;

	/* Adjust for town */
	if (p_ptr->depth == 0) town_adjust(&dungeon_hgt, &dungeon_wid);

	/* Verify wy, adjust if needed */
	if (wy > dungeon_hgt - SCREEN_HGT) wy = dungeon_hgt - SCREEN_HGT;
	if (wy < 0) wy = 0;

	/* Verify wx, adjust if needed */
	if (wx > dungeon_wid - SCREEN_WID) wx = dungeon_wid - SCREEN_WID;
	if (wx < 0) wx = 0;

	/* React to changes */
	if ((t->offset_y != wy) || (t->offset_x != wx))
	{
		/* Save wy, wx */
		t->offset_y = wy;
		t->offset_x = wx;

		/* Redraw map */
		p_ptr->redraw |= (PR_MAP);

		/* Redraw for big graphics */
		if ((tile_width > 1) || (tile_height > 1)) redraw_stuff();
      
		/* Hack -- optional disturb on "panel change" */
		if (OPT(disturb_panel) && !OPT(center_player)) disturb(0, 0);
  
		/* Changed */
		return (TRUE);
	}

	/* No change */
	return (FALSE);
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:50,代码来源:xtra2.c

示例5: do_cmd_alter_aux

/**
 * Manipulate an adjacent grid in some way
 *
 * Attack monsters, tunnel through walls, disarm traps, open doors.
 *
 * This command must always take energy, to prevent free detection
 * of invisible monsters.
 *
 * The "semantics" of this command must be chosen before the player
 * is confused, and it must be verified against the new grid.
 */
void do_cmd_alter_aux(int dir)
{
	int y, x;
	bool more = false;

	/* Get location */
	y = player->py + ddy[dir];
	x = player->px + ddx[dir];

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

	/* Apply confusion */
	if (player_confuse_dir(player, &dir, false)) {
		/* Get location */
		y = player->py + ddy[dir];
		x = player->px + ddx[dir];
	}

	/* Action depends on what's there */
	if (cave->squares[y][x].mon > 0)
		/* Attack monsters */
		py_attack(y, x);
	else if (square_isdiggable(cave, y, x))
		/* Tunnel through walls and rubble */
		more = do_cmd_tunnel_aux(y, x);
	else if (square_iscloseddoor(cave, y, x))
		/* Open closed doors */
		more = do_cmd_open_aux(y, x);
	else if (square_isknowntrap(cave, y, x))
		/* Disarm traps */
		more = do_cmd_disarm_aux(y, x);
	else
		/* Oops */
		msg("You spin around.");

	/* Cancel repetition unless we can continue */
	if (!more) disturb(player, 0);
}
开发者ID:pete-mack,项目名称:angband,代码行数:50,代码来源:cmd-cave.c

示例6: do_mon_spell

/**
 * Process a monster spell 
 *
 * \param index is the monster spell flag (RSF_FOO)
 * \param mon is the attacking monster
 * \param seen is whether the player can see the monster at this moment
 */
void do_mon_spell(int index, struct monster *mon, bool seen)
{
	char m_name[80];
	bool ident, hits = FALSE;

	/* Extract the monster level */
	int rlev = ((mon->race->level >= 1) ? mon->race->level : 1);

	const struct monster_spell *spell = monster_spell_by_index(index);

	/* Get the monster name (or "it") */
	monster_desc(m_name, sizeof(m_name), mon, MDESC_STANDARD);

	/* See if it hits */
	if (spell->hit == 100)
		hits = TRUE;
	else if (spell->hit == 0)
		hits = FALSE;
	else
		hits = check_hit(player, spell->hit, rlev);

	/* Tell the player what's going on */
	disturb(player, 1);
	spell_message(mon, spell, seen, hits);

	if (!hits) return;

	/* Try a saving throw if available */
	if (spell->save_message &&
		randint0(100) < player->state.skills[SKILL_SAVE]) {
		msg("%s", spell->save_message);
		return;
	}

	/* Do effects */
	effect_do(spell->effect, NULL, &ident, TRUE, 0, 0, 0);

	return;
}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:46,代码来源:mon-spell.c

示例7: do_autopickup

/**
 * Pick up everything on the floor that requires no player action
 */
int do_autopickup(void)
{
	int py = player->py;
	int px = player->px;

	struct object *obj, *next;

	/* Objects picked up.  Used to determine time cost of command. */
	byte objs_picked_up = 0;

	/* Nothing to pick up -- return */
	if (!square_object(cave, py, px))
		return 0;

	/* Always pickup gold, effortlessly */
	player_pickup_gold();

	/* Scan the remaining objects */
	obj = square_object(cave, py, px);
	while (obj) {
		next = obj->next;

		/* Ignore all hidden objects and non-objects */
		if (!ignore_item_ok(obj)) {
			/* Hack -- disturb */
			disturb(player, 0);

			/* Automatically pick up items into the backpack */
			if (auto_pickup_okay(obj)) {
				/* Pick up the object with message */
				player_pickup_aux(obj, TRUE);
				objs_picked_up++;
			}
		}
		obj = next;
	}

	return objs_picked_up;
}
开发者ID:myshkin,项目名称:angband,代码行数:42,代码来源:cmd-pickup.c

示例8: check_for_player_interrupt

/**
 * Allow for user abort during repeated commands, running and resting.
 *
 * This will only check during every 128th game turn while resting.
 */
void check_for_player_interrupt(game_event_type type, game_event_data *data,
								void *user)
{
	/* Check for "player abort" */
	if (player->upkeep->running ||
	    cmd_get_nrepeats() > 0 ||
	    (player_is_resting(player) && !(turn & 0x7F))) {
		ui_event e;

		/* Do not wait */
		inkey_scan = SCAN_INSTANT;

		/* Check for a key */
		e = inkey_ex();
		if (e.type != EVT_NONE) {
			/* Flush and disturb */
			event_signal(EVENT_INPUT_FLUSH);
			disturb(player, 0);
			msg("Cancelled.");
		}
	}
}
开发者ID:NickMcConnell,项目名称:FirstAgeAngband,代码行数:27,代码来源:ui-game.c

示例9: _water_process_world

static void _water_process_world(void)
{
    int inven_ct = 0;
    int equip_ct = 0;
    int chance = 15;
    int i;
    for (i = 0; i < INVEN_TOTAL; i++)
    {
        object_type *o_ptr = &inventory[i];
        u32b         flgs[TR_FLAG_SIZE];
        char         o_name[MAX_NLEN];

        if (!o_ptr->k_idx) continue;
        if (!object_is_armour(o_ptr)) continue;
        if (randint0(1000) >= chance) continue;
        if (o_ptr->ac + o_ptr->to_a <= 0) continue;

        object_flags(o_ptr, flgs);
        if (have_flag(flgs, TR_IGNORE_ACID)) continue;

        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        msg_format("Your watery touch corrodes your %s!", o_name);
                
        o_ptr->to_a--;

        if (i >= EQUIP_BEGIN) ++equip_ct;
        else ++inven_ct;
    }

    if (equip_ct)
    {
        p_ptr->update |= PU_BONUS;
        p_ptr->window |= PW_EQUIP | PW_PLAYER;
    }

    if (equip_ct + inven_ct)
        disturb(1, 0);
}
开发者ID:MichaelDiBernardo,项目名称:poschengband,代码行数:38,代码来源:race_elemental.c

示例10: do_cmd_hold

/*
 * Stay still.  Search.  Enter stores.
 * Pick up treasure if "pickup" is true.
 */
void do_cmd_hold(cmd_code code, cmd_arg args[])
{
	/* Take a turn */
	p_ptr->energy_use = 100;

	/* Spontaneous Searching */
	if ((p_ptr->state.skills[SKILL_SEARCH_FREQUENCY] >= 50) ||
	    one_in_(50 - p_ptr->state.skills[SKILL_SEARCH_FREQUENCY]))
	{
		search(FALSE);
	}

	/* Continuous Searching */
	if (p_ptr->searching)
	{
		search(FALSE);
	}

	/* Pick things up, not using extra energy */
	do_autopickup();

	/* Hack -- enter a store if we are on one */
	if ((cave->feat[p_ptr->py][p_ptr->px] >= FEAT_SHOP_HEAD) &&
	    (cave->feat[p_ptr->py][p_ptr->px] <= FEAT_SHOP_TAIL))
	{
		/* Disturb */
		disturb(p_ptr, 0, 0);

		cmd_insert(CMD_ENTER_STORE);

		/* Free turn XXX XXX XXX */
		p_ptr->energy_use = 0;
	}
	else
	{
	    event_signal(EVENT_SEEFLOOR);
	}
}
开发者ID:qwerty16,项目名称:angband,代码行数:42,代码来源:cmd2.c

示例11: save_game

/*
 * Save the game
 */
void save_game(void)
{
	/* Disturb the player */
	disturb(p_ptr, 1, 0);

	/* Clear messages */
	message_flush();

	/* Handle stuff */
	handle_stuff(p_ptr);

	/* Message */
	prt("Saving game...", 0, 0);

	/* Refresh */
	Term_fresh();

	/* The player is not dead */
	my_strcpy(p_ptr->died_from, "(saved)", sizeof(p_ptr->died_from));

	/* Forbid suspend */
	signals_ignore_tstp();

	/* Save the player */
	if (savefile_save(savefile))
		prt("Saving game... done.", 0, 0);
	else
		prt("Saving game... failed!", 0, 0);

	/* Allow suspend again */
	signals_handle_tstp();

	/* Refresh */
	Term_fresh();

	/* Note that the player is not dead */
	my_strcpy(p_ptr->died_from, "(alive and well)", sizeof(p_ptr->died_from));
}
开发者ID:essarrdee,项目名称:angband,代码行数:41,代码来源:files.c

示例12: exit_game_panic

/*
 * Handle abrupt death of the visual system
 *
 * This routine is called only in very rare situations, and only
 * by certain visual systems, when they experience fatal errors.
 *
 * XXX XXX Hack -- clear the death flag when creating a HANGUP
 * save file so that player can see tombstone when restart.
 *
 * TODO: Hookify
 */
void exit_game_panic(void)
{
#ifndef AVT_HOOKIFY_EXIT
	/* If nothing important has happened, just quit */
	if (!character_generated || character_saved) quit("panic");
#endif

	/* Mega-Hack -- see "msg_print()" */
	msg_flag = FALSE;

	/* Clear the top line */
	prt("", 0, 0);

#ifndef AVT_HOOKIFY_EXIT
	/* Hack -- turn off some things */
	disturb(1, 0);

	/* Hack -- Delay death XXX XXX XXX */
	if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;

	/* Hardcode panic save */
	p_ptr->panic_save = 1;
#endif

	/* Forbid suspend */
	signals_ignore_tstp();

#ifndef AVT_HOOKIFY_EXIT
	/* Indicate panic save */
	strcpy(p_ptr->died_from, "(panic save)");

	/* Panic save, or get worried */
	if (!save_player()) quit("panic save failed!");
#endif

	/* Successful panic save */
	quit("panic save succeeded!");
}
开发者ID:tingley,项目名称:tactical,代码行数:49,代码来源:avt_files.c

示例13: hit_trap

/**
 * Hit a trap. 
 */
extern void hit_trap(int y, int x)
{
	bool ident;
	struct trap *trap;
	struct effect *effect;

    /* Count the hidden traps here */
    int num = num_traps(cave, y, x, -1);

    /* Oops.  We've walked right into trouble. */
    if      (num == 1) msg("You stumble upon a trap!");
    else if (num >  1) msg("You stumble upon some traps!");


	/* Look at the traps in this grid */
	for (trap = square_trap(cave, y, x); trap; trap = trap->next) {
		/* Require that trap be capable of affecting the character */
		if (!trf_has(trap->kind->flags, TRF_TRAP)) continue;
	    
		/* Disturb the player */
		disturb(player, 0);

		/* Fire off the trap */
		effect = trap->kind->effect;
		effect_do(effect, NULL, &ident, false, 0, 0, 0);

		/* Trap may have gone */
		if (!square_trap(cave, y, x)) break;

		/* Trap becomes visible (always XXX) */
		trf_on(trap->flags, TRF_VISIBLE);
		square_memorize(cave, y, x);
	}

    /* Verify traps (remove marker if appropriate) */
    (void)square_verify_trap(cave, y, x, 0);
}
开发者ID:Axydlbaaxr,项目名称:angband,代码行数:40,代码来源:trap.c

示例14: player_set_food

/*
 * Set "p_ptr->food", notice observable changes
 *
 * The "p_ptr->food" variable can get as large as 20000, allowing the
 * addition of the most "filling" item, Elvish Waybread, which adds
 * 7500 food units, without overflowing the 32767 maximum limit.
 *
 * Perhaps we should disturb the player with various messages,
 * especially messages about hunger status changes.  XXX XXX XXX
 *
 * Digestion of food is handled in "dungeon.c", in which, normally,
 * the player digests about 20 food units per 100 game turns, more
 * when "fast", more when "regenerating", less with "slow digestion".
 */
bool player_set_food(struct player *p, int v)
{
    int old_aux, new_aux;

    bool notice = FALSE;

    /* Hack -- Force good values */
    v = MIN(v, PY_FOOD_MAX);
    v = MAX(v, 0);

    /* Current value */
    if (p->food < PY_FOOD_FAINT)      old_aux = 0;
    else if (p->food < PY_FOOD_WEAK)  old_aux = 1;
    else if (p->food < PY_FOOD_ALERT) old_aux = 2;
    else if (p->food < PY_FOOD_FULL)  old_aux = 3;
    else                              old_aux = 4;

    /* New value */
    if (v < PY_FOOD_FAINT)      new_aux = 0;
    else if (v < PY_FOOD_WEAK)  new_aux = 1;
    else if (v < PY_FOOD_ALERT) new_aux = 2;
    else if (v < PY_FOOD_FULL)  new_aux = 3;
    else                        new_aux = 4;

    /* Food increase */
    if (new_aux > old_aux) {
        switch (new_aux) {
        case 1:
            msg("You are still weak.");
            break;
        case 2:
            msg("You are still hungry.");
            break;
        case 3:
            msg("You are no longer hungry.");
            break;
        case 4:
            msg("You are full!");
            break;
        }

        /* Change */
        notice = TRUE;
    }

    /* Food decrease */
    else if (new_aux < old_aux) {
        switch (new_aux) {
        case 0:
            msgt(MSG_NOTICE, "You are getting faint from hunger!");
            break;
        case 1:
            msgt(MSG_NOTICE, "You are getting weak from hunger!");
            break;
        case 2:
            msgt(MSG_HUNGRY, "You are getting hungry.");
            break;
        case 3:
            msgt(MSG_NOTICE, "You are no longer full.");
            break;
        }

        /* Change */
        notice = TRUE;
    }

    /* Use the value */
    p->food = v;

    /* Nothing to notice */
    if (!notice) return (FALSE);

    /* Disturb */
    disturb(p_ptr, 0, 0);

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

    /* Redraw hunger */
    p->redraw |= (PR_STATUS);

    /* Handle stuff */
    handle_stuff(p_ptr);

    /* Result */
    return (TRUE);
//.........这里部分代码省略.........
开发者ID:Rydelfox,项目名称:angband,代码行数:101,代码来源:timed.c

示例15: move_player

/**
 * Move player in the given direction.
 *
 * This routine should only be called when energy has been expended.
 *
 * Note that this routine handles monsters in the destination grid,
 * and also handles attempting to move into walls/doors/rubble/etc.
 */
void move_player(int dir, bool disarm)
{
	int y = player->py + ddy[dir];
	int x = player->px + ddx[dir];

	int m_idx = cave->squares[y][x].mon;
	struct monster *mon = cave_monster(cave, m_idx);
	bool alterable = (square_isknowntrap(cave, y, x) ||
					  square_iscloseddoor(cave, y, x));

	/* Attack monsters, alter traps/doors on movement, hit obstacles or move */
	if (m_idx > 0) {
		/* Mimics surprise the player */
		if (is_mimicking(mon)) {
			become_aware(mon);

			/* Mimic wakes up */
			mon_clear_timed(mon, MON_TMD_SLEEP, MON_TMD_FLG_NOMESSAGE, false);

		} else {
			py_attack(y, x);
		}
	} else if (disarm && square_isknown(cave, y, x) && alterable) {
		/* Auto-repeat if not already repeating */
		if (cmd_get_nrepeats() == 0)
			cmd_set_repeat(99);

		do_cmd_alter_aux(dir);
	} else if (player->upkeep->running && square_isknowntrap(cave, y, x)) {
		/* Stop running before known traps */
		disturb(player, 0);
	} else if (!square_ispassable(cave, y, x)) {
		disturb(player, 0);

		/* Notice unknown obstacles, mention known obstacles */
		if (!square_isknown(cave, y, x)) {
			if (square_isrubble(cave, y, x)) {
				msgt(MSG_HITWALL,
					 "You feel a pile of rubble blocking your way.");
				square_memorize(cave, y, x);
				square_light_spot(cave, y, x);
			} else if (square_iscloseddoor(cave, y, x)) {
				msgt(MSG_HITWALL, "You feel a door blocking your way.");
				square_memorize(cave, y, x);
				square_light_spot(cave, y, x);
			} else {
				msgt(MSG_HITWALL, "You feel a wall blocking your way.");
				square_memorize(cave, y, x);
				square_light_spot(cave, y, x);
			}
		} else {
			if (square_isrubble(cave, y, x))
				msgt(MSG_HITWALL,
					 "There is a pile of rubble blocking your way.");
			else if (square_iscloseddoor(cave, y, x))
				msgt(MSG_HITWALL, "There is a door blocking your way.");
			else
				msgt(MSG_HITWALL, "There is a wall blocking your way.");
		}
	} else {
		/* Move player */
		monster_swap(player->py, player->px, y, x);

		/* Handle store doors, or notice objects */
		if (square_isshop(cave, y, x)) {
			disturb(player, 0);
			event_signal(EVENT_ENTER_STORE);
			event_remove_handler_type(EVENT_ENTER_STORE);
			event_signal(EVENT_USE_STORE);
			event_remove_handler_type(EVENT_USE_STORE);
			event_signal(EVENT_LEAVE_STORE);
			event_remove_handler_type(EVENT_LEAVE_STORE);
		} else {
			square_know_pile(cave, y, x);
			cmdq_push(CMD_AUTOPICKUP);
		}

		/* Discover invisible traps, set off visible ones */
		if (square_issecrettrap(cave, y, x)) {
			disturb(player, 0);
			hit_trap(y, x);
		} else if (square_isknowntrap(cave, y, x)) {
			disturb(player, 0);
			hit_trap(y, x);
		}

		/* Update view and search */
		update_view(cave, player);
		search();
	}

	player->upkeep->running_firststep = false;
//.........这里部分代码省略.........
开发者ID:pete-mack,项目名称:angband,代码行数:101,代码来源:cmd-cave.c


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