示例#1
0
void mag_points(int level, struct char_data *ch, struct char_data *victim,
		     int spellnum, int savetype)
{
  int healing = 0, move = 0;

  if (victim == NULL)
    return;

  switch (spellnum) {
  case SPELL_CURE_LIGHT:
    healing = dice(1, 8) + 1 + (level / 4);
    send_to_char(victim, "You feel better.\r\n");
    break;
  case SPELL_CURE_CRITIC:
    healing = dice(3, 8) + 3 + (level / 4);
    send_to_char(victim, "You feel a lot better!\r\n");
    break;
  case SPELL_HEAL:
    healing = 100 + dice(3, 8);
    send_to_char(victim, "A warm feeling floods your body.\r\n");
    break;
  }
  GET_HIT(victim) = MIN(GET_MAX_HIT(victim), GET_HIT(victim) + healing);
  GET_MOVE(victim) = MIN(GET_MAX_MOVE(victim), GET_MOVE(victim) + move);
  update_pos(victim);
}
示例#2
0
void do_shout (struct char_data *ch, char *argument, int cmd)
{
  static char buf1[MAX_STRING_LENGTH];
  struct descriptor_data *i;


  if (IS_SET (ch->specials.act, PLR_NOSHOUT)) {
    send_to_char ("You can't shout!!\n\r", ch);
    return;
  }

  if (GET_MOVE (ch) < 10) {
    send_to_char ("You are too exhausted.\n\r", ch);
    return;
  }

  GET_MOVE (ch) -= 10;

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

  if (!(*argument))
    send_to_char ("Shout? Yes! Fine! Shout we must, but WHAT??\n\r", ch);
  else {
    send_to_char ("Ok.\n\r", ch);
    sprintf (buf1, "$n shouts '%s'", argument);

    for (i = descriptor_list; i; i = i->next)
      if (i->character != ch && !i->connected &&
        !IS_SET (i->character->specials.act, PLR_NOSHOUT))
        act (buf1, 0, ch, 0, i->character, TO_VICT);
  }
}
示例#3
0
/* cause the morph to happen: universal thru this function to prevent errors */
void perform_morph(char_data *ch, ubyte form) {
	ACMD(do_dismount);
	double move_mod, health_mod, mana_mod;

	if (IS_NPC(ch)) {
		return;
	}

	if (IS_RIDING(ch) && form != MORPH_NONE) {
		do_dismount(ch, "", 0, 0);
	}

	// read current pools
	health_mod = (double) GET_HEALTH(ch) / GET_MAX_HEALTH(ch);
	move_mod = (double) GET_MOVE(ch) / GET_MAX_MOVE(ch);
	mana_mod = (double) GET_MANA(ch) / GET_MAX_MANA(ch);

	/* Remove his morph bonuses from his current form */
	update_morph_stats(ch, FALSE);

	/* Set the new form */
	GET_MORPH(ch) = form;

	/* Add new morph bonuses */
	update_morph_stats(ch, TRUE);
	
	// this fixes all the things
	affect_total(ch);

	// set new pools
	GET_HEALTH(ch) = (sh_int) (GET_MAX_HEALTH(ch) * health_mod);
	GET_MOVE(ch) = (sh_int) (GET_MAX_MOVE(ch) * move_mod);
	GET_MANA(ch) = (sh_int) (GET_MAX_MANA(ch) * mana_mod);

	/* check for claws */
	if (MORPH_FLAGGED(ch, MORPH_FLAG_NO_CLAWS) && AFF_FLAGGED(ch, AFF_CLAWS)) {
		affects_from_char_by_aff_flag(ch, AFF_CLAWS);
	}
}
示例#4
0
/* Some initializations for characters, including initial skills */
void do_start(struct char_data *ch)
{
  GET_LEVEL(ch) = 1;
  GET_TOT_LEVEL(ch) = 1;
  GET_EXP(ch) = 1;
  GET_CLASS_1(ch) = GET_CLASS(ch);
  GET_MULTIS(ch) = 1;

  set_title(ch, NULL);
  roll_real_abils(ch);

  GET_MAX_HIT(ch)  = 10;
  GET_MAX_MANA(ch) = 100;
  GET_MAX_MOVE(ch) = 100;

  switch (GET_CLASS(ch)) {

  case CLASS_ADEPT:
    break;

  case CLASS_MEDIC:
    break;

  case CLASS_BANDIT:
    SET_SKILL(ch, SKILL_SNEAK, 10);
    SET_SKILL(ch, SKILL_HIDE, 5);
    SET_SKILL(ch, SKILL_STEAL, 15);
    SET_SKILL(ch, SKILL_BACKSTAB, 10);
    SET_SKILL(ch, SKILL_PICK_LOCK, 10);
    SET_SKILL(ch, SKILL_TRACK, 10);
    break;

  case CLASS_SOLDIER:
    break;
  }

  advance_level(ch);

  GET_HIT(ch) = GET_MAX_HIT(ch);
  GET_MANA(ch) = GET_MAX_MANA(ch);
  GET_MOVE(ch) = GET_MAX_MOVE(ch);

  GET_COND(ch, THIRST) = 24;
  GET_COND(ch, HUNGER) = 24;
  GET_COND(ch, DRUNK) = 0;

  if (CONFIG_SITEOK_ALL)
    SET_BIT_AR(PLR_FLAGS(ch), PLR_SITEOK);
}
示例#5
0
文件: genmob.c 项目: matthewbode/mg2
int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  char ldesc[MAX_STRING_LENGTH], ddesc[MAX_STRING_LENGTH];

  ldesc[MAX_STRING_LENGTH - 1] = '\0';
  ddesc[MAX_STRING_LENGTH - 1] = '\0';
  strip_cr(strncpy(ldesc, GET_LDESC(mob), MAX_STRING_LENGTH - 1));
  strip_cr(strncpy(ddesc, GET_DDESC(mob), MAX_STRING_LENGTH - 1));

  fprintf(fd,	"#%d\n"
		"%s%c\n"
		"%s%c\n"
		"%s%c\n"
		"%s%c\n",
	mvnum,
	GET_ALIAS(mob), STRING_TERMINATOR,
	GET_SDESC(mob), STRING_TERMINATOR,
	ldesc, STRING_TERMINATOR,
	ddesc, STRING_TERMINATOR
  );
  fprintf(fd,	"%ld %ld %d E\n"
		"%d %d %d %dd%d+%d %dd%d+%d\n",
		MOB_FLAGS(mob), AFF_FLAGS(mob), GET_ALIGNMENT(mob),
		GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob),
		GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob),
		GET_DAMROLL(mob)
  );
  fprintf(fd, 	"%d %d\n"
		"%d %d %d\n",
		GET_GOLD(mob), GET_EXP(mob),
		GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob)
  );

  if (write_mobile_espec(mvnum, mob, fd) < 0)
    log("SYSERR: GenOLC: Error writing E-specs for mobile #%d.", mvnum);

  script_save_to_disk(fd, mob, MOB_TRIGGER);

#if CONFIG_GENOLC_MOBPROG
  if (write_mobile_mobprog(mvnum, mob, fd) < 0)
    log("SYSERR: GenOLC: Error writing MobProgs for mobile #%d.", mvnum);
#endif

  return TRUE;
}
示例#6
0
文件: medit.c 项目: axanon/tbamud
void medit_autoroll_stats(struct descriptor_data *d)
{
  int mob_lev;

  mob_lev = GET_LEVEL(OLC_MOB(d));
  mob_lev = GET_LEVEL(OLC_MOB(d)) = LIMIT(mob_lev, 1, LVL_IMPL);

  GET_MOVE(OLC_MOB(d))    = mob_lev*10;          /* hit point bonus (mobs don't use movement points */
  GET_HIT(OLC_MOB(d))     = mob_lev/5;           /* number of hitpoint dice */
  GET_MANA(OLC_MOB(d))    = mob_lev/5;           /* size of hitpoint dice   */

  GET_NDD(OLC_MOB(d))     = MAX(1, mob_lev/6);   /* number damage dice 1-5  */
  GET_SDD(OLC_MOB(d))     = MAX(2, mob_lev/6);   /* size of damage dice 2-5 */
  GET_DAMROLL(OLC_MOB(d)) = mob_lev/6;           /* damroll (dam bonus) 0-5 */

  GET_HITROLL(OLC_MOB(d)) = mob_lev/3;           /* hitroll 0-10            */
  GET_EXP(OLC_MOB(d))     = (mob_lev*mob_lev*100);
  GET_GOLD(OLC_MOB(d))    = (mob_lev*10);
  GET_AC(OLC_MOB(d))      = (100-(mob_lev*6));   /* AC 94 to -80            */

  /* 'Advanced' stats are only rolled if advanced options are enabled */
  if (CONFIG_MEDIT_ADVANCED) {
    GET_STR(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18); /* 2/3 level in range 11 to 18 */
    GET_INT(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18);
    GET_WIS(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18);
    GET_DEX(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18);
    GET_CON(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18);
    GET_CHA(OLC_MOB(d))     = LIMIT((mob_lev*2)/3, 11, 18);

    GET_SAVE(OLC_MOB(d), SAVING_PARA)   = mob_lev / 4;  /* All Saving throws */
    GET_SAVE(OLC_MOB(d), SAVING_ROD)    = mob_lev / 4;  /* set to a quarter  */
    GET_SAVE(OLC_MOB(d), SAVING_PETRI)  = mob_lev / 4;  /* of the mobs level */
    GET_SAVE(OLC_MOB(d), SAVING_BREATH) = mob_lev / 4;
    GET_SAVE(OLC_MOB(d), SAVING_SPELL)  = mob_lev / 4;
  }

}
示例#7
0
bool
can_psidrain(struct creature *ch, struct creature *vict, int *out_dist, bool msg)
{
    const char *to_char = NULL;
    const char *to_vict = NULL;
    int dist;

    if (CHECK_SKILL(ch, SKILL_PSIDRAIN) < 30 || !IS_PSIONIC(ch)) {
        to_char = "You have no idea how.";
        goto failure;
    }

    if (ROOM_FLAGGED(ch->in_room, ROOM_NOPSIONICS) && GET_LEVEL(ch) < LVL_GOD) {
        to_char = "Psychic powers are useless here!";
        goto failure;
    }

    if (GET_LEVEL(vict) >= LVL_AMBASSADOR && GET_LEVEL(ch) < GET_LEVEL(vict)) {
        to_char = "You cannot locate them.";
        to_vict = "$n has just tried to psidrain you.";
        goto failure;
    }

    if (vict == ch) {
        to_char = "Ha ha... Funny!";
        goto failure;
    }

    if (is_fighting(ch) && vict->in_room != ch->in_room) {
        to_char = "You cannot focus outside the room during battle!";
        goto failure;
    }

    if (ch->in_room != vict->in_room &&
        ch->in_room->zone != vict->in_room->zone) {
        to_char = "$N is not in your zone.";
        goto failure;
    }

    if (ROOM_FLAGGED(vict->in_room, ROOM_NOPSIONICS)
        && GET_LEVEL(ch) < LVL_GOD) {
        to_char = "Psychic powers are useless where $E is!";
        goto failure;
    }

    if (!ok_to_attack(ch, vict, msg))
        return false;

    if (GET_MOVE(ch) < 20) {
        to_char = "You are too physically exhausted.";
        goto failure;
    }

    dist = find_distance(ch->in_room, vict->in_room);
    if (out_dist)
        *out_dist = dist;
    if (dist > ((GET_LEVEL(ch) / 6))) {
        to_char = "$N is out of your psychic range.";
        goto failure;
    }

    if (NULL_PSI(vict)) {
        to_char = "It is pointless to attempt this on $M.";
        goto failure;
    }

    return true;

failure:
    if (msg) {
        if (to_char)
            act(to_char, false, ch, NULL, vict, TO_CHAR);
        if (to_vict)
            act(to_vict, false, ch, NULL, vict, TO_VICT);
    }
    return false;
}
示例#8
0
void
perform_psidrain(struct creature *ch, struct creature *vict)
{
    int find_distance(struct room_data *tmp, struct room_data *location);
    int dist, drain, prob, percent;

    if (!can_psidrain(ch, vict, &dist, true))
        return;


    if (AFF3_FLAGGED(vict, AFF3_PSISHIELD) && creature_distrusts(vict, ch)) {
        prob = CHECK_SKILL(ch, SKILL_PSIDRAIN) + GET_INT(ch);
        prob += skill_bonus(ch, SKILL_PSIDRAIN);

        percent = skill_bonus(vict, SPELL_PSISHIELD);
        percent += number(1, 120);

        if (mag_savingthrow(vict, GET_LEVEL(ch), SAVING_PSI))
            percent *= 2;

        if (GET_INT(vict) > GET_INT(ch))
            percent += (GET_INT(vict) - GET_INT(ch)) * 8;

        if (percent >= prob) {
            act("Your attack is deflected by $N's psishield!",
                false, ch, NULL, vict, TO_CHAR);
            act("$n's psychic attack is deflected by your psishield!",
                false, ch, NULL, vict, TO_VICT);
            act("$n staggers under an unseen force.",
                true, ch, NULL, vict, TO_NOTVICT);

            return;
        }
    }

    if (GET_MANA(vict) <= 0) {
        act("$E is completely drained of psychic energy.",
            true, ch, NULL, vict, TO_CHAR);
        return;
    }

    drain = dice(GET_LEVEL(ch), GET_INT(ch) + GET_REMORT_GEN(ch)) +
        CHECK_SKILL(ch, SKILL_PSIDRAIN);
    if (dist > 0)
        drain /= dist + 1;

    drain /= 4;

    drain = MAX(0, MIN(GET_MANA(vict), drain));

    prob = CHECK_SKILL(ch, SKILL_PSIDRAIN) + GET_INT(ch) +
        (AFF3_FLAGGED(vict, AFF3_PSISHIELD) ? -20 : 0);

    if (is_fighting(vict))
        prob += 15;

    if (dist > 0)
        prob -= dist * 3;

    act("$n strains against an unseen force.", false, ch, NULL, vict, TO_ROOM);

    //
    // failure
    //

    if (number(0, 121) > prob) {
        send_to_char(ch, "You are unable to create the drainage link!\r\n");
        WAIT_STATE(ch, 2 RL_SEC);

        if (IS_NPC(vict) && !is_fighting(vict)) {

            if (ch->in_room == vict->in_room) {
                add_combat(vict, ch, false);
                add_combat(ch, vict, true);
            } else {
                remember(vict, ch);
                if (NPC2_FLAGGED(vict, NPC2_HUNT))
                    start_hunting(vict, ch);
            }
        }
    }
    //
    // success
    //
    else {

        act("A torrent of psychic energy is ripped out of $N's mind!",
            false, ch, NULL, vict, TO_CHAR);
        if (ch->in_room != vict->in_room &&
            GET_LEVEL(vict) + number(0, CHECK_SKILL(vict, SKILL_PSIDRAIN)) >
            GET_LEVEL(ch))
            act("Your psychic energy is ripped from you from afar!",
                false, ch, NULL, vict, TO_VICT);
        else
            act("Your psychic energy is ripped from you by $n!",
                false, ch, NULL, vict, TO_VICT);
        GET_MANA(vict) -= drain;
        GET_MANA(ch) = MIN(GET_MAX_MANA(ch), GET_MANA(ch) + drain);
        GET_MOVE(ch) -= 20;
        WAIT_STATE(vict, 1 RL_SEC);
        WAIT_STATE(ch, 5 RL_SEC);
        gain_skill_prof(ch, SKILL_PSIDRAIN);

        if (IS_NPC(vict) && !(is_fighting(vict))) {
            if (ch->in_room == vict->in_room) {
                remember(vict, ch);
                if (NPC2_FLAGGED(vict, NPC2_HUNT))
                    start_hunting(vict, ch);
                add_combat(vict, ch, false);
                add_combat(ch, vict, true);
            }
        }
    }
}
示例#9
0
/* do_simple_move assumes
 *    1. That there is no master and no followers.
 *    2. That the direction exists.
 *
 *   Returns :
 *   1 : If succes.
 *   0 : If fail
 */
int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{
  char throwaway[MAX_INPUT_LENGTH] = ""; /* Functions assume writable. */
  room_rnum was_in;

  int need_movement, moveadd = 0;
  struct obj_data *k;

  /*
   * Check for special routines (North is 1 in command list, but 0 here) Note
   * -- only check if following; this avoids 'double spec-proc' bug
   */
  if (need_specials_check && special(ch, dir + 1, throwaway))
    return (0);

  /* blocked by a leave trigger ? */
  if (!leave_mtrigger(ch, dir))
    return 0;
  if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir))
    return 0;

  /* charmed? */
  if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && IN_ROOM(ch) == IN_ROOM(ch->master)) {
    send_to_char(ch, "The thought of leaving your master makes you weep.\r\n");
    act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM);
    return (0);
  }

  /* if this room or the one we're going to needs a boat, check for one */
  if ((SECT(IN_ROOM(ch)) == SECT_WATER_NOSWIM) ||
      (SECT(EXIT(ch, dir)->to_room) == SECT_WATER_NOSWIM)) {
    if (!has_boat(ch)) {
      send_to_char(ch, "You need a boat to go there.\r\n");
      return (0);
    }
  }

  /* move points needed is avg. move loss for src and destination sect type
   * You know .. I don't like this system, let's base this not ONLY on terrain type
   * but also on dex of char. 
   * Needs to adjust on max abils
   * Original:
   * need_movement = (movement_loss[SECT(IN_ROOM(ch))] +
		   movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2;
   */

   if (GET_DEX(ch) <= 5) 				/* 0(1?)-5 Dex */
      moveadd = 8;
   if ((GET_DEX(ch) >= 6) && (GET_DEX(ch) <= 10)) 	/* 6-10 Dex */
      moveadd = 6;
   if ((GET_DEX(ch) >= 11) && (GET_DEX(ch) <= 15))  	/* 11-15 Dex */
      moveadd = 4;
   if (GET_DEX(ch) >= 16) 				/* 16+ Up to ..? Dex */
      moveadd = 2;

   need_movement = (movement_loss[SECT(IN_ROOM(ch))] + movement_loss[SECT(EXIT(ch, dir)->to_room)] + moveadd) / 2;

  if (GET_MOVE(ch) < need_movement && !IS_NPC(ch)) {
    if (need_specials_check && ch->master)
      send_to_char(ch, "You are too exhausted to follow.\r\n");
    else
      send_to_char(ch, "You are too exhausted.\r\n");

    return (0);
  }
  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_ATRIUM)) {
    if (!House_can_enter(ch, GET_ROOM_VNUM(EXIT(ch, dir)->to_room))) {
      send_to_char(ch, "That's private property -- no trespassing!\r\n");
      return (0);
    }
  }
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_TUNNEL) &&
     num_pc_in_room(&(world[EXIT(ch, dir)->to_room])) >= tunnel_size) {
    if (tunnel_size > 1)
      send_to_char(ch, "There isn't enough room for you to go there!\r\n");
    else
      send_to_char(ch, "There isn't enough room there for more than one person!\r\n");
    return (0);
  }


 /* Room big enough for you? */
   if ((SIZE(EXIT(ch, dir)->to_room) < GET_SIZE(ch)) && (SIZE(EXIT(ch, dir)->to_room) != SIZE_SPECIAL) && (GET_LEVEL(ch) < LVL_GOD)) { //GOD+ can enter any room
    send_to_char(ch, "You are too big to fit in there!\r\n");
    return (0);
  }


  /* Mortals and low level gods cannot enter greater god rooms. */
/* irrelevant because of min/max level -mak 8.21.05 -reinstated 2.9.06 

  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_GODROOM) &&
	GET_LEVEL(ch) < LVL_GOD) { 
    send_to_char(ch, "You aren't godly enough to use that room!\r\n");
    return (0);
  }
uncomment to fix GODROOM */

/* No access for non-IMPs */
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_IMPROOM) &&
	GET_LEVEL(ch) < LVL_IMPL) {
    send_to_char(ch, "You dare not disturb the Implementors!\r\n");
    return (0);
  }
  if (GET_LEVEL(ch) < ROOM_MIN_LEVEL(EXIT(ch, dir)->to_room)) {
    if (world[EXIT(ch, dir)->to_room].max_level_message ) {
       send_to_char(ch, world[EXIT(ch, dir)->to_room].min_level_message);
       send_to_char(ch, "\r\n");
    }
    else
    send_to_char(ch, "You are not experienced enough to enter that room.\r\n");
    return 0;
  }
  if (ROOM_MAX_LEVEL(EXIT(ch, dir)->to_room) > 0) {
   if (GET_LEVEL(ch) > ROOM_MAX_LEVEL(EXIT(ch, dir)->to_room)  && GET_LEVEL(ch) < LVL_SAINT ) {
    if (world[EXIT(ch, dir)->to_room].max_level_message ){
       send_to_char(ch, world[EXIT(ch, dir)->to_room].max_level_message);
       send_to_char(ch, "\r\n");
    }
    else
    send_to_char(ch, "You are too experienced to enter that room.\r\n");
    return 0;
   }
  }
  if (AFF_FLAGGED(ch, AFF_FLEET_FEET)) {
      need_movement = need_movement / 2;
      if (need_movement < 2) need_movement = 1;}

  if (AFF_FLAGGED(ch, AFF_AIRWALK)) need_movement = 1;
  
  /* Now we know we're allowed to go into the room. */
  if (GET_LEVEL(ch) < LVL_SAINT && !IS_NPC(ch))
    GET_MOVE(ch) -= need_movement;

  if (!AFF_FLAGGED(ch, AFF_SNEAK)) {
    char buf2[MAX_STRING_LENGTH];

    snprintf(buf2, sizeof(buf2), "$n leaves %s.", dirs[dir]);
    act(buf2, TRUE, ch, 0, 0, TO_ROOM);
  }
  was_in = IN_ROOM(ch);
  char_from_room(ch);
  char_to_room(ch, world[was_in].dir_option[dir]->to_room);

  /* move them first, then move them back if they aren't allowed to go. */
  /* see if an entry trigger disallows the move */
  if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir)) {
    char_from_room(ch);
    char_to_room(ch, was_in);
    return 0;
  }

  if (!AFF_FLAGGED(ch, AFF_SNEAK))
    act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM);

  if (ch->desc != NULL)
    look_at_room(IN_ROOM(ch), ch, 0);

  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH) && GET_LEVEL(ch) < LVL_SAINT) {
    clanlog(ch, "%s entered a Death Room", GET_NAME(ch));
    was_in = IN_ROOM(ch);
    log_death_trap(ch);
    death_cry(ch);
    /* Fix the PCs size first if it needs fixing */
    fix_size(ch);

    extract_char(ch);

    for (k = world[was_in].contents; k; k = world[was_in].contents)
        extract_obj(k);

    return (0);
  }

  entry_memory_mtrigger(ch);
  if (!greet_mtrigger(ch, dir)) {
    char_from_room(ch);
    char_to_room(ch, was_in);
    look_at_room(IN_ROOM(ch), ch, 0);
  } else greet_memory_mtrigger(ch);

  /* send warning message if moves are getting low */
  if ( GET_MOVE(ch) < (GET_MAX_MOVE(ch) / 10) )
  {
    send_to_char(ch, "You cannot go much further.\r\n");
  }

  return (1);
}
示例#10
0
int mag_points_char(struct spell_info_type *sinfo, struct char_data *caster, struct char_data *vict, int level)
{
  int modifier = dice(sinfo->num_dice, sinfo->size_dice);

  if (sinfo->unaffect)
    modifier = -modifier;

  modifier = modBySpecialization(caster, sinfo, modifier);
  gain_exp(caster, modifier * 2);
  switch (sinfo->point_loc) {
    case APPLY_AGE:
      vict->player.time.birth += (SECS_PER_MUD_YEAR * modifier);
      break;
    case APPLY_STR:
      GET_VSTR(vict) += modifier;
      GET_STR(vict) = MIN(100, GET_VSTR(vict));
      break;
    case APPLY_DEX:
      GET_VDEX(vict) += modifier;
      GET_DEX(vict) = MIN(100, GET_VDEX(vict));
      break;
    case APPLY_INT:
      GET_VINT(vict) += modifier;
      GET_INT(vict) = MIN(100, GET_VINT(vict));
      break;
    case APPLY_WIS:
      GET_VWIS(vict) += modifier;
      GET_WIS(vict) = MIN(100, GET_VWIS(vict));
      break;
    case APPLY_CON:
      GET_VCON(vict) += modifier;
      GET_CON(vict) = MIN(100, GET_VCON(vict));
      break;
    case APPLY_AGI:
      GET_VAGI(vict) += modifier;
      GET_AGI(vict) = MIN(100, GET_VAGI(vict));
      break;
    case APPLY_MANA:
      GET_MANA(vict) += modifier;
      if (GET_MANA(vict) > GET_MAX_MANA(vict))
        GET_MANA(vict) = GET_MAX_MANA(vict);
      break;
    case APPLY_HIT:
      GET_HIT(vict) += modifier;
      if (GET_HIT(vict) > GET_MAX_HIT(vict))
        GET_HIT(vict) = GET_MAX_HIT(vict);
      break;
    case APPLY_MOVE:
      GET_MOVE(vict) += modifier;
      if (GET_MOVE(vict) > GET_MAX_MOVE(vict))
        GET_MOVE(vict) = GET_MAX_MOVE(vict);
      break;
    case APPLY_HITROLL:
      GET_HITROLL(vict) += modifier;
      break;
    case APPLY_DAMROLL:
      GET_DAMROLL(vict) += modifier;
      break;
    case APPLY_SAVING_PARA:
      GET_SAVE(vict,SAVING_PARA) += modifier;
      break;
    case APPLY_SAVING_ROD:
      GET_SAVE(vict,SAVING_ROD) += modifier;
      break;
    case APPLY_SAVING_PETRI:
      GET_SAVE(vict,SAVING_PETRI) += modifier;
      break;
    case APPLY_SAVING_BREATH:
      GET_SAVE(vict,SAVING_BREATH) += modifier;
      break;
    case APPLY_SAVING_SPELL:
      GET_SAVE(vict,SAVING_SPELL) += modifier;
      break;
    case APPLY_MAX_HIT:
      GET_MAX_HIT(vict) += modifier;
      break;
    case APPLY_MAX_MANA:
      GET_MAX_MANA(vict) += modifier;
      break;
    case APPLY_MAX_MOVE:
      GET_MAX_MOVE(vict) += modifier;
      break;
    case APPLY_RES_DARK:
      GET_RESIST(vict, DAM_DARK) += modifier;
      break;
    case APPLY_RES_FIRE:
      GET_RESIST(vict, DAM_FIRE) += modifier;
      break;
    case APPLY_RES_COLD:
      GET_RESIST(vict, DAM_COLD) += modifier;
      break;
    case APPLY_RES_ACID:
      GET_RESIST(vict, DAM_ACID) += modifier;
      break;
    case APPLY_RES_POISON:
      GET_RESIST(vict, DAM_POISON) += modifier;
      break;
    case APPLY_RES_DISEASE:
      GET_RESIST(vict, DAM_DISEASE) += modifier;
      break;
    case APPLY_RES_CHARM:
      GET_RESIST(vict, DAM_CHARM) += modifier;
      break;
    case APPLY_RES_SLEEP:
      GET_RESIST(vict, DAM_SLEEP) += modifier;
      break;
    case APPLY_RES_SLASH:
      GET_RESIST(vict, DAM_SLASH) += modifier;
      break;
    case APPLY_RES_PIERCE:
      GET_RESIST(vict, DAM_PIERCE) += modifier;
      break;
    case APPLY_RES_BLUDGEON:
      GET_RESIST(vict, DAM_BLUDGEON) += modifier;
      break;
    case APPLY_RES_NWEAP:
      GET_RESIST(vict, DAM_NWEAP) += modifier;
      break;
    case APPLY_RES_MWEAP:
      GET_RESIST(vict, DAM_MWEAP) += modifier;
      break;
    case APPLY_RES_MAGIC:
      GET_RESIST(vict, DAM_MAGIC) += modifier;
      break;
    case APPLY_RES_ELECTRICITY:
      GET_RESIST(vict, DAM_ELECTRICITY) += modifier;
      break;
  }
  return 1;
}
示例#11
0
文件: limits.cpp 项目: bodrich/bylins
void beat_points_update(int pulse)
{
	CHAR_DATA *i, *next_char;
	int restore;

	if (!UPDATE_PC_ON_BEAT)
		return;

	// only for PC's
	for (i = character_list; i; i = next_char)
	{
		next_char = i->next;
		if (IS_NPC(i))
			continue;

		if (IN_ROOM(i) == NOWHERE)
		{
			log("SYSERR: Pulse character in NOWHERE.");
			continue;
		}

		if (RENTABLE(i) <= time(NULL))
		{
			RENTABLE(i) = 0;
			AGRESSOR(i) = 0;
			AGRO(i) = 0;
			i->agrobd = false;
		}
		if (AGRO(i) < time(NULL))
			AGRO(i) = 0;
		beat_punish(i);

// This line is used only to control all situations when someone is
// dead (POS_DEAD). You can comment it to minimize heartbeat function
// working time, if you're sure, that you control these situations
// everywhere. To the time of this code revision I've fix some of them
// and haven't seen any other.
//             if (GET_POS(i) == POS_DEAD)
//                     die(i, NULL);

		if (GET_POS(i) < POS_STUNNED)
			continue;

		// Restore hitpoints
		restore = hit_gain(i);
		restore = interpolate(restore, pulse);

		if (AFF_FLAGGED(i, AFF_BANDAGE))
		{
			AFFECT_DATA* aff;
			for(aff = i->affected; aff; aff = aff->next)
			{
				if (aff->type == SPELL_BANDAGE)
				{
					restore += MIN(GET_REAL_MAX_HIT(i) / 10, aff->modifier);
					break;
				}
			}
		}

		if (GET_HIT(i) < GET_REAL_MAX_HIT(i))
			GET_HIT(i) = MIN(GET_HIT(i) + restore, GET_REAL_MAX_HIT(i));

		// Проверка аффекта !исступление!. Поместил именно здесь,
		// но если кто найдет более подходящее место переносите =)
		//Gorrah: перенес в handler::affect_total
		//check_berserk(i);

		// Restore PC caster mem
		if (!IS_MANA_CASTER(i) && !MEMQUEUE_EMPTY(i))
		{
			restore = mana_gain(i);
			restore = interpolate(restore, pulse);
			GET_MEM_COMPLETED(i) += restore;

	if (AFF_FLAGGED(i, AFF_RECALL_SPELLS))
		handle_recall_spells(i);

			while (GET_MEM_COMPLETED(i) > GET_MEM_CURRENT(i)
					&& !MEMQUEUE_EMPTY(i))
			{
				int spellnum;
				spellnum = MemQ_learn(i);
				GET_SPELL_MEM(i, spellnum)++;
				GET_CASTER(i) += spell_info[spellnum].danger;
			}

			if (MEMQUEUE_EMPTY(i))
			{
				if (GET_RELIGION(i) == RELIGION_MONO)
				{
					send_to_char
					("Наконец ваши занятия окончены. Вы с улыбкой захлопнули свой часослов.\r\n",
					 i);
					act("Окончив занятия, $n с улыбкой захлопнул$g часослов.",
						FALSE, i, 0, 0, TO_ROOM);
				}
				else
				{
					send_to_char
					("Наконец ваши занятия окончены. Вы с улыбкой убрали свои резы.\r\n", i);
					act("Окончив занятия, $n с улыбкой убрал$g резы.", FALSE, i, 0, 0, TO_ROOM);
				}
			}
		}

		if (!IS_MANA_CASTER(i) && MEMQUEUE_EMPTY(i))
		{
			GET_MEM_TOTAL(i) = 0;
			GET_MEM_COMPLETED(i) = 0;
		}

		// Гейн маны у волхвов
		if (IS_MANA_CASTER(i) && GET_MANA_STORED(i) < GET_MAX_MANA(i))
		{
			GET_MANA_STORED(i) += mana_gain(i);
			if (GET_MANA_STORED(i) >= GET_MAX_MANA(i))
			{
				GET_MANA_STORED(i) = GET_MAX_MANA(i);
				send_to_char("Ваша магическая энергия полностью восстановилась\r\n", i);
			}
		}
		if (IS_MANA_CASTER(i) && GET_MANA_STORED(i) > GET_MAX_MANA(i))
		{
			GET_MANA_STORED(i) = GET_MAX_MANA(i);
		}
		// Restore moves
		restore = move_gain(i);
		restore = interpolate(restore, pulse);
//		GET_MOVE(i) = MIN(GET_MOVE(i) + restore, GET_REAL_MAX_MOVE(i));
//MZ.overflow_fix
		if (GET_MOVE(i) < GET_REAL_MAX_MOVE(i))
			GET_MOVE(i) = MIN(GET_MOVE(i) + restore, GET_REAL_MAX_MOVE(i));
//-MZ.overflow_fix
	}
}
示例#12
0
文件: medit.c 项目: axanon/tbamud
/* Display main menu. */
static void medit_disp_stats_menu(struct descriptor_data *d)
{
  struct char_data *mob;
  char buf[MAX_STRING_LENGTH];

  mob = OLC_MOB(d);
  get_char_colors(d->character);
  clear_screen(d);

  /* Color codes have to be used here, for count_color_codes to work */
  sprintf(buf, "(range \ty%d\tn to \ty%d\tn)", GET_HIT(mob) + GET_MOVE(mob), (GET_HIT(mob) * GET_MANA(mob)) + GET_MOVE(mob));

  /* Top section - standard stats */
  write_to_output(d,
  "-- Mob Number:  %s[%s%d%s]%s\r\n"
  "(%s1%s) Level:       %s[%s%4d%s]%s\r\n"
  "(%s2%s) %sAuto Set Stats (based on level)%s\r\n\r\n"
  "Hit Points  (xdy+z):        Bare Hand Damage (xdy+z): \r\n"
  "(%s3%s) HP NumDice:  %s[%s%5d%s]%s    (%s6%s) BHD NumDice:  %s[%s%5d%s]%s\r\n"
  "(%s4%s) HP SizeDice: %s[%s%5d%s]%s    (%s7%s) BHD SizeDice: %s[%s%5d%s]%s\r\n"
  "(%s5%s) HP Addition: %s[%s%5d%s]%s    (%s8%s) DamRoll:      %s[%s%5d%s]%s\r\n"
  "%-*s(range %s%d%s to %s%d%s)\r\n\r\n"

  "(%sA%s) Armor Class: %s[%s%4d%s]%s        (%sD%s) Hitroll:   %s[%s%5d%s]%s\r\n"
  "(%sB%s) Exp Points:  %s[%s%10d%s]%s  (%sE%s) Alignment: %s[%s%5d%s]%s\r\n"
  "(%sC%s) Gold:        %s[%s%10d%s]%s\r\n\r\n",
      cyn, yel, OLC_NUM(d), cyn, nrm,
      cyn, nrm, cyn, yel, GET_LEVEL(mob), cyn, nrm,
      cyn, nrm, cyn, nrm,
      cyn, nrm, cyn, yel, GET_HIT(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_NDD(mob), cyn, nrm,
      cyn, nrm, cyn, yel, GET_MANA(mob), cyn, nrm,  cyn, nrm, cyn, yel, GET_SDD(mob), cyn, nrm,
      cyn, nrm, cyn, yel, GET_MOVE(mob), cyn, nrm,  cyn, nrm, cyn, yel, GET_DAMROLL(mob), cyn, nrm,

      count_color_chars(buf)+28, buf,
      yel, GET_NDD(mob) + GET_DAMROLL(mob), nrm,
      yel, (GET_NDD(mob) * GET_SDD(mob)) + GET_DAMROLL(mob), nrm,

      cyn, nrm, cyn, yel, GET_AC(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_HITROLL(mob), cyn, nrm,
      cyn, nrm, cyn, yel, GET_EXP(mob), cyn, nrm,  cyn, nrm, cyn, yel, GET_ALIGNMENT(mob), cyn, nrm,
      cyn, nrm, cyn, yel, GET_GOLD(mob), cyn, nrm
      );

  if (CONFIG_MEDIT_ADVANCED) {
    /* Bottom section - non-standard stats, togglable in cedit */
    write_to_output(d,
    "(%sF%s) Str: %s[%s%2d/%3d%s]%s   Saving Throws\r\n"
    "(%sG%s) Int: %s[%s%3d%s]%s      (%sL%s) Paralysis     %s[%s%3d%s]%s\r\n"
    "(%sH%s) Wis: %s[%s%3d%s]%s      (%sM%s) Rods/Staves   %s[%s%3d%s]%s\r\n"
    "(%sI%s) Dex: %s[%s%3d%s]%s      (%sN%s) Petrification %s[%s%3d%s]%s\r\n"
    "(%sJ%s) Con: %s[%s%3d%s]%s      (%sO%s) Breath        %s[%s%3d%s]%s\r\n"
    "(%sK%s) Cha: %s[%s%3d%s]%s      (%sP%s) Spells        %s[%s%3d%s]%s\r\n\r\n",
        cyn, nrm, cyn, yel, GET_STR(mob), GET_ADD(mob), cyn, nrm,
        cyn, nrm, cyn, yel, GET_INT(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_PARA), cyn, nrm,
        cyn, nrm, cyn, yel, GET_WIS(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_ROD), cyn, nrm,
        cyn, nrm, cyn, yel, GET_DEX(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_PETRI), cyn, nrm,
        cyn, nrm, cyn, yel, GET_CON(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_BREATH), cyn, nrm,
        cyn, nrm, cyn, yel, GET_CHA(mob), cyn, nrm,   cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_SPELL), cyn, nrm
        );
  }

  /* Quit to previous menu option */
  write_to_output(d, "(%sQ%s) Quit to main menu\r\nEnter choice : ", cyn, nrm);

  OLC_MODE(d) = MEDIT_STATS_MENU;
}
示例#13
0
void
save_player_to_file(struct creature *ch, const char *path)
{
    void expire_old_grievances(struct creature *);
    // Save vital statistics
    FILE *ouf;
    char *tmp_path;
    struct alias_data *cur_alias;
    int idx;
    int hit = GET_HIT(ch), mana = GET_MANA(ch), move = GET_MOVE(ch);

    tmp_path = tmp_sprintf("%s.tmp", path);
    ouf = fopen(tmp_path, "w");

    if (!ouf) {
        fprintf(stderr, "Unable to open XML player file for save.[%s] (%s)\n",
            path, strerror(errno));
        return;
    }
    struct aff_stash *aff_stash = stash_creature_affects(ch);

    expire_old_grievances(ch);

    fprintf(ouf, "<creature name=\"%s\" idnum=\"%ld\">\n",
        GET_NAME(ch), ch->char_specials.saved.idnum);

    fprintf(ouf,
        "<points hit=\"%d\" mana=\"%d\" move=\"%d\" maxhit=\"%d\" maxmana=\"%d\" maxmove=\"%d\"/>\n",
        ch->points.hit, ch->points.mana, ch->points.move, ch->points.max_hit,
        ch->points.max_mana, ch->points.max_move);

    fprintf(ouf, "<money gold=\"%" PRId64 "\" cash=\"%" PRId64 "\" xp=\"%d\"/>\n",
        ch->points.gold, ch->points.cash, ch->points.exp);

    fprintf(ouf,
        "<stats level=\"%d\" sex=\"%s\" race=\"%s\" height=\"%d\" weight=\"%f\" align=\"%d\"/>\n",
        GET_LEVEL(ch), genders[(int)GET_SEX(ch)],
        race_name_by_idnum(GET_RACE(ch)), GET_HEIGHT(ch), GET_WEIGHT(ch),
        GET_ALIGNMENT(ch));

    fprintf(ouf, "<class name=\"%s\"", class_names[GET_CLASS(ch)]);
    if (GET_REMORT_CLASS(ch) != CLASS_UNDEFINED)
        fprintf(ouf, " remort=\"%s\"", class_names[GET_REMORT_CLASS(ch)]);
    if (GET_REMORT_GEN(ch) > 0)
        fprintf(ouf, " gen=\"%d\"", GET_REMORT_GEN(ch));

    if (IS_CYBORG(ch)) {
        if (GET_OLD_CLASS(ch) != -1)
            fprintf(ouf, " subclass=\"%s\"",
                borg_subchar_class_names[GET_OLD_CLASS(ch)]);
        if (GET_TOT_DAM(ch))
            fprintf(ouf, " total_dam=\"%d\"", GET_TOT_DAM(ch));
        if (GET_BROKE(ch))
            fprintf(ouf, " broken=\"%d\"", GET_BROKE(ch));
    }
    if (GET_CLASS(ch) == CLASS_MAGE &&
        GET_SKILL(ch, SPELL_MANA_SHIELD) > 0) {
        fprintf(ouf, " manash_low=\"%ld\" manash_pct=\"%ld\"",
            ch->player_specials->saved.mana_shield_low,
            ch->player_specials->saved.mana_shield_pct);
    }
    fprintf(ouf, "/>\n");

    fprintf(ouf,
        "<time birth=\"%ld\" death=\"%ld\" played=\"%ld\" last=\"%ld\"/>\n",
        ch->player.time.birth, ch->player.time.death, ch->player.time.played,
        ch->player.time.logon);

    fprintf(ouf,
        "<carnage pkills=\"%d\" akills=\"%d\" mkills=\"%d\" deaths=\"%d\" reputation=\"%d\"",
        GET_PKILLS(ch), GET_ARENAKILLS(ch), GET_MOBKILLS(ch),
        GET_PC_DEATHS(ch), ch->player_specials->saved.reputation);
    fprintf(ouf, "/>\n");

    fprintf(ouf,
        "<attr str=\"%d\" int=\"%d\" wis=\"%d\" dex=\"%d\" con=\"%d\" cha=\"%d\"/>\n",
            ch->real_abils.str, ch->real_abils.intel, ch->real_abils.wis,
            ch->real_abils.dex, ch->real_abils.con, ch->real_abils.cha);

    fprintf(ouf, "<condition hunger=\"%d\" thirst=\"%d\" drunk=\"%d\"/>\n",
        GET_COND(ch, FULL), GET_COND(ch, THIRST), GET_COND(ch, DRUNK));

    fprintf(ouf, "<player wimpy=\"%d\" lp=\"%d\" clan=\"%d\"/>\n",
        GET_WIMP_LEV(ch), GET_LIFE_POINTS(ch), GET_CLAN(ch));

    if (ch->desc)
        ch->player_specials->desc_mode = ch->desc->input_mode;
    if (ch->player_specials->rentcode == RENT_CREATING ||
        ch->player_specials->rentcode == RENT_REMORTING) {
        fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" "
            "currency=\"%d\" state=\"%s\"/>\n",
            ch->player_specials->rentcode, ch->player_specials->rent_per_day,
            ch->player_specials->rent_currency,
            desc_modes[(int)ch->player_specials->desc_mode]);
    } else {
        fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" currency=\"%d\"/>\n",
            ch->player_specials->rentcode, ch->player_specials->rent_per_day,
            ch->player_specials->rent_currency);
    }
    fprintf(ouf, "<home town=\"%d\" homeroom=\"%d\" loadroom=\"%d\"/>\n",
        GET_HOME(ch), GET_HOMEROOM(ch), GET_LOADROOM(ch));

    fprintf(ouf, "<quest");
    if (GET_QUEST(ch))
        fprintf(ouf, " current=\"%d\"", GET_QUEST(ch));
    if (GET_LEVEL(ch) >= LVL_IMMORT)
        fprintf(ouf, " allowance=\"%d\"", GET_QUEST_ALLOWANCE(ch));
    if (GET_IMMORT_QP(ch) != 0)
        fprintf(ouf, " points=\"%d\"", GET_IMMORT_QP(ch));
    fprintf(ouf, "/>\n");

    fprintf(ouf, "<bits flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\"/>\n",
        ch->char_specials.saved.act, ch->player_specials->saved.plr2_bits);
    if (PLR_FLAGGED(ch, PLR_FROZEN)) {
        fprintf(ouf, "<frozen thaw_time=\"%d\" freezer_id=\"%d\"/>\n",
            ch->player_specials->thaw_time, ch->player_specials->freezer_id);
    }

    fprintf(ouf, "<prefs flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" tongue=\"%s\"/>\n",
        ch->player_specials->saved.pref, ch->player_specials->saved.pref2,
        tongue_name(GET_TONGUE(ch)));

    fprintf(ouf, "<affects flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" flag3=\"%" PRIx32 "\"/>\n",
        ch->char_specials.saved.affected_by,
        ch->char_specials.saved.affected2_by,
        ch->char_specials.saved.affected3_by);

    for (idx = 0; idx < MAX_WEAPON_SPEC; idx++) {
        if (GET_WEAP_SPEC(ch, idx).level > 0)
            fprintf(ouf, "<weaponspec vnum=\"%d\" level=\"%d\"/>\n",
                GET_WEAP_SPEC(ch, idx).vnum,
                GET_WEAP_SPEC(ch, idx).level);
    }

    if (GET_TITLE(ch) && *GET_TITLE(ch)) {
        fprintf(ouf, "<title>%s</title>\n", xmlEncodeTmp(GET_TITLE(ch)));
    }

    if (GET_LEVEL(ch) >= 50) {
        fprintf(ouf, "<immort badge=\"%s\" qlog=\"%d\" invis=\"%d\"/>\n",
            xmlEncodeSpecialTmp(BADGE(ch)), GET_QLOG_LEVEL(ch),
            GET_INVIS_LVL(ch));
        if (POOFIN(ch) && *POOFIN(ch))
            fprintf(ouf, "<poofin>%s</poofin>\n", xmlEncodeTmp(POOFIN(ch)));
        if (POOFOUT(ch) && *POOFOUT(ch))
            fprintf(ouf, "<poofout>%s</poofout>\n", xmlEncodeTmp(POOFOUT(ch)));
    }
    if (ch->player.description && *ch->player.description) {
        fprintf(ouf, "<description>%s</description>\n",
            xmlEncodeTmp(tmp_gsub(tmp_gsub(ch->player.description, "\r\n",
                        "\n"), "\r", "")));
    }
    for (cur_alias = ch->player_specials->aliases; cur_alias;
        cur_alias = cur_alias->next)
        fprintf(ouf, "<alias type=\"%d\" alias=\"%s\" replace=\"%s\"/>\n",
            cur_alias->type, xmlEncodeSpecialTmp(cur_alias->alias),
            xmlEncodeSpecialTmp(cur_alias->replacement));

    for (struct affected_type *cur_aff = aff_stash->saved_affs;
         cur_aff;
         cur_aff = cur_aff->next)
        fprintf(ouf,
            "<affect type=\"%d\" duration=\"%d\" modifier=\"%d\" location=\"%d\" level=\"%d\" instant=\"%s\" affbits=\"%lx\" index=\"%d\" owner=\"%ld\"/>\n",
            cur_aff->type, cur_aff->duration, cur_aff->modifier,
            cur_aff->location, cur_aff->level,
            (cur_aff->is_instant) ? "yes" : "no", cur_aff->bitvector,
            cur_aff->aff_index, cur_aff->owner);

    if (!IS_IMMORT(ch)) {
        for (idx = 0; idx < MAX_SKILLS; idx++)
            if (ch->player_specials->saved.skills[idx] > 0)
                fprintf(ouf, "<skill name=\"%s\" level=\"%d\"/>\n",
                    spell_to_str(idx), GET_SKILL(ch, idx));
        write_tongue_xml(ch, ouf);
        for (GList * it = GET_RECENT_KILLS(ch); it; it = it->next) {
            struct kill_record *kill = it->data;
            fprintf(ouf, "<recentkill vnum=\"%d\" times=\"%d\"/>\n",
                kill->vnum, kill->times);
        }
        for (GList * it = GET_GRIEVANCES(ch); it; it = it->next) {
            struct grievance *grievance = it->data;
            fprintf(ouf,
                "<grievance time=\"%lu\" player=\"%d\" reputation=\"%d\" kind=\"%s\"/>\n",
                (long unsigned)grievance->time, grievance->player_id,
                grievance->rep, grievance_kind_descs[grievance->grievance]);
        }
    }

    
    if (IS_PC(ch) && ch->player_specials->tags) {
        GHashTableIter iter;
        char *key;

        g_hash_table_iter_init(&iter, ch->player_specials->tags);

        while (g_hash_table_iter_next(&iter, (gpointer *)&key, NULL)) {
            fprintf(ouf, "<tag tag=\"%s\"/>\n", key);
        }
    }

    fprintf(ouf, "</creature>\n");
    fclose(ouf);

    // on success, move temp file on top of the old file
    rename(tmp_path, path);

    restore_creature_affects(ch, aff_stash);
    free(aff_stash);

    GET_HIT(ch) = MIN(GET_MAX_HIT(ch), hit);
    GET_MANA(ch) = MIN(GET_MAX_MANA(ch), mana);
    GET_MOVE(ch) = MIN(GET_MAX_MOVE(ch), move);
}
示例#14
0
void
check_idling( CharData * ch )
{
#define VOID_TIME 8
#define EXTRACT_TIME 32
  void Crash_rentsave(CharData *ch, int cost);
  void Crash_cryosave(CharData *ch, int cost);

  /*
  ** CONJURED timer
  */
  int i = 0;

  for(;i < 4;i++) {
      if( GET_CONJ_CNT(ch, i) > 0)
      {
          SET_CONJ_CNT(ch, i) -= 1;
          
          if(SET_CONJ_CNT(ch, i) == 0)
              switch(GET_CLASS(ch)) {
                  case CLASS_RANGER:
                      sendChar( ch, "The creatures of the wild will answer your call again.\r\n" );
                      break;
                  case CLASS_NECROMANCER:
                      sendChar(ch, "The dead will heed your summons once more.\r\n");
                  case CLASS_MAGIC_USER:
                      switch(i) {
                          case TIMER_GATE: sendChar(ch, "Demons will answer your summons again.\r\n"); break;
                          case TIMER_MONSTER: sendChar(ch, "Monsters will answer your summons again.\r\n"); break;
                          case TIMER_ELEMENTAL: sendChar(ch, "Elementals will answer your summons again.\r\n"); break;
                      }
                      break;
                  default:
                      sendChar( ch, "Conjured creatures will answer your summons again.\r\n" );
              }
      }
  }
  
  /*
  ** HUNTED timer
  */
  if( IS_SET_AR( PLR_FLAGS(ch), PLR_HUNTED ) && ch->desc &&
    (--(ch)->player_specials->saved.phunt_countdown <= 0))
  {
    sendChar( ch, "You are no longer hunted.\r\n" );
    unset_hunted_player(ch);
  }
  /*
  ** THIEF timer
  */
  if( IS_SET_AR(PLR_FLAGS(ch), PLR_THIEF) && ch->desc &&
    (--(ch)->player_specials->saved.pthief_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_THIEF);
    send_to_char("You are no longer a registered thief.\r\n", ch);
    (ch)->player_specials->saved.pthief_countdown = 0;
  }
  /* KILLER timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_KILLER)
     && (--(ch)->player_specials->saved.pkill_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
    send_to_char("You are no longer a registered killer.\r\n", ch);
    (ch)->player_specials->saved.pkill_countdown = 0;
  }
  /* JAILED timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_JAILED)
     && (--(ch)->player_specials->saved.jail_timer <= 0))
  {
    int jail_exit_room;
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_JAILED);

    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM) && IN_ROOM(ch) == real_room(GOLD_TEAM_JAIL))
    {
      jail_exit_room = real_room(GOLD_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }
    if (PRF_FLAGGED(ch, PRF_BLACK_TEAM) && IN_ROOM(ch) == real_room(BLACK_TEAM_JAIL))
    {
      jail_exit_room = real_room(BLACK_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM) && IN_ROOM(ch) == real_room(ROGUE_TEAM_JAIL))
    {
      jail_exit_room = real_room(ROGUE_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    sendChar(ch, "Your imprisonement is over.\r\n");
//    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else if (PRF_FLAGGED(ch, PRF_BLACK_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//	else if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else
//	jail_exit_room = getStartRoom(ch);

//    char_to_room(ch, jail_exit_room);
//    look_at_room(ch, 0);
  }
  /*
  ** If your hunted there is NO escape.
  */
  if(( ++(ch->char_specials.timer) > VOID_TIME ) &&
    !IS_SET_AR(PLR_FLAGS(ch), PLR_HUNTED))
  {
    if (GET_WAS_IN(ch) == NOWHERE && ch->in_room != NOWHERE)
    {
      GET_WAS_IN(ch) = ch->in_room;
      end_fight(ch);
      act("$n disappears into the void.", TRUE, ch, 0, 0, TO_ROOM);
      send_to_char("You have been idle, and are pulled into a void.\r\n", ch);
      save_char(ch, NOWHERE);
      Crash_crashsave(ch);
      GET_WAS_IN(ch) = ch->in_room;
      char_from_room(ch);
      char_to_room(ch, 1);
    }
    //else if (ch->char_specials.timer > EXTRACT_TIME)
    //{
      //if (ch->in_room != NOWHERE)
	//char_from_room(ch);
      //char_to_room(ch, 1);
      //if (ch->desc)
	//SET_DCPENDING(ch->desc);
      //ch->desc = NULL;

      //Crash_idlesave(ch);	/* apparently causing problems? */
      //crashRentSave(ch, -1);

      //mudlog( NRM, LVL_LRGOD, TRUE, "%s force-rented and extracted (idle).", GET_NAME(ch));
      //extract_char(ch);
    //}
  }
#undef VOID_TIME
#undef EXTRACT_TIME
}
示例#15
0
void convert_mobs_to_disk(int zone_num)
{
    int i, rmob_num, zone, top;
    FILE *mob_file;
    char fname[64];
    struct char_data *mob;
    struct mob_attacks_data *attack;
    struct mob_equipment_data *equipment;
    struct mob_action_data *action;
    MPROG_DATA *mob_prog;

    zone = zone_table[zone_num].number;
    top = zone_table[zone_num].top;

    sprintf(fname, "%s/%i.mob", MOB_PREFIX, zone);

    if (!(mob_file = fopen(fname, "w"))) {
        mudlog("SYSERR: OLC: Cannot open mob file!", 'G', COM_BUILDER, TRUE);
        return;
    }

    /*. Seach database for mobs in this zone and save em .*/
    for (i = zone * 100; i <= top; i++) {
        rmob_num = real_mobile(i);

        if (rmob_num != -1) {
            if (fprintf(mob_file, "#%d\n", i) < 0) {
                mudlog("SYSERR: OLC: Cannot write mob file!\r\n", 'G', COM_BUILDER, TRUE);
                fclose(mob_file);
                return;
            }

            mob = (mob_proto + rmob_num);
            attack = GET_ATTACKS(mob);
            equipment = GET_EQUIP(mob);
            action = GET_ACTION(mob);
            mob_prog = mob_index[rmob_num].mobprogs;

            /*. Clean up strings .*/
            strcpy(buf1, GET_LDESC(mob));
            strip_string(buf1);
            if (GET_DDESC(mob)) {
                strcpy(buf2, GET_DDESC(mob));
                strip_string(buf2);
            } else
                strcpy(buf2, "");

            fprintf(mob_file, "%s~\n"
                    "%s~\n"
                    "%s~\n"
                    "%s~\n"
                    "%ld %ld %i X\n"
                    "%d %d %i %dd%d+%d %dd%d+%d\n"
                    "%d %d\n" /*. Gold & Exp are longs in my mud, ignore any warning .*/
                    "%d %d %d %d %d %d\n", GET_ALIAS(mob), GET_SDESC(mob), buf1, buf2, MOB_FLAGS(mob), AFF_FLAGS(mob), GET_ALIGNMENT(mob), GET_LEVEL(mob), GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob), GET_GOLD(mob), GET_EXP(mob), GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_CLASS(mob), GET_RACE(mob), GET_SIZE(mob));

            while (attack) {
                fprintf(mob_file, "T %d %dd%d+%d %d\n", attack->attacks, attack->nodice, attack->sizedice, attack->damroll, attack->attack_type);
                attack = attack->next;
            }

            while (action) {
                fprintf(mob_file, "A %d %d %s\n", action->chance, action->minpos, action->action);
                action = action->next;
            }

            while (equipment) {
                fprintf(mob_file, "E %d %d %d %d\n", equipment->pos, equipment->chance, equipment->vnum, equipment->max);
                equipment = equipment->next;
            }

            /*. Deal with Extra stats in case they are there .*/
            if ((GET_STR(mob) != 11) && (GET_STR(mob) < 19))
                fprintf(mob_file, "Str: %d\n", (GET_STR(mob) * 5));
            else if ((GET_STR(mob) > 18) && (GET_STR(mob) != 50))
                fprintf(mob_file, "Str: 100\n");
            if ((GET_DEX(mob) != 11) && (GET_DEX(mob) < 19)) {
                fprintf(mob_file, "Dex: %d\n", (GET_DEX(mob) * 5));
                fprintf(mob_file, "Agi: %d\n", (GET_DEX(mob) * 5));
            } else if ((GET_DEX(mob) > 18) && (GET_DEX(mob) != 50)) {
                fprintf(mob_file, "Dex: 100\n");
                fprintf(mob_file, "Agi: 100\n");
            }
            if ((GET_INT(mob) != 11) && (GET_INT(mob) < 19))
                fprintf(mob_file, "Int: %d\n", (GET_INT(mob) * 5));
            else if ((GET_INT(mob) > 18) && (GET_INT(mob) != 50))
                fprintf(mob_file, "Int: 100\n");
            if ((GET_WIS(mob) != 11) && (GET_WIS(mob) < 19))
                fprintf(mob_file, "Wis: %d\n", (GET_WIS(mob) * 5));
            else if ((GET_WIS(mob) > 18) && (GET_WIS(mob) != 50))
                fprintf(mob_file, "Wis: 100\n");
            if ((GET_CON(mob) != 11) && (GET_CON(mob) < 19))
                fprintf(mob_file, "Con: %d\n", (GET_CON(mob) * 5));
            else if ((GET_CON(mob) > 18) && (GET_CON(mob) != 50))
                fprintf(mob_file, "Con: 100\n");

            /*. Deal with Mob Progs .*/
            while (mob_prog) {
                switch (mob_prog->type) {
                case IN_FILE_PROG:
                    fprintf(mob_file, ">in_file_prog");
                    break;
                case ACT_PROG:
                    fprintf(mob_file, ">act_prog");
                    break;
                case SPEECH_PROG:
                    fprintf(mob_file, ">speech_prog");
                    break;
                case RAND_PROG:
                    fprintf(mob_file, ">rand_prog");
                    break;
                case FIGHT_PROG:
                    fprintf(mob_file, ">fight_prog");
                    break;
                case HITPRCNT_PROG:
                    fprintf(mob_file, ">hitprcnt_prog");
                    break;
                case DEATH_PROG:
                    fprintf(mob_file, ">death_prog");
                    break;
                case ENTRY_PROG:
                    fprintf(mob_file, ">entry_prog");
                    break;
                case GREET_PROG:
                    fprintf(mob_file, ">greet_prog");
                    break;
                case ALL_GREET_PROG:
                    fprintf(mob_file, ">all_greet_prog");
                    break;
                case GIVE_PROG:
                    fprintf(mob_file, ">give_prog");
                    break;
                case BRIBE_PROG:
                    fprintf(mob_file, ">bribe_prog");
                    break;
                case SHOUT_PROG:
                    fprintf(mob_file, ">shout_prog");
                    break;
                case HOLLER_PROG:
                    fprintf(mob_file, ">holler_prog");
                    break;
                case TELL_PROG:
                    fprintf(mob_file, ">tell_prog");
                    break;
                case TIME_PROG:
                    fprintf(mob_file, ">time_prog");
                    break;
                }
                strcpy(buf1, mob_prog->arglist);
                strip_string(buf1);
                strcpy(buf2, mob_prog->comlist);
                strip_string(buf2);
                fprintf(mob_file, " %s~\n%s", buf1, buf2);
                mob_prog = mob_prog->next;
                if (!mob_prog)
                    fprintf(mob_file, "~\n|\n");
                else
                    fprintf(mob_file, "~\n");
            }
        }
    }
    fclose(mob_file);
}
示例#16
0
/* do_simple_move assumes that there is no master, no followers and that the
 * direction exists. It returns 1 for success, 0 if failure. */
int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{
  char throwaway[MAX_INPUT_LENGTH] = ""; /* Functions assume writable. */
  room_rnum was_in = IN_ROOM(ch);
  int need_movement;

  /* Check for special routines (North is 1 in command list, but 0 here) Note
   * -- only check if following; this avoids 'double spec-proc' bug */
  if (need_specials_check && special(ch, dir + 1, throwaway))
    return (0);

  /* blocked by a leave trigger ? */
  if (!leave_mtrigger(ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;
  if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;
  if (!leave_otrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;
  /* charmed? */
  if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && IN_ROOM(ch) == IN_ROOM(ch->master)) {
    send_to_char(ch, "The thought of leaving your master makes you weep.\r\n");
    act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM);
    return (0);
  }

  /* if this room or the one we're going to needs a boat, check for one */
  if ((SECT(IN_ROOM(ch)) == SECT_WATER_NOSWIM) ||
      (SECT(EXIT(ch, dir)->to_room) == SECT_WATER_NOSWIM)) {
    if (!has_boat(ch)) {
      send_to_char(ch, "You need a boat to go there.\r\n");
      return (0);
    }
  }

  /* If this room or the one we're going to needs flight, check for it. */
  if ((SECT(IN_ROOM(ch)) == SECT_FLYING) || (SECT(EXIT(ch, dir)->to_room) == SECT_FLYING)) {
    if (!has_flight(ch)) {
      send_to_char(ch, "You need to be flying to go there!\r\n");
      return (0);
    }
  }

  /* If this room or the one we're going to needs scuba, check for it. */
  if ((SECT(IN_ROOM(ch)) == SECT_UNDERWATER) || (SECT(EXIT(ch, dir)->to_room) == SECT_UNDERWATER)) {
    if (!has_scuba(ch)) {
      send_to_char(ch, "You need to be able to breathe water to go there!\r\n");
      return (0);
    }
  }

  /* move points needed is avg. move loss for src and destination sect type */
  need_movement = (movement_loss[SECT(IN_ROOM(ch))] +
		   movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2;

  if (GET_MOVE(ch) < need_movement && !IS_NPC(ch)) {
    if (need_specials_check && ch->master)
      send_to_char(ch, "You are too exhausted to follow.\r\n");
    else
      send_to_char(ch, "You are too exhausted.\r\n");

    return (0);
  }
  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_ATRIUM)) {
    if (!House_can_enter(ch, GET_ROOM_VNUM(EXIT(ch, dir)->to_room))) {
      send_to_char(ch, "That's private property -- no trespassing!\r\n");
      return (0);
    }
  }
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_TUNNEL) &&
      num_pc_in_room(&(world[EXIT(ch, dir)->to_room])) >= CONFIG_TUNNEL_SIZE) {
    if (CONFIG_TUNNEL_SIZE > 1)
      send_to_char(ch, "There isn't enough room for you to go there!\r\n");
    else
      send_to_char(ch, "There isn't enough room there for more than one person!\r\n");
    return (0);
  }
  /* Mortals and low level gods cannot enter greater god rooms. */
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_GODROOM) &&
	GET_LEVEL(ch) < LVL_GOD) {
    send_to_char(ch, "You aren't godly enough to use that room!\r\n");
    return (0);
  }

  /* Now we know we're allowed to go into the room. */
  if (GET_LEVEL(ch) < LVL_IMMORT && !IS_NPC(ch))
    GET_MOVE(ch) -= need_movement;

  if (!AFF_FLAGGED(ch, AFF_SNEAK)) {
    char buf2[MAX_STRING_LENGTH];

    snprintf(buf2, sizeof(buf2), "$n leaves %s.", dirs[dir]);
    act(buf2, TRUE, ch, 0, 0, TO_ROOM);
  }
  was_in = IN_ROOM(ch);
  char_from_room(ch);
  char_to_room(ch, world[was_in].dir_option[dir]->to_room);

  /* move them first, then move them back if they aren't allowed to go. Also,
   * see if an entry trigger disallows the move */
  if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir)) {
    char_from_room(ch);
    char_to_room(ch, was_in);
    return 0;
  }

  if (!AFF_FLAGGED(ch, AFF_SNEAK))
    act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM);

  if (ch->desc != NULL)
    look_at_room(ch, 0);

  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) {
    mudlog(BRF, LVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(IN_ROOM(ch)), world[IN_ROOM(ch)].name);
    death_cry(ch);
    extract_char(ch);
    return (0);
  }

  entry_memory_mtrigger(ch);
  if (!greet_mtrigger(ch, dir)) {
    char_from_room(ch);
    char_to_room(ch, was_in);
    look_at_room(ch, 0);
  } else greet_memory_mtrigger(ch);

  return (1);
}
示例#17
0
void
mob_char_indirect (CHAR_DATA * mob, char *token, int *value, int *type)
{
	CHAR_DATA *ch;
	CHAR_DATA *person;
	int i;

	struct ind_data_t
	{
		int which_case;
		char ind[15];
		int type;
	} ind_data[] =
	{
		{
			0, "str", MP_TYPE_INTEGER},
			{
				1, "dex", MP_TYPE_INTEGER},
				{
					2, "int", MP_TYPE_INTEGER},
					{
						3, "con", MP_TYPE_INTEGER},
						{
							4, "wil", MP_TYPE_INTEGER},
							{
								5, "aur", MP_TYPE_INTEGER},
								{
									6, "hit", MP_TYPE_INTEGER},
									{
										7, "maxhit", MP_TYPE_INTEGER},
										{
											8, "moves", MP_TYPE_INTEGER},
											{
												9, "maxmoves", MP_TYPE_INTEGER},
												{
													10, "deity", MP_TYPE_INTEGER},
													{
														11, "circle", MP_TYPE_INTEGER},
														{
															12, "race", MP_TYPE_INTEGER},
															{
																13, "sex", MP_TYPE_INTEGER},
																{
																	14, "clan_1", MP_TYPE_INTEGER},
																	{
																		15, "piety", MP_TYPE_INTEGER},
																		{
																			16, "offense", MP_TYPE_INTEGER},
																			{
																				17, "clan_2", MP_TYPE_INTEGER},
																				{
																					18, "fightmode", MP_TYPE_INTEGER},
																					{
																						19, "next_in_room", MP_TYPE_CHAR_DATA},
																						{
																							20, "name", MP_TYPE_STRING},
																							{
																								21, "level", MP_TYPE_INTEGER},
																								{
																									22, "fighting", MP_TYPE_CHAR_DATA},
																									{
																										23, "realname", MP_TYPE_STRING},
																										{
																											24, "in_room", MP_TYPE_INTEGER},
																											{
																												25, "equip", MP_TYPE_OBJ_DATA},
																												{
																													26, "inv", MP_TYPE_OBJ_DATA},
																													{
																														27, "reset_room", MP_TYPE_INTEGER},
																														{
																															28, "prisoner", MP_TYPE_CHAR_DATA},
																															{
																																0, "\0", 0}
	};

	*type = -1;

	if (!*value)
		return;

	ch = (CHAR_DATA *) * value;

	for (i = 0; *ind_data[i].ind; i++)
	{
		if (!str_cmp (ind_data[i].ind, token))
			break;
	}

	if (!*ind_data[i].ind)
		return;

	*type = ind_data[i].type;

	switch (ind_data[i].which_case)
	{
	case 0:
		*value = GET_STR (ch);
		break;
	case 1:
		*value = GET_DEX (ch);
		break;
	case 2:
		*value = GET_INT (ch);
		break;
	case 3:
		*value = GET_CON (ch);
		break;
	case 4:
		*value = GET_WIL (ch);
		break;
	case 5:
		*value = GET_AUR (ch);
		break;
	case 6:
		*value = GET_HIT (ch);
		break;
	case 7:
		*value = GET_MAX_HIT (ch);
		break;
	case 8:
		*value = GET_MOVE (ch);
		break;
	case 9:
		*value = GET_MAX_MOVE (ch);
		break;
	case 10:
		*value = ch->deity;
		break;
	case 11:
		*value = ch->circle;
		break;
	case 12:
		*value = ch->race;
		break;
	case 13:
		*value = ch->sex;
		break;
	case 14:
		*value = 0;		/* ch->clan_1; */
		break;
	case 15:
		*value = ch->ppoints;
		break;
	case 16:
		*value = ch->offense;
		break;
	case 17:
		*value = 0;		/* ch->clan_2; */
		break;
	case 18:
		*value = ch->fight_mode;
		break;
	case 19:
		if (!is_he_here (mob, ch, 0))
			person = NULL;
		else
		{
			person = ch->next_in_room;

			while (person && !CAN_SEE (mob, person))
				person = person->next_in_room;
		}

		*value = (long int) person;

		break;

	case 20:
		*value = (long int) ch->short_descr;
		break;
	case 21:
		*value = GET_TRUST (ch);
		break;
	case 22:
		*value = (long int) ch->fighting;
		break;
	case 23:
		*value = (long int) GET_NAME (ch);
		break;
	case 24:
		*value = ch->in_room;
		break;
	case 25:
		*value = (long int) ch->equip;
		break;
	case 26:
		if (ch->right_hand)
			*value = (long int) ch->right_hand;
		else
			*value = (long int) ch->left_hand;
		break;
	case 27:
		if (ch->pc)
			*value = 0;

		else if (ch->mob->reset_zone != 0 || ch->mob->reset_cmd != 0)
			*value = zone_table[ch->mob->reset_zone].cmd[ch->mob->reset_cmd].arg1;
		else
			*value = 0;
		break;
	case 28:
		*value = (long int) (IS_SUBDUER (ch) ? ch->subdue : NULL);
		break;
	}
}
示例#18
0
文件: medit.c 项目: vedicveko/Aarait
void medit_parse(struct descriptor_data *d, char *arg)
{
  int i = -1;
  char *oldtext = NULL;

  if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) {
    i = atoi(arg);
    if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) {
      SEND_TO_Q("Field must be numerical, try again : ", d);
      return;
    }
  } else {	/* String response. */
    if (!genolc_checkstring(d, arg))
      return;
  }
  switch (OLC_MODE(d)) {
/*-------------------------------------------------------------------*/
  case MEDIT_CONFIRM_SAVESTRING:
    /*
     * Ensure mob has MOB_ISNPC set or things will go pear shaped.
     */
    SET_BIT(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC);
    switch (*arg) {
    case 'y':
    case 'Y':
      /*
       * Save the mob in memory and to disk.
       */
      SEND_TO_Q("Saving mobile to memory.\r\n", d);
      medit_save_internally(d);
      sprintf(buf, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d));
      mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE);
      /* FALL THROUGH */
    case 'n':
    case 'N':
      cleanup_olc(d, CLEANUP_ALL);
      return;
    default:
      SEND_TO_Q("Invalid choice!\r\n", d);
      SEND_TO_Q("Do you wish to save the mobile? : ", d);
      return;
    }
    break;

/*-------------------------------------------------------------------*/
  case MEDIT_MAIN_MENU:
    i = 0;
    switch (*arg) {
    case 'q':
    case 'Q':
      if (OLC_VAL(d)) {	/* Anything been changed? */
	SEND_TO_Q("Do you wish to save the changes to the mobile? (y//n) : ", d);
	OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING;
      } else
	cleanup_olc(d, CLEANUP_ALL);
      return;
    case '1':
      OLC_MODE(d) = MEDIT_SEX;
      medit_disp_sex(d);
      return;
    case '2':
      OLC_MODE(d) = MEDIT_ALIAS;
      i--;
      break;
    case '3':
      OLC_MODE(d) = MEDIT_S_DESC;
      i--;
      break;
    case '4':
      OLC_MODE(d) = MEDIT_L_DESC;
      i--;
      break;
    case '5':
      OLC_MODE(d) = MEDIT_D_DESC;
      send_editor_help(d);
      SEND_TO_Q("Enter mob description:\r\n\r\n", d);
      if (OLC_MOB(d)->player.description) {
	SEND_TO_Q(OLC_MOB(d)->player.description, d);
	oldtext = str_dup(OLC_MOB(d)->player.description);
      }
      string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext);
      OLC_VAL(d) = 1;
      return;
    case '6':
      OLC_MODE(d) = MEDIT_LEVEL;
      i++;
      break;
    case '7':
      OLC_MODE(d) = MEDIT_ALIGNMENT;
      i++;
      break;
    case '8':
      OLC_MODE(d) = MEDIT_HITROLL;
      i++;
      break;
    case '9':
      OLC_MODE(d) = MEDIT_DAMROLL;
      i++;
      break;
    case 'a':
    case 'A':
      OLC_MODE(d) = MEDIT_NDD;
      i++;
      break;
    case 'b':
    case 'B':
      OLC_MODE(d) = MEDIT_SDD;
      i++;
      break;
    case 'c':
    case 'C':
      OLC_MODE(d) = MEDIT_NUM_HP_DICE;
      i++;
      break;
    case 'd':
    case 'D':
      OLC_MODE(d) = MEDIT_SIZE_HP_DICE;
      i++;
      break;
    case 'e':
    case 'E':
      OLC_MODE(d) = MEDIT_ADD_HP;
      i++;
      break;
    case 'f':
    case 'F':
      OLC_MODE(d) = MEDIT_AC;
      i++;
      break;
    case 'g':
    case 'G':
      OLC_MODE(d) = MEDIT_EXP;
      i++;
      break;
    case 'h':
    case 'H':
      OLC_MODE(d) = MEDIT_GOLD;
      i++;
      break;
    case 'i':
    case 'I':
      OLC_MODE(d) = MEDIT_POS;
      medit_disp_positions(d);
      return;
    case 'j':
    case 'J':
      OLC_MODE(d) = MEDIT_DEFAULT_POS;
      medit_disp_positions(d);
      return;
    case 'k':
    case 'K':
      OLC_MODE(d) = MEDIT_ATTACK;
      medit_disp_attack_types(d);
      return;
    case 'l':
    case 'L':
      OLC_MODE(d) = MEDIT_NPC_FLAGS;
      medit_disp_mob_flags(d);
      return;
    case 'm':
    case 'M':
      OLC_MODE(d) = MEDIT_AFF_FLAGS;
      medit_disp_aff_flags(d);
      return;
    case 'n':
    case 'N':
     OLC_MODE(d) = MEDIT_CLASS;
     medit_disp_class_flags(d);
     return;
    case 'r':
    case 'R':
     OLC_MODE(d) = MEDIT_RACE;
     medit_disp_race_flags(d);
     return;
    case 's':
    case 'S':
     OLC_MODE(d) = MEDIT_MSIZE;
     medit_disp_size_flags(d);
     return;
    case 'w':
    case 'W':
     OLC_MODE(d) = MEDIT_WEIGHT;
      send_to_char("Please enter the mobiles weight in pounds: ", d->character); 
     return;

#if CONFIG_OASIS_MPROG
    case 'p':
    case 'P':
      OLC_MODE(d) = MEDIT_MPROG;
      medit_disp_mprog(d);
      return;
#endif
    default:
      medit_disp_menu(d);
      return;
    }
    if (i == 0)
      break;
    else if (i == 1)
      SEND_TO_Q("\r\nEnter new value : ", d);
    else if (i == -1)
      SEND_TO_Q("\r\nEnter new text :\r\n] ", d);
    else
      SEND_TO_Q("Oops...\r\n", d);
    return;
/*-------------------------------------------------------------------*/
  case MEDIT_ALIAS:
    if (GET_ALIAS(OLC_MOB(d)))
      free(GET_ALIAS(OLC_MOB(d)));
    GET_ALIAS(OLC_MOB(d)) = str_udup(arg);
    break;
/*-------------------------------------------------------------------*/
  case MEDIT_S_DESC:
    if (GET_SDESC(OLC_MOB(d)))
      free(GET_SDESC(OLC_MOB(d)));
    GET_SDESC(OLC_MOB(d)) = str_udup(arg);
    break;
/*-------------------------------------------------------------------*/
  case MEDIT_L_DESC:
    if (GET_LDESC(OLC_MOB(d)))
      free(GET_LDESC(OLC_MOB(d)));
    if (arg && *arg) {
      strcpy(buf, arg);
      strcat(buf, "\r\n");
      GET_LDESC(OLC_MOB(d)) = str_dup(buf);
    } else
      GET_LDESC(OLC_MOB(d)) = str_dup("undefined");

    break;
/*-------------------------------------------------------------------*/
  case MEDIT_D_DESC:
    /*
     * We should never get here.
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog("SYSERR: OLC: medit_parse(): Reached D_DESC case!", BRF, LVL_BUILDER, TRUE);
    SEND_TO_Q("Oops...\r\n", d);
    break;
/*-------------------------------------------------------------------*/
#if CONFIG_OASIS_MPROG
  case MEDIT_MPROG_COMLIST:
    /*
     * We should never get here, but if we do, bail out.
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog("SYSERR: OLC: medit_parse(): Reached MPROG_COMLIST case!", BRF, LVL_BUILDER, TRUE);
    break;
#endif
/*-------------------------------------------------------------------*/
  case MEDIT_NPC_FLAGS:
    if ((i = atoi(arg)) <= 0)
      break;
    else if (i <= NUM_MOB_FLAGS)
      TOGGLE_BIT(MOB_FLAGS(OLC_MOB(d)), 1 << (i - 1));
    medit_disp_mob_flags(d);
    return;
/*-------------------------------------------------------------------*/
  case MEDIT_AFF_FLAGS:
    if ((i = atoi(arg)) <= 0)
      break;
    else if (i <= NUM_AFF_FLAGS)
      TOGGLE_BIT(AFF_FLAGS(OLC_MOB(d)), 1 << (i - 1));
    medit_disp_aff_flags(d);
    return;
/*-------------------------------------------------------------------*/
#if CONFIG_OASIS_MPROG
  case MEDIT_MPROG:
    if ((i = atoi(arg)) == 0)
      medit_disp_menu(d);
    else if (i == OLC_MTOTAL(d)) {
      struct mob_prog_data *temp;
      CREATE(temp, struct mob_prog_data, 1);
      temp->next = OLC_MPROGL(d);
      temp->type = -1;
      temp->arglist = NULL;
      temp->comlist = NULL;
      OLC_MPROG(d) = temp;
      OLC_MPROGL(d) = temp;
      OLC_MODE(d) = MEDIT_CHANGE_MPROG;
      medit_change_mprog (d);
    } else if (i < OLC_MTOTAL(d)) {
      struct mob_prog_data *temp;
      int x = 1;
      for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next)
        x++;
      OLC_MPROG(d) = temp;
      OLC_MODE(d) = MEDIT_CHANGE_MPROG;
      medit_change_mprog (d);
    } else if (i == (OLC_MTOTAL(d) + 1)) {
      SEND_TO_Q("Which mob prog do you want to purge? ", d);
      OLC_MODE(d) = MEDIT_PURGE_MPROG;
    } else
      medit_disp_menu(d);
    return;

  case MEDIT_PURGE_MPROG:
    if ((i = atoi(arg)) > 0 && i < OLC_MTOTAL(d)) {
      struct mob_prog_data *temp;
      int x = 1;

      for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next)
	x++;
      OLC_MPROG(d) = temp;
      REMOVE_FROM_LIST(OLC_MPROG(d), OLC_MPROGL(d), next);
      free(OLC_MPROG(d)->arglist);
      free(OLC_MPROG(d)->comlist);
      free(OLC_MPROG(d));
      OLC_MPROG(d) = NULL;
      OLC_VAL(d) = 1;
    }
    medit_disp_mprog(d);
    return;

  case MEDIT_CHANGE_MPROG:
    if ((i = atoi(arg)) == 1)
      medit_disp_mprog_types(d);
    else if (i == 2) {
      SEND_TO_Q("Enter new arg list: ", d);
      OLC_MODE(d) = MEDIT_MPROG_ARGS;
    } else if (i == 3) {
      SEND_TO_Q("Enter new mob prog commands:\r\n", d);
      /*
       * Pass control to modify.c for typing.
       */
      OLC_MODE(d) = MEDIT_MPROG_COMLIST;
      if (OLC_MPROG(d)->comlist) {
        SEND_TO_Q(OLC_MPROG(d)->comlist, d);
        oldtext = str_dup(OLC_MPROG(d)->comlist);
      }
      string_write(d, &OLC_MPROG(d)->comlist, MAX_STRING_LENGTH, 0, oldtext);
      OLC_VAL(d) = 1;
    } else
      medit_disp_mprog(d);
    return;
#endif

/*-------------------------------------------------------------------*/

/*
 * Numerical responses.
 */

#if CONFIG_OASIS_MPROG
  case MEDIT_MPROG_TYPE:
    /*
     * This calculation may be off by one too many powers of 2?
     * Someone who actually uses MobProgs will have to check.
     */
    OLC_MPROG(d)->type = (1 << LIMIT(atoi(arg), 0, NUM_PROGS - 1));
    OLC_VAL(d) = 1;
    medit_change_mprog(d);
    return;

  case MEDIT_MPROG_ARGS:
    OLC_MPROG(d)->arglist = str_dup(arg);
    OLC_VAL(d) = 1;
    medit_change_mprog(d);
    return;
#endif

  case MEDIT_SEX:
    GET_SEX(OLC_MOB(d)) = LIMIT(i, 0, NUM_GENDERS - 1);
    break;

  case MEDIT_HITROLL:
    GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50);
    break;

  case MEDIT_DAMROLL:
    GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50);
    break;

  case MEDIT_NDD:
    GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30);
    break;

  case MEDIT_SDD:
    GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127);
    break;

  case MEDIT_NUM_HP_DICE:
    GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30);
    break;

  case MEDIT_SIZE_HP_DICE:
    GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000);
    break;

  case MEDIT_ADD_HP:
    GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000);
    break;

  case MEDIT_AC:
    GET_AC(OLC_MOB(d)) = LIMIT(i, 10, 200);
    break;

  case MEDIT_EXP:
    GET_EXP(OLC_MOB(d)) = MAX(i, 0);
    break;

  case MEDIT_GOLD:
    add_money_to_char(OLC_MOB(d), MAX(i, 0), COPPER_COINS);
    break;

  case MEDIT_POS:
    GET_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1);
    break;

  case MEDIT_DEFAULT_POS:
    GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1);
    break;

  case MEDIT_ATTACK:
    GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1);
    break;

  case MEDIT_LEVEL:
    GET_LEVEL(OLC_MOB(d)) = i;
    break;

  case MEDIT_ALIGNMENT:
    GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000);
    break;

  case MEDIT_CLASS:
    GET_CLASS(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_CLASS, atoi(arg)));
    break;
  case MEDIT_RACE:
    GET_RACE(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_RACE, atoi(arg)));
    // INT, WIS, STR, DEX, CON, CHA
    GET_INT(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][0];
    GET_WIS(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][1];
    GET_STR(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][2];
    GET_DEX(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][3];
    GET_CON(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][4];
    GET_CHA(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][5];
    GET_HIT(OLC_MOB(d)) = mob_hp[i][0];
    GET_MANA(OLC_MOB(d)) = mob_hp[i][2];
    GET_MOVE(OLC_MOB(d)) = mob_hp[i][3];
    break;

  case MEDIT_WEIGHT:
    GET_MOB_WEIGHT(OLC_MOB(d)) = LIMIT(i, 1, 1000);
    break;

  case MEDIT_MSIZE:
    GET_MOB_SIZE(OLC_MOB(d)) = atoi(arg);
    break;

/*-------------------------------------------------------------------*/
  default:
    /*
     * We should never get here.
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog("SYSERR: OLC: medit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE);
    SEND_TO_Q("Oops...\r\n", d);
    break;
  }
示例#19
0
文件: medit.c 项目: vedicveko/Aarait
/*
 * Display main menu.
 */
void medit_disp_menu(struct descriptor_data *d)
{
  struct char_data *mob;

  mob = OLC_MOB(d);
  get_char_colors(d->character);
  clear_screen(d);

  sprintf(buf,
	  "-- Mob Number:  [%s%d%s]\r\n"
	  "%s1%s) Sex: %s%-7.7s%s	         %s2%s) Alias: %s%s\r\n"
	  "%s3%s) S-Desc: %s%s\r\n"
	  "%s4%s) L-Desc:-\r\n%s%s"
	  "%s5%s) D-Desc:-\r\n%s%s"
     "%s6%s) Level:       [%s%4d%s],  %s7%s) Alignment:    [%s%4d%s]\r\n"
     "%s8%s) HR//SKY:      [%s%4d%s],  %s9%s) DR//FD:        [%s%4d%s]\r\n"
     "%sA%s) NumDamDice:  [%s%4d%s],  %sB%s) SizeDamDice:  [%s%4d%s]\r\n"
	  "%sC%s) Num HP Dice: [%s%4d%s],  %sD%s) Size HP Dice: [%s%4d%s],  %sE%s) HP Bonus: [%s%5d%s]\r\n"
	  "%sF%s) Armor Class: [%s%4d%s],  %sG%s) Exp:     [%s%9d%s],  %sH%s) Gold:  [%s%8d%s]\r\n",

	  cyn, OLC_NUM(d), nrm,
	  grn, nrm, yel, genders[(int)GET_SEX(mob)], nrm,
	  grn, nrm, yel, GET_ALIAS(mob),
	  grn, nrm, yel, GET_SDESC(mob),
	  grn, nrm, yel, GET_LDESC(mob),
	  grn, nrm, yel, GET_DDESC(mob),
	  grn, nrm, cyn, GET_LEVEL(mob), nrm,
	  grn, nrm, cyn, GET_ALIGNMENT(mob), nrm,
	  grn, nrm, cyn, GET_HITROLL(mob), nrm,
	  grn, nrm, cyn, GET_DAMROLL(mob), nrm,
	  grn, nrm, cyn, GET_NDD(mob), nrm,
	  grn, nrm, cyn, GET_SDD(mob), nrm,
	  grn, nrm, cyn, GET_HIT(mob), nrm,
	  grn, nrm, cyn, GET_MANA(mob), nrm,
	  grn, nrm, cyn, GET_MOVE(mob), nrm,
	  grn, nrm, cyn, GET_AC(mob), nrm,
	  grn, nrm, cyn, GET_EXP(mob), nrm,
	  grn, nrm, cyn, convert_all_to_copper(mob), nrm
	  );
  SEND_TO_Q(buf, d);

  sprintbit(MOB_FLAGS(mob), action_bits, buf1);
  sprintbit(AFF_FLAGS(mob), affected_bits, buf2);
  sprintf(buf,
	  "%sI%s) Position  : %s%s\r\n"
	  "%sJ%s) Default   : %s%s\r\n"
	  "%sK%s) Attack    : %s%s\r\n"
          "%sN%s) Class     : %s%s\r\n"
          "%sR%s) Race      : %s%s\r\n"
          "%sS%s) Size      : %s%d\r\n"
          "%sW%s) Weight    : %s%d\r\n"
	  "%sL%s) NPC Flags : %s%s\r\n"
	  "%sM%s) AFF Flags : %s%s\r\n"
#if CONFIG_OASIS_MPROG
	  "%sP%s) Mob Progs : %s%s\r\n"
#endif
	  "%sQ%s) Quit\r\n"
	  "Enter choice : ",

	  grn, nrm, yel, position_types[(int)GET_POS(mob)],
	  grn, nrm, yel, position_types[(int)GET_DEFAULT_POS(mob)],
	  grn, nrm, yel, attack_hit_text[GET_ATTACK(mob)].singular,
          grn, nrm, cyn, npc_class_types[(int)GET_CLASS(mob)],
          grn, nrm, cyn, npc_race_types[(int)GET_RACE(mob)],
          grn, nrm, cyn, GET_MOB_SIZE(mob),
          grn, nrm, cyn, GET_MOB_WEIGHT(mob), 
	  grn, nrm, cyn, buf1,
	  grn, nrm, cyn, buf2,
#if CONFIG_OASIS_MPROG
	  grn, nrm, cyn, (OLC_MPROGL(d) ? "Set." : "Not Set."),
#endif
	  grn, nrm
	  );
  SEND_TO_Q(buf, d);

  OLC_MODE(d) = MEDIT_MAIN_MENU;
}
示例#20
0
bool
psionic_mob_fight(struct creature *ch, struct creature *precious_vict)
{
    struct creature *vict = NULL;

    if (!is_fighting(ch))
        return false;

    // pick an enemy
    if (!(vict = choose_opponent(ch, precious_vict)))
        return false;

    int aggression = calculate_mob_aggression(ch, vict);

    // Psions can't really do anything when there's a psishield in place
    if (AFF3_FLAGGED(vict, AFF3_PSISHIELD)
        && can_cast_spell(ch, SPELL_PSIONIC_SHATTER)) {
        cast_spell(ch, vict, NULL, NULL, SPELL_PSIONIC_SHATTER);
        return true;
    }
    // Prioritize healing with aggression
    if (GET_HIT(ch) < (GET_MAX_HIT(ch) * MIN(20, MAX(80, aggression)) / 100)
        && can_cast_spell(ch, SPELL_WOUND_CLOSURE)) {
        cast_spell(ch, ch, NULL, NULL, SPELL_WOUND_CLOSURE);
        return true;
    }

    if (aggression > 75) {
        // extremely aggressive - just attack hard
        if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        } else if (GET_POSITION(vict) > POS_SITTING
            && can_cast_spell(ch, SPELL_EGO_WHIP)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP);
            return true;
        }
    }
    if (aggression > 50) {
        // somewhat aggressive - balance attacking with crippling
        if (GET_MANA(ch) < GET_MAX_MANA(ch) / 2
            && can_cast_spell(ch, SKILL_PSIDRAIN)
            && can_psidrain(ch, vict, NULL, false)) {
            perform_psidrain(ch, vict);
            return true;
        } else if (!affected_by_spell(vict, SPELL_PSYCHIC_CRUSH)
            && can_cast_spell(ch, SPELL_PSYCHIC_CRUSH)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_CRUSH);
            return true;
        } else if (!affected_by_spell(vict, SPELL_MOTOR_SPASM)
            && can_cast_spell(ch, SPELL_MOTOR_SPASM)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_MOTOR_SPASM);
            return true;
        } else if (!affected_by_spell(ch, SPELL_ADRENALINE)
            && can_cast_spell(ch, SPELL_ADRENALINE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_ADRENALINE);
            return true;
        } else if (GET_POSITION(vict) > POS_SITTING
            && can_cast_spell(ch, SPELL_EGO_WHIP)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP);
            return true;
        } else if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        }
    }
    if (aggression > 25) {
        // not very aggressive - play more defensively
        if (IS_PSIONIC(vict)
            && !affected_by_spell(ch, SPELL_PSYCHIC_RESISTANCE)
            && can_cast_spell(ch, SPELL_PSYCHIC_RESISTANCE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_PSYCHIC_RESISTANCE);
            return true;
        } else if (!IS_CONFUSED(vict)
            && can_cast_spell(ch, SPELL_CONFUSION)
            && (IS_MAGE(vict) || IS_PSIONIC(vict) || IS_CLERIC(vict) ||
                IS_KNIGHT(vict) || IS_PHYSIC(vict))) {
            cast_spell(ch, vict, NULL, NULL, SPELL_CONFUSION);
            return true;
        } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4
            && can_cast_spell(ch, SPELL_ENDURANCE)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_ENDURANCE);
            return true;
        } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4
            && can_cast_spell(ch, SPELL_DERMAL_HARDENING)) {
            cast_spell(ch, ch, NULL, NULL, SPELL_DERMAL_HARDENING);
            return true;
        } else if (!AFF2_FLAGGED(ch, AFF2_VERTIGO)
            && can_cast_spell(ch, SPELL_VERTIGO)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_VERTIGO);
            return true;
        } else if (!affected_by_spell(vict, SPELL_PSYCHIC_FEEDBACK)
            && can_cast_spell(ch, SPELL_PSYCHIC_FEEDBACK)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_FEEDBACK);
            return true;
        } else if (!affected_by_spell(vict, SPELL_WEAKNESS)
            && can_cast_spell(ch, SPELL_WEAKNESS)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_WEAKNESS);
            return true;
        } else if (!affected_by_spell(vict, SPELL_CLUMSINESS)
            && can_cast_spell(ch, SPELL_CLUMSINESS)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_CLUMSINESS);
            return true;
        } else if (can_cast_spell(ch, SKILL_PSIBLAST)) {
            perform_offensive_skill(ch, vict, SKILL_PSIBLAST);
            return true;
        }
    }
    if (aggression > 5) {
        // attempt to neutralize or get away
        if (GET_POSITION(vict) > POS_SLEEPING
            && can_cast_spell(ch, SPELL_MELATONIC_FLOOD)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_MELATONIC_FLOOD);
            return true;
        } else if (can_cast_spell(ch, SPELL_ASTRAL_SPELL)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_ASTRAL_SPELL);
            return true;
        } else if (can_cast_spell(ch, SPELL_AMNESIA)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_AMNESIA);
            return true;
        } else if (can_cast_spell(ch, SPELL_FEAR)) {
            cast_spell(ch, vict, NULL, NULL, SPELL_FEAR);
            return true;
        }
    }

    return false;
}
示例#21
0
文件: limits.c 项目: matthewbode/mg2
/* Update PCs, NPCs, and objects */
void point_update(void)
{
  struct char_data *i, *next_char;
  struct obj_data *j, *next_thing, *jj, *next_thing2;

  /* characters */
  for (i = character_list; i; i = next_char) {
    next_char = i->next;
	
    gain_condition(i, FULL, -1);
    gain_condition(i, DRUNK, -1);
    gain_condition(i, THIRST, -1);
	
    if (GET_POS(i) >= POS_STUNNED) {
      GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i));
      GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i));
      GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i));
      if (AFF_FLAGGED(i, AFF_POISON))
	if (damage(i, i, 2, SPELL_POISON) == -1)
	  continue;	/* Oops, they died. -gg 6/24/98 */
      if (GET_POS(i) <= POS_STUNNED)
	update_pos(i);
    } else if (GET_POS(i) == POS_INCAP) {
      if (damage(i, i, 1, TYPE_SUFFERING) == -1)
	continue;
    } else if (GET_POS(i) == POS_MORTALLYW) {
      if (damage(i, i, 2, TYPE_SUFFERING) == -1)
	continue;
    }
    if (!IS_NPC(i)) {
      update_char_objects(i);
      if (GET_LEVEL(i) < idle_max_level)
	check_idling(i);
    }
  }

  /* objects */
  for (j = object_list; j; j = next_thing) {
    next_thing = j->next;	/* Next in object list */

    /* If this is a corpse */
    if (IS_CORPSE(j)) {
      /* timer count down */
      if (GET_OBJ_TIMER(j) > 0)
	GET_OBJ_TIMER(j)--;

      if (!GET_OBJ_TIMER(j)) {

	if (j->carried_by)
	  act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
	else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
	  act("A quivering horde of maggots consumes $p.",
	      TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
	}
	for (jj = j->contains; jj; jj = next_thing2) {
	  next_thing2 = jj->next_content;	/* Next in inventory */
	  obj_from_obj(jj);

	  if (j->in_obj)
	    obj_to_obj(jj, j->in_obj);
	  else if (j->carried_by)
	    obj_to_room(jj, IN_ROOM(j->carried_by));
	  else if (IN_ROOM(j) != NOWHERE)
	    obj_to_room(jj, IN_ROOM(j));
	  else
	    core_dump();
	}
	extract_obj(j);
      }
    }
    /* If the timer is set, count it down and at 0, try the trigger */
    /* note to .rej hand-patchers: make this last in your point-update() */
    else if (GET_OBJ_TIMER(j)>0) {
      GET_OBJ_TIMER(j)--; 
      if (!GET_OBJ_TIMER(j))
        timer_otrigger(j);
    }
  }
}
示例#22
0
void
do_hex (CHAR_DATA * ch, char *argument, int cmd)
{
  int sn;
  int duration, modifier;
  CHAR_DATA *tch;
  char buf[MAX_STRING_LENGTH];

  if (!real_skill (ch, SKILL_HEX))
    {
      send_to_char ("You shiver at the thought.\n\r", ch);
      return;
    }

  argument = one_argument (argument, buf);

  if (!(tch = get_char_room_vis (ch, buf)))
    {
      send_to_char ("You don't see that person here.\n\r", ch);
      return;
    }

  if (IS_MORTAL (ch) && !IS_MORTAL (tch))
    {
      send_to_char
	("Immortals are total losers.  It can't get any worse for them.\n\r",
	 ch);
      return;
    }

  if (GET_HIT (ch) + GET_MOVE (ch) <= 35)
    {
      send_to_char
	("You can't concentrate hard enough for that right now.\n\r", ch);
      return;
    }

  sprintf (buf, "Hexing %s", tch->tname);
  weaken (ch, 0, 20, buf);
  sense_activity (ch, SKILL_HEX);

  if (!skill_use (ch, SKILL_HEX, 0))
    {
      send_to_char
	("You lose your concentration, and your malignant energies dissipate.\n",
	 ch);
      return;
    }

  act
    ("You channel a stream of malignant psychic energy into $N, entwining $M in an ethereal web of ill-fortune and grief.",
     false, ch, 0, tch, TO_CHAR | _ACT_FORMAT);
  act ("A chill runs down your spine.", false, ch, 0, tch, TO_VICT);

  sn = spell_lookup ("curse");

  modifier = ch->skills[SKILL_HEX] / 5 + number (1, 10);
  duration = ch->skills[SKILL_HEX] / 5 + number (1, 48);

  magic_add_affect (tch, MAGIC_AFFECT_CURSE, duration, modifier, 0, 0, sn);

  tch->curse += ch->skills[SKILL_HEX] / 5 + number (1, 5);
}
示例#23
0
/* nb, also mess up anyone affected by AFF_POISON */
void pulse_heal(void)
{
    CharData *ch;
    int gain = number(18,24);

    for (ch = character_list; ch; ch = ch->next) {
        if(ch->in_room == NOWHERE)
            continue;

        if(!(pvpFactor() > 1)) {
            if( GET_POS(ch) == POS_INCAP )      damage(ch, ch, 1, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_MORTALLYW )  damage(ch, ch, 2, TYPE_SUFFERING);
            else if( GET_POS(ch) == POS_DEAD) {
                if(IN_ARENA(ch) || IN_QUEST_FIELD(ch) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA) ||
                   ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG))
                    // If they're dying in the arena, they eventually get better (or killed by someone)
                {
                    GET_HIT(ch) = number(GET_HIT(ch), 1);
                    sendChar(ch, "You slowly recover.\r\n");
                    update_pos(ch);
                }
                else {
                    raw_kill(ch, NULL);
                    continue;
                }
            }
        }

        if (IS_AFFECTED(ch, AFF_PULSE_HIT))
            if (GET_HIT(ch) < GET_MAX_HIT(ch)) GET_HIT(ch) += gain;
        if (IS_AFFECTED(ch, AFF_PULSE_MANA))
            if (GET_MANA(ch) < GET_MAX_MANA(ch)) GET_MANA(ch) += gain;
        if (IS_AFFECTED(ch, AFF_POISON)) doPoison(ch);
        if (IS_AFFECTED(ch, AFF_DISEASE)) doDisease(ch);
	if (affected_by_spell(ch, SKILL_INVIGORATE)) doInvigorate(ch);
        if (IS_BOUNTY_HUNTER(ch) && GET_ADVANCE_LEVEL(ch) >= 1 && IS_AFFECTED(ch, AFF_HIDE)) GET_MOVE(ch) = MIN(GET_MOVE(ch) + 3*gain, GET_MAX_MOVE(ch));
        if (IS_PRESTIDIGITATOR(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + GET_ADVANCE_LEVEL(ch) * 2, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SPELL_HIPPOCRATIC_OATH)) GET_MANA(ch) = MIN(GET_MANA(ch) + 25, GET_MAX_MANA(ch));
        if (affected_by_spell(ch, SKILL_PET_MEND)) GET_HIT(ch) = MIN(GET_HIT(ch) * 115 / 100, GET_MAX_HIT(ch));
        if (IS_HOLY_PRIEST(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + 10 + 2*GET_ADVANCE_LEVEL(ch), GET_MAX_MANA(ch));

        /* The room might be poisoned! (Or later, otherwise dangerous) */
        if (ch->in_room != NOWHERE) {
            if (ROOM_FLAGGED(ch->in_room, ROOM_POISONED)) {
                if (!mag_savingthrow(ch, SAVING_SPELL)) {
                    act("$n chokes and gags!", TRUE, ch, 0, 0, TO_ROOM);
                    act("You choke and gag!", TRUE, ch, 0, 0, TO_CHAR);
                    add_affect( ch, ch, SPELL_POISON, 30, APPLY_NONE, 0, 5 TICKS,
                            AFF_POISON, FALSE, FALSE, FALSE, FALSE);
                }
            }
        }

        if(IS_DEFENDER(ch) && !affected_by_spell(ch, SKILL_DEFENDER_HEALTH))
            add_affect(ch, ch, SKILL_DEFENDER_HEALTH, GET_LEVEL(ch), APPLY_HIT, GET_ADVANCE_LEVEL(ch)*5, -1, FALSE, FALSE, FALSE, FALSE, FALSE);

    }
}
示例#24
0
文件: save.c 项目: sean/dominionmud
/*
 * Write the char to the file.
 *
 * @param ch the character to be written
 * @param fp the file to write to
 */
void fwrite_char( struct char_data *ch, FILE *fp )
{
  extern struct race_data * races;
  
  struct affected_type *paf;
  int          sn, i;
  
  fprintf( fp, "#%s\n", IS_NPC( ch ) ? "MOB" : "PLAYER"		);
  
  fprintf( fp, "Name        %s~\n",	GET_NAME(ch)			);
  fprintf( fp, "ShtDsc      %s~\n",	GET_SHORT_DESC(ch) ?
	   GET_SHORT_DESC(ch) : "" );
  fprintf( fp, "LngDsc      %s~\n",	GET_LONG_DESC(ch) ?
	   GET_LONG_DESC(ch) : "" );
  fprintf( fp, "Dscr        %s~\n",	GET_DESCRIPTION(ch) ?
	   GET_DESCRIPTION(ch) : "" );
  // fprintf( fp, "Prmpt       %s~\n",	ch->pcdata->prompt	);
  fprintf( fp, "Sx          %d\n",	GET_SEX(ch)			);
  fprintf( fp, "Race        %s~\n",	races[ (int)GET_RACE(ch) ].name );
  fprintf( fp, "Lvl         %d\n",	GET_LEVEL(ch)			);
  fprintf( fp, "Trst        %d\n",	GET_TRUST(ch)			);
  /*
    fprintf( fp, "Playd       %ld\n",
    GET_PLAYED(ch) + (int)( time( 0 ) - GET_LOGON(ch) )		);
  */
  // fprintf( fp, "Note        %ld\n",   (unsigned long)ch->last_note );
  fprintf( fp, "Room        %ld\n",
	   (  ch->in_room == NOWHERE && ch->was_in_room )
	   ? ch->was_in_room : ch->in_room );
  
  fprintf( fp, "HpMnMv      %d %d %d %d %d %d\n",
	   GET_HIT(ch), GET_MAX_HIT(ch),
	   GET_MANA(ch), GET_MAX_MANA(ch),
	   GET_MOVE(ch), GET_MAX_MOVE(ch) );
  fprintf( fp, "Gold        %ld\n",	GET_GOLD(ch)		);
  fprintf( fp, "Exp         %ld\n",	GET_EXP(ch)		);
  fprintf( fp, "Act         %lld\n",  PLR_FLAGS(ch)           );
  fprintf( fp, "Act2        %lld\n",  PLR2_FLAGS(ch)          );
  fprintf( fp, "Pref        %lld\n",  PRF_FLAGS(ch)		);
  fprintf( fp, "Pref2       %lld\n",  PRF2_FLAGS(ch)		);
  fprintf( fp, "AffdBy      %lld\n",	AFF_FLAGS(ch)		);
  fprintf( fp, "AffdBy2     %lld\n",	AFF2_FLAGS(ch)		);
  /* Bug fix from Alander */
  fprintf( fp, "Pos         %d\n",
	   GET_POS(ch) == POS_FIGHTING ? POS_STANDING : GET_POS(ch) );
  fprintf( fp, "Prac        %d\n",    GET_PRACTICES(ch)       );
  fprintf( fp, "PAlign      %d\n",	GET_PERMALIGN(ch)	);
  fprintf( fp, "CAlign      %d\n",	GET_ALIGNMENT(ch)	);
  fprintf( fp, "SavThr      " );
  for ( i = 0; i < NUM_SAVES; i++ )
    fprintf( fp, "%d%s",    GET_SAVE(ch, i), (i != NUM_SAVES-1 ? ", " : "\n")	);
  fprintf( fp, "Hitroll     %d\n",	GET_HITROLL(ch)		);
  fprintf( fp, "Damroll     %d\n",	GET_DAMROLL(ch)		);
  fprintf( fp, "Armr        " );
  for ( i = 0; i < ARMOR_LIMIT; i++ )
    fprintf( fp, "%d%s",   GET_AC(ch, i), (i != ARMOR_LIMIT-1 ? ", " : "\n") );
  fprintf( fp, "Wimp        %d\n",	GET_WIMP_LEV(ch)	);
  
  if ( IS_NPC( ch ) ) {
    fprintf( fp, "Vnum        %ld\n",	GET_MOB_VNUM(ch)	);
  } else {
    fprintf( fp, "Paswd       %s~\n",	GET_PASSWD(ch)		);
    fprintf( fp, "Poofin      %s~\n",	POOFIN(ch) ?
	     POOFIN(ch) : "" );
    fprintf( fp, "Poofout     %s~\n",	POOFOUT(ch) ?
	     POOFOUT(ch) : "" );
    fprintf( fp, "Ttle        %s~\n",	GET_TITLE(ch) ?
	     GET_TITLE(ch) : "" );
    fprintf( fp, "AtrPrm      %d/%d %d %d %d %d %d %d\n",
	     ch->real_abils.str,
	     ch->real_abils.str_add,
	     ch->real_abils.intel,
	     ch->real_abils.wis,
	     ch->real_abils.dex,
	     ch->real_abils.con,
	     ch->real_abils.cha,
	     ch->real_abils.will );
    
    fprintf( fp, "AtrMd       %d/%d %d %d %d %d %d %d\n",
	     ch->aff_abils.str, 
	     ch->aff_abils.str_add, 
	     ch->aff_abils.intel, 
	     ch->aff_abils.wis, 
	     ch->aff_abils.dex, 
	     ch->aff_abils.con, 
	     ch->aff_abils.cha, 
	     ch->aff_abils.will );
    
    fprintf( fp, "Conditions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_COND(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    fprintf( fp, "Addictions  " );
    for ( i = 0; i < MAX_COND; i++ )
      fprintf( fp, "%d%s", GET_ADDICT(ch, i), (i != MAX_COND-1 ? ", " : "\n") );
    
    for ( sn = 0; sn < MAX_SKILLS; sn++ ) {
      if ( skill_name( sn ) &&
           strcmp( skill_name( sn ), "!UNUSED!" ) &&
           GET_SKILL(ch, sn) > 0 ) {
	fprintf( fp, "Skill       %d '%s'\n",
		 GET_SKILL(ch, sn),
		 skill_name( sn ) );
      }
    }
  }
  
  for ( paf = ch->affected; paf; paf = paf->next )  {
    fprintf( fp, "Afft       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  for ( paf = ch->affected2; paf; paf = paf->next )  {
    fprintf( fp, "Afft2       %18s~ %3d %3d %3d %lld\n",
	     skill_name( paf->type ),
	     paf->duration,
	     paf->modifier,
	     paf->location,
	     paf->bitvector );
  }
  
  fprintf( fp, "End\n\n" );
  return;
}
示例#25
0
void regen_update( void ) {
    CharData *i, *next_char;
    int hit, mana, move;
    int vivify_level;

    for( i = character_list; i; i = next_char )
    {
        next_char = i->next;

        if(affected_by_spell(i, SKILL_EMACIATED) && (GET_COND(i, HUNGER) != 0 || IS_VAMPIRE(i)) && GET_COND(i, THIRST) != 0) {
            if(!affected_by_spell(i, SKILL_EMACIATED_MANA) && !affected_by_spell(i, SKILL_EMACIATED_HIT))
                affect_from_char(i, SKILL_EMACIATED);
            else if(percentSuccess(4)) {
                affect_from_char(i, SKILL_EMACIATED_MANA);
                affect_from_char(i, SKILL_EMACIATED_HIT);
            }
        }

        // Dwarves sober up 3x faster than most races (unless they drink more...)
        if(IS_DWARF(i) && !number(0, 35))
            gain_condition(i, DRUNK, -1);

        vivify_level = spell_level(i, SPELL_VIVIFY);
        affect_from_char(i, SPELL_VIVIFY);
        if(GET_POS(i) <= POS_MEDITATING) {
            add_affect(i, i, SPELL_VIVIFY, MIN(vivify_level + 1, 100), APPLY_NONE, 0, -1,
                    0, FALSE, FALSE, FALSE, FALSE);
        }

        if(GET_POS(i) >= POS_MORTALLYW)
        {
            hit = hit_gain(i);
            mana = mana_gain(i);
            move = move_gain(i);

            if(affected_by_spell(i, SPELL_VIVIFY)) {
                if(hit > 0)
                    hit += spell_level(i, SPELL_VIVIFY) * GET_MAX_HIT(i)/600;
                if(mana > 0)
                    mana += spell_level(i, SPELL_VIVIFY) * GET_MAX_MANA(i)/600;
                if(move > 0)
                    move += spell_level(i, SPELL_VIVIFY) * GET_MAX_MOVE(i)/600;
            }

            // Regeneration is increased on pvp holidays.  If you're incapactitated, you will
            // eventually recover.
            if(pvpHoliday(i)) {
                if (GET_POS(i) < POS_SLEEPING)
                    hit = 20;
                else {
                    hit  = (hit  > 0) ? hit *3 : 20;
                    mana = (mana > 0) ? mana*2 : 40;
                    move = (move > 0) ? move*2 : 40;
                }
            }
                

            // 72 seconds per tick...
            if(hit < 0 || GET_HIT(i) < GET_MAX_HIT(i)) {
                if(hit>0)
                    GET_HIT(i) += hit/72 + (hit % 72 > number(0, 71)? 1:0);
                else
                    GET_HIT(i)  = MAX(GET_HIT(i) + hit/72 + (-hit % 72 > number(0, 71)?-1:0), -9);
            }
            else {
                int surplus = (GET_HIT(i) - GET_MAX_HIT(i));
                GET_HIT(i) -= surplus / 72 + (surplus % 72 > number(0, 71)? 1:0);
            }


            if(mana>0)
                GET_MANA(i) = MAX(MIN(GET_MANA(i) + mana/72 + (mana % 72 > number(0, 71)?1:0), GET_MAX_MANA(i)), 0);
            else
                GET_MANA(i) = MIN(GET_MANA(i) + mana/72 + (-mana % 72 > number(0, 71)?-1:0), GET_MAX_MANA(i));

            if(move>0)
                GET_MOVE(i) = MIN(GET_MOVE(i) + move/72 + (move % 72 > number(0, 71)?1:0), GET_MAX_MOVE(i));
            else
                GET_MOVE(i) = MAX(MIN(GET_MOVE(i) + move/72 + (-move % 72 > number(0, 71)?-1:0), GET_MAX_MOVE(i)), 0);

            update_pos(i);
        }
    }
}
示例#26
0
文件: save.c 项目: sean/dominionmud
/*
 * Read in a char.
 */
int fread_char( struct char_data *ch, FILE *fp )
{
  int         error_count = 0;
  char        *word;
  char        buf [ MAX_STRING_LENGTH ];
  struct affected_type *paf;
  int         sn;
  int         i;
  int         j;
  int         status;
  int         status1;
  char        *p;
  int         tmpi;
  int         num_keys;
  int         last_key = 0;
  
  char        def_sdesc  [] = "Your short description was corrupted.";
  char        def_ldesc  [] = "Your long description was corrupted.";
  char        def_desc   [] = "Your description was corrupted.";
  char        def_title  [] = "Your title was corrupted.";
  
  struct key_data key_tab [] = {
    { "ShtDsc", TRUE,  (int) &def_sdesc,	{ &GET_SHORT_DESC(ch),   NULL } },
    { "LngDsc", TRUE,  (int) &def_ldesc,	{ &GET_LONG_DESC(ch),    NULL } },
    { "Dscr",   TRUE,  (int) &def_desc,		{ &GET_DESCRIPTION(ch),  NULL } },
    { "Sx",     FALSE, SEX_MALE,		{ &GET_SEX(ch),          NULL } },
    { "Race",   FALSE, MAND,			{ &GET_RACE(ch),         NULL } },
    { "Lvl",    FALSE, MAND,			{ &GET_LEVEL(ch),        NULL } },
    { "Trst",   FALSE, 0,			{ &GET_TRUST(ch),        NULL } },
    { "HpMnMv", FALSE, MAND,			{ &GET_HIT(ch),
						  &GET_MAX_HIT(ch),
						  &GET_MANA(ch),
						  &GET_MAX_MANA(ch),
						  &GET_MOVE(ch),
						  &GET_MAX_MOVE(ch),     NULL } },
    { "Gold",   FALSE, 0,			{ &GET_GOLD(ch),         NULL } },
    { "Exp",    FALSE, MAND,			{ &GET_EXP(ch),          NULL } },
    { "Act",     FALSE, DEFLT,			{ &PLR_FLAGS(ch),        NULL } },
    { "Act2",    FALSE, DEFLT,			{ &PLR2_FLAGS(ch),       NULL } },
    { "AffdBy",  FALSE, 0,			{ &AFF_FLAGS(ch),        NULL } },
    { "AffdBy2", FALSE, 0,			{ &AFF2_FLAGS(ch),       NULL } },
    { "Pref",    FALSE, 0,			{ &PRF_FLAGS(ch),        NULL } },
    { "Pref2",   FALSE, 0,			{ &PRF2_FLAGS(ch),       NULL } },
    { "Pos",    FALSE, POS_STANDING, 		{ &GET_POS(ch),          NULL } },
    { "Prac",   FALSE, MAND,			{ &GET_PRACTICES(ch),    NULL } },
    { "PAlign",  FALSE, 0,			{ &GET_PERMALIGN(ch),    NULL } },
    { "CAlign",  FALSE, 0,			{ &GET_ALIGNMENT(ch),    NULL } },
    { "Ttle",   TRUE,  (int) &def_title,	{ &GET_TITLE(ch),        NULL } },
#if 0
    { "SavThr", FALSE, MAND,			{ &ch->saving_throw,  NULL } },
    { "Hit",    FALSE, MAND,			{ &ch->hitroll,       NULL } },
    { "Dam",    FALSE, MAND,			{ &ch->damroll,       NULL } },
    { "Armr",   FALSE, MAND,			{ &ch->armor,         NULL } },
    { "Wimp",   FALSE, 10,			{ &ch->wimpy,         NULL } },
    { "Deaf",   FALSE, 0,			{ &ch->deaf,          NULL } },
    { "Immskll",TRUE,  DEFLT,			{ &ch->pcdata->immskll,
                                                  NULL } },
    { "AtrPrm", FALSE, MAND,			{ &ch->pcdata->perm_str,
						  &ch->pcdata->perm_int,
						  &ch->pcdata->perm_wis,
						  &ch->pcdata->perm_dex,
						  &ch->pcdata->perm_con,
                                                  NULL } },
    { "AtrMd",  FALSE, MAND,			{ &ch->pcdata->mod_str,
						  &ch->pcdata->mod_int,
						  &ch->pcdata->mod_wis,
						  &ch->pcdata->mod_dex,
						  &ch->pcdata->mod_con,
                                                  NULL } },
    { "Cond",   FALSE, DEFLT,			{ &ch->pcdata->condition [0],
						  &ch->pcdata->condition [1],
						  &ch->pcdata->condition [2],
                                                  NULL } },
    { "Pglen",  FALSE, 20,			{ &ch->pcdata->pagelen,
                                                  NULL } },
    { "Playd",   FALSE, 0,			{ &ch->played,        NULL } },
#endif
    { "Paswd",   TRUE,  MAND,			{ &GET_PASSWD(ch),    NULL } },
    { "Poofin",  TRUE,  DEFLT,			{ &POOFIN(ch),        NULL } },
    { "Poofout", TRUE,  DEFLT,			{ &POOFOUT(ch),       NULL } },
    { "\0",     FALSE, 0                                                   } };
  
  for ( num_keys = 0; *key_tab [num_keys].key; )
    num_keys++;
  
  for ( ; !feof (fp) ; )
  {
    
    word = fread_word_stat( fp, &status );
    
    if ( !word )
    {
      log( "fread_char:  Error reading key.  EOF?" );
      fread_to_eol( fp );
      break;
    }
    
    /* This little diddy searches for the keyword
       from the last keyword found */
    
    for ( i = last_key;
          i < last_key + num_keys &&
                str_cmp (key_tab [i % num_keys].key, word); )
      i++;
    
    i = i % num_keys;
    
    if ( !str_cmp (key_tab [i].key, word) )
      last_key = i;
    else
      i = num_keys;
    
    if ( *key_tab [i].key )         /* Key entry found in key_tab */
    {
      if ( key_tab [i].string == SPECIFIED )
        log( "Key already specified." );
      
      /* Entry is a string */
      
      else
        if ( key_tab [i].string )
        {
          if ( ( p = fread_string( fp, (char*)&status ) ) && !status )
          {
            free( *(char **)key_tab [i].ptrs [0] );
            *(char **)key_tab [i].ptrs [0] = p;
          }
        }
      
      /* Entry is an integer */
        else
          for ( j = 0; key_tab [i].ptrs [j]; j++ )
          {
            tmpi = fread_number_stat( fp, &status );
            if ( !status )
              *(int *)key_tab [i].ptrs [j] = tmpi;
          }
      
      if ( status )
      {
        fread_to_eol( fp );
        continue;
      }
      else
        key_tab [i].string = SPECIFIED;
    }
    
    else if ( *word == '*' || !str_cmp( word, "Nm" ) )
      fread_to_eol( fp );
    
    else if ( !str_cmp( word, "End" ) )
      break;
    
    else if ( !str_cmp( word, "Room" ) )
    {
      ch->in_room = fread_number_stat( fp, &status );
      if ( !ch->in_room )
        ch->in_room = NOWHERE;
    }
    
    else if ( !str_cmp( word, "Race" ) )
    {
      i  = race_lookup( fread_string( fp, (char*)&status ) );
      
      if ( status )
        log( "Fread_char: Unknown Race." );
      else
        GET_RACE(ch) = i;
    }
    
    else if ( !str_cmp( word, "Skill" ) )
    {
      i  = fread_number_stat( fp, &status );
      sn = skill_lookup( fread_word_stat( fp, &status1 ) );
      
      if ( status || status1 )
      {
        log( "Fread_char: Error reading skill." );
        fread_to_eol( fp );
        continue;
      }
      
      if ( sn < 0 )
        log( "Fread_char: unknown skill." );
      else
        GET_SKILL(ch, sn) = i;
    }
    
    else if ( !str_cmp ( word, "Afft" ) )
    {
      
      int status;

      CREATE(paf, struct affected_type, 1);
      memset(paf, 0, sizeof( struct affected_type ));
      
      paf->type           = skill_lookup( fread_string( fp,
                                                        (char*)&status ) );
      paf->duration       = fread_number_stat( fp, &status );
      paf->modifier       = fread_number_stat( fp, &status );
      paf->location       = fread_number_stat( fp, &status );
      paf->bitvector      = fread_number_stat( fp, &status );
      paf->next           = ch->affected;
      ch->affected        = paf;
    }
    
    else
    {
示例#27
0
void
perform_smoke(struct creature *ch, int type)
{

    const char *to_vict = NULL;
    struct affected_type af;
    int hp_mod = 0, mana_mod = 0, move_mod = 0, spell = 0;
    uint8_t lev = 0;
    int accum_dur = 0, accum_affect = 0;

    init_affect(&af);
    af.type = SMOKE_EFFECTS;
    af.level = 30;
    af.owner = GET_IDNUM(ch);

    switch (type) {
    case SMOKE_DIRTWEED:
        to_vict = "Your head hurts.";
        af.duration = 3;
        af.modifier = -2;
        af.location = APPLY_INT;
        af.bitvector = AFF_CONFUSION;
        af.aff_index = 1;
        accum_dur = 1;
        accum_affect = 1;
        move_mod = -number(3, 10);
        mana_mod = -number(1, 2);
        break;
    case SMOKE_DESERTWEED:
        af.location = APPLY_MOVE;
        af.duration = 4;
        af.modifier = 10;
        mana_mod = dice(1, 4);
        move_mod = dice(3, 4);
        break;
    case SMOKE_INDICA:
        to_vict = "Your mind is elevated to another plane.";
        af.location = APPLY_WIS;
        af.duration = 5;
        af.modifier = number(1, 2);
        mana_mod = dice(6, 4);
        move_mod = -number(1, 3);
        break;
    case SMOKE_UNHOLY_REEFER:
        af.location = APPLY_WIS;
        af.duration = 5;
        af.modifier = number(0, 2);
        mana_mod = number(1, 4);
        move_mod = -number(1, 3);
        spell = SPELL_ESSENCE_OF_EVIL;
        lev = 20;
        break;
    case SMOKE_MARIJUANA:
        to_vict = "You feel stoned.";
        af.location = APPLY_INT;
        af.duration = 3;
        af.modifier = -1;
        mana_mod = dice(4, 4);
        break;
    case SMOKE_TOBACCO:
        af.location = APPLY_MOVE;
        af.duration = 3;
        af.modifier = -number(10, 20);
        accum_dur = 1;
        mana_mod = dice(3, 3);
        break;
    case SMOKE_HEMLOCK:
        to_vict = "The smoke burns your lungs!";
        af.location = APPLY_HIT;
        af.duration = number(3, 6);
        af.modifier = -number(30, 60);
        accum_affect = 1;
        hp_mod = -number(10, 16);
        mana_mod = -10;
        move_mod = -10;
        spell = SPELL_POISON;
        lev = LVL_AMBASSADOR;
        break;
    case SMOKE_PEYOTE:
        to_vict = "You feel a strange sensation.";
        spell = SPELL_ASTRAL_SPELL;
        lev = LVL_GRIMP;
        af.location = APPLY_MANA;
        af.modifier = number(10, 20);
        af.duration = number(1, 3);
        move_mod = number(6, 12);
        break;
    case SMOKE_HOMEGROWN:
        to_vict = "There's no place like home...";
        spell = SPELL_WORD_OF_RECALL;
        lev = number(30, 60);
        mana_mod = number(20, 40);
        move_mod = number(2, 10);
        break;

    default:
        af.type = 0;
        break;
    }

    if (to_vict)
        act(to_vict, false, ch, NULL, NULL, TO_CHAR);

    GET_HIT(ch) = MIN(MAX(GET_HIT(ch) + hp_mod, 0), GET_MAX_HIT(ch));
    GET_MANA(ch) = MIN(MAX(GET_MANA(ch) + mana_mod, 0), GET_MAX_MANA(ch));
    GET_MOVE(ch) = MIN(MAX(GET_MOVE(ch) + move_mod, 0), GET_MAX_MOVE(ch));

    if (af.type &&
        (!affected_by_spell(ch, af.type) || accum_affect || accum_dur))
        affect_join(ch, &af, accum_dur, true, accum_affect, true);

    if (spell && lev)
        call_magic(ch, ch, NULL, NULL, spell, (int)lev, CAST_CHEM);

    WAIT_STATE(ch, 6);

}
示例#28
0
/** Move a PC/NPC character from their current location to a new location. This
 * is the standard movement locomotion function that all normal walking
 * movement by characters should be sent through. This function also defines
 * the move cost of normal locomotion as:
 * ( (move cost for source room) + (move cost for destination) ) / 2
 *
 * @pre Function assumes that ch has no master controlling character, that
 * ch has no followers (in other words followers won't be moved by this
 * function) and that the direction traveled in is one of the valid, enumerated
 * direction.
 * @param ch The character structure to attempt to move.
 * @param dir The defined direction (NORTH, SOUTH, etc...) to attempt to
 * move into.
 * @param need_specials_check If TRUE will cause
 * @retval int 1 for a successful move (ch is now in a new location)
 * or 0 for a failed move (ch is still in the original location). */
int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{
  /* Begin Local variable definitions */
  /*---------------------------------------------------------------------*/
  /* Used in our special proc check. By default, we pass a NULL argument
   * when checking for specials */
  char spec_proc_args[MAX_INPUT_LENGTH] = "";
  /* The room the character is currently in and will move from... */
  room_rnum was_in = IN_ROOM(ch);
  /* ... and the room the character will move into. */
  room_rnum going_to = EXIT(ch, dir)->to_room;
  /* How many movement points are required to travel from was_in to going_to.
   * We redefine this later when we need it. */
  int need_movement = 0;
  /* Contains the "leave" message to display to the was_in room. */
  char leave_message[SMALL_BUFSIZE];
  /*---------------------------------------------------------------------*/
  /* End Local variable definitions */


  /* Begin checks that can prevent a character from leaving the was_in room. */
  /* Future checks should be implemented within this section and return 0.   */
  /*---------------------------------------------------------------------*/
  /* Check for special routines that might activate because of the move and
   * also might prevent the movement. Special requires commands, so we pass
   * in the "command" equivalent of the direction (ie. North is '1' in the
   * command list, but NORTH is defined as '0').
   * Note -- only check if following; this avoids 'double spec-proc' bug */
  if (need_specials_check && special(ch, dir + 1, spec_proc_args))
    return 0;

  /* Leave Trigger Checks: Does a leave trigger block exit from the room? */
  if (!leave_mtrigger(ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;
  if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;
  if (!leave_otrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
    return 0;

  /* Charm effect: Does it override the movement? */
  if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && was_in == IN_ROOM(ch->master))
  {
    send_to_char(ch, "The thought of leaving your master makes you weep.\r\n");
    act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM);
    return (0);
  }

  /* Water, No Swimming Rooms: Does the deep water prevent movement? */
  if ((SECT(was_in) == SECT_WATER_NOSWIM) ||
      (SECT(going_to) == SECT_WATER_NOSWIM))
  {
    if (!has_boat(ch))
    {
      send_to_char(ch, "You need a boat to go there.\r\n");
      return (0);
    }
  }

  /* Flying Required: Does lack of flying prevent movement? */
  if ((SECT(was_in) == SECT_FLYING) || (SECT(going_to) == SECT_FLYING))
  {
    if (!has_flight(ch))
    {
      send_to_char(ch, "You need to be flying to go there!\r\n");
      return (0);
    }
  }

  /* Underwater Room: Does lack of underwater breathing prevent movement? */
  if ((SECT(was_in) == SECT_UNDERWATER) || (SECT(going_to) == SECT_UNDERWATER))
  {
    if (!has_scuba(ch) && !IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_NOHASSLE)) {
      send_to_char(ch, "You need to be able to breathe water to go there!\r\n");
      return (0);
    }
  }

  /* Houses: Can the player walk into the house? */
  if (ROOM_FLAGGED(was_in, ROOM_ATRIUM))
  {
    if (!House_can_enter(ch, GET_ROOM_VNUM(going_to)))
    {
      send_to_char(ch, "That's private property -- no trespassing!\r\n");
      return (0);
    }
  }

  /* Check zone level recommendations */
  if ((ZONE_MINLVL(GET_ROOM_ZONE(going_to)) != -1) && ZONE_MINLVL(GET_ROOM_ZONE(going_to)) > GET_LEVEL(ch)) {
    send_to_char(ch, "This zone is above your recommended level.\r\n");
  }

  /* Check zone flag restrictions */
  if (ZONE_FLAGGED(GET_ROOM_ZONE(going_to), ZONE_CLOSED)) {
    send_to_char(ch, "A mysterious barrier forces you back! That area is off-limits.\r\n");
    return (0);
  }
  if (ZONE_FLAGGED(GET_ROOM_ZONE(going_to), ZONE_NOIMMORT) && (GET_ADMLEVEL(ch) >= ADMLVL_IMMORT) && (GET_ADMLEVEL(ch) < ADMLVL_GRGOD)) {
    send_to_char(ch, "A mysterious barrier forces you back! That area is off-limits.\r\n");
    return (0);
  }

  /* Room Size Capacity: Is the room full of people already? */
  if (ROOM_FLAGGED(going_to, ROOM_TUNNEL) &&
      num_pc_in_room(&(world[going_to])) >= CONFIG_TUNNEL_SIZE)
  {
    if (CONFIG_TUNNEL_SIZE > 1)
      send_to_char(ch, "There isn't enough room for you to go there!\r\n");
    else
      send_to_char(ch, "There isn't enough room there for more than one person!\r\n");
    return (0);
  }

  /* Room Level Requirements: Is ch privileged enough to enter the room? */
  if (ROOM_FLAGGED(going_to, ROOM_GODROOM) && GET_ADMLEVEL(ch) < ADMLVL_GOD)
  {
    send_to_char(ch, "You aren't godly enough to use that room!\r\n");
    return (0);
  }

  /* All checks passed, nothing will prevent movement now other than lack of
   * move points. */
  /* move points needed is avg. move loss for src and destination sect type */
  need_movement = (movement_loss[SECT(was_in)] +
		   movement_loss[SECT(going_to)]) / 2;

  /* Move Point Requirement Check */
  if (GET_MOVE(ch) < need_movement && !IS_NPC(ch))
  {
    if (need_specials_check && ch->master)
      send_to_char(ch, "You are too exhausted to follow.\r\n");
    else
      send_to_char(ch, "You are too exhausted.\r\n");

    return (0);
  }

  /*---------------------------------------------------------------------*/
  /* End checks that can prevent a character from leaving the was_in room. */


  /* Begin: the leave operation. */
  /*---------------------------------------------------------------------*/
  /* If applicable, subtract movement cost. */
  if (GET_ADMLEVEL(ch) < ADMLVL_IMMORT && !IS_NPC(ch))
    GET_MOVE(ch) -= need_movement;

  /* Generate the leave message and display to others in the was_in room. */
  if (!AFF_FLAGGED(ch, AFF_SNEAK))
  {
    snprintf(leave_message, sizeof(leave_message), "$n leaves %s.", dirs[dir]);
    act(leave_message, TRUE, ch, 0, 0, TO_ROOM);
  }

  char_from_room(ch);
  char_to_room(ch, going_to);
  /*---------------------------------------------------------------------*/
  /* End: the leave operation. The character is now in the new room. */


  /* Begin: Post-move operations. */
  /*---------------------------------------------------------------------*/
  /* Post Move Trigger Checks: Check the new room for triggers.
   * Assumptions: The character has already truly left the was_in room. If
   * the entry trigger "prevents" movement into the room, it is the triggers
   * job to provide a message to the original was_in room. */
  if (!entry_mtrigger(ch) || !enter_wtrigger(&world[going_to], ch, dir)) {
    char_from_room(ch);
    char_to_room(ch, was_in);
    return 0;
  }

  /* Display arrival information to anyone in the destination room... */
  if (!AFF_FLAGGED(ch, AFF_SNEAK))
    act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM);

  /* ... and the room description to the character. */
  if (ch->desc != NULL)
    look_at_room(ch, 0);

  /* ... and Kill the player if the room is a death trap. */
  if (ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_ADMLEVEL(ch) < ADMLVL_IMMORT)
  {
    mudlog(BRF, ADMLVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(going_to), world[going_to].name);
    death_cry(ch);
    extract_char(ch);
    return (0);
  }

  /* At this point, the character is safe and in the room. */
  /* Fire memory and greet triggers, check and see if the greet trigger
   * prevents movement, and if so, move the player back to the previous room. */
  entry_memory_mtrigger(ch);
  if (!greet_mtrigger(ch, dir))
  {
    char_from_room(ch);
    char_to_room(ch, was_in);
    look_at_room(ch, 0);
    /* Failed move, return a failure */
    return (0);
  }
  else
    greet_memory_mtrigger(ch);
  /*---------------------------------------------------------------------*/
  /* End: Post-move operations. */

  /* Only here is the move successful *and* complete. Return success for
   * calling functions to handle post move operations. */
  return (1);
}
示例#29
0
文件: medit.c 项目: axanon/tbamud
void medit_parse(struct descriptor_data *d, char *arg)
{
  int i = -1, j;
  char *oldtext = NULL;

  if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) {
    i = atoi(arg);
    if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) {
      write_to_output(d, "Try again : ");
      return;
    }
  } else {	/* String response. */
    if (!genolc_checkstring(d, arg))
      return;
  }
  switch (OLC_MODE(d)) {
  case MEDIT_CONFIRM_SAVESTRING:
    /* Ensure mob has MOB_ISNPC set. */
    SET_BIT_AR(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC);
    switch (*arg) {
    case 'y':
    case 'Y':
      /* Save the mob in memory and to disk. */
      medit_save_internally(d);
      mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d));
      if (CONFIG_OLC_SAVE) {
        medit_save_to_disk(zone_table[real_zone_by_thing(OLC_NUM(d))].number);
        write_to_output(d, "Mobile saved to disk.\r\n");
      } else
        write_to_output(d, "Mobile saved to memory.\r\n");
      cleanup_olc(d, CLEANUP_ALL);
      return;
    case 'n':
    case 'N':
      /* If not saving, we must free the script_proto list. We do so by
       * assigning it to the edited mob and letting free_mobile in
       * cleanup_olc handle it. */
      OLC_MOB(d)->proto_script = OLC_SCRIPT(d);
      cleanup_olc(d, CLEANUP_ALL);
      return;
    default:
      write_to_output(d, "Invalid choice!\r\n");
      write_to_output(d, "Do you wish to save your changes? : ");
      return;
    }
    break;

  case MEDIT_MAIN_MENU:
    i = 0;
    switch (*arg) {
    case 'q':
    case 'Q':
      if (OLC_VAL(d)) {	/* Anything been changed? */
	write_to_output(d, "Do you wish to save your changes? : ");
	OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING;
      } else
	cleanup_olc(d, CLEANUP_ALL);
      return;
    case '1':
      OLC_MODE(d) = MEDIT_SEX;
      medit_disp_sex(d);
      return;
    case '2':
      OLC_MODE(d) = MEDIT_KEYWORD;
      i--;
      break;
    case '3':
      OLC_MODE(d) = MEDIT_S_DESC;
      i--;
      break;
    case '4':
      OLC_MODE(d) = MEDIT_L_DESC;
      i--;
      break;
    case '5':
      OLC_MODE(d) = MEDIT_D_DESC;
      send_editor_help(d);
      write_to_output(d, "Enter mob description:\r\n\r\n");
      if (OLC_MOB(d)->player.description) {
	write_to_output(d, "%s", OLC_MOB(d)->player.description);
	oldtext = strdup(OLC_MOB(d)->player.description);
      }
      string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext);
      OLC_VAL(d) = 1;
      return;
    case '6':
      OLC_MODE(d) = MEDIT_POS;
      medit_disp_positions(d);
      return;
    case '7':
      OLC_MODE(d) = MEDIT_DEFAULT_POS;
      medit_disp_positions(d);
      return;
    case '8':
      OLC_MODE(d) = MEDIT_ATTACK;
      medit_disp_attack_types(d);
      return;
    case '9':
      OLC_MODE(d) = MEDIT_STATS_MENU;
      medit_disp_stats_menu(d);
      return;
    case 'a':
    case 'A':
      OLC_MODE(d) = MEDIT_NPC_FLAGS;
      medit_disp_mob_flags(d);
      return;
    case 'b':
    case 'B':
      OLC_MODE(d) = MEDIT_AFF_FLAGS;
      medit_disp_aff_flags(d);
      return;
    case 'w':
    case 'W':
      write_to_output(d, "Copy what mob? ");
      OLC_MODE(d) = MEDIT_COPY;
      return;
    case 'x':
    case 'X':
      write_to_output(d, "Are you sure you want to delete this mobile? ");
      OLC_MODE(d) = MEDIT_DELETE;
      return;
    case 's':
    case 'S':
      OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU;
      dg_script_menu(d);
      return;
    default:
      medit_disp_menu(d);
      return;
    }
    if (i == 0)
      break;
    else if (i == 1)
      write_to_output(d, "\r\nEnter new value : ");
    else if (i == -1)
      write_to_output(d, "\r\nEnter new text :\r\n] ");
    else
      write_to_output(d, "Oops...\r\n");
    return;

  case MEDIT_STATS_MENU:
    i=0;
    switch(*arg) {
    case 'q':
    case 'Q':
      medit_disp_menu(d);
      return;
    case '1':  /* Edit level */
      OLC_MODE(d) = MEDIT_LEVEL;
      i++;
      break;
    case '2':  /* Autoroll stats */
      medit_autoroll_stats(d);
      medit_disp_stats_menu(d);
      OLC_VAL(d) = TRUE;
      return;
    case '3':
      OLC_MODE(d) = MEDIT_NUM_HP_DICE;
      i++;
      break;
    case '4':
      OLC_MODE(d) = MEDIT_SIZE_HP_DICE;
      i++;
      break;
    case '5':
      OLC_MODE(d) = MEDIT_ADD_HP;
      i++;
      break;
    case '6':
      OLC_MODE(d) = MEDIT_NDD;
      i++;
      break;
    case '7':
      OLC_MODE(d) = MEDIT_SDD;
      i++;
      break;
    case '8':
      OLC_MODE(d) = MEDIT_DAMROLL;
      i++;
      break;
    case 'a':
    case 'A':
      OLC_MODE(d) = MEDIT_AC;
      i++;
      break;
    case 'b':
    case 'B':
      OLC_MODE(d) = MEDIT_EXP;
      i++;
      break;
    case 'c':
    case 'C':
      OLC_MODE(d) = MEDIT_GOLD;
      i++;
      break;
    case 'd':
    case 'D':
      OLC_MODE(d) = MEDIT_HITROLL;
      i++;
      break;
    case 'e':
    case 'E':
      OLC_MODE(d) = MEDIT_ALIGNMENT;
      i++;
      break;
    case 'f':
    case 'F':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_STR;
      i++;
      break;
    case 'g':
    case 'G':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_INT;
      i++;
      break;
    case 'h':
    case 'H':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_WIS;
      i++;
      break;
    case 'i':
    case 'I':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_DEX;
      i++;
      break;
    case 'j':
    case 'J':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_CON;
      i++;
      break;
    case 'k':
    case 'K':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_CHA;
      i++;
      break;
    case 'l':
    case 'L':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_PARA;
      i++;
      break;
    case 'm':
    case 'M':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_ROD;
      i++;
      break;
    case 'n':
    case 'N':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_PETRI;
      i++;
      break;
    case 'o':
    case 'O':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_BREATH;
      i++;
      break;
    case 'p':
    case 'P':
      if (!CONFIG_MEDIT_ADVANCED) {
        write_to_output(d, "Invalid Choice!\r\nEnter Choice : ");
        return;
	  }
      OLC_MODE(d) = MEDIT_SPELL;
      i++;
      break;
    default:
      medit_disp_stats_menu(d);
      return;
    }
    if (i == 0)
      break;
    else if (i == 1)
      write_to_output(d, "\r\nEnter new value : ");
    else if (i == -1)
      write_to_output(d, "\r\nEnter new text :\r\n] ");
    else
      write_to_output(d, "Oops...\r\n");
    return;

  case OLC_SCRIPT_EDIT:
    if (dg_script_edit_parse(d, arg)) return;
    break;

  case MEDIT_KEYWORD:
    smash_tilde(arg);
    if (GET_ALIAS(OLC_MOB(d)))
      free(GET_ALIAS(OLC_MOB(d)));
    GET_ALIAS(OLC_MOB(d)) = str_udup(arg);
    break;

  case MEDIT_S_DESC:
    smash_tilde(arg);
    if (GET_SDESC(OLC_MOB(d)))
      free(GET_SDESC(OLC_MOB(d)));
    GET_SDESC(OLC_MOB(d)) = str_udup(arg);
    break;

  case MEDIT_L_DESC:
    smash_tilde(arg);
    if (GET_LDESC(OLC_MOB(d)))
      free(GET_LDESC(OLC_MOB(d)));
    if (arg && *arg) {
      char buf[MAX_INPUT_LENGTH];
      snprintf(buf, sizeof(buf), "%s\r\n", arg);
      GET_LDESC(OLC_MOB(d)) = strdup(buf);
    } else
      GET_LDESC(OLC_MOB(d)) = strdup("undefined");

    break;

  case MEDIT_D_DESC:
    /*
     * We should never get here.
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached D_DESC case!");
    write_to_output(d, "Oops...\r\n");
    break;

  case MEDIT_NPC_FLAGS:
    if ((i = atoi(arg)) <= 0)
      break;
    else if ( (j = medit_get_mob_flag_by_number(i)) == -1) {
       write_to_output(d, "Invalid choice!\r\n");
       write_to_output(d, "Enter mob flags (0 to quit) :");
       return;
    } else if (j <= NUM_MOB_FLAGS) {
      TOGGLE_BIT_AR(MOB_FLAGS(OLC_MOB(d)), (j));
    }
    medit_disp_mob_flags(d);
    return;

  case MEDIT_AFF_FLAGS:
    if ((i = atoi(arg)) <= 0)
      break;
    else if (i <= NUM_AFF_FLAGS)
      TOGGLE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), i);

    /* Remove unwanted bits right away. */
    REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_CHARM);
    REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_POISON);
    REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_GROUP);
    REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_SLEEP);
    medit_disp_aff_flags(d);
    return;

/* Numerical responses. */

  case MEDIT_SEX:
    GET_SEX(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_GENDERS - 1);
    break;

  case MEDIT_HITROLL:
    GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_DAMROLL:
    GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_NDD:
    GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_SDD:
    GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_NUM_HP_DICE:
    GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_SIZE_HP_DICE:
    GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_ADD_HP:
    GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_AC:
    GET_AC(OLC_MOB(d)) = LIMIT(i, -200, 200);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_EXP:
    GET_EXP(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_EXP);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_GOLD:
    GET_GOLD(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_GOLD);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_STR:
    GET_STR(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_INT:
    GET_INT(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_WIS:
    GET_WIS(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_DEX:
    GET_DEX(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_CON:
    GET_CON(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_CHA:
    GET_CHA(OLC_MOB(d)) = LIMIT(i, 11, 25);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_PARA:
    GET_SAVE(OLC_MOB(d), SAVING_PARA) = LIMIT(i, 0, 100);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_ROD:
    GET_SAVE(OLC_MOB(d), SAVING_ROD) = LIMIT(i, 0, 100);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_PETRI:
    GET_SAVE(OLC_MOB(d), SAVING_PETRI) = LIMIT(i, 0, 100);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_BREATH:
    GET_SAVE(OLC_MOB(d), SAVING_BREATH) = LIMIT(i, 0, 100);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_SPELL:
    GET_SAVE(OLC_MOB(d), SAVING_SPELL) = LIMIT(i, 0, 100);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_POS:
    GET_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1);
    break;

  case MEDIT_DEFAULT_POS:
    GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1);
    break;

  case MEDIT_ATTACK:
    GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1);
    break;

  case MEDIT_LEVEL:
    GET_LEVEL(OLC_MOB(d)) = LIMIT(i, 1, LVL_IMPL);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_ALIGNMENT:
    GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000);
    OLC_VAL(d) = TRUE;
    medit_disp_stats_menu(d);
    return;

  case MEDIT_COPY:
    if ((i = real_mobile(atoi(arg))) != NOWHERE) {
      medit_setup_existing(d, i);
    } else
      write_to_output(d, "That mob does not exist.\r\n");
    break;

  case MEDIT_DELETE:
    if (*arg == 'y' || *arg == 'Y') {
      if (delete_mobile(GET_MOB_RNUM(OLC_MOB(d))) != NOBODY)
        write_to_output(d, "Mobile deleted.\r\n");
      else
        write_to_output(d, "Couldn't delete the mobile!\r\n");

      cleanup_olc(d, CLEANUP_ALL);
      return;
    } else if (*arg == 'n' || *arg == 'N') {
      medit_disp_menu(d);
      OLC_MODE(d) = MEDIT_MAIN_MENU;
      return;
    } else
      write_to_output(d, "Please answer 'Y' or 'N': ");
    break;

  default:
    /* We should never get here. */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached default case!");
    write_to_output(d, "Oops...\r\n");
    break;
  }

/* END OF CASE If we get here, we have probably changed something, and now want
   to return to main menu.  Use OLC_VAL as a 'has changed' flag */

  OLC_VAL(d) = TRUE;
  medit_disp_menu(d);
}
示例#30
0
void suffer_activity(int pulse)
{
  struct char_data *ch, *next_ch;
  char *desc;
  char dam_msg1[120] = "msg1 for suffer room not defined, report this to an imm!\r\n";
  char dam_msg2[120] = "msg2 for suffer room not defined, report this to an imm!\r\n";
  char dam_msg3[120] = "msg3 for suffer room not defined, report this to an imm!\r\n";
  char dam_msg4[120] = "msg4 for suffer room not defined, report this to an imm!\r\n";
  char death_char[120] = "You drift into coma and die.";
  char death_room[120] = "$n has drifted into coma and dies.";
  char suffer_msg[120] = "$n is suffering.";
  int percent_hp;
  int min_dam = 10, max_dam = 20, dam_amount;
  int hot = FALSE, cold = FALSE , dry = FALSE;

  for (ch = character_list; ch; ch = next_ch) {
       next_ch = ch->next;

      if (GET_LEVEL(ch) >= LVL_IMMORT) /* Lets not hurt our immortals */
          continue;

      if (IS_NPC(ch))
          continue;

      // I'm adding in a check to make outlaws "suffer" if in a peace room
      // Added by Sanji
      if( (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL) || IN_ARENA(ch) ||  IS_SET_AR(ROOM_FLAGS((ch)->in_room), ROOM_CLAN)) &&
        (IS_SET_AR(PLR_FLAGS(ch), PLR_HUNTED) || IS_SET_AR(PLR_FLAGS(ch), PLR_THIEF))) {
            int to_room = 18001;	// Samsera center

            // hurt the little cheater
            GET_HIT(ch)  = MAX(1, GET_HIT(ch) - GET_MAX_HIT(ch)/8);
            GET_MANA(ch) = MAX(0, GET_MANA(ch) - GET_MAX_MANA(ch)/8);
            GET_MOVE(ch) = MAX(0, GET_MOVE(ch) - GET_MAX_MOVE(ch)/8);

            // where to send the victim?
            //do
            //{
            //    to_room = number( 0, top_of_world );
            //} while (IS_SET_AR(world[to_room].room_flags, ROOM_PRIVATE) ||
            //        IS_SET_AR(world[to_room].room_flags, ROOM_DEATH) ||
            //        IS_SET_AR(world[to_room].room_flags, ROOM_PEACEFUL));

            // Lets send out a message, more can be added later.
            //
            send_to_char("Naughty naughty.  No hiding!\r\n", ch);

            // Time to move the victim
            char_from_room(ch);
            char_to_room(ch, real_room(to_room));
            look_at_room(ch, 0);
      }

      hot = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT));
      cold = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD));
      dry = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY));

      if (!hot && !cold && !dry)
          continue;


      /* Getting ready to pull the damage amount out of the extra desc in the room */
      if ((desc = find_exdesc("min_dam", world[ch->in_room].ex_description)) != NULL)
           min_dam = atoi(desc);
      else
           min_dam = 0;

      if ((desc = find_exdesc("max_dam", world[ch->in_room].ex_description)) != NULL)
          max_dam = atoi(desc);
      else
          max_dam = 25;

     if (max_dam < min_dam) {
         send_to_char("SYSERR: Max damage lower then Min damage.  Report to an Immortal.\r\n", ch);
         return;
     }

     dam_amount = number(min_dam, max_dam);

     if ((desc = find_exdesc("suffer1", world[ch->in_room].ex_description)) != NULL)
          sprintf(dam_msg1, "%s", desc);
     if ((desc = find_exdesc("suffer2", world[ch->in_room].ex_description)) != NULL)
          sprintf(dam_msg2, "%s", desc);
     if ((desc = find_exdesc("suffer3", world[ch->in_room].ex_description)) != NULL)
          sprintf(dam_msg3, "%s", desc);
     if ((desc = find_exdesc("suffer4", world[ch->in_room].ex_description)) != NULL)
	  sprintf(dam_msg4, "%s", desc);
     if ((desc = find_exdesc("death_char", world[ch->in_room].ex_description)) != NULL)
          sprintf(death_char, "%s", desc);
     if ((desc = find_exdesc("death_room", world[ch->in_room].ex_description)) != NULL)
          sprintf(death_room, "%s", desc);
     if ((desc = find_exdesc("suffer_msg", world[ch->in_room].ex_description)) != NULL)
          sprintf(suffer_msg, "%s", desc);


     if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD) && IS_AFFECTED(ch, AFF_NO_COLD))
         continue;
     else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) && IS_AFFECTED(ch, AFF_NO_HOT))
         continue;
     else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) && IS_AFFECTED(ch, AFF_NO_DRY))
         continue;

    // DUH! added a check for soak
     if (((ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) || ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY)) && (GET_COND(ch, THIRST) > 0)))
         GET_COND(ch, THIRST) = 0;


     if (dam_amount >= GET_HIT(ch))
         dam_amount = GET_HIT(ch) + number(4, 7);
     else
        act(suffer_msg, FALSE, ch, 0, 0, TO_ROOM);

     GET_HIT(ch) -= dam_amount;

     percent_hp = (100 * GET_HIT(ch)) / GET_MAX_HIT(ch);
// need a check here to see if the char is still in the room!
   if ((ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT)) || (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD)) || (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY))){
     if (percent_hp > 75)
         send_to_char(dam_msg1, ch);
     else if (percent_hp > 50)
              send_to_char(dam_msg2, ch);
     else if (percent_hp > 30)
              send_to_char(dam_msg3, ch);
     else if (percent_hp >= 15)
              send_to_char(dam_msg4, ch);
     else if (percent_hp >= 1) {
	      GET_HIT(ch) = number (-3, -5);
              send_to_char("You have passed out.\r\n", ch);
	      act("$n has passed out and fallen to the ground.",
		   FALSE, ch, 0, 0, TO_ROOM);
              update_pos(ch);
     } else {
          GET_HIT(ch) = number(-7, -10);
          act(death_char, FALSE, ch, 0, 0, TO_CHAR);
          act(death_room, FALSE, ch, 0, 0, TO_ROOM);
          update_pos(ch);
          GET_MANA(ch) = 1;
          die(ch, NULL, 0);
     }
    }
  } /* End of for loop */
}