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


C++ IS_SET函数代码示例

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


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

示例1: lasso_bigmem

int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_exclude, uintptr_t marker_ct, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm2, double lasso_h2, double lasso_minlambda, uint32_t select_covars, uintptr_t* select_covars_bitfield, double* pheno_d_collapsed, uintptr_t covar_ct, char* covar_names, uintptr_t max_covar_name_len, uintptr_t* covar_nm, double* covar_d, uint32_t hh_or_mt_exists, uintptr_t sample_valid_ct, uintptr_t* sample_include2, uintptr_t* sample_male_include2, uintptr_t* loadbuf_raw, uintptr_t* loadbuf_collapsed, double* rand_matrix, double* misc_arr, double* residuals, uintptr_t* polymorphic_markers, uintptr_t* polymorphic_marker_ct_ptr, uint64_t* iter_tot_ptr, double** xhat_ptr) {
  uintptr_t unfiltered_sample_ct4 = (unfiltered_sample_ct + 3) / 4;
  double* data_arr = (double*)g_bigstack_base; // marker-major
  double sqrt_n_recip = sqrt(1.0 / ((double)((intptr_t)sample_valid_ct)));
  double lambda_max = 0.0;
  double err_cur = 0.0;
  uint64_t iter_tot = 0;
  uintptr_t sample_valid_ctl2 = QUATERCT_TO_WORDCT(sample_valid_ct);
  uintptr_t polymorphic_marker_ct = 0;
  uintptr_t unselected_covar_ct = 0;
  uintptr_t final_mask = get_final_mask(sample_valid_ct);
  double lambda_min = lasso_minlambda;
  uint32_t chrom_fo_idx = 0xffffffffU; // exploit overflow
  uint32_t chrom_end = 0;
  uint32_t is_x = 0;
  uint32_t is_y = 0;
  uint32_t min_ploidy_1 = 0;
  int32_t retval = 0;
  double cur_mapping[4];
  double* xhat;
  double* prod_matrix;
  double* dptr;
  double* dptr2;
  uintptr_t* ulptr_end_init;
  uintptr_t* ulptr_end;
  uintptr_t* active_set;
  uintptr_t* ulptr;
  double sige;
  double loghi;
  double loglo;
  double logdelta;
  double lambda;
  double xjold;
  double err_last;
  double dxx;
  double dyy;
  double zz;
  uintptr_t cur_word;
  uintptr_t cur_genotype;
  uintptr_t ulii;
  uintptr_t iter;
  uintptr_t col_ct;
  uintptr_t col_ctl;
  uintptr_t col_idx;
  uintptr_t col_nz_ct;
  uintptr_t col_to_z;
  uintptr_t col_uidx;
  uintptr_t covar_idx;
  uintptr_t sample_idx;
  uintptr_t sample_idx_stop;
  uintptr_t marker_idx;
  uint32_t lambi;
  uint32_t marker_uidx;
  uint32_t homrar_ct;
  uint32_t missing_ct;
  uint32_t het_ct;
  uint32_t homset_ct;
  uint32_t uii;

  cur_mapping[1] = 0; // missing
  if (fseeko(bedfile, bed_offset, SEEK_SET)) {
    goto lasso_bigmem_ret_READ_FAIL;
  }
  ulptr_end_init = &(loadbuf_collapsed[sample_valid_ct / BITCT2]);
  fputs("--lasso: Populating data matrix...", stdout);
  fflush(stdout);
  if (covar_ct) {
    dxx = 1.0 / ((double)((intptr_t)sample_valid_ct));
    dyy = (double)((intptr_t)(sample_valid_ct - 1));
    if (!select_covars_bitfield) {
      for (covar_idx = 0; covar_idx < covar_ct; covar_idx++) {
	if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[covar_idx * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) {
	  goto lasso_bigmem_ret_CONST_COVAR;
	}
      }
      if (!select_covars) {
        unselected_covar_ct = covar_ct;
      }
    } else {
      ulii = 0;
      for (covar_idx = 0; covar_idx < covar_ct; covar_idx++) {
	if (IS_SET(select_covars_bitfield, covar_idx)) {
	  continue;
	}
	if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) {
          goto lasso_bigmem_ret_CONST_COVAR;
	}
	ulii++;
      }
      unselected_covar_ct = ulii;
      for (covar_idx = 0; covar_idx < covar_ct; covar_idx++) {
	if (!IS_SET(select_covars_bitfield, covar_idx)) {
	  continue;
	}
	if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) {
          goto lasso_bigmem_ret_CONST_COVAR;
	}
	ulii++;
      }
    }
//.........这里部分代码省略.........
开发者ID:joseffrank,项目名称:plink-ng,代码行数:101,代码来源:plink_lasso.c

示例2: slap_set_filter

int
slap_set_filter( SLAP_SET_GATHER gatherer,
	SetCookie *cp, struct berval *fbv,
	struct berval *user, struct berval *target, BerVarray *results )
{
#define STACK_SIZE	64
#define IS_SET(x)	( (unsigned long)(x) >= 256 )
#define IS_OP(x)	( (unsigned long)(x) < 256 )
#define SF_ERROR(x)	do { rc = -1; goto _error; } while ( 0 )
#define SF_TOP()	( (BerVarray)( ( stp < 0 ) ? 0 : stack[ stp ] ) )
#define SF_POP()	( (BerVarray)( ( stp < 0 ) ? 0 : stack[ stp-- ] ) )
#define SF_PUSH(x)	do { \
		if ( stp >= ( STACK_SIZE - 1 ) ) SF_ERROR( overflow ); \
		stack[ ++stp ] = (BerVarray)(long)(x); \
	} while ( 0 )

	BerVarray	set, lset;
	BerVarray	stack[ STACK_SIZE ] = { 0 };
	int		len, rc, stp;
	unsigned long	op;
	char		c, *filter = fbv->bv_val;

	if ( results ) {
		*results = NULL;
	}

	stp = -1;
	while ( ( c = *filter++ ) ) {
		set = NULL;
		switch ( c ) {
		case ' ':
		case '\t':
		case '\x0A':
		case '\x0D':
			break;

		case '(' /* ) */ :
			if ( IS_SET( SF_TOP() ) ) {
				SF_ERROR( syntax );
			}
			SF_PUSH( c );
			break;

		case /* ( */ ')':
			set = SF_POP();
			if ( IS_OP( set ) ) {
				SF_ERROR( syntax );
			}
			if ( SF_TOP() == (void *)'(' /* ) */ ) {
				SF_POP();
				SF_PUSH( set );
				set = NULL;

			} else if ( IS_OP( SF_TOP() ) ) {
				op = (unsigned long)SF_POP();
				lset = SF_POP();
				SF_POP();
				set = slap_set_join( cp, lset, op, set );
				if ( set == NULL ) {
					SF_ERROR( memory );
				}
				SF_PUSH( set );
				set = NULL;

			} else {
				SF_ERROR( syntax );
			}
			break;

		case '|':	/* union */
		case '&':	/* intersection */
		case '+':	/* string concatenation */
			set = SF_POP();
			if ( IS_OP( set ) ) {
				SF_ERROR( syntax );
			}
			if ( SF_TOP() == 0 || SF_TOP() == (void *)'(' /* ) */ ) {
				SF_PUSH( set );
				set = NULL;

			} else if ( IS_OP( SF_TOP() ) ) {
				op = (unsigned long)SF_POP();
				lset = SF_POP();
				set = slap_set_join( cp, lset, op, set );
				if ( set == NULL ) {
					SF_ERROR( memory );
				}
				SF_PUSH( set );
				set = NULL;
				
			} else {
				SF_ERROR( syntax );
			}
			SF_PUSH( c );
			break;

		case '[' /* ] */:
			if ( ( SF_TOP() == (void *)'/' ) || IS_SET( SF_TOP() ) ) {
				SF_ERROR( syntax );
			}
//.........这里部分代码省略.........
开发者ID:benegon,项目名称:openldap,代码行数:101,代码来源:sets.c

示例3: do_objectgate

/* syntax : objectgate <object>
 * ex. objectgate 2.bells
 */
void do_objectgate (CHAR_DATA *ch, char *argument)
{
  OBJ_DATA *obj;
  char arg1[MAX_INPUT_LENGTH];

  argument = one_argument(argument, arg1);

  if (IS_NPC(ch)) return;
  if (!IS_CLASS(ch, CLASS_MAGE) && !IS_CLASS(ch, CLASS_LICH))
  {
    send_to_char("Huh?\n\r", ch );
    return;
  }
  if (IS_CLASS(ch, CLASS_LICH) && ch->pcdata->powers[CON_LORE] < 1)
  {
    send_to_char("But you don't know how to do that silly.\n\r",ch);
    return;
  }
  if (arg1[0] == '\0')
  {
    send_to_char("What object do you want to attempt to gate?\n\r",ch);
    return;
  }
  if ((obj = get_obj_world(ch, arg1)) == NULL)
  {
    send_to_char("No such object.\n\r",ch);
    return;
  }
  if (IS_SET(obj->quest, QUEST_ARTIFACT) || IS_SET(obj->quest, QUEST_RELIC))
  {
    send_to_char("You cannot grab artifacts or relics.\n\r",ch);
    return;
  }
  if (obj->carried_by != NULL)
  {
    send_to_char("Someone is holding the item.\n\r",ch);
    return;
  }
  if (obj->in_room == NULL)
  {
    send_to_char("It seems to be inside something.\n\r",ch);
    return;
  }
  if (!IS_SET(obj->wear_flags, ITEM_TAKE))
  {
    send_to_char("This item is too big.\n\r",ch);
    return;
  }
  if( IS_SET(obj->in_room->room_flags, ROOM_ASTRAL))
  {
    send_to_char( "You can't find it's room.\n\r",ch);
    return;
  }
  if(IS_SET(ch->in_room->room_flags, ROOM_ASTRAL))
  {
    send_to_char( "Your room is not connected to the astral plane.\n\r",ch);
    return;
  }
  obj_from_room( obj );
  obj_to_char( obj, ch );
  send_to_char("The item appears in your hand.\n\r",ch);
  return;
}
开发者ID:smthbh,项目名称:dystopia-mud,代码行数:66,代码来源:mage.c

示例4: call_magic

/*
 * This function is the very heart of the entire magic system.  All
 * invocations of all types of magic -- objects, spoken and unspoken PC
 * and NPC spells, the works -- all come through this function eventually.
 * This is also the entry point for non-spoken or unrestricted spells.
 * Spellnum 0 is legal but silently ignored here, to make callers simpler.
 */
int	call_magic(struct char_data *caster, struct char_data *cvict,
               struct obj_data *ovict, struct spell_info_type *sptr,
               int level, int casttype, char *tar_str)
{
    int savetype;

    if (!magic_enabled)
        return (0);

    if (caster->nr != real_mobile(DG_CASTER_PROXY)) {
        if (ROOM_FLAGGED(IN_ROOM(caster), ROOM_NOMAGIC)) {
            send_to_char("Your magic fizzles out and dies.\r\n", caster);
            act("$n's magic fizzles out and dies.", FALSE, caster, 0, 0, TO_ROOM);
            return (0);
        }
        if (ROOM_FLAGGED(IN_ROOM(caster), ROOM_PEACEFUL) &&
                (sptr->violent || IS_SET(sptr->routines, MAG_DAMAGE))) {
            send_to_char("A flash of white light fills the room, dispelling your "
                         "violent magic!\r\n", caster);
            act("White light from no particular source suddenly fills the room, "
                "then vanishes.", FALSE, caster, 0, 0, TO_ROOM);
            return (0);
        }
    }
    /* determine the type of saving throw */
    switch (casttype) {
    case CAST_STAFF:
    case CAST_SCROLL:
    case CAST_POTION:
    case CAST_WAND:
        savetype = SAVING_ROD;
        break;
    case CAST_SPELL:
        savetype = SAVING_SPELL;
        break;
    default:
        savetype = SAVING_BREATH;
        break;
    }

    if (IS_SET(sptr->routines, MAG_DAMAGE))
        if (mag_damage(level, caster, cvict, sptr, savetype) == -1)
            return (-1);        /* Successful and target died, don't cast again. */

    if (IS_SET(sptr->routines, MAG_AFFECTS))
        mag_affects(level, caster, cvict, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_UNAFFECTS))
        mag_unaffects(level, caster, cvict, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_POINTS))
        mag_points(level, caster, cvict, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_ALTER_OBJS))
        mag_alter_objs(level, caster, ovict, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_GROUPS))
        mag_groups(level, caster, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_MASSES))
        mag_masses(level, caster, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_AREAS))
        mag_areas(level, caster, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_SUMMONS))
        mag_summons(level, caster, ovict, sptr, savetype);

    if (IS_SET(sptr->routines, MAG_CREATIONS))
        mag_creations(level, caster, sptr);

    if (IS_SET(sptr->routines, MAG_MANUAL))
        switch (sptr->number) {
        case SPELL_CHARM:
            MANUAL_SPELL(spell_charm);
            break;
        case SPELL_CREATE_WATER:
            MANUAL_SPELL(spell_create_water);
            break;
        case SPELL_DETECT_POISON:
            MANUAL_SPELL(spell_detect_poison);
            break;
        case SPELL_ENCHANT_WEAPON:
            MANUAL_SPELL(spell_enchant_weapon);
            break;
        case SPELL_IDENTIFY:
            MANUAL_SPELL(spell_identify);
            break;
        case SPELL_LOCATE_OBJECT:
            MANUAL_SPELL(spell_locate_object);
            break;
        case SPELL_SUMMON:
            MANUAL_SPELL(spell_summon);
//.........这里部分代码省略.........
开发者ID:tbjers,项目名称:arcanerealms,代码行数:101,代码来源:spell_parser.c

示例5: cast_spell

int	cast_spell(struct char_data *ch, struct char_data *tch,
               struct obj_data *tobj, struct spell_info_type *sptr,
               char *tar_str)
{

    if (!magic_enabled)
        return (0);

    if (!sptr) {
        extended_mudlog(NRM, SYSL_BUGS, TRUE, "cast_spell() called without a valid sptr: ch: %s, tch: %s",
                        GET_NAME(ch), GET_NAME(tch));
        return (0);
    }

    if (GET_POS(ch) < sptr->min_position) {
        switch (GET_POS(ch)) {
        case POS_SLEEPING:
            send_to_char("You dream about great magical powers.\r\n", ch);
            break;
        case POS_RESTING:
            send_to_char("You cannot concentrate while resting.\r\n", ch);
            break;
        case POS_SITTING:
            send_to_char("You can't do this sitting!\r\n", ch);
            break;
        case POS_FIGHTING:
            send_to_char("Impossible!  You can't concentrate enough!\r\n", ch);
            break;
        default:
            send_to_char("You can't do much of anything like this!\r\n", ch);
            break;
        }
        return (0);
    }
    if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == tch)) {
        send_to_char("You are afraid you might hurt your master!\r\n", ch);
        return (0);
    }
    if ((tch != ch) && IS_SET(sptr->targets, TAR_SELF_ONLY)) {
        send_to_char("You can only cast this spell upon yourself!\r\n", ch);
        return (0);
    }
    if ((tch == ch) && IS_SET(sptr->targets, TAR_NOT_SELF)) {
        send_to_char("You cannot cast this spell upon yourself!\r\n", ch);
        return (0);
    }
    if (IS_SET(sptr->routines, MAG_GROUPS) && !AFF_FLAGGED(ch, AFF_GROUP)) {
        send_to_char("You can't cast this spell if you're not in a group!\r\n",ch);
        return (0);
    }

    if (cast_mtrigger(tch, ch, tar_str, sptr) == 0)
        return (0);
    if (cast_otrigger(tobj, ch, tar_str, sptr) == 0)
        return (0);
    if (cast_wtrigger(ch, tch, tobj, tar_str, sptr) == 0)
        return (0);

    send_to_char(OK, ch);
    say_spell(ch, sptr, tch, tobj);

    return (call_magic(ch, tch, tobj, sptr, (GET_SKILL(ch, sptr->skill)/100), CAST_SPELL,
                       tar_str));
}
开发者ID:tbjers,项目名称:arcanerealms,代码行数:64,代码来源:spell_parser.c

示例6: is_leader

bool is_leader(CHAR_DATA * ch)
{
    /* update by: Zak Johnson ([email protected]) Thanks Zak! */
    return IS_SET(ch->act, PLR_MORTAL_LEADER) ? 1 : 0;
} /* end: is_leader */
开发者ID:verias,项目名称:SRMud,代码行数:5,代码来源:clan.c

示例7: do_clanadd

void do_clanadd(CHAR_DATA * ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    int clan;

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);

    if (!can_clan(ch))
    {
	send_to_char("huh?\n\r", ch);
	return;
    }
    if (arg1[0] == '\0' || arg2[0] == '\0')
    {
	send_to_char("Syntax: guild <char> <cln name>\n\r", ch);
	return;
    }
    if ((victim = get_char_world(ch, arg1)) == NULL)
    {
	send_to_char("They aren't playing.\n\r", ch);
	return;
    }

    /** thanks to Zanthras for the bug fix here...*/
    if (is_clan(victim) && !is_same_clan(ch, victim) &&
	((ch->level < SUPREME) & (ch->trust < SUPREME)))
    {
	send_to_char("They are a member of a clan other than your own.\n\r", ch);
	return;
    }

    if (!str_prefix(arg2, "none"))
    {
	send_to_char("They are no longer a member of any clan.\n\r", ch);
	send_to_char("You are no longer a member of any clan!\n\r", victim);
	victim->clan = 0;
	victim->rank = 0;

	/* add by: Zak Jonhson ([email protected]) */
	if (IS_SET(victim->act, PLR_MORTAL_LEADER))
	    REMOVE_BIT(victim->act, PLR_MORTAL_LEADER);

	return;
    }
    if ((clan = clan_lookup(arg2)) == 0)
    {
	send_to_char("No such clan exists.\n\r", ch);
	return;
    }
    sprintf(buf, "They are now a %s of the %s.\n\r",
	    clan_table[clan].rank[0].rankname, clan_table[clan].name);
    send_to_char(buf, ch);

    sprintf(buf, "You are now a %s of the %s.\n\r",
	    clan_table[clan].rank[0].rankname, clan_table[clan].name);
    send_to_char(buf, victim);

    victim->clan = clan;
    victim->rank = 0;		/* lowest, default */
} /* end: do_guild */
开发者ID:verias,项目名称:SRMud,代码行数:63,代码来源:clan.c

示例8: cmd_eval


//.........这里部分代码省略.........
      return (lval_char != NULL && lval_char->position > POS_SLEEPING);
    case CHK_ISDELAY:
      return (lval_char != NULL && lval_char->mprog_delay > 0);
    case CHK_ISVISIBLE:
      switch (code)
	{
	default:
	case 'i':
	case 'n':
	case 't':
	case 'r':
	case 'q':
	  return (lval_char != NULL && can_see (mob, lval_char));
	case 'o':
	case 'p':
	  return (lval_obj != NULL && can_see_obj (mob, lval_obj));
	}
    case CHK_HASTARGET:
      return (lval_char != NULL && lval_char->mprog_target != NULL
	      && lval_char->in_room == lval_char->mprog_target->in_room);
    case CHK_ISTARGET:
      return (lval_char != NULL && mob->mprog_target == lval_char);
    default:;
    }

  /* 
   * Case 4: Keyword, actor and value
   */
  line = one_argument (line, buf);
  switch (check)
    {
    case CHK_AFFECTED:
      return (lval_char != NULL
	      && IS_SET (lval_char->affected_by,
			 flag_lookup (buf, affect_flags)));
    case CHK_ACT:
      return (lval_char != NULL
	      && IS_SET (lval_char->act, flag_lookup (buf, act_flags)));
    case CHK_IMM:
      return (lval_char != NULL
	      && IS_SET (lval_char->imm_flags, flag_lookup (buf, imm_flags)));
    case CHK_OFF:
      return (lval_char != NULL
	      && IS_SET (lval_char->off_flags, flag_lookup (buf, off_flags)));
    case CHK_CARRIES:
      if (is_number (buf))
	return (lval_char != NULL
		&& has_item (lval_char, atoi (buf), -1, FALSE));
      else
	return (lval_char != NULL
		&& (get_obj_carry (lval_char, buf) != NULL));
    case CHK_WEARS:
      if (is_number (buf))
	return (lval_char != NULL
		&& has_item (lval_char, atoi (buf), -1, TRUE));
      else
	return (lval_char != NULL && (get_obj_wear (lval_char, buf) != NULL));
    case CHK_HAS:
      return (lval_char != NULL
	      && has_item (lval_char, -1, item_lookup (buf), FALSE));
    case CHK_USES:
      return (lval_char != NULL
	      && has_item (lval_char, -1, item_lookup (buf), TRUE));
    case CHK_NAME:
      switch (code)
	{
开发者ID:BlinkenMUD,项目名称:BlinkenMUD,代码行数:67,代码来源:mob_prog.c

示例9: damage


//.........这里部分代码省略.........

			if (!IS_NPC(victim) && (GET_LEVEL(victim) > 20)) {
				act(messages->god_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR);
				act(messages->god_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT);
				act(messages->god_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT);
			} else if (dam != 0) {
				if (GET_POS(victim) == POSITION_DEAD) {
					act(messages->die_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR);
					act(messages->die_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT);
					act(messages->die_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT);
				} else {
					act(messages->hit_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR);
					act(messages->hit_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT);
					act(messages->hit_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT);
				}
			} else { /* Dam == 0 */
				act(messages->miss_msg.attacker_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_CHAR);
				act(messages->miss_msg.victim_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_VICT);
				act(messages->miss_msg.room_msg, FALSE, ch, ch->equipment[WIELD], victim, TO_NOTVICT);
			}
		}
	}
	}
	switch (GET_POS(victim)) {
		case POSITION_MORTALLYW:
			act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, TO_ROOM);
			act("You are mortally wounded, and will die soon, if not aided.", FALSE, victim, 0, 0, TO_CHAR);
			break;
		case POSITION_INCAP:
			act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, TO_ROOM);
			act("You are incapacitated an will slowly die, if not aided.", FALSE, victim, 0, 0, TO_CHAR);
			break;
		case POSITION_STUNNED:
			act("$n is stunned, but will probably regain conscience again.", TRUE, victim, 0, 0, TO_ROOM);
			act("You're stunned, but will probably regain conscience again.", FALSE, victim, 0, 0, TO_CHAR);
			break;
		case POSITION_DEAD:
			act("$n is dead! R.I.P.", TRUE, victim, 0, 0, TO_ROOM);
			act("You are dead!  Sorry...", FALSE, victim, 0, 0, TO_CHAR);
			break;

		default:  /* >= POSITION SLEEPING */

			max_hit=hit_limit(victim);

			if (dam > (max_hit/5))
				act("That Really did HURT!",FALSE, victim, 0, 0, TO_CHAR);

			if (GET_HIT(victim) < (max_hit/5)) {

				act("You wish that your wounds would stop BLEEDING that much!",FALSE,victim,0,0,TO_CHAR);
				if (IS_NPC(victim))
					if (IS_SET(victim->specials.act, ACT_WIMPY))
						do_flee(victim, "", 0);
			}
			break;		
	}

	if (!IS_NPC(victim) && !(victim->desc)) {
		do_flee(victim, "", 0);
		if (!victim->specials.fighting) {
			act("$n is rescued by divine forces.", FALSE, victim, 0, 0, TO_ROOM);
			victim->specials.was_in_room = victim->in_room;
			char_from_room(victim);
			char_to_room(victim, 0);
		}
	}

	if (GET_POS(victim) < POSITION_STUNNED)
		if (ch->specials.fighting == victim)
			stop_fighting(ch);

	if (!AWAKE(victim))
		if (victim->specials.fighting)
			stop_fighting(victim);

	if (GET_POS(victim) == POSITION_DEAD) {
		if (IS_NPC(victim) || victim->desc)
			if (IS_AFFECTED(ch, AFF_GROUP)) {
					group_gain(ch, victim);
			} else {
				/* Calculate level-difference bonus */
				exp = GET_EXP(victim)/3;
				if (IS_NPC(ch))
					exp += (exp*MIN(4, (GET_LEVEL(victim) - GET_LEVEL(ch))))>>3;
				else
					exp += (exp*MIN(8, (GET_LEVEL(victim) - GET_LEVEL(ch))))>>3;
				exp = MAX(exp, 1);
				gain_exp(ch, exp);
				change_alignment(ch, victim);
			}
		if (!IS_NPC(victim)) {
			sprintf(buf, "%s killed by %s at %s",
				GET_NAME(victim),
				(IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch)),
				world[victim->in_room].name);
			log(buf);
		}
		die(victim);
	}
开发者ID:MUDOmnibus,项目名称:DikuMUD-Alfa,代码行数:101,代码来源:fight.c

示例10: do_makejetpack

void do_makejetpack( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    int level, chance, strength;
    bool checktool, checkbatt, checkchem, checkcirc, checkmetal;
    OBJ_DATA *obj;
    OBJ_INDEX_DATA *pObjIndex;
    int vnum;

    strcpy( arg , argument );

    switch( ch->substate )
    {
    	default:
    	        if ( arg[0] == '\0' )
                {
                  send_to_char( "&RUsage: Makejetpack <Name>\n\r&w", ch);
                  return;
                }

                checktool  = FALSE;
                checkbatt  = FALSE;
                checkchem  = FALSE;
                checkcirc  = FALSE;
                checkmetal = FALSE;

                if ( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
                {
                   send_to_char( "&RYou need to be in a factory or workshop to do that.\n\r", ch);
                   return;
                }

                for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
                {
                  if (obj->item_type == ITEM_TOOLKIT)
                    checktool = TRUE;
                  if (obj->item_type == ITEM_BATTERY)
                    checkbatt = TRUE;
                  if (obj->item_type == ITEM_CIRCUIT)
                    checkcirc = TRUE;
                  if (obj->item_type == ITEM_CHEMICAL)
                    checkchem = TRUE;
                  if (obj->item_type == ITEM_RARE_METAL)
                    checkmetal = TRUE;
                }

                if ( !checktool )
                {
                   send_to_char( "&RYou need toolkit to make the Jetpack\n\r", ch);
                   return;
                }

                if ( !checkmetal )
                {
                   send_to_char( "&RYou need a piece metal to craft the Jetpack.\n\r", ch);
                   return;
                }

                if ( !checkbatt )
                {
                   send_to_char( "&RYou need a battery for the mechanism to work.\n\r", ch);
                   return;
                }

                if ( !checkcirc )
                {
                   send_to_char( "&RYou need a small circuit.\n\r", ch);
                   return;
                }

                if ( !checkchem )
                {
                   send_to_char( "&RSome chemicals for the combustion.\n\r", ch);
                   return;
                }

                chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makejetpack]);
                if ( number_percent( ) < chance )
                {
                   send_to_char( "&GYou begin the long process of crafting a Jetpack\n\r", ch);
                   act( AT_PLAIN, "$n takes $s tools and begins to work on something.", ch, NULL, argument , TO_ROOM );
                   add_timer ( ch , TIMER_DO_FUN , 15 , do_makejetpack , 1 );
                   ch->dest_buf   = str_dup(arg);
                   return;
                }
                send_to_char("&RYou can't figure out how to fit the parts together.\n\r",ch);
                learn_from_failure( ch, gsn_makejetpack );
                return;

        case 1:
                if ( !ch->dest_buf )
                 return;
                strcpy(arg, ch->dest_buf);
                DISPOSE( ch->dest_buf);
                break;

        case SUB_TIMER_DO_ABORT:
                DISPOSE( ch->dest_buf );
                ch->substate = SUB_NONE;
//.........这里部分代码省略.........
开发者ID:ccubed,项目名称:SWFoteCustom,代码行数:101,代码来源:tech.c

示例11: set_char_color

char *get_exits( CHAR_DATA * ch )
{
   static char buf[MAX_STRING_LENGTH];
   EXIT_DATA *pexit;
   bool found = FALSE;

   buf[0] = '\0';

   if( !check_blind( ch ) )
      return buf;

   set_char_color( AT_EXITS, ch );

   mudstrlcpy( buf, "[Exits:", MAX_STRING_LENGTH );

   for( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
   {
      if( IS_IMMORTAL( ch ) )
         /*
          * Immortals see all exits, even secret ones 
          */
      {
         if( pexit->to_room )
         {
            found = TRUE;
            mudstrlcat( buf, " ", MAX_STRING_LENGTH );

            mudstrlcat( buf, capitalize( dir_name[pexit->vdir] ), MAX_STRING_LENGTH );

            /*
             * New code added to display closed, or otherwise invisible exits to immortals 
             * Installed by Samson 1-25-98 
             */
            if( IS_SET( pexit->exit_info, EX_CLOSED ) )
               mudstrlcat( buf, "->(Closed)", MAX_STRING_LENGTH );
            if( IS_SET( pexit->exit_info, EX_DIG ) )
               mudstrlcat( buf, "->(Dig)", MAX_STRING_LENGTH );
            if( IS_SET( pexit->exit_info, EX_WINDOW ) )
               mudstrlcat( buf, "->(Window)", MAX_STRING_LENGTH );
            if( IS_SET( pexit->exit_info, EX_HIDDEN ) )
               mudstrlcat( buf, "->(Hidden)", MAX_STRING_LENGTH );
            if( xIS_SET( pexit->to_room->room_flags, ROOM_DEATH ) )
               mudstrlcat( buf, "->(Deathtrap)", MAX_STRING_LENGTH );
         }
      }
      else
      {
         if( pexit->to_room
             && !IS_SET( pexit->exit_info, EX_SECRET )
             && ( !IS_SET( pexit->exit_info, EX_WINDOW ) || IS_SET( pexit->exit_info, EX_ISDOOR ) )
             && !IS_SET( pexit->exit_info, EX_HIDDEN ) )
         {
            found = TRUE;
            mudstrlcat( buf, " ", MAX_STRING_LENGTH );

            mudstrlcat( buf, capitalize( dir_name[pexit->vdir] ), MAX_STRING_LENGTH );

            if( IS_SET( pexit->exit_info, EX_CLOSED ) )
               mudstrlcat( buf, "->(Closed)", MAX_STRING_LENGTH );
            if( IS_AFFECTED( ch, AFF_DETECTTRAPS ) && xIS_SET( pexit->to_room->room_flags, ROOM_DEATH ) )
               mudstrlcat( buf, "->(Deathtrap)", MAX_STRING_LENGTH );
         }
      }
   }

   if( !found )
      mudstrlcat( buf, " none]", MAX_STRING_LENGTH );
   else
      mudstrlcat( buf, "]", MAX_STRING_LENGTH );
   mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH );
   return buf;
}
开发者ID:Igdra,项目名称:smaugfuss,代码行数:72,代码来源:mapper.c

示例12: do_makemodule

/* The effectiveness of the modules can vary depending on the level of the technitian's makemodule skill */
void do_makemodule( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    int affecttype, affectammount;
    char name[MAX_STRING_LENGTH];
    int level, chance;
    bool checklens, checkbat, checksuper, checkcircuit, checktool; 
    OBJ_DATA *obj;
    OBJ_INDEX_DATA *pObjIndex;
            
    argument = one_argument( argument, arg );


    switch( ch->substate )
    { 
    	default:
    	        
     		if(str_cmp(arg, "hull") && str_cmp( arg, "slave") && str_cmp( arg, "tractor") && str_cmp(arg, "torpedo") && str_cmp(arg, "rocket") && str_cmp(arg, "missile") && str_cmp(arg, "primary") && str_cmp(arg, "secondary") && str_cmp(arg, "shield") && str_cmp(arg, "speed") && str_cmp(arg, "hyperspeed") && str_cmp(arg, "energy") && str_cmp(arg, "manuever") && str_cmp(arg, "chaff") && str_cmp(arg, "alarm")){
    		  send_to_char("Modules may affect the following aspects of the ship:\n\rPrimary, Secondary, Missile, Rocket, Torpedo, Hull, Shield, Speed, Hyperspeed, Energy, Manuever, Slave, Tractor, Chaff, and Alarm.\n\r", ch);
    		  return;
    		}
                checklens = FALSE;
                checkbat = FALSE;
                checksuper = FALSE;
                checkcircuit = FALSE;
                checktool = FALSE;
                if ( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
                {
                   send_to_char( "&RYou need to be in a factory or workshop to do that.\n\r", ch);
                   return;
                }
                
                for ( obj = ch->last_carrying; obj; obj = obj->prev_content )     
                {
                  if (obj->item_type == ITEM_LENS)
                    checklens = TRUE;
                  if (obj->item_type == ITEM_BATTERY)
          	    checkbat = TRUE;
                  if (obj->item_type == ITEM_SUPERCONDUCTOR)
                    checksuper = TRUE;
                  if (obj->item_type == ITEM_CIRCUIT)
                    checkcircuit = TRUE;
                  if (obj->item_type == ITEM_TOOLKIT)
                    checktool = TRUE;
          	    
                }
                
                if ( !checklens )
                {
                   send_to_char( "&RYou need a lens to control the energy.\n\r", ch);
                   return;
                }
 
                if ( !checkbat )
                {
                   send_to_char( "&RYou need a battery to power the module.\n\r", ch);
                   return;
                }

                if ( !checksuper )
                {
                   send_to_char( "&RYou need a superconductor to focus the energy.\n\r", ch);
                   return;
                }

                if ( !checkcircuit )
                {
                   send_to_char( "&RYou need a circuit board to control the module.\n\r", ch);
                   return;
                }

                if ( !checktool )
                {
                   send_to_char( "&RYou need a toolkit to build the module.\n\r", ch);
                   return;
                }
                
                
                

    	        chance = IS_NPC(ch) ? ch->top_level
	                 : (int) (ch->pcdata->learned[gsn_makemodule]);
                if ( number_percent( ) < chance )
    		{
    		   send_to_char( "&GYou begin the long process of creating a module.\n\r", ch);
    		   act( AT_PLAIN, "$n takes $s tools and begins to work.", ch,
		        NULL, argument , TO_ROOM );
		   add_timer ( ch , TIMER_DO_FUN , 10 , do_makemodule , 1 );
    		   ch->dest_buf = str_dup(arg);
    		   return;
	        }
	        send_to_char("&RYou can't figure out what to do.\n\r",ch);
	        learn_from_failure( ch, gsn_makemodule );
    	   	return;	
    	
    	case 1: 
    		if ( !ch->dest_buf )
    		     return;
    		strcpy(arg, ch->dest_buf);
//.........这里部分代码省略.........
开发者ID:ccubed,项目名称:SWFoteCustom,代码行数:101,代码来源:tech.c

示例13: check_psionic_talents

void check_psionic_talents (CHAR_DATA *ch)
{
    ACCOUNT_DATA	*account;
    int		chance = 0, roll = 0;
    int		cur_talents = 0, i = 0, j = 1;
    int		talents [8] = { SKILL_CLAIRVOYANCE,
                            SKILL_DANGER_SENSE,
                            SKILL_EMPATHIC_HEAL,
                            SKILL_HEX,
                            SKILL_MENTAL_BOLT,
                            SKILL_PRESCIENCE,
                            SKILL_SENSITIVITY,
                            SKILL_TELEPATHY
                       };
    bool		check = TRUE, again = TRUE, awarded = FALSE, block = FALSE;
    char		buf [MAX_STRING_LENGTH] = {'\0'};
    char		*date = NULL;

    if ( is_newbie (ch) || ch->aur <= 15 )
        return;

    if ( ch->pc && ch->pc->account ) {
        if ( !(account = load_account (ch->pc->account)) )
            return;
        if ( IS_SET (account->flags, ACCOUNT_NOPSI) )
            block = TRUE;
        if ( account->roleplay_points < 2 )
            block = TRUE;
        free_account (account);
    }
    else return;

    if ( block )
        return;

    if ( ch->aur < 16 )
        return;
    else if ( ch->aur == 16 )
        chance = 5;
    else if ( ch->aur == 17 )
        chance = 10;
    else if ( ch->aur == 18 )
        chance = 20;
    else if ( ch->aur == 19 )
        chance = 30;
    else if ( ch->aur == 20 )
        chance = 45;
    else if ( ch->aur == 21 )
        chance = 50;
    else if ( ch->aur == 22 )
        chance = 60;
    else if ( ch->aur == 23 )
        chance = 70;
    else if ( ch->aur == 24 )
        chance = 80;
    else
        chance = 95;

    chance += number(1,10);
    chance = MIN(chance, 95);

    for ( i = 0; i <= 7; i++ )
        if ( ch->skills[talents[i]] )
            cur_talents++;

    while ( check && cur_talents <= 4 ) {
        if ( number(1,100) <= chance ) {
            again = TRUE;
            while ( again ) {
                roll = talents[number(0,7)];
                if ( !ch->skills [roll] ) {
                    ch->skills [roll] = 1;
                    cur_talents++;
                    again = FALSE;
                    awarded = TRUE;
                }
                chance /= 2;
            }
            if ( cur_talents >= 4 )
                check = FALSE;
        }
        else check = FALSE;
    }

    if ( !awarded )
        return;

    snprintf (buf, MAX_STRING_LENGTH,  "This character rolled positive for the following talents:\n\n");

    for ( i = 0; i <= 7; i++ )
        if ( ch->skills [talents[i]] )
            snprintf (buf + strlen(buf), MAX_STRING_LENGTH,  "   %d. %s\n", j++, skill_data[talents[i]].skill_name);

    date = timestr(date);

    add_message ("Psi_talents", 2, "Server", date, ch->tname, "", buf, 0);
    add_message (ch->tname, 3, "Server", date, "Psionic Talents.", "", buf, 0);

    mem_free (date);
}
开发者ID:stefanludlow,项目名称:Argila,代码行数:100,代码来源:magic.c

示例14: generic_find

int generic_find(char *arg, int bitvector, struct char_data *ch,
		   struct char_data **tar_ch, struct obj_data **tar_obj)
{
    static char *ignore[] = {
	"the",
	"in",
	"on",
	"at",
	"\n" };

    int i;
    char name[256];
    bool found;

    found = FALSE;


    /* Eliminate spaces and "ignore" words */
    while (*arg && !found) {

	for(; *arg == ' '; arg++)   ;

	for(i=0; (name[i] = *(arg+i)) && (name[i]!=' '); i++)   ;
	name[i] = 0;
	arg+=i;
	if (search_block(name, ignore, TRUE) > -1)
	    found = TRUE;

    }

    if (!name[0])
	return(0);

    *tar_ch  = 0;
    *tar_obj = 0;

    if (IS_SET(bitvector, FIND_CHAR_ROOM)) {      /* Find person in room */
	if ( ( *tar_ch = get_char_room_vis(ch, name) ) != NULL ) {
	    return(FIND_CHAR_ROOM);
	}
    }

    if (IS_SET(bitvector, FIND_CHAR_WORLD)) {
	if ( ( *tar_ch = get_char_vis(ch, name) ) != NULL ) {
	    return(FIND_CHAR_WORLD);
	}
    }

    if (IS_SET(bitvector, FIND_OBJ_EQUIP)) {
	for(found=FALSE, i=0; i<MAX_WEAR && !found; i++)
	    if (ch->equipment[i] && str_cmp(name, ch->equipment[i]->name) == 0) {
		*tar_obj = ch->equipment[i];
		found = TRUE;
	    }
	    if (found) {
		return(FIND_OBJ_EQUIP);
	    }
    }

    if (IS_SET(bitvector, FIND_OBJ_INV)) {
	if ( ( *tar_obj = get_obj_in_list_vis(ch, name, ch->carrying) )
	!= NULL ) {
	    return(FIND_OBJ_INV);
	}
    }

    if (IS_SET(bitvector, FIND_OBJ_ROOM)) {
	*tar_obj = get_obj_in_list_vis(ch, name, world[ch->in_room].contents);
	if ( *tar_obj != NULL ) {
	    return(FIND_OBJ_ROOM);
	}
    }

    if (IS_SET(bitvector, FIND_OBJ_WORLD)) {
	if ( ( *tar_obj = get_obj_vis(ch, name) ) != NULL ) {
	    return(FIND_OBJ_WORLD);
	}
    }

    return(0);
}
开发者ID:MUDOmnibus,项目名称:Rom1,代码行数:81,代码来源:handler.c

示例15: sw_mcp2515_check_message

uint8_t sw_mcp2515_check_message(void) {
	return (!IS_SET(MCP2515_INT));
}
开发者ID:swilson007,项目名称:SwCanbus,代码行数:3,代码来源:rawMcp2515.c


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