Ejemplo n.º 1
0
/* functions to perform assignments */
void ASSIGNMOB(mob_vnum mob, SPECIAL(fname))
{
  if (real_mobile(mob) >= 0) {
    mob_index[real_mobile(mob)].func = fname;
    if (get_spec_name(mob_procs, fname) == 0) {
      sprintf(buf, "SYSWAR: Assign spec not in table to mob #%d",
            mob);
      log(buf);

    }
  }
  else if (!mini_mud) {
    sprintf(buf, "SYSERR: Attempt to assign spec to non-existant mob #%d",
            mob);
    log(buf);
  }
}
Ejemplo n.º 2
0
void ASSIGNMOB(mob_vnum mob, SPECIAL(fname))
{
  mob_rnum rnum;

  if ((rnum = real_mobile(mob)) >= 0)
    mob_index[rnum].func = fname;
  else if (!mini_mud)
    log("SYSERR: Attempt to assign spec to non-existant mob #%d", mob);
}
Ejemplo n.º 3
0
/* Save new/edited mob to memory. */
void medit_save_internally(struct descriptor_data *d)
{
  int i;
  mob_rnum new_rnum;
  struct descriptor_data *dsc;
  struct char_data *mob;

  i = (real_mobile(OLC_NUM(d)) == NOBODY);

  if ((new_rnum = add_mobile(OLC_MOB(d), OLC_NUM(d))) == NOBODY) {
    log("medit_save_internally: add_mobile failed.");
    return;
  }

  /* Update triggers and free old proto list */
  if (mob_proto[new_rnum].proto_script &&
      mob_proto[new_rnum].proto_script != OLC_SCRIPT(d))
    free_proto_script(&mob_proto[new_rnum], MOB_TRIGGER);

  mob_proto[new_rnum].proto_script = OLC_SCRIPT(d);

  /* this takes care of the mobs currently in-game */
  for (mob = character_list; mob; mob = mob->next) {
    if (GET_MOB_RNUM(mob) != new_rnum)
      continue;

    /* remove any old scripts */
    if (SCRIPT(mob))
      extract_script(mob, MOB_TRIGGER);

    free_proto_script(mob, MOB_TRIGGER);
    copy_proto_script(&mob_proto[new_rnum], mob, MOB_TRIGGER);
    assign_triggers(mob, MOB_TRIGGER);
  }
  /* end trigger update */

  if (!i)	/* Only renumber on new mobiles. */
    return;

  /* Update keepers in shops being edited and other mobs being edited. */
  for (dsc = descriptor_list; dsc; dsc = dsc->next) {
    if (STATE(dsc) == CON_SEDIT)
      S_KEEPER(OLC_SHOP(dsc)) += (S_KEEPER(OLC_SHOP(dsc)) != NOTHING && S_KEEPER(OLC_SHOP(dsc)) >= new_rnum);
    else if (STATE(dsc) == CON_MEDIT)
      GET_MOB_RNUM(OLC_MOB(dsc)) += (GET_MOB_RNUM(OLC_MOB(dsc)) != NOTHING && GET_MOB_RNUM(OLC_MOB(dsc)) >= new_rnum);
  }

  /* Update other people in zedit too. From: C.Raehl 4/27/99 */
  for (dsc = descriptor_list; dsc; dsc = dsc->next)
    if (STATE(dsc) == CON_ZEDIT)
      for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++)
        if (OLC_ZONE(dsc)->cmd[i].command == 'M')
          if (OLC_ZONE(dsc)->cmd[i].arg1 >= new_rnum)
            OLC_ZONE(dsc)->cmd[i].arg1++;
}
Ejemplo n.º 4
0
/* Assign castle special procedures. NOTE: The mobile number isn't fully 
 * specified. It's only an offset from the zone's base. */
void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc))
{
  mob_vnum vmv = castle_virtual(mobnum);
  mob_rnum rmr = NOBODY;

  if (vmv != NOBODY)
    rmr = real_mobile(vmv);

  if (rmr == NOBODY) {
    if (!mini_mud)
      log("SYSERR: assign_kings_castle(): can't find mob #%d.", vmv);
      /* SYSERR_DESC: When the castle_mob_spec() function is given a mobnum
       * that does not correspond to a mod loaded (when not in minimud mode),
       * this error will result. */
  } else
    mob_index[rmr].func = specproc;
}
Ejemplo n.º 5
0
int add_quest(struct aq_data *nqst)
{
  qst_rnum rnum;
  mob_rnum qmrnum;
  zone_rnum rznum = real_zone_by_thing(nqst->vnum);

  /* The quest already exists, just update it.  */
  if ((rnum = real_quest(nqst->vnum)) != NOWHERE) {
    copy_quest(&aquest_table[rnum], nqst, TRUE);
  } else {
    /* increase the number of quest table entries */
    total_quests++;
    RECREATE(aquest_table, struct aq_data, total_quests );
    /* Initialise top quest strings to null */
    QST_NAME(total_quests - 1) = NULL;
    QST_DESC(total_quests - 1) = NULL;
    QST_INFO(total_quests - 1) = NULL;
    QST_DONE(total_quests - 1) = NULL;
    QST_QUIT(total_quests - 1) = NULL;
    /* Now process enties from the top down to see where the new one goes */
    for (rnum = total_quests - 1; rnum > 0; rnum--) {
      if (nqst->vnum > QST_NUM(rnum - 1))
        break; //found the place
      aquest_table[rnum] = aquest_table[rnum - 1]; //shift quest up one
    }
    copy_quest(&aquest_table[rnum], nqst, FALSE);
  }
  qmrnum = real_mobile(QST_MASTER(rnum));
  /* Make sure we assign spec procs to the questmaster */
  if (qmrnum != NOBODY && mob_index[qmrnum].func &&
     mob_index[qmrnum].func != questmaster)
     QST_FUNC(rnum) = mob_index[qmrnum].func;
  if(qmrnum != NOBODY) 
    mob_index[qmrnum].func = questmaster;

  /* And make sure we save the updated quest information to disk */
  if (rznum != NOWHERE)
    add_to_save_list(zone_table[rznum].number, SL_QST);
  else
    mudlog(BRF, ADMLVL_BUILDER, TRUE,
           "SYSERR: GenOLC: Cannot determine quest zone.");

  return rnum;
}
Ejemplo n.º 6
0
void quest_hist(struct char_data *ch)
{
  int i = 0, counter = 0;
  qst_rnum rnum = NOTHING;

  send_to_char(ch, "Quests that you have completed:\r\n"
    "Index Description                                          Questmaster\r\n"
    "----- ---------------------------------------------------- -----------\r\n");
  for (i = 0; i < GET_NUM_QUESTS(ch); i++) {
    if ((rnum = real_quest(ch->player_specials->saved.completed_quests[i])) != NOTHING)
      send_to_char(ch, "\tg%4d\tn) \tc%-52.52s\tn \ty%s\tn\r\n",
 ++counter, QST_DESC(rnum), (real_mobile(QST_MASTER(rnum)) == NOBODY) ? "Unknown" : GET_NAME(&mob_proto[(real_mobile(QST_MASTER(rnum)))]));
    else
      send_to_char(ch,
        "\tg%4d\tn) \tcUnknown Quest (it no longer exists)\tn\r\n", ++counter);
  }
  if (!counter)
    send_to_char(ch, "You haven't completed any quests yet.\r\n");
}
Ejemplo n.º 7
0
void assign_spec_procs (char type, sh_int vnum, int which, char startup)
{
	if (startup) { /*startup should always = 0 except one time at boot up*/
		do_initial_specs();
		return;
	} else {
		switch (toupper(type)) {
		case 'M':
			if (which < 0 || which > NUM_MOB_SPECS)  mob_index[real_mobile(vnum)].func=NULL;
			else ASSIGNMOB(vnum, mob_specproc_info[which].sfunc);
			break;
		case 'O':
			 if (which < 0 || which > NUM_OBJ_SPECS)  obj_index[real_object(vnum)].func=NULL;
			 else ASSIGNOBJ(vnum, obj_specproc_info[which].sfunc);
			 break;
		case 'R':
			 if (which < 0 || which > NUM_ROOM_SPECS)  world[real_room(vnum)].func=NULL;
			 else ASSIGNROOM(vnum, room_specproc_info[which].sfunc);
			 break;
		}  /*switch type*/
	}  /*else !startup*/
}
Ejemplo n.º 8
0
void assign_the_quests(void)
{
  qst_rnum rnum;
  mob_rnum mrnum;

  cmd_tell = find_command("tell");

  for (rnum = 0; rnum < total_quests; rnum ++) {
    if (QST_MASTER(rnum) == NOBODY) {
      log("SYSERR: Quest #%d has no questmaster specified.", QST_NUM(rnum));
      continue;
    }
    if ((mrnum = real_mobile(QST_MASTER(rnum))) == NOBODY) {
      log("SYSERR: Quest #%d has an invalid questmaster.", QST_NUM(rnum));
      continue;
    }
    if (mob_index[QST_MASTER(rnum)].func &&
 mob_index[(mrnum)].func != questmaster)
      QST_FUNC(rnum) = mob_index[(mrnum)].func;
    mob_index[(mrnum)].func = questmaster;
  }
}
Ejemplo n.º 9
0
int save_mobiles(zone_rnum rznum)
{
  zone_vnum vznum;
  FILE *mobfd;
  room_vnum i;
  mob_rnum rmob;
  int written;
  char mobfname[64], usedfname[64];

  if (rznum < 0 || rznum > top_of_zone_table) {
    log("SYSERR: GenOLC: save_mobiles: Invalid real zone number %d. (0-%d)", rznum, top_of_zone_table);
    return FALSE;
  }

  vznum = zone_table[rznum].number;
  sprintf(mobfname, "%s%d.new", MOB_PREFIX, vznum);
  if ((mobfd = fopen(mobfname, "w")) == NULL) {
    mudlog("SYSERR: GenOLC: Cannot open mob file for writing.", BRF, LVL_GOD, TRUE);
    return FALSE;
  }

  for (i = vznum * 100; i <= zone_table[rznum].top; i++) {
    if ((rmob = real_mobile(i)) == NOBODY)
      continue;
    check_mobile_strings(&mob_proto[rmob]);
    if (write_mobile_record(i, &mob_proto[rmob], mobfd) < 0)
      log("SYSERR: GenOLC: Error writing mobile #%d.", i);
  }
  fputs("$\n", mobfd);
  written = ftell(mobfd);
  fclose(mobfd);
  sprintf(usedfname, "%s%d.mob", MOB_PREFIX, vznum);
  remove(usedfname);
  rename(mobfname, usedfname);
  remove_from_save_list(vznum, SL_MOB);
  log("GenOLC: '%s' saved, %d bytes written.", usedfname, written);
  return written;
}
Ejemplo n.º 10
0
/*
 * Save new/edited mob to memory.
 */
void medit_save_internally(struct descriptor_data *d)
{
  int i;
  mob_rnum new_rnum;
  struct descriptor_data *dsc;

  i = (real_mobile(OLC_NUM(d)) == NOBODY);

  if ((new_rnum = add_mobile(OLC_MOB(d), OLC_NUM(d))) < 0) {
    log("medit_save_internally: add_object failed.");
    return;
  }

  if (!i)	/* Only renumber on new mobiles. */
    return;

  /*
   * Update keepers in shops being edited and other mobs being edited.
   */
  for (dsc = descriptor_list; dsc; dsc = dsc->next) {
    if (STATE(dsc) == CON_SEDIT)
      S_KEEPER(OLC_SHOP(dsc)) += (S_KEEPER(OLC_SHOP(dsc)) >= new_rnum);
    else if (STATE(dsc) == CON_MEDIT)
      GET_MOB_RNUM(OLC_MOB(dsc)) += (GET_MOB_RNUM(OLC_MOB(dsc)) >= new_rnum);
  }

  /*
   * Update other people in zedit too. From: C.Raehl 4/27/99
   */
  for (dsc = descriptor_list; dsc; dsc = dsc->next)
    if (STATE(dsc) == CON_ZEDIT)
      for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++)
        if (OLC_ZONE(dsc)->cmd[i].command == 'M')
          if (OLC_ZONE(dsc)->cmd[i].arg1 >= new_rnum)
            OLC_ZONE(dsc)->cmd[i].arg1++;
}
Ejemplo n.º 11
0
void zedit_parse(struct descriptor_data *d, char *arg)
{
  int pos, i = 0;

  switch (OLC_MODE(d)) {
/*-------------------------------------------------------------------*/
  case ZEDIT_CONFIRM_SAVESTRING:
    switch (*arg) {
    case 'y':
    case 'Y':
      /*
       * Save the zone in memory, hiding invisible people.
       */
      SEND_TO_Q("Saving zone info in memory.\r\n", d);
      zedit_save_internally(d);
      sprintf(buf, "OLC: %s edits zone info for room %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);
      break;
    default:
      SEND_TO_Q("Invalid choice!\r\n", d);
      SEND_TO_Q("Do you wish to save the zone info? : ", d);
      break;
    }
    break;
   /* End of ZEDIT_CONFIRM_SAVESTRING */

/*-------------------------------------------------------------------*/
  case ZEDIT_MAIN_MENU:
    switch (*arg) {
    case 'q':
    case 'Q':
      if (OLC_ZONE(d)->age || OLC_ZONE(d)->number) {
	SEND_TO_Q("Do you wish to save the changes to the zone info? (y//n) : ", d);
	OLC_MODE(d) = ZEDIT_CONFIRM_SAVESTRING;
      } else {
	SEND_TO_Q("No changes made.\r\n", d);
	cleanup_olc(d, CLEANUP_ALL);
      }
      break;
    case 'n':
    case 'N':
      /*
       * New entry.
       */
      SEND_TO_Q("What number in the list should the new command be? : ", d);
      OLC_MODE(d) = ZEDIT_NEW_ENTRY;
      break;
    case 'e':
    case 'E':
      /*
       * Change an entry.
       */
      SEND_TO_Q("Which command do you wish to change? : ", d);
      OLC_MODE(d) = ZEDIT_CHANGE_ENTRY;
      break;
    case 'd':
    case 'D':
      /*
       * Delete an entry.
       */
      SEND_TO_Q("Which command do you wish to delete? : ", d);
      OLC_MODE(d) = ZEDIT_DELETE_ENTRY;
      break;
    case 'z':
    case 'Z':
      /*
       * Edit zone name.
       */
      SEND_TO_Q("Enter new zone name : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_NAME;
      break;
    case 't':
    case 'T':
      /*
       * Edit top of zone.
       */
      if (GET_LEVEL(d->character) < LVL_IMPL)
	zedit_disp_menu(d);
      else {
	SEND_TO_Q("Enter new top of zone : ", d);
	OLC_MODE(d) = ZEDIT_ZONE_TOP;
      }
      break;
    case 'l':
    case 'L':
      /*
       * Edit zone lifespan.
       */
      SEND_TO_Q("Enter new zone lifespan : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_LIFE;
      break;
    case 'r':
    case 'R':
      /*
       * Edit zone reset mode.
       */
      SEND_TO_Q("\r\n"
		"0) Never reset\r\n"
		"1) Reset only when no players in zone\r\n"
		"2) Normal reset\r\n"
		"Enter new zone reset type : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_RESET;
      break;
    default:
      zedit_disp_menu(d);
      break;
    }
    break;
    /* End of ZEDIT_MAIN_MENU */

/*-------------------------------------------------------------------*/
  case ZEDIT_NEW_ENTRY:
    /*
     * Get the line number and insert the new line.
     */
    pos = atoi(arg);
    if (isdigit(*arg) && new_command(OLC_ZONE(d), pos)) {
      if (start_change_command(d, pos)) {
	zedit_disp_comtype(d);
	OLC_ZONE(d)->age = 1;
      }
    } else
      zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_DELETE_ENTRY:
    /*
     * Get the line number and delete the line.
     */
    pos = atoi(arg);
    if (isdigit(*arg)) {
      delete_command(OLC_ZONE(d), pos);
      OLC_ZONE(d)->age = 1;
    }
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_CHANGE_ENTRY:
    /*
     * Parse the input for which line to edit, and goto next quiz.
     */
    pos = atoi(arg);
    if (isdigit(*arg) && start_change_command(d, pos)) {
      zedit_disp_comtype(d);
      OLC_ZONE(d)->age = 1;
    } else
      zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_COMMAND_TYPE:
    /*
     * Parse the input for which type of command this is, and goto next
     * quiz.
     */
    OLC_CMD(d).command = toupper(*arg);
    if (!OLC_CMD(d).command || (strchr("MOPEDGR", OLC_CMD(d).command) == NULL)) {
      SEND_TO_Q("Invalid choice, try again : ", d);
    } else {
      if (OLC_VAL(d)) {	/* If there was a previous command. */
	SEND_TO_Q("Is this command dependent on the success of the previous one? (y//n)\r\n", d);
	OLC_MODE(d) = ZEDIT_IF_FLAG;
      } else {	/* 'if-flag' not appropriate. */
	OLC_CMD(d).if_flag = 0;
	zedit_disp_arg1(d);
      }
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_IF_FLAG:
    /*
     * Parse the input for the if flag, and goto next quiz.
     */
    switch (*arg) {
    case 'y':
    case 'Y':
      OLC_CMD(d).if_flag = 1;
      break;
    case 'n':
    case 'N':
      OLC_CMD(d).if_flag = 0;
      break;
    default:
      SEND_TO_Q("Try again : ", d);
      return;
    }
    zedit_disp_arg1(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG1:
    /*
     * Parse the input for arg1, and goto next quiz.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
      if ((pos = real_mobile(atoi(arg))) >= 0) {
	OLC_CMD(d).arg1 = pos;
	zedit_disp_arg2(d);
      } else
	SEND_TO_Q("That mobile does not exist, try again : ", d);
      break;
    case 'O':
    case 'P':
    case 'E':
    case 'G':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg1 = pos;
	zedit_disp_arg2(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    case 'D':
    case 'R':
    default:
      /*
       * We should never get here.
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG1: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG2:
    /*
     * Parse the input for arg2, and goto next quiz.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
    case 'O':
      OLC_CMD(d).arg2 = atoi(arg);
      OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
      zedit_disp_arg4(d);
      break;
    case 'G':
      OLC_CMD(d).arg2 = atoi(arg);
      zedit_disp_arg4(d);
      break;
    case 'P':
    case 'E':
      OLC_CMD(d).arg2 = atoi(arg);
      zedit_disp_arg3(d);
      break;
    case 'D':
      pos = atoi(arg);
      /*
       * Count directions.
       */
      if (pos < 0 || pos > NUM_OF_DIRS)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg2 = pos;
	zedit_disp_arg3(d);
      }
      break;
    case 'R':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg2 = pos;
	zedit_disp_menu(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    default:
      /*
       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG2: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG3:
    /*
     * Parse the input for arg3, and goto arg4's menu.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'E':
      pos = atoi(arg);
      /*
       * Count number of wear positions.  We could use NUM_WEARS, this is
       * more reliable.
       */
      while (*equipment_types[i] != '\n')
	i++;
      if (pos < 0 || pos > i)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      }
      break;
    case 'P':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    case 'D':
      pos = atoi(arg);
      if (pos < 0 || pos > 2)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      }
      break;
    case 'M':
    case 'O':
    case 'G':
    case 'R':
    default:
      /*
       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

  case ZEDIT_ARG4:
    /*
     * Parse the input for arg4, and go back to main menu.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
    case 'O':
    case 'G':
    case 'E':
      pos = atoi(arg);
      if (pos < 0 || pos > 100)
        SEND_TO_Q("Try again : ", d);
      else {
        OLC_CMD(d).arg4 = pos;
        zedit_disp_menu(d);
      }
      break;

    case 'P':
    case 'D':
        OLC_CMD(d).arg3 = 100;
      break;

    default:
      /*

       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;


/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_NAME:
    /*
     * Add new name and return to main menu.
     */
    if (genolc_checkstring(d, arg)) {
      if (OLC_ZONE(d)->name)
        free(OLC_ZONE(d)->name);
      else
        log("SYSERR: OLC: ZEDIT_ZONE_NAME: no name to free!");
      OLC_ZONE(d)->name = str_dup(arg);
      OLC_ZONE(d)->number = 1;
    }
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_RESET:
    /*
     * Parse and add new reset_mode and return to main menu.
     */
    pos = atoi(arg);
    if (!isdigit(*arg) || pos < 0 || pos > 2)
      SEND_TO_Q("Try again (0-2) : ", d);
    else {
      OLC_ZONE(d)->reset_mode = pos;
      OLC_ZONE(d)->number = 1;
      zedit_disp_menu(d);
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_LIFE:
    /*
     * Parse and add new lifespan and return to main menu.
     */
    pos = atoi(arg);
    if (!isdigit(*arg) || pos < 0 || pos > 240)
      SEND_TO_Q("Try again (0-240) : ", d);
    else {
      OLC_ZONE(d)->lifespan = pos;
      OLC_ZONE(d)->number = 1;
      zedit_disp_menu(d);
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_TOP:
    /*
     * Parse and add new top room in zone and return to main menu.
     */
    if (OLC_ZNUM(d) == top_of_zone_table)
      OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, 32000);
    else
      OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, zone_table[OLC_ZNUM(d) + 1].number * 100);
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  default:
    /*
     * We should never get here, but just in case...
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog("SYSERR: OLC: zedit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE);
    SEND_TO_Q("Oops...\r\n", d);
    break;
  }
}
Ejemplo n.º 12
0
void medit_parse(struct descriptor_data *d, char *arg)
{

    int number;
    int mob_number;  // the RNUM

    switch(d->edit_mode)
    {
    case MEDIT_CONFIRM_EDIT:
        /* if player hits 'Y' then edit mob */
        switch (*arg) {
        case 'y':
        case 'Y':
            medit_disp_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            /* free up the editing mob */
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit it?\r\n", CH);
            break;
        }
        break;                      /* end of MEDIT_CONFIRM_EDIT */

    case MEDIT_CONFIRM_SAVESTRING:
        switch(*arg) {
        case 'y':
        case 'Y':
            // first write to the internal tables
            if (!from_ip_zone(d->edit_number)) {
                sprintf(buf,"%s wrote new mob #%ld",
                        GET_CHAR_NAME(d->character), d->edit_number);
                mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            }
            mob_number = real_mobile(d->edit_number);
            if (mob_number > 0) {
                // first we go through the entire list of mobs to find out
                // which are pointing to this prototype; if it is, it gets
                // replaced
                struct char_data *i, *temp;
                int c;
                for (i = character_list; i; i = i->next) {
                    if (mob_number == i->nr) {
                        // alloc a temp mobile
                        temp = Mem->GetCh();
                        *temp = *i;
                        *i = *d->edit_mob;
                        /* copy game-time dependent vars over */
                        i->in_room = temp->in_room;
                        i->nr = mob_number;
                        i->affected = temp->affected;
                        i->carrying = temp->carrying;
                        i->cyberware = temp->cyberware;
                        i->bioware = temp->bioware;
                        // any eq worn
                        for (c = 0; c < NUM_WEARS; ++c)
                            i->equipment[c] = temp->equipment[c];
                        i->next_in_room = temp->next_in_room;
                        i->next = temp->next;
                        i->next_fighting = temp->next_fighting;
                        i->followers = temp->followers;
                        i->master = temp->master;
                        i->char_specials.fighting = temp->char_specials.fighting;
                        i->char_specials.hunting = temp->char_specials.hunting;
                        i->mob_specials.last_direction = temp->mob_specials.last_direction;
                        i->mob_specials.memory = temp->mob_specials.memory;
                        i->mob_specials.wait_state = temp->mob_specials.wait_state;
                        Mem->ClearCh(temp);
                    } // end if statement

                } // end for loop

                // now you can free the old prototype and put in the new one
                if (mob_proto[mob_number].player.physical_text.keywords)
                    delete [] mob_proto[mob_number].player.physical_text.keywords;
                if (mob_proto[mob_number].player.title)
                    delete [] mob_proto[mob_number].player.title;
                if (mob_proto[mob_number].player.physical_text.name)
                    delete [] mob_proto[mob_number].player.physical_text.name;
                if (mob_proto[mob_number].player.physical_text.room_desc)
                    delete [] mob_proto[mob_number].player.physical_text.room_desc;
                if (mob_proto[mob_number].player.physical_text.look_desc)
                    delete [] mob_proto[mob_number].player.physical_text.look_desc;
                if (mob_proto[mob_number].mob_specials.arrive)
                    delete [] mob_proto[mob_number].mob_specials.arrive;
                if (mob_proto[mob_number].mob_specials.leave)
                    delete [] mob_proto[mob_number].mob_specials.leave;


                mob_proto[mob_number] = *d->edit_mob;
                mob_proto[mob_number].nr = mob_number;

            } else {  // if not, we need to make a new spot in the list
                int             counter;
                int             found = FALSE;

                struct char_data *new_mob_proto;
                struct index_data *new_mob_index;
                struct char_data *temp_mob;

                // two because you are adding one and you need one over
                new_mob_index = new struct index_data[top_of_mobt + 2];
                new_mob_proto = new struct char_data[top_of_mobt + 2];
                // count through the tables
                for (counter = 0; counter < top_of_mobt + 1; counter++) {
                    /* if we haven't found it */
                    if (!found) {
                        /* check if current virtual is bigger than our virtual */
                        if (MOB_VNUM_RNUM(counter) > d->edit_number) {
                            /* eureka. insert now */
                            /*---------*/
                            new_mob_index[counter].vnum = d->edit_number;
                            new_mob_index[counter].number = 0;
                            new_mob_index[counter].func = NULL;
                            /*---------*/
                            new_mob_proto[counter] = *(d->edit_mob);
                            new_mob_proto[counter].in_room = NOWHERE;
                            /* it is now safe (and necessary!) to assign real number to
                             * the edit_mob, which has been -1 all this time */
                            d->edit_mob->nr = counter;
                            /* and assign to prototype as well */
                            new_mob_proto[counter].nr = counter;
                            found = TRUE;
                            /* insert the other proto at this point */
                            new_mob_index[counter + 1] = mob_index[counter];
                            new_mob_proto[counter + 1] = mob_proto[counter];
                            new_mob_proto[counter + 1].nr = counter + 1;
                        } else {
                            /* just copy from old to new, no num change */
                            new_mob_proto[counter] = mob_proto[counter];
                            new_mob_index[counter] = mob_index[counter];
                        }

                    } else { // if !found else
                        /* we HAVE already found it.. therefore copy to mobile + 1 */
                        new_mob_index[counter + 1] = mob_index[counter];
                        new_mob_proto[counter + 1] = mob_proto[counter];
                        new_mob_proto[counter + 1].nr = counter + 1;
                    }
                } // for loop through list


                /* if we STILL haven't found it, means the mobile was > than all
                * the other mobs.. so insert at end */
                if (!found) {
                    new_mob_index[top_of_mobt + 1].vnum = d->edit_number;
                    new_mob_index[top_of_mobt + 1].number = 0;
                    new_mob_index[top_of_mobt + 1].func = NULL;

                    clear_char(new_mob_proto + top_of_mobt + 1);
                    new_mob_proto[top_of_mobt + 1] = *(d->edit_mob);
                    new_mob_proto[top_of_mobt + 1].in_room = NOWHERE;
                    new_mob_proto[top_of_mobt + 1].nr = top_of_mobt + 1;
                    /* it is now safe (and necessary!) to assign real number to
                     * the edit_mob, which has been -1 all this time */
                    d->edit_mob->nr = top_of_mobt + 1;
                }
                top_of_mobt++;

                /* we also have to renumber all the mobiles currently    *
                *  existing in the world. This is because when I start   *
                * extracting mobiles, bad things will happen!           */
                for (temp_mob = character_list; temp_mob; temp_mob = temp_mob->next)
                    if (GET_MOB_RNUM (temp_mob) >= d->edit_mob->nr)
                        GET_MOB_RNUM (temp_mob)++;

                /* free and replace old tables */
                delete [] mob_proto;
                delete [] mob_index;
                mob_proto = new_mob_proto;
                mob_index = new_mob_index;

                /* RENUMBER ZONE TABLES HERE, only              *
                *   because I ADDED a mobile!                   *
                *   This code shamelessly ripped off from db.c */

                int zone, cmd_no;
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    for (cmd_no = 0; cmd_no < zone_table[zone].num_cmds; cmd_no++) {
                        switch (ZCMD.command) {
                        case 'M':
                            ZCMD.arg1 = (ZCMD.arg1 >= d->edit_mob->nr ? ZCMD.arg1 + 1 : ZCMD.arg1);
                            break;
                        }

                    }

            } // finally done putting the mobile into memory

            send_to_char("Writing mobile to disk...", CH);
            write_mobs_to_disk(d->character->player_specials->saved.zonenum);

            // again, here we don't delete it cause we don't want to end up
            // deleting the strings from the prototypes
            if (d->edit_mob)
                Mem->ClearCh(d->edit_mob);
            d->edit_mob = NULL;
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            send_to_char("Done.\r\n", d->character);
            break;
        case 'n':
        case 'N':
            send_to_char("Mobile not saved, aborting.\r\n", d->character);
            STATE(d) = CON_PLAYING;
            // complete nuke
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            d->edit_zone = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("Invalid choice!\r\n", d->character);
            send_to_char("Do you wish to save this mobile internally?\r\n", d->character);
            break;
        }

        break;

    case MEDIT_MAIN_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "y");
            break;
        case 'x':
        case 'X':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "n");
            break;
        case '1':
            send_to_char("Enter keywords:", CH);
            d->edit_mode = MEDIT_EDIT_NAMELIST;
            break;
        case '2':
            send_to_char("Enter name:", CH);
            d->edit_mode = MEDIT_SHORT_DESCR;
            break;
        case '3':
            send_to_char("Enter room description:", CH);
            d->edit_mode = MEDIT_REG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_REG_DESC_LENGTH;
            d->mail_to = 0;
            break;
        case '4':
            // go to modify.cc
            send_to_char("Enter look description:\r\n", CH);
            d->edit_mode = MEDIT_LONG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_MESSAGE_LENGTH;
            d->mail_to = 0;
            break;
        case '5':
            medit_disp_mobflags_menu(d);
            d->edit_mode = MEDIT_MOB_FLAGS;
            break;
        case '6':
            medit_disp_affected_menu(d);
            d->edit_mode = MEDIT_AFF_FLAGS;
            break;
        case '8':
            send_to_char("Enter average nuyen: ", CH);
            d->edit_mode = MEDIT_NUYEN;
            break;
        case '9':
            send_to_char("Enter bonus karma points: ", CH);
            d->edit_mode = MEDIT_EXPERIENCE;
            break;
        case 'a':
            medit_disp_att_menu(d);
            d->edit_mode = MEDIT_ATTRIBUTES;
            break;
        case 'b':
            send_to_char("Enter level: ", CH);
            d->edit_mode = MEDIT_LEVEL;
            break;
        case 'c':
            send_to_char("Enter ballistic armor points: ", CH);
            d->edit_mode = MEDIT_BALLISTIC;
            break;
        case 'd':
            send_to_char("Enter impact armor points: ", CH);
            d->edit_mode = MEDIT_IMPACT;
            break;
        case 'e':
            send_to_char("Enter max physical points: ", CH);
            d->edit_mode = MEDIT_PHYSICAL;
            break;
        case 'f':
            send_to_char("Enter max mental points: ", CH);
            d->edit_mode = MEDIT_MENTAL;
            break;
        case 'g':
            medit_disp_pos_menu(d);
            send_to_char("Enter position: ", CH);
            d->edit_mode = MEDIT_POSITION;
            break;
        case 'h':
            medit_disp_pos_menu(d);
            send_to_char("Enter default position: ", CH);
            d->edit_mode = MEDIT_DEFAULT_POSITION;
            break;
        case 'i':
            medit_disp_gender_menu(d);
            d->edit_mode = MEDIT_GENDER;
            break;
        case 'j':
            send_to_char("Enter weight (in kilograms): ", CH);
            d->edit_mode = MEDIT_WEIGHT;
            break;
        case 'k':
            send_to_char("Enter height (in centimeters): ", CH);
            d->edit_mode = MEDIT_HEIGHT;
            break;
        case 'l':
            medit_disp_class_menu(d);
            d->edit_mode = MEDIT_CLASS;
            break;
        case 'm':
            medit_disp_attack_menu(d);
            d->edit_mode = MEDIT_ATTACK_TYPE;
            break;
        case 'n':
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
            break;
        case 'o':
            send_to_char("Enter arrive text: ", CH);
            d->edit_mode = MEDIT_ARRIVE_MSG;
            break;
        case 'p':
            send_to_char("Enter leave text: ", CH);
            d->edit_mode = MEDIT_LEAVE_MSG;
            break;

        default:
            medit_disp_menu(d);
            break;
        }
        break;

    case MEDIT_EDIT_NAMELIST:
        if (MOB->player.physical_text.keywords)
            delete [] MOB->player.physical_text.keywords;
        MOB->player.physical_text.keywords = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_SHORT_DESCR:
        if (MOB->player.physical_text.name)
            delete [] MOB->player.physical_text.name;
        MOB->player.physical_text.name = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_ARRIVE_MSG:
        if (MOB->mob_specials.arrive)
            delete [] MOB->mob_specials.arrive;
        MOB->mob_specials.arrive = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_LEAVE_MSG:
        if (MOB->mob_specials.leave)
            delete [] MOB->mob_specials.leave;
        MOB->mob_specials.leave = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_REG_DESCR:
        // you should not come here
        break;

    case MEDIT_LONG_DESCR:
        // you should not come here
        break;

    case MEDIT_MOB_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > MOB_MAX))
            medit_disp_mobflags_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                MOB_FLAGS(MOB).ToggleBit(number-1);
                medit_disp_mobflags_menu(d);
            }
        }
        break;

    case MEDIT_AFF_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > AFF_MAX))
            medit_disp_affected_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                AFF_FLAGS(MOB).ToggleBit(number - 1);
                medit_disp_affected_menu(d);
            }
        }
        break;

    case MEDIT_NUYEN:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average nuyen: ", CH);
        } else {
            GET_NUYEN(MOB) = number;
            send_to_char("Enter average credstick value: ", CH);
            d->edit_mode = MEDIT_CREDSTICK;
        }
        break;

    case MEDIT_CREDSTICK:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average credstick value: ", CH);
        } else {
            GET_BANK(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_EXPERIENCE:
        number = atoi(arg);
        if ((number < 0) || (number > 7500)) {
            send_to_char("Value must range between 0 and 7500.\r\n", CH);
            send_to_char("Enter bonus karma points: ", CH);
        } else {
            int karma;
            if (number > (karma=calc_karma(NULL, MOB))) {
                send_to_char("Bonus karma may not be higher than actual karma.  Lowering.\r\n", CH);
                number = karma;
            }
            GET_KARMA(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_SKILLS:
        switch (*arg) {
        case '0':
            medit_disp_menu(d);
            break;
        case '1':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1;
            break;
        case '2':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2;
            break;
        case '3':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3;
            break;
        case '4':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4;
            break;
        case '5':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5;
            break;

        default:
            medit_disp_skill_menu(d);
            break;
        }
        break; // end of MEDIT_SKILLS

    case MEDIT_SKILL1:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1_VAL;
        }
        break;

    case MEDIT_SKILL2:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2_VAL;
        }
        break;
    case MEDIT_SKILL3:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3_VAL;
        }
        break;
    case MEDIT_SKILL4:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4_VAL;
        }
        break;
    case MEDIT_SKILL5:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5_VAL;
        }
        break;

    case MEDIT_SKILL1_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[0] = 0;
            MOB->mob_specials.mob_skills[1] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[1] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[0]) = MOB->mob_specials.mob_skills[1];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0],
                      MOB->mob_specials.mob_skills[1]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL2_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[2] = 0;
            MOB->mob_specials.mob_skills[3] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[3] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[2]) = MOB->mob_specials.mob_skills[3];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[2],
                      MOB->mob_specials.mob_skills[3]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL3_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[4] = 0;
            MOB->mob_specials.mob_skills[5] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[5] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[4]) = MOB->mob_specials.mob_skills[5];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[4],
                      MOB->mob_specials.mob_skills[5]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL4_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[6] = 0;
            MOB->mob_specials.mob_skills[7] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[7] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[6]) = MOB->mob_specials.mob_skills[7];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[6],
                      MOB->mob_specials.mob_skills[7]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL5_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[8] = 0;
            MOB->mob_specials.mob_skills[9] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[9] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[8]) = MOB->mob_specials.mob_skills[9];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[8],
                      MOB->mob_specials.mob_skills[9]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;


    case MEDIT_ATTRIBUTES:
        switch (*arg) {
        case '1':
            send_to_char("Enter body attribute: ", CH);
            d->edit_mode = MEDIT_BOD;
            break;
        case '2':
            send_to_char("Enter quickness attribute: ", CH);
            d->edit_mode = MEDIT_QUI;
            break;
        case '3':
            send_to_char("Enter strength attribute: ", CH);
            d->edit_mode = MEDIT_STR;
            break;
        case '4':
            send_to_char("Enter charisma attribute: ", CH);
            d->edit_mode = MEDIT_CHA;
            break;
        case '5':
            send_to_char("Enter intelligence attribute: ", CH);
            d->edit_mode = MEDIT_INT;
            break;
        case '6':
            send_to_char("Enter willpower attribute: ", CH);
            d->edit_mode = MEDIT_WIL;
            break;
        case '7':
            send_to_char("Enter magic attribute: ", CH);
            d->edit_mode = MEDIT_MAG;
            break;
        case 'q':
        case 'Q': // back to main menu
            medit_disp_menu(d);
            break;
        default:
            medit_disp_att_menu(d);
            break;
        }
        break;

    case MEDIT_BOD:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter body attribute: ", CH);
        } else {
            GET_REAL_BOD(MOB) = number;
            MOB->real_abils.bod_index = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_QUI:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter quickness attribute: ", CH);
        } else {
            GET_REAL_QUI(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_INT(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_STR:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter strength attribute: ", CH);
        } else {
            GET_REAL_STR(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_CHA:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter charisma attribute: ", CH);
        } else {
            GET_REAL_CHA(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_INT:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter intelligence attribute: ", CH);
        } else {
            GET_REAL_INT(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_QUI(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_WIL:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter willpower attribute: ", CH);
        } else {
            GET_REAL_WIL(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_MAG:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Value must range between 0 and 50.\r\n", CH);
            send_to_char("Enter magic attribute: ", CH);
        } else {
            MOB->real_abils.mag = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_LEVEL:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Invalid choice.\r\n", CH);
            send_to_char("Enter level: ", CH);
        } else {
            GET_LEVEL(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_BALLISTIC:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter ballistic armor points: ", CH);
        } else {
            GET_BALLISTIC(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_IMPACT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter impact armor points: ", CH);
        } else {
            GET_IMPACT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_PHYSICAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max physical points: ", CH);
        } else {
            GET_MAX_PHYSICAL(MOB) = number * 100;
            GET_PHYSICAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_MENTAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max mental points: ", CH);
        } else {
            GET_MAX_MENTAL(MOB) = number * 100;
            GET_MENTAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_WEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter weight (in kilograms): ", CH);
        } else {
            GET_WEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_HEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter height (in centimeters): ", CH);
        } else {
            GET_HEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_CLASS:
        number = atoi(arg);
        if ((number < 1) || (number > NUM_MOB_CLASSES))
            medit_disp_class_menu(d);
        else {
            GET_RACE(MOB) = (number - 1);
            medit_disp_menu(d);
        }
        break;

    case MEDIT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_DEFAULT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter default position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_DEFAULT_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_GENDER:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_gender_menu(d);
        } else if (number != 0) // 0 = quit
            GET_SEX(MOB) = (number - 1);
        medit_disp_menu(d);
        break;

    case MEDIT_ATTACK_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > NUM_ATTACK_TYPES)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_attack_menu(d);
        } else if (number != 0) // 0 = quit
            MOB->mob_specials.attack_type = number-1 + TYPE_HIT;
        medit_disp_menu(d);
        break;

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

  if (spellnum < 1 || spellnum > TOP_SPELL_DEFINE)
    return (0);

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


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

  if (IS_SET(SINFO.routines, MAG_AFFECTS))
    mag_affects(level, caster, cvict, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_UNAFFECTS))
    mag_unaffects(level, caster, cvict, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_POINTS))
    mag_points(level, caster, cvict, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_ALTER_OBJS))
    mag_alter_objs(level, caster, ovict, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_GROUPS))
    mag_groups(level, caster, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_MASSES))
    mag_masses(level, caster, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_AREAS))
    mag_areas(level, caster, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_SUMMONS))
    mag_summons(level, caster, ovict, spellnum, savetype);

  if (IS_SET(SINFO.routines, MAG_CREATIONS))
    mag_creations(level, caster, spellnum);

  if (IS_SET(SINFO.routines, MAG_MANUAL))
    switch (spellnum) {
    case SPELL_CHARM:		MANUAL_SPELL(spell_charm); break;
    case SPELL_CREATE_WATER:	MANUAL_SPELL(spell_create_water); break;
    case SPELL_DETECT_POISON:	MANUAL_SPELL(spell_detect_poison); break;
    case SPELL_ENCHANT_WEAPON:  MANUAL_SPELL(spell_enchant_weapon); break;
    case SPELL_IDENTIFY:	MANUAL_SPELL(spell_identify); break;
    case SPELL_LOCATE_OBJECT:   MANUAL_SPELL(spell_locate_object); break;
    case SPELL_SUMMON:		MANUAL_SPELL(spell_summon); break;
    case SPELL_WORD_OF_RECALL:  MANUAL_SPELL(spell_recall); break;
    case SPELL_TELEPORT:	MANUAL_SPELL(spell_teleport); break;
    }

  return (1);
}
Ejemplo n.º 14
0
// MAIN LOOP!
void zedit_parse(struct descriptor_data *d, char *arg)
{
    int number, i = 0, zone;

    switch (d->edit_mode)
    {
    case ZEDIT_CONFIRM_EDIT_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            *d->edit_zon = zone_table[d->edit_number];
            if (zone_table[d->edit_number].name)
                d->edit_zon->name = str_dup(zone_table[d->edit_number].name);
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_CREATE_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            // set a few vars
            ZON->name = str_dup("an unfinished zone");
            ZON->number = CH->player_specials->saved.zonenum;
            ZON->top = ZON->number * 100 + 99;
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_SAVEDATA:
        switch (*arg) {
            int zone_num;
        case 'y':
        case 'Y':
            zone_num = real_zone(ZON->number);
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first we insert into memory
            if (zone_num > -1) { // ie, it already exists
                ZON->cmd = zone_table[zone_num].cmd;
                delete [] zone_table[zone_num].name;
                zone_table[zone_num] = *ZON;
            } else { // here we got to add a new spot
                int counter;
                int found = 0;
                struct zone_data *new_z_table;
                // create new table + 2
                new_z_table = new struct zone_data[top_of_zone_table + 2];

                for (counter = 0; counter < top_of_zone_table + 1; counter++) {
                    if (!found) {
                        if (zone_table[counter].number > CH->player_specials->saved.zonenum) {
                            new_z_table[counter] = *(ZON);
                            found = 1;
                            new_z_table[counter + 1] = zone_table[counter];
                        } else
                            new_z_table[counter] = zone_table[counter];
                    } else
                        new_z_table[counter + 1] = zone_table[counter];
                }
                if (!found)
                    new_z_table[top_of_zone_table + 1] = *(ZON);
                top_of_zone_table++;
                delete [] zone_table;
                zone_table = new_z_table;
            }
            write_zone_to_disk(ZONENUM);
            write_index_file("zon");
            d->edit_mode = 0;
            delete ZON;
            ZON = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);

            break; // end of 'y' case in confirm savestring
        case 'n':
        case 'N':
            if (ZON) {
                if (ZON->name)
                    delete [] ZON->name;
                delete ZON;
            }
            STATE(d) = CON_PLAYING;
            ZON = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // end of 'n' case in confirm savestring
        default:
            send_to_char("Please enter yes or no.\r\n"
                         "Do you wish to save this zone internally?\r\n", CH);
            break;
        }
        break; // end of confirm savestring

    case ZEDIT_CONFIRM_ADD_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to add a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_INSERT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            // so it knows to insert if they decide to save
            d->edit_number2 = TRUE;
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to insert a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_EDIT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            *COM = zone_table[real_zone(ZONENUM)].cmd[d->edit_number];
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit the command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_DATA_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVEDATA;
            break;
        case '1':
            send_to_char("Enter zone name: ", CH);
            d->edit_mode = ZEDIT_ZONE_NAME;
            break;
        case '2':
            send_to_char("Enter top of zone: ", CH);
            d->edit_mode = ZEDIT_TOP_OF_ZONE;
            break;
        case '3':
            send_to_char("Lifespan (in ticks between resets): ", CH);
            d->edit_mode = ZEDIT_LIFESPAN;
            break;
        case '4':
            CLS(CH);
            send_to_char("1) Don't reset\r\n"
                         "2) Reset only if no PCs are in the zone\r\n"
                         "3) Always reset\r\n"
                         "0) Quit\r\n"
                         "Enter reset mode: ", CH);
            d->edit_mode = ZEDIT_RESET_MODE;
            break;
        case '5':
            send_to_char("Zone security (1 (none) - 15 (paranoid)):\r\n", CH);
            d->edit_mode = ZEDIT_SECURITY;
            break;
        case '6':
            send_to_char("0) Seattle\r\n"
                         "1) Portland\r\n"
                         "Enter juridiction: ", CH);
            d->edit_mode = ZEDIT_JURID;
            break;
        case '7':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Enter ID list seperated by spaces:\r\n", CH);
            d->edit_mode = ZEDIT_ID_LIST;
            break;
        case '8':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Zone is connected (1 - yes, 0 - no)? ", CH);
            d->edit_mode = ZEDIT_CONNECTED;
            break;
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            zedit_disp_data_menu(d);
            break;
        }
        break;

    case ZEDIT_COMMAND_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVECMDS;
            break;
        case '1':
            zedit_disp_type_cmd(d);
            d->edit_mode = ZEDIT_CMD_TYPE;
            break;
        case '2':
            send_to_char("\r\n1) Always\r\n2) If last\r\nEnter your selection: ",
                         CH);
            d->edit_mode = ZEDIT_IF_FLAG_CMD;
            break;
        case '3':
            switch (COM->command) {
            case 'M':
            case 'S':
                send_to_char("\r\nEnter virtual number of mob: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'H':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'G':
            case 'R':
            case 'N':
            case 'C':
                send_to_char("\r\nEnter virtual number of obj: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'D':
                zedit_disp_direction_menu(d);
                d->edit_mode = ZEDIT_DIRECTION_OF_DOOR;
                break;
            case 'V':
                send_to_char("\r\nEnter virtual number of vehicle: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '4':
            switch (COM->command) {
            case 'M':
            case 'S':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'N':
            case 'G':
            case 'H':
            case 'V':
                send_to_char("Enter max allowed to exist in game: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            case 'R':
            case 'D':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_REMOVE_ROOM;
                break;
            case 'C':
                send_to_char(" 0) Cyberware\r\n 1) Bioware\r\nEnter location to place obj: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '5':
            switch (COM->command) {
            case 'M':
            case 'O':
            case 'V':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'H':
                send_to_char("Enter the host number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'P':
                send_to_char("Enter the object number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'E':
                zedit_disp_wear_menu(d);
                d->edit_mode = ZEDIT_WEAR;
                break;
            case 'D':
                zedit_disp_state_menu(d);
                d->edit_mode = ZEDIT_DOOR_STATE;
                break;
            case 'N':
                send_to_char("Enter total number to give mob: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        }
        break;

    case ZEDIT_CONFIRM_SAVECMDS:
        int zone_num, top_of_cmds;
        switch (*arg) {
        case 'y':
        case 'Y':
            zone_num = real_zone(ZONENUM);
            top_of_cmds = zone_table[zone_num].num_cmds;
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first, determine if you are adding or replacing
            if (d->edit_number < top_of_cmds) {
                if (!d->edit_number2)
                    zone_table[zone_num].cmd[d->edit_number] = *(COM);
                else {
                    int counter;
                    struct reset_com *new_cmds;
                    new_cmds = new struct reset_com[top_of_cmds + 1];
                    if (top_of_cmds > 1) {
                        // first count your way up
                        for (counter = 0; counter < d->edit_number; counter++)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter];
                        for (counter = top_of_cmds; counter > d->edit_number;
                                counter--)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter-1];
                        new_cmds[d->edit_number] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    } else {
                        new_cmds[1] = zone_table[zone_num].cmd[0];
                        new_cmds[0] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        if (zone_table[zone_num].cmd)
                            delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    }
                }
            } else {
                int counter;
                struct reset_com *new_cmds;
                // create a new set of commands, with 1 extra spot
                new_cmds = new struct reset_com[top_of_cmds + 1];
                // we know it is always going in at the end, so we copy the old 1st
                if (top_of_cmds > 0) { // you have to do this in case there are 0 cmds
                    for (counter = 0; counter < top_of_cmds; counter++)
                        new_cmds[counter] = zone_table[zone_num].cmd[counter];
                    // tada, here it goes now, do not increase counter, for loop
                    new_cmds[counter] = *(COM);          // already did!
                    zone_table[zone_num].num_cmds++;
                    delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                } else {
                    new_cmds[0] = *(COM);
                    zone_table[zone_num].num_cmds++;
                    if (zone_table[zone_num].cmd)
                        delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                }
            } // end else
            write_zone_to_disk(ZONENUM);
            d->edit_mode = 0;
            delete COM;
            COM = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);
            break; // for 'y' case
        case 'n':
        case 'N':
            if (COM)
                delete COM;
            STATE(d) = CON_PLAYING;
            COM = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // for 'n' case
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            break;
        } // for switch in confirm save cmds
        break; // for ZEDIT_CONFIRM_SAVECMDS

    case ZEDIT_ARG3:
        number = atoi(arg);
        switch (COM->command) {
        case 'H':
            COM->arg3 = MAX(0, real_host(number));
            break;
        case 'M':
        case 'V':
        case 'O':
            COM->arg3 = MAX(0, real_room(number));
            if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                                  number <= zone_table[real_zone(ZONENUM)].top))
                COM->arg3 = 0;
            break;
        case 'P':
            COM->arg3 = MAX(0, real_object(number));
            if (!access_level(CH, LVL_ADMIN) && (number < 600 || number > 699)) {
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                        break;
                if (zone <= top_of_zone_table) {
                    for (i = 0; i < 5; i++)
                        if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                            break;
                } else
                    i = 5;
            }
            if (i >= 5)
                COM->arg3 = 0;
            break;
        case 'N':
            COM->arg3 = MIN(25, MAX(0, number));
            break;
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DOOR_STATE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            zedit_disp_state_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_WEAR:
        number = atoi(arg);
        if ((number < 0) || (number > (NUM_WEARS - 1))) {
            zedit_disp_wear_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_REMOVE_ROOM:
        number = atoi(arg);
        COM->arg1 = MAX(0, real_room(number));
        if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                              number <= zone_table[real_zone(ZONENUM)].top))
            COM->arg1 = 0;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG2:
        number = atoi(arg);
        if (COM->command == 'C' && (number < 0 || number > 1)) {
            send_to_char("Value must be either 0 (cyberware) or 1 (bioware).\r\n"
                         "Enter location to place obj: ", CH);
            return;
        } else if ((number < -1) || (number > 1000)) {
            send_to_char("Value must be between -1 and 1000.\r\n"
                         "Enter max allowed to exist in game: ", CH);
            return;
        }
        COM->arg2 = number;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DIRECTION_OF_DOOR:
        number = atoi(arg);
        if (number < 0 || number > 10) {
            zedit_disp_direction_menu(d);
            return;
        } else if (number != 0)
            COM->arg2 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG1:
        number = atoi(arg);
        if (COM->command == 'V') {
            COM->arg1 = MAX(0, real_vehicle(number));
        } else {
            if (COM->command == 'M' || COM->command == 'S') {
                COM->arg1 = MAX(0, real_mobile(number));
                if (!access_level(CH, LVL_ADMIN)) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5)
                    COM->arg1 = 0;
            } else {
                if (COM->command == 'R')
                    COM->arg2 = MAX(0, real_object(number));
                else
                    COM->arg1 = MAX(0, real_object(number));
                if (!access_level(CH, LVL_ADMIN) && (number < 300 || number > 699 || (number > 499 && number < 600))) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5) {
                    if (COM->command == 'R')
                        COM->arg2 = 0;
                    else
                        COM->arg1 = 0;
                }
            }
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_CMD_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > 9) && *arg != 'n') {
            zedit_disp_type_cmd(d);
            send_to_char("\r\nInvalid selection.  Please try again: ", CH);
            return;
        } else {
            COM->command = get_real_type(arg);
            if ((COM->command == 'E') || (COM->command == 'G') ||
                    (COM->command == 'P') || (COM->command == 'N') || (COM->command == 'C'))
                COM->if_flag = 1;
            else
                COM->if_flag = 0;
            COM->arg1 = 0;
            COM->arg2 = 0;
            COM->arg3 = 0;
        }

        zedit_disp_command_menu(d);
        break;

    case ZEDIT_IF_FLAG_CMD:
        number = atoi(arg);
        if ((number < 1) || (number > 2)) {
            send_to_char("Invalid selection.\r\n1) Always\r\n2) If last\r\n"
                         "Enter your selection: ", CH);
        } else {
            COM->if_flag = COM->if_flag;
            zedit_disp_command_menu(d);
        }
        break;

    case ZEDIT_ZONE_NAME:
        if (ZON->name)
            delete [] ZON->name;
        ZON->name = str_dup(arg);
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_SECURITY:
        number = atoi(arg);
        if (number < 1 || number > 15) {
            send_to_char("Security rating must range from 1 to 15.\r\nZone security: ", CH);
            return;
        }
        ZON->security = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_ID_LIST: {
        int t[5] = {0, 0, 0, 0, 0};
        if (sscanf(arg, "%d %d %d %d %d\n", &t[0], &t[1], &t[2], &t[3], &t[4]) == 5) {
            ZON->editor_ids[0] = t[0];
            ZON->editor_ids[1] = t[1];
            ZON->editor_ids[2] = t[2];
            ZON->editor_ids[3] = t[3];
            ZON->editor_ids[4] = t[4];
        }
        zedit_disp_data_menu(d);
    }
    break;
    case ZEDIT_CONNECTED:
        number = atoi(arg);
        if (number != 0 && number != 1) {
            send_to_char("Value must be 0 or 1!  Zone is connected? ", CH);
            return;
        }

        sprintf(arg, "%s set zone %d to connected %d (was %d)",
                GET_CHAR_NAME( CH ), ZON->number, number, ZON->connected );
        mudlog(arg, CH, LOG_WIZLOG, TRUE);

        ZON->connected = number;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_TOP_OF_ZONE:
        number = atoi(arg);
        if ((d->edit_number == top_of_zone_table) || (d->edit_number == -1))
            if ((number < ZON->number * 100) || (number > (ZON->number * 100 + 499))) {
                send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                             (ZON->number * 100 + 499));
                send_to_char("Enter top of zone: ", CH);
                return;
            } else
                ZON->top = number;
        else if ((number < ZON->number * 100) ||
                 (number > zone_table[d->edit_number + 1].number * 100 - 1)) {
            send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                         zone_table[d->edit_number + 1].number * 100 - 1);
            send_to_char("Enter top of zone: ", CH);
            return;
        } else
            ZON->top = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_LIFESPAN:
        number = atoi(arg);
        if ((number < 0) || (number > 1440)) {
            send_to_char("Value must range from 0 to 1440\r\n", CH);
            send_to_char("Lifespan (in ticks between resets): ", CH);
        } else {
            ZON->lifespan = number;
            zedit_disp_data_menu(d);
        }
        break;

    case ZEDIT_RESET_MODE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.  Please enter from 0 to 3.\r\n", CH);
            send_to_char("Enter reset mode: ", CH);
            return;
        } else if (number != 0)
            ZON->reset_mode = number - 1;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_JURID:
        number = atoi(arg);
        if (number < 0 || number > 3) {
            send_to_char("Invalid choice.  Please enter from 0 to 1.\r\n", CH);
            send_to_char("Enter Juridiction: ", CH);
            return;
        } else
            ZON->juridiction = number;
        zedit_disp_data_menu(d);
        break;
    }
}
Ejemplo n.º 15
0
void write_mobs_to_disk(int zone)
{
    int counter, realcounter;
    FILE *fp;
    struct char_data *mob;
    zone = real_zone(zone);
    int i;

    // ideally, this would just fill a VTable with vals...maybe one day

    sprintf(buf, "%s/%d.mob", MOB_PREFIX, zone_table[zone].number);
    fp = fopen(buf, "w+");

    /* start running through all mobiles in this zone */
    for (counter = zone_table[zone].number * 100;
            counter <= zone_table[zone].top;
            counter++) {
        /* write mobile to disk */
        realcounter = real_mobile(counter);

        if (realcounter >= 0) {
            mob = mob_proto+realcounter;
            if (!strcmp("an unfinished mob", GET_NAME(mob)))
                continue;
            fprintf(fp, "#%ld\n", GET_MOB_VNUM(mob));

            fprintf(fp,
                    "Keywords:\t%s\n"
                    "Name:\t%s\n"
                    "RoomDesc:$\n%s\n~\n",
                    mob->player.physical_text.keywords?
                    mob->player.physical_text.keywords : "mob unnamed",
                    mob->player.physical_text.name?
                    mob->player.physical_text.name : "An unnamed mob",
                    cleanup(buf2, mob->player.physical_text.room_desc?
                            mob->player.physical_text.room_desc : "An unnamed mob is here."));
            fprintf(fp, "LookDesc:$\n%s~\n",
                    cleanup(buf2,
                            mob->player.physical_text.look_desc?
                            mob->player.physical_text.look_desc
                            : "An unnamed mob is here."));

            if (mob->mob_specials.arrive)
                fprintf(fp, "ArriveMsg:\t%s\n", mob->mob_specials.arrive);
            if (mob->mob_specials.leave)
                fprintf(fp, "LeaveMsg:\t%s\n", mob->mob_specials.leave);

            fprintf(fp,
                    "MobFlags:\t%s\n"
                    "AffFlags:\t%s\n"
                    "Race:\t%s\n"
                    "Gender:\t%s\n",
                    MOB_FLAGS(mob).ToString(),
                    AFF_FLAGS(mob).ToString(),
                    npc_classes[(int)mob->player.race],
                    genders[(int)mob->player.sex]);

            if (mob->char_specials.position != POS_STANDING)
                fprintf(fp, "Position:\t%s\n",
                        position_types[(int)mob->char_specials.position]);
            if (mob->mob_specials.default_pos)
                fprintf(fp, "DefaultPos:\t%s\n",
                        position_types[(int)mob->mob_specials.default_pos]);

            if (mob->mob_specials.attack_type != TYPE_HIT)
                fprintf(fp, "AttackType:\t%s\n",
                        attack_types[mob->mob_specials.attack_type-TYPE_HIT]);

            fprintf(fp,
                    "[ATTRIBUTES]\n"
                    "\tBod:\t%d\n"
                    "\tQui:\t%d\n"
                    "\tStr:\t%d\n"
                    "\tCha:\t%d\n"
                    "\tInt:\t%d\n"
                    "\tWil:\t%d\n"
                    "\tMag:\t%d\n",
                    GET_REAL_BOD(mob), GET_REAL_QUI(mob), GET_REAL_STR(mob),
                    GET_REAL_CHA(mob), GET_REAL_INT(mob), GET_REAL_WIL(mob),
                    mob->real_abils.mag / 100);
            fprintf(fp,
                    "[POINTS]\n"
                    "\tHeight:\t%d\n"
                    "\tWeight:\t%d\n",
                    mob->player.height, mob->player.weight);

            if (GET_LEVEL(mob) > 0)
                fprintf(fp, "\tLevel:\t%d\n", GET_LEVEL(mob));
            if (int(GET_MAX_PHYSICAL(mob) / 100) != 10)
                fprintf(fp, "\tMaxPhys:\t%d\n", int(GET_MAX_PHYSICAL(mob) / 100));
            if (int(GET_MAX_MENTAL(mob) / 100) != 10)
                fprintf(fp, "\tMaxMent:\t%d\n", int(GET_MAX_MENTAL(mob) / 100));
            if (GET_BALLISTIC(mob) > 0)
                fprintf(fp, "\tBallistic:\t%d\n", GET_BALLISTIC(mob));
            if (GET_IMPACT(mob) > 0)
                fprintf(fp, "\tImpact:\t%d\n", GET_IMPACT(mob));
            if (GET_NUYEN(mob) > 0)
                fprintf(fp, "\tCash:\t%d\n", GET_NUYEN(mob));
            if (GET_BANK(mob) > 0)
                fprintf(fp, "\tBank:\t%d\n", GET_BANK(mob));
            if (GET_KARMA(mob) > 0)
                fprintf(fp, "\tKarma:\t%d\n", GET_KARMA(mob));
            fprintf(fp, "[SKILLS]\n");

            for (i = 0; i <= 8; i = i +2)
                if (mob->mob_specials.mob_skills[i])
                    fprintf(fp, "\t%s:\t%d\n", skills[mob->mob_specials.mob_skills[i]].name,
                            mob->mob_specials.mob_skills[i+1]);



            fprintf(fp, "BREAK\n");
        } // close if statement
    } // close for loop

    fprintf(fp, "END\n");
    fclose(fp);

    write_index_file("mob");
}
Ejemplo n.º 16
0
void boot_the_shops()
{
  char *buf;
  int temp;
  int count;
  FILE *shop_f;
  if (!(shop_f = fopen(SHOP_FILE, "r")))
    {
      perror("Error in boot shop\n");
      exit(0);
    }
  
  number_of_shops = 0;

  for(;;)    {
    buf = fread_string(shop_f);
    if(*buf == '#')        /* a new shop */        {
      if(!number_of_shops)        /* first shop */
        CREATE(shop_index, struct shop_data, 1);
      else
        if(!(shop_index=
             (struct shop_data*) realloc(
                                         shop_index,(number_of_shops + 1)*
                                         sizeof(struct shop_data)))) {
          perror("Error in boot shop\n");
          exit(0);
        }

      for(count=0;count<MAX_PROD;count++)
        {
          fscanf(shop_f,"%d \n", &temp);
          if (temp >= 0)
            shop_index[number_of_shops].producing[count]=
              real_object(temp);
          else
            shop_index[number_of_shops].producing[count]= temp;
        }
      fscanf(shop_f,"%f \n",
             &shop_index[number_of_shops].profit_buy);
      fscanf(shop_f,"%f \n",
             &shop_index[number_of_shops].profit_sell);
      for(count=0;count<MAX_TRADE;count++)
        {
          fscanf(shop_f,"%d \n", &temp);
          shop_index[number_of_shops].type[count] =
            (byte) temp;
        }
      shop_index[number_of_shops].no_such_item1 =
        fread_string(shop_f);
      shop_index[number_of_shops].no_such_item2 =
        fread_string(shop_f);
      shop_index[number_of_shops].do_not_buy =
        fread_string(shop_f);
      shop_index[number_of_shops].missing_cash1 =
        fread_string(shop_f);
      shop_index[number_of_shops].missing_cash2 =
        fread_string(shop_f);
      shop_index[number_of_shops].message_buy =
        fread_string(shop_f);
      shop_index[number_of_shops].message_sell =
        fread_string(shop_f);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].temper1);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].temper2);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].keeper);
      
      shop_index[number_of_shops].keeper =
        real_mobile(shop_index[number_of_shops].keeper);
      
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].with_who);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].in_room);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].open1);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].close1);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].open2);
      fscanf(shop_f,"%d \n",
             &shop_index[number_of_shops].close2);
      number_of_shops++;
    }
    else 
      if(*buf == '$')        /* EOF */
Ejemplo n.º 17
0
void
boot_the_shops(FILE * shop_f, char *filename, int rec_count)
{
  char *buf, buf2[150];
  int temp, count, new_format = 0;
  struct shop_buy_data list[MAX_SHOP_OBJ + 1];
  int done = 0;

  sprintf(buf2, "beginning of shop file %s", filename);

  while (!done)
    {
      buf = fread_string(shop_f, buf2);
      if (*buf == '#')
    {       /* New shop */
      sscanf(buf, "#%d\n", &temp);
      sprintf(buf2, "shop #%d in shop file %s", temp, filename);
      FREE(buf);        /* Plug memory leak! */
      if (!top_shop)
        CREATE(shop_index, struct shop_data, rec_count);

      SHOP_NUM(top_shop) = temp;
      temp = read_list(shop_f, list, new_format, MAX_PROD, LIST_PRODUCE);
      CREATE(shop_index[top_shop].producing, int, temp);
      for (count = 0; count < temp; count++)
        SHOP_PRODUCT(top_shop, count) = BUY_TYPE(list[count]);

      read_line(shop_f, "%f", &SHOP_BUYPROFIT(top_shop));
      read_line(shop_f, "%f", &SHOP_SELLPROFIT(top_shop));

      temp = read_type_list(shop_f, list, new_format, MAX_TRADE);
      CREATE(shop_index[top_shop].type, struct shop_buy_data, temp);
      for (count = 0; count < temp; count++)
        {
          SHOP_BUYTYPE(top_shop, count) = (byte) BUY_TYPE(list[count]);
          SHOP_BUYWORD(top_shop, count) = BUY_WORD(list[count]);
        }

      shop_index[top_shop].no_such_item1 = fread_string(shop_f, buf2);
      shop_index[top_shop].no_such_item2 = fread_string(shop_f, buf2);
      shop_index[top_shop].do_not_buy = fread_string(shop_f, buf2);
      shop_index[top_shop].missing_cash1 = fread_string(shop_f, buf2);
      shop_index[top_shop].missing_cash2 = fread_string(shop_f, buf2);
      shop_index[top_shop].message_buy = fread_string(shop_f, buf2);
      shop_index[top_shop].message_sell = fread_string(shop_f, buf2);
      read_line(shop_f, "%d", &SHOP_BROKE_TEMPER(top_shop));
      read_line(shop_f, "%d", &SHOP_BITVECTOR(top_shop));
      read_line(shop_f, "%d", &SHOP_KEEPER(top_shop));

      SHOP_KEEPER(top_shop) = real_mobile(SHOP_KEEPER(top_shop));
      read_line(shop_f, "%d", &SHOP_TRADE_WITH(top_shop));

      temp = read_list(shop_f, list, new_format, 1, LIST_ROOM);
      CREATE(shop_index[top_shop].in_room, int, temp);
      for (count = 0; count < temp; count++)
        SHOP_ROOM(top_shop, count) = BUY_TYPE(list[count]);

      read_line(shop_f, "%d", &SHOP_OPEN1(top_shop));
      read_line(shop_f, "%d", &SHOP_CLOSE1(top_shop));
      read_line(shop_f, "%d", &SHOP_OPEN2(top_shop));
      read_line(shop_f, "%d", &SHOP_CLOSE2(top_shop));

      SHOP_BANK(top_shop) = 0;
      SHOP_SORT(top_shop) = 0;
      SHOP_FUNC(top_shop) = 0;
      top_shop++;
    }
      else
    {
      if (*buf == '$')      /* EOF */
Ejemplo n.º 18
0
/* assign special procedures to mobiles */
void assign_mobiles(void)
{
	int cityguard(struct char_data *ch, int cmd, char *arg);
	int receptionist(struct char_data *ch, int cmd, char *arg);
	int guild(struct char_data *ch, int cmd, char *arg);
	int guild_guard(struct char_data *ch, int cmd, char *arg);
	int puff(struct char_data *ch, int cmd, char *arg);
	int fido(struct char_data *ch, int cmd, char *arg);
	int janitor(struct char_data *ch, int cmd, char *arg);
	int mayor(struct char_data *ch, int cmd, char *arg);
	int snake(struct char_data *ch, int cmd, char *arg);
	int thief(struct char_data *ch, int cmd, char *arg);
	int magic_user(struct char_data *ch, int cmd, char *arg);

	mob_index[real_mobile(1)].func = puff;

	mob_index[real_mobile(3060)].func = cityguard;
	mob_index[real_mobile(3067)].func = cityguard;
	mob_index[real_mobile(3061)].func = janitor;
	mob_index[real_mobile(3062)].func = fido;
	mob_index[real_mobile(3066)].func = fido;

	mob_index[real_mobile(3005)].func = receptionist;

	mob_index[real_mobile(3020)].func = guild;
	mob_index[real_mobile(3021)].func = guild;
	mob_index[real_mobile(3022)].func = guild;
	mob_index[real_mobile(3023)].func = guild;

	mob_index[real_mobile(3024)].func = guild_guard;
	mob_index[real_mobile(3025)].func = guild_guard;
	mob_index[real_mobile(3026)].func = guild_guard;
	mob_index[real_mobile(3027)].func = guild_guard;

	mob_index[real_mobile(3143)].func = mayor;

	/* MORIA */
	mob_index[real_mobile(4000)].func = snake;
	mob_index[real_mobile(4001)].func = snake;
	mob_index[real_mobile(4053)].func = snake;

	mob_index[real_mobile(4103)].func = thief;
	mob_index[real_mobile(4100)].func = magic_user;
	mob_index[real_mobile(4102)].func = snake;

	/* SEWERS */
	mob_index[real_mobile(7006)].func = snake;

	/* FOREST */
	mob_index[real_mobile(6113)].func = snake;
	mob_index[real_mobile(6114)].func = snake;

	mob_index[real_mobile(6910)].func = magic_user;

	boot_the_shops();
	assign_the_shopkeepers();
}
Ejemplo n.º 19
0
int add_mobile(struct char_data *mob, mob_vnum vnum)
{
  int rnum, i, found = FALSE, shop, cmd_no;
  zone_rnum zone;
  struct char_data *live_mob;

  if ((rnum = real_mobile(vnum)) != NOBODY) {
    /* Copy over the mobile and free() the old strings. */
    copy_mobile(&mob_proto[rnum], mob);

    /* Now re-point all existing mobile strings to here. */
    for (live_mob = character_list; live_mob; live_mob = live_mob->next)
      if (rnum == live_mob->nr)
        update_mobile_strings(live_mob, &mob_proto[rnum]);

    add_to_save_list(zone_table[real_zone_by_thing(vnum)].number, SL_MOB);
    log("GenOLC: add_mobile: Updated existing mobile #%d.", vnum);
    return TRUE;
  }

  RECREATE(mob_proto, struct char_data, top_of_mobt + 2);
  RECREATE(mob_index, struct index_data, top_of_mobt + 2);
  top_of_mobt++;

  for (i = top_of_mobt; i > 0; i--) {
    if (vnum > mob_index[i - 1].vnum) {
      mob_proto[i] = *mob;
      mob_proto[i].nr = i;
      copy_mobile_strings(mob_proto + i, mob);
      mob_index[i].vnum = vnum;
      mob_index[i].number = 0;
      mob_index[i].func = 0;
      found = i;
      break;
    }
    mob_index[i] = mob_index[i - 1];
    mob_proto[i] = mob_proto[i - 1];
    mob_proto[i].nr++;
  }
  if (!found) {
    mob_proto[0] = *mob;
    mob_proto[0].nr = 0;
    copy_mobile_strings(&mob_proto[0], mob);
    mob_index[0].vnum = vnum;
    mob_index[0].number = 0;
    mob_index[0].func = 0;
  }

  log("GenOLC: add_mobile: Added mobile %d at index #%d.", vnum, found);

#if CONFIG_GENOLC_MOBPROG
  GET_MPROG(OLC_MOB(d)) = OLC_MPROGL(d);
  GET_MPROG_TYPE(OLC_MOB(d)) = (OLC_MPROGL(d) ? OLC_MPROGL(d)->type : 0);
  while (OLC_MPROGL(d)) {
    GET_MPROG_TYPE(OLC_MOB(d)) |= OLC_MPROGL(d)->type;
    OLC_MPROGL(d) = OLC_MPROGL(d)->next;
  }
#endif

  /*
   * Update live mobile rnums.
   */
  for (live_mob = character_list; live_mob; live_mob = live_mob->next)
    GET_MOB_RNUM(live_mob) += (GET_MOB_RNUM(live_mob) >= found);

  /*
   * Update zone table.
   */
  for (zone = 0; zone <= top_of_zone_table; zone++)
    for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++)
      if (ZCMD(zone, cmd_no).command == 'M')
	ZCMD(zone, cmd_no).arg1 += (ZCMD(zone, cmd_no).arg1 >= found);

  /*
   * Update shop keepers.
   */
  if (shop_index)
    for (shop = 0; shop <= top_shop - top_shop_offset; shop++)
      SHOP_KEEPER(shop) += (SHOP_KEEPER(shop) >= found);

  add_to_save_list(zone_table[real_zone_by_thing(vnum)].number, SL_MOB);
  return found;
}
Ejemplo n.º 20
0
void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
{
  qst_rnum rnum;
  mob_rnum qmrnum;
  char buf[MAX_STRING_LENGTH];
  char targetname[MAX_STRING_LENGTH];

  if (GET_ADMLEVEL(ch) < ADMLVL_IMMORT)
    send_to_char(ch, "Huh!?!\r\n");
  else if (!*argument)
    send_to_char(ch, "%s\r\n", quest_imm_usage);
  else if ((rnum = real_quest(atoi(argument))) == NOTHING )
    send_to_char(ch, "That quest does not exist.\r\n");
  else {
    sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));
    switch (QST_TYPE(rnum)) {
      case AQ_OBJ_FIND:
      case AQ_OBJ_RETURN:
        snprintf(targetname, sizeof(targetname), "%s",
                 real_object(QST_TARGET(rnum)) == NOTHING ?
                 "An unknown object" :
    obj_proto[real_object(QST_TARGET(rnum))].short_description);
 break;
      case AQ_ROOM_FIND:
      case AQ_ROOM_CLEAR:
        snprintf(targetname, sizeof(targetname), "%s",
          real_room(QST_TARGET(rnum)) == NOWHERE ?
                 "An unknown room" :
    world[real_room(QST_TARGET(rnum))].name);
        break;
      case AQ_MOB_FIND:
      case AQ_MOB_KILL:
      case AQ_MOB_SAVE:
 snprintf(targetname, sizeof(targetname), "%s",
                 real_mobile(QST_TARGET(rnum)) == NOBODY ?
    "An unknown mobile" :
    GET_NAME(&mob_proto[real_mobile(QST_TARGET(rnum))]));
 break;
      default:
 snprintf(targetname, sizeof(targetname), "Unknown");
 break;
    }
    qmrnum = real_mobile(QST_MASTER(rnum));
    send_to_char(ch,
        "VNum  : [\ty%5d\tn], RNum: [\ty%5d\tn] -- Questmaster: [\ty%5d\tn] \ty%s\tn\r\n"
        "Name  : \ty%s\tn\r\n"
 "Desc  : \ty%s\tn\r\n"
 "Accept Message:\r\n\tc%s\tn"
 "Completion Message:\r\n\tc%s\tn"
 "Quit Message:\r\n\tc%s\tn"
 "Type  : \ty%s\tn\r\n"
        "Target: \ty%d\tn \ty%s\tn, Quantity: \ty%d\tn\r\n"
 "Value : \ty%d\tn, Penalty: \ty%d\tn, Min Level: \ty%2d\tn, Max Level: \ty%2d\tn\r\n"
 "Flags : \tc%s\tn\r\n",
     QST_NUM(rnum), rnum,
 QST_MASTER(rnum) == NOBODY ? -1 : QST_MASTER(rnum),
 (qmrnum == NOBODY) ? "(Invalid vnum)" : GET_NAME(&mob_proto[(qmrnum)]),
        QST_NAME(rnum), QST_DESC(rnum),
        QST_INFO(rnum), QST_DONE(rnum),
 (QST_QUIT(rnum) &&
  (str_cmp(QST_QUIT(rnum), "undefined") != 0)
          ? QST_QUIT(rnum) : "Nothing\r\n"),
     quest_types[QST_TYPE(rnum)],
 QST_TARGET(rnum) == NOBODY ? -1 : QST_TARGET(rnum),
 targetname,
 QST_QUANTITY(rnum),
     QST_POINTS(rnum), QST_PENALTY(rnum), QST_MINLEVEL(rnum),
 QST_MAXLEVEL(rnum), buf);
    if (QST_PREREQ(rnum) != NOTHING)
      send_to_char(ch, "Preq  : [\ty%5d\tn] \ty%s\tn\r\n",
        QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum),
        QST_PREREQ(rnum) == NOTHING ? "" :
   real_object(QST_PREREQ(rnum)) == NOTHING ? "an unknown object" :
       obj_proto[real_object(QST_PREREQ(rnum))].short_description);
    if (QST_TYPE(rnum) == AQ_OBJ_RETURN)
      send_to_char(ch, "Mob   : [\ty%5d\tn] \ty%s\tn\r\n",
        QST_RETURNMOB(rnum),
 real_mobile(QST_RETURNMOB(rnum)) == NOBODY ? "an unknown mob" :
           mob_proto[real_mobile(QST_RETURNMOB(rnum))].player.short_descr);
    if (QST_TIME(rnum) != -1)
      send_to_char(ch, "Limit : There is a time limit of %d turn%s to complete.\r\n",
   QST_TIME(rnum),
   QST_TIME(rnum) == 1 ? "" : "s");
    else
      send_to_char(ch, "Limit : There is no time limit on this quest.\r\n");
    send_to_char(ch, "Prior :");
    if (QST_PREV(rnum) == NOTHING)
      send_to_char(ch, " \tyNone.\tn\r\n");
    else
      send_to_char(ch, " [\ty%5d\tn] \tc%s\tn\r\n",
        QST_PREV(rnum), QST_DESC(real_quest(QST_PREV(rnum))));
    send_to_char(ch, "Next  :");
    if (QST_NEXT(rnum) == NOTHING)
      send_to_char(ch, " \tyNone.\tn\r\n");
    else
      send_to_char(ch, " [\ty%5d\tn] \tc%s\tn\r\n",
        QST_NEXT(rnum), QST_DESC(real_quest(QST_NEXT(rnum))));
  }
}
Ejemplo n.º 21
0
/* assign special procedures to mobiles */
void assign_mobiles()
{

  static struct special_proc_entry specials[] = {

    { 1, puff },
    { 2, Ringwraith },
    { 3, tormentor },
    { 4, Inquisitor},
    { 6, AcidBlob },
    { 25, magic_user },

    { 30, MageGuildMaster }, 
    { 31, ClericGuildMaster }, 
    { 32, ThiefGuildMaster }, 
    { 33, WarriorGuildMaster },
    { 34, MageGuildMaster }, 
    { 35, ClericGuildMaster }, 
    { 36, ThiefGuildMaster }, 
    { 37, WarriorGuildMaster },
    { 38, fighter},  /* armor golem */
    { 39, creeping_death},  

    {199, AGGRESSIVE},
    {200, AGGRESSIVE},
/*
**  D&D standard
*/

    { 210, snake },	   /* spider */
    { 211, fighter},       /* gnoll  */
    { 220, fighter},       /* fighter */
    { 221, fighter},       /* bugbear */
    { 223, ghoul },	   /* ghoul */
    { 226, fighter },	   /* ogre */
    { 236, ghoul },	    /* ghast */
    { 227, snake },	/* spider */
    { 230, BreathWeapon }, /* baby black */
    { 232, blink },       /* blink dog */
    { 233, BreathWeapon }, /* baby blue */
    { 234, cleric }, /* cleric */
    { 239, shadow },      /* shadow    */
    { 240, snake },       /* toad      */
    { 243, BreathWeapon }, /* teenage white */
    { 247, fighter}, /* minotaur */
    { 251, CarrionCrawler },
    { 261, fighter },
    { 262, regenerator },
    { 264, fighter },
    { 265, magic_user},
    { 266, magic_user },
    { 267, Devil},
    { 269, Demon},
    { 271, regenerator },
    { 248, snake },       /* snake       */
    { 249, snake },       /* snake       */
    { 250, snake },       /* snake       */
    { 257, magic_user },  /* magic_user  */

    {600, DruidChallenger},
    {601, DruidChallenger},
    {602, DruidChallenger},
    {603, DruidChallenger},
    {604, DruidChallenger},
    {605, DruidChallenger},
    {606, DruidChallenger},
    {607, DruidChallenger},
    {608, DruidChallenger},
    {609, DruidChallenger},
    {610, DruidChallenger},
    {611, DruidChallenger},
    {612, DruidChallenger},
    {613, DruidChallenger},
    {614, DruidChallenger},
    {615, DruidChallenger},
    {616, DruidChallenger},
    {617, DruidChallenger},
    {618, DruidChallenger},
    {619, DruidChallenger},
    {620, DruidChallenger},
    {621, DruidChallenger},
    {622, DruidChallenger},
    {623, DruidChallenger},
    {624, DruidChallenger},
    {625, DruidChallenger},
    {626, DruidChallenger},
    {627, DruidChallenger},
    {628, DruidChallenger},
    {629, DruidChallenger},
    {630, DruidChallenger},
    {631, DruidChallenger},
    {632, DruidChallenger},
    {633, DruidChallenger},
    {634, DruidChallenger},
    {635, DruidChallenger},
    {636, DruidChallenger},
    {637, DruidChallenger},
    {638, DruidChallenger},
    {639, DruidChallenger},
    {640, DruidChallenger},
    {641, DruidGuildMaster},
    {642, DruidGuildMaster},

    {651, MonkChallenger},
    {652, MonkChallenger},
    {653, MonkChallenger},
    {654, MonkChallenger},
    {655, MonkChallenger},
    {656, MonkChallenger},
    {657, MonkChallenger},
    {658, MonkChallenger},
    {659, MonkChallenger},
    {660, MonkChallenger},
    {661, MonkChallenger},
    {662, MonkChallenger},
    {663, MonkChallenger},
    {664, MonkChallenger},
    {665, MonkChallenger},
    {666, MonkChallenger},
    {667, MonkChallenger},
    {668, MonkChallenger},
    {669, MonkChallenger},
    {670, MonkChallenger},
    {671, MonkChallenger},
    {672, MonkChallenger},
    {673, MonkChallenger},
    {674, MonkChallenger},
    {675, MonkChallenger},
    {676, MonkChallenger},
    {677, MonkChallenger},
    {678, MonkChallenger},
    {679, MonkChallenger},
    {680, MonkChallenger},
    {681, MonkChallenger},
    {682, MonkChallenger},
    {683, MonkChallenger},
    {684, MonkChallenger},
    {685, MonkChallenger},
    {686, MonkChallenger},
    {687, MonkChallenger},
    {688, MonkChallenger},
    {689, MonkChallenger},
    {690, MonkChallenger},
    {691, monk_master},

/*
  frost giant area 
*/

    { 9401, fighter },
    { 9403, magic_user },
    { 9404, fighter },
    { 9405, thief },
    { 9406, fighter },
    { 9407, fighter },
    { 9408, fighter },
    { 9409, fighter },
    { 9410, fighter },
    { 9411, fighter },
    { 9412, fighter },
    { 9413, fighter },
    { 9414, fighter },
    { 9415, fighter },
    { 9416, fido},
    { 9418, BreathWeapon },
    { 9419, BreathWeapon },
    { 9420, fighter },
    { 9421, fighter },
    { 9424, StormGiant },
    { 9426, MonkChallenger },
    { 9427, cleric },
    { 9428, magic_user },
    { 9429, fighter },
    { 9430, regenerator },
    { 9431, snake },
    { 9432, magic_user },
    { 9433, fighter },
    { 9434, fighter },
    { 9435, snake  },
    { 9436, fido },

/*
**   shire
*/
    { 1000, magic_user },
    { 1035, fighter},
    { 1012, fighter},
    { 1026, fighter}, 
    { 1010, fighter},
    { 1011, fighter},
    { 1012, fighter},
    { 1014, fighter},
    { 1015, fighter},
    { 1016, fighter},
    { 1017, fighter},
    { 1001, fighter},
    { 1023, fighter},
    { 1031, receptionist },
    { 1032, fighter},

    { 1701, monk},
    { 1702, monk},
    { 1703, monk},
    { 1704, monk},
    { 1705, monk},
    { 1706, monk},
    { 1707, monk},
    { 1708, monk},
    { 1709, monk},
    { 1710, monk},
    { 1711, monk},
    { 1712, monk},
    { 1713, monk},
    { 1714, monk},
    { 1715, monk},
    { 1716, monk},
    { 1717, monk},
    { 1718, monk},

    /* Thand's thief area */
    { 1105, thief},
    { 1108, thief},
    { 1115, fido},
    /* end of Thand's thief area */

    { 6001, real_rabbit},
    { 6005, real_fox},
/*
  prydain
*/
    { 6601, PrydainGuard},
    { 6602, PrydainGuard},
    { 6604, fighter},
    { 6605, PrydainGuard},
    { 6606, PrydainGuard},
    { 6608, fighter},
    { 6613, fighter},
    { 6619, PrydainGuard},
    { 6620, PrydainGuard},
    { 6621, fighter},
    { 6622, fighter},
    { 6614, PrydainGuard},
    { 6609, BreathWeapon},
    { 6642, BreathWeapon},
    { 6640, jugglernaut },
    { 6612, magic_user },
    { 6615, magic_user },
    { 6616, magic_user },
    { 6624, magic_user },
    { 6637, magic_user },
    { 6634, fighter },
    { 6635, BreathWeapon},
    { 6625, Demon},
    { 6638, StatTeller},

/*
  deadhame
*/
    { 24782, fighter },

/*
**  G1
*/
    { 9200, fighter },
    { 9201, fighter },
    { 9202, fighter },
    { 9203, fighter },
    { 9204, fighter },
    { 9206, fighter },
    { 9207, fighter },
    { 9211, fighter },
    { 9212, fighter },
    { 9216, fighter },
    { 9213, CarrionCrawler},
    { 9208, cleric },
    { 9217, BreathWeapon},
    { 9218, fighter},

/*
**  chessboard
*/
    { 1400, chess_game },  /* black pieces */
    { 1401, chess_game },
    { 1402, chess_game },
    { 1403, chess_game },
    { 1404, chess_game },
    { 1405, chess_game },
    { 1406, chess_game },
    { 1407, chess_game },
    { 1408, chess_game },
    { 1409, chess_game },
    { 1410, chess_game },
    { 1411, chess_game },
    { 1412, chess_game },
    { 1413, chess_game },
    { 1414, chess_game },
    { 1415, chess_game },
    
    { 1448, chess_game },  /* white pieces */
    { 1449, chess_game },
    { 1450, chess_game },
    { 1451, chess_game },
    { 1452, chess_game },
    { 1453, chess_game },
    { 1454, chess_game },
    { 1455, chess_game },
    { 1456, chess_game },
    { 1457, chess_game },
    { 1458, chess_game },
    { 1459, chess_game },
    { 1460, chess_game },
    { 1461, chess_game },
    { 1462, chess_game },
    { 1463, chess_game },
    
#if 0
    { 1401, fighter}, 
    { 1404, fighter}, 
    { 1406, fighter}, 
    { 1457, fighter}, 
    { 1460, fighter}, 
    { 1462, fighter}, 
#endif

    { 1499, sisyphus }, 
    { 1471, paramedics }, 
    { 1470, jabberwocky },
    { 1472, flame }, 
    { 1437, banana }, 
    { 1428, jugglernaut },
    { 1495, delivery_elf },  
    { 1493, delivery_beast },

/*
**  Bandits Temple
*/
    { 2113, ghoul },
    { 2115, ghost },
    { 2116, ghost },
    { 2111, cleric },
    { 2112, cleric },
    { 2117, druid_protector },


    /* Astral plane */
    { 2715, astral_portal },
    { 2716, astral_portal },
    { 2717, astral_portal },
    { 2718, astral_portal },
    { 2719, astral_portal },
    { 2720, astral_portal },
    { 2721, astral_portal },
    { 2722, astral_portal },
    { 2723, astral_portal },
    { 2724, astral_portal },
    { 2725, astral_portal },
    { 2726, astral_portal },
    { 2727, astral_portal },
    { 2728, astral_portal },
    { 2729, astral_portal },
    { 2730, astral_portal },
    { 2731, astral_portal },
    { 2732, astral_portal },
    { 2733, astral_portal },
    { 2734, astral_portal },
    { 2735, astral_portal },
    { 2736, astral_portal },


/*
**  Valley of the Mage
*/
    { 21106, snake },
    { 21107, RustMonster},
    { 21108, wraith},
    { 21111, web_slinger},
    { 21112, trapper},
    { 21114, troguard},
    { 21121, trogcook},
    { 21122, shaman},
    { 21123, troguard},
    { 21124, golgar},
    { 21118, troguard},
    { 21119, troguard},
/*
    { 21130, Valik},
*/
    { 21135, regenerator},
    { 21138, ghostsoldier},
    { 21139, ghostsoldier},
/*
    { 21140, keystone},
    { 21141, lattimore},
    { 21142, guardian},
*/
    { 21144, troguard},
    { 21145, troguard},
    { 21146, coldcaster},
    { 21147, RustMonster},

/*
**  New Thalos
*/
    { 3600, MageGuildMaster },
    { 3601, ClericGuildMaster },
    { 3602, WarriorGuildMaster },
    { 3603, ThiefGuildMaster },
    { 3604, receptionist},
    { 3619, fighter},
    { 3620, fighter},
    { 3632, fighter},
    { 3634, fighter},
    { 3636, fighter},
    { 3638, fighter},
    { 3639, fighter}, /* caramon */
    { 3641, cleric},  /* curley g. */
    { 3640, magic_user},  /* raist */
    { 3656, NewThalosGuildGuard},
    { 3657, NewThalosGuildGuard},
    { 3658, NewThalosGuildGuard},
    { 3659, NewThalosGuildGuard},
    { 3661, SultanGuard},   /* wandering */
    { 3662, SultanGuard},   /* not */
    { 3682, SultanGuard},   /* royal */
    { 3670, BreathWeapon},  /* Cryohydra */
    { 3674, BreathWeapon},  /* Behir */
    { 3675, BreathWeapon},  /* Chimera */
    { 3676, BreathWeapon},  /* Couatl */
    { 3681, cleric },       /* High priest */
    { 3689, NewThalosMayor }, /* Guess */
    { 3644, fido},
    { 3635, thief}, 
/*
**  Skexie
*/
    { 15813, magic_user},
    { 15815, magic_user},
    { 15820, magic_user },	
    { 15821, vampire },	
    { 15844, cleric },	
    { 15847, fighter },	
    { 15831, fighter },	
    { 15832, fighter },	
    { 15822, fighter },	
    { 15819, fighter },	
    { 15805, fighter },	
/*
**  Challenge
*/
    { 15858, BreathWeapon },
    { 15861, magic_user },
    { 15862, magic_user },
    { 15863, fighter },
    { 15864, sisyphus },
    { 15877, magic_user },
    { 15868, snake },
    { 15866, magic_user },
    { 15810, magic_user },
    { 15880, fighter },
    { 15879, BreathWeapon },
    { 15873, magic_user },
    { 15871, magic_user },
    { 15852, fighter },
    { 15875, cleric },
    { 15869, magic_user },
    
/*
**  abyss
*/
    { 25000, magic_user },      /* Demi-lich  */
    { 25001, Keftab }, 
    { 25009, BreathWeapon },    /* hydra */
    { 25002, vampire },	        /* Crimson */
    { 25003, StormGiant },      /* MistDaemon */
    { 25006, StormGiant },      /* Storm giant */
    { 25014, StormGiant },      /* DeathKnight */    
    { 25009, BreathWeapon },    /* hydra */
    { 25017, AbyssGateKeeper }, /* Abyss Gate Keeper */
    { 25013, fighter},          /* kalas */
    { 25008, magic_user},       /* efreeti */
    { 25034, fighter },         /* marilith */
    { 25035, magic_user},       /* balor  */
/*
**  Paladin's guild
*/
    { 25100, PaladinGuildGuard},
    { 25101, PaladinGuildGuard},
/*
** Shark's Junk
*/
    { 196, GreyParamedic},
    { 197, AmberParamedic},
    { 198, GameGuard}, 
/*
**  Abyss Fire Giants
*/
    { 25500, fighter },
    { 25501, fighter },
    { 25502, fighter },
    { 25505, fighter },
    { 25504, BreathWeapon},
    { 25503, cleric  },

/*
**  Temple Labrynth
*/

    { 10900, temple_labrynth_liar },
    { 10901, temple_labrynth_liar },
    { 10902, temple_labrynth_sentry},

/*
**  Gypsy Village
*/

    { 16106, fido},
    { 16107, CaravanGuildGuard},
    { 16108, CaravanGuildGuard},
    { 16109, CaravanGuildGuard},
    { 16110, CaravanGuildGuard},
    { 16111, WarriorGuildMaster},
    { 16112, MageGuildMaster},
    { 16113, ThiefGuildMaster},
    { 16114, ClericGuildMaster},
    { 16122, receptionist},
    { 16105, StatTeller},

/*
**  Draagdim
*/

    { 2500, NudgeNudge },  /* jailer */
/*
**  mordilnia
*/
    {18200, magic_user},
    {18205, receptionist},
    {18206, MageGuildMaster},
    {18207, ClericGuildMaster},    
    {18208, ThiefGuildMaster},
    {18209, WarriorGuildMaster},    
    {18210, MordGuildGuard},  /*18266 3*/  
    {18211, MordGuildGuard},  /*18276 1*/
    {18212, MordGuildGuard},  /*18272 0*/
    {18213, MordGuildGuard},  /*18256 2*/
    {18215, MordGuard },    
    {18216, janitor},
    {18217, fido},    
    {18218, fighter},    
    {18221, fighter},
    {18222, MordGuard},
    {18223, MordGuard},    

/*
**  Graecia:
*/
    {13706, fighter},
    {13709, fighter},
    {13711, fighter},
    {13714, fighter},
    {13721, fighter},
    {13722, fighter},
    {13732, snake},
    {13762, fighter},
    {13764, fighter},
    {13766, fighter},
    {13769, fighter},
    {13771, fighter},
    {13775, fighter},

    {13779, magic_user},
    {13784, magic_user},
    {13785, magic_user},
    {13787, magic_user},
    {13789, magic_user},
    {13791, magic_user},
    {13793, magic_user},
    {13795, magic_user},
    {13797, magic_user},
    { 13843, fighter },


    
/*
**  Eastern Path
*/
    
    {16001, fighter},
    {16006, fighter},
    {16007, fighter},
    {16008, fighter},
    {16009, fighter},
    {16016, fighter},
    {16017, fighter},
    {16020, snake },
    {16021, cleric},
    {16022, fighter},
    {16023, thief},
    {16027, fighter},
    {16033, fighter},
    {16034, fighter},
    {16035, fighter},
    {16036, magic_user},
    {16043, fighter},
    {16050, fighter},
    {16052, fighter},
    {16048, fighter},
    {16056, cleric},
    {16057, magic_user},
    {16037, DwarvenMiners },
    {16014, magic_user},
    {16039, Tyrannosaurus_swallower},

/*
**  undercaves.. level 1
*/
    {16201, magic_user},
    {16204, magic_user},
    {16205, magic_user},
    {16206, magic_user},
    {16210, fighter},
    {16211, magic_user},
    {16214, fighter},
    {16215, fighter},
    {16216, cleric},
    {16217, magic_user},
    {16219, death_knight},
/*
** Sauria
*/
    {21803, Tyrannosaurus_swallower},
    {21810, Tyrannosaurus_swallower},

/*
**  Bay Isle
*/
    {16610, Demon},
    {16620, BreathWeapon},
    {16640, cleric},
    {16650, cleric},

#if 0
/*
**  King's Mountain
*/
    {16700, BreathWeapon},
    {16702, shadow},
    {16703, magic_user},
    {16709, vampire},
    {16710, Devil},
    {16711, Devil},
    {16712, Devil},
    {16713, ghoul},
    {16714, ghoul},
    {16715, wraith},
    {16717, fighter},
    {16720, Devil},
    {16721, Devil},
    {16724, Devil},
    {16725, magic_user},
    {16726, cleric},
    {16727, Devil},
    {16728, Devil},
    {16730, Devil},
    {16731, Devil},
    {16732, Demon},
    {16733, Demon},
    {16734, Demon},
    {16735, Demon},
    {16736, cleric},
    {16738, BreathWeapon},
#endif

/*
**  Sewer Rats
*/
    {7002, attack_rats},
    {2531, DragonHunterLeader},
    {3063, HuntingMercenary},

/*
**  Mages Tower
*/
    {1500, shadow},
    {1504, magic_user},
    {1506, magic_user},
    {1507, magic_user},
    {1508, magic_user},
    {1510, magic_user},
    {1514, magic_user},
    {1515, magic_user},
    {1516, magic_user},
    {1517, magic_user},
    {1518, magic_user},
    {1520, magic_user},
    {1521, magic_user},
    {1522, magic_user},
    {1523, magic_user},
    {1524, magic_user},
    {1525, magic_user},
    {1526, magic_user},
    {1527, magic_user},
    {1528, magic_user},
    {1529, magic_user},
    {1530, magic_user},
    {1531, magic_user},
    {1532, magic_user},
    {1533, magic_user},
    {1534, magic_user},
    {1537, magic_user},
    {1538, magic_user},
    {1540, magic_user},
    {1541, magic_user},
    {1548, magic_user},
    {1549, magic_user},
    {1552, magic_user},
    {1553, magic_user},
    {1554, magic_user},
    {1556, magic_user},
    {1557, magic_user},
    {1559, magic_user},
    {1560, magic_user},
    {1562, magic_user},
    {1564, magic_user},
    {1565, magic_user},
/*
**  Forest of Rhowyn
*/

    {13901, ThrowerMob },

/*
**  Quikland
*/
    {6202, fighter},
    {6204, magic_user},
    {6206, fighter},
    {6207, fighter},
    {6208, fighter},
/*
** Dwarf Village
*/
    {6500, fighter},
    {6501, fighter},
    {6502, wraith},
    {6506, fighter},
    {6507, fighter},
    {6508, fighter},
    {6514, fighter},
    {6516, fighter},
    {6516, snake},

/*
**  Lycanthropia
*/
    {16901, fighter},
    {16902, fighter},
    {16903, fighter},
    {16904, fighter},
    {16905, fighter},
    {16906, fighter},
    {16907, magic_user},
    {16908, fighter},
    {16910, fighter},
    {16911, fighter},

/*
**  Main City
*/

    { 3000, magic_user }, 
    { 3060, MidgaardCityguard }, 
    { 3080, fighter},
    { 3067, MidgaardCityguard }, 
    { 3061, janitor },
    { 3062, fido }, 
    { 3066, fido },
    { 3005, receptionist },
    { 3020, MageGuildMaster }, 
    { 3021, ClericGuildMaster }, 
    { 3022, ThiefGuildMaster }, 
    { 3023, WarriorGuildMaster },

    { 3007, sailor },    /* Sailor */
    { 3024, guild_guard }, 
    { 3025, guild_guard }, 
    { 3026, guild_guard },
    { 3027, guild_guard },
    { 3070, RepairGuy }, 
    { 3071, RepairGuy },
    { 3069, MidgaardCityguard },	/* post guard */
    { 3068, ninja_master },
    { 3073, loremaster },
    { 3074, hunter },

/*
**  Lower city
*/
    { 3143, mayor },
    { 7009, MidgaardCityguard },

/*
**   Hammor's Stuff
*/
    { 3900, eric_johnson }, { 3901, andy_wilcox }, { 3950, zombie_master },
    { 3952, BreathWeapon },

/* 
**  MORIA 
*/
    { 4000, snake }, 
    { 4001, snake }, 
    { 4053, snake },

    { 4103, thief }, 
    { 4100, magic_user }, 
    { 4101, regenerator },
    { 4102, snake },

/*
**  Pyramid
*/

    { 5308, RustMonster },
    { 5303, vampire },

/*
**  Arctica
*/
    { 6800, fighter},
    { 6803, fighter},
    { 6801, BreathWeapon },
    { 6802, BreathWeapon },
    { 6815, magic_user },
    { 6821, snake },
    { 6824, BreathWeapon },
    { 6825, thief },

/* 
** SEWERS 
*/
    { 7009, fighter},
    { 7006, snake },
    { 7008, snake },
    { 7042, magic_user },	/* naga       */
    { 7040, BreathWeapon },     /* Red    */
    { 7041, magic_user },	/* sea hag    */
    { 7045, ettin },		/* berserk teacher */
    { 7200, magic_user },	/* mindflayer */ 
    { 7201, magic_user },	/* senior     */
    { 7202, magic_user },	/* junior     */
    

/* 
** FOREST 
*/

    { 6111, magic_user },	/* tree */
    { 6113, snake },
    { 6114, snake },
    { 6112, BreathWeapon }, /* green */
    { 6910, magic_user },

/*
**  Great Eastern Desert
*/
    { 5000, thief },	/* rag. dervish */
    { 5002, snake },	/* coral snake */
    { 5003, snake },	/* scorpion    */
    { 5004, snake },	/* purple worm  */
    { 5014, cleric },	/* myconoid */
    { 5005, BreathWeapon }, /* brass */

/*
**  Drow (edition 1)
*/
    { 5010, magic_user },	/* dracolich */
    { 5104, cleric },
    { 5103, magic_user },	/* drow mage */
    { 5107, cleric },	/* drow mat. mot */
    { 5108, magic_user },	/* drow mat. mot */
    { 5109, cleric },	/* yochlol */

/*
**   Thalos
*/
    { 5200, magic_user },	/* beholder    */

/*
**  Zoo
*/
    { 9021, snake },	/* Gila Monster */

/*
**  Castle Python
*/
    { 11001, fighter},  /* lord python */
    { 11002, fighter},
    { 11004, fighter},
    { 11005, fighter},
    { 11006, fighter},
    { 11007, fighter},
    { 11016, receptionist },
    { 11017, NudgeNudge },

/*
**  miscellaneous
*/
    { 9061, vampire},	/* vampiress  */

/*
**  White Plume Mountain
*/

    { 17004, magic_user }, /* gnyosphinx   */
    { 17017, magic_user }, /* ogre magi   */
    { 17014, ghoul },	/* ghoul  */
    { 17009, geyser },	/* geyser  */
    { 17011, vampire },	/* vampire Amelia  */
    { 17002, wraith },	/* wight*/
    { 17005, shadow },	/* shadow */
    { 17010, green_slime }, /* green slime */

/*
**  Arachnos
*/

#if 0
    { 20001, snake },	/* Young (large) spider */
#endif

    { 20003, snake },	/* wolf (giant) spider  */

    { 20005, snake },	/* queen wasp      */

#if 0
    { 20006, snake },	/* drone spider    */
#endif

    { 20010, snake },	/* bird spider     */
    { 20009, magic_user }, /* quasit         */
    { 20014, magic_user }, /* Arachnos        */
    { 20015, magic_user }, /* Ki Rin          */
    { 20011, OldHag },		/* hermit (hey, DM wrote it!) */
    { 20002, BreathWeapon }, /* Yevaud */
    { 20017, BreathWeapon }, /* Elder  */
    { 20016, BreathWeapon }, /* Baby   */
    { 20012, fighter}, /* donjonkeeper */

/*
**  SSMinnow
*/

    { 21700, fighter },		/* Captain Saltmere */
    { 21701, fighter },		/* First Mate */
    { 21702, thief },		/* Stowaway */
    { 21705, magic_user },		/* Elven Priestss */
    { 21706, fighter },		/* Jedadia */
    { 21712, fighter },		/* Crew Memeber */
    { 21714, snake },		/* Zatagaster */
    { 21716, magic_user },

/*
**  Sunsor's elf area
*/

    { 22605, timnus },         /* timnus */
    { 22604, baby_bear},	/* mother bear */
    { 22624, baby_bear},	/* baby bears. */

#if 0
/*
**   The Darklands
*/

    { 24050, cleric },
    { 24052, magic_user2 }, 
    { 24053, magic_user2 }, 
    { 24054, magic_user2 }, 
    { 24055, magic_user2 }, 
    { 24056, magic_user2 }, 
    { 24057, magic_user2 }, 
    { 24058, magic_user2 }, 
    { 24059, magic_user2 }, 
#endif

/*
**   Abbarach
*/
    { 27001, magic_user },
    { 27002, magic_user },
    { 27003, magic_user },
    { 27004, magic_user },
    { 27005, magic_user },
    { 27006, Tytan },
    { 27007, replicant },
    { 27016, AbbarachDragon },
    { 27014, magic_user },
    { 27017, magic_user },
    { 27018, magic_user },
    { 27019, magic_user },
    { 27025, Samah}, /* in skills.c ... shoot me*/

    { 27401, fighter},
    { 27403, fighter},
    { 27407, fighter},
    { 27408, fighter},
    { 27409, fighter},
    { 27411, fighter},
    { 27415, fighter},
    { 27416, fighter},
    { 27417, fighter},
    { 27418, fighter},
    { 27419, fighter},
    { 27420, fighter},

    { 27404, magic_user},
    { 27405, magic_user},
    { 27422, magic_user},

    { 27413, cleric},
    { 27414, cleric},

    { 27429, AGGRESSIVE },
    { 27430, AGGRESSIVE },

    { 7526, winger},
    { 7522, magic_user},
    { 7531, magic_user},
    {7510, fighter},
    {7514, fighter},
    {7515, fighter},
    {7516, fighter},
    {7527, fighter},
    {7528, fighter},
    {7530, fighter},

    { -1, NULL },
  };

  int	i, rnum;
  char buf[MAX_STRING_LENGTH];

  for (i=0; specials[i].vnum>=0; i++) {
    rnum = real_mobile(specials[i].vnum);
    if (rnum<0) {
      sprintf(buf, "mobile_assign: Mobile %d not found in database.",
	      specials[i].vnum);
      logE(buf);
    } else {
      mob_index[rnum].func = specials[i].proc;
    }
  }

	boot_the_shops();
	assign_the_shopkeepers();
}
Ejemplo n.º 22
0
void parse_quest(FILE *quest_file, int vnum)
{
  static int i = 0;

  struct char_data *mob = NULL;
  char line[MAX_INPUT_LENGTH];
  char value[MAX_INPUT_LENGTH];
  char field[20];
  int numval = 0;
  int nummsgs = 0;
  int numneeds = 0;
  int mob_rnum = 0;

  i++;
  mob_rnum = real_mobile(vnum);
  if (mob_rnum == -1) {
    stderr_log("Error trying to assign quest to non-existant mob.");
    fflush(NULL);
    exit(1);
  }
  mob = (mob_proto + mob_rnum);
  GET_MOB_QUEST_NUM(mob) = i;
  (mob_quests + i)->maxlevel = 51;
  (mob_quests + i)->qnum = i;
  while (get_line(quest_file, line)) {
    if (line[0] == 'S') {
      return;
    }
    parse_pline(line, field, value);
    numval = atoi(value);

    switch (UPPER(*field)) {
      case 'A':
        if (strcmp(field, "amount") == 0) {
          (mob_quests + i)->needs[numneeds].amount = numval;
          numneeds++;
          (mob_quests + i)->maxneeds = numneeds;
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'C':
        if (strcmp(field, "classlist") == 0) {
          (mob_quests + i)->classlist = asciiflag_conv(value);
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'D':
        if (strcmp(field, "destroy") == 0) {
          if (strcasecmp(value, "no") == 0) {
            (mob_quests + i)->needs[numneeds].destroy = 0;
          }
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'F':
        if (strcmp(field, "flags") == 0) {
          (mob_quests + i)->flags = asciiflag_conv(value);
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'G':
        if (strcmp(field, "goal") == 0) {
          (mob_quests + i)->goal = search_block(value, goal_list, FALSE);
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'K':
        if (strcmp(field, "keywords") == 0) {
          RECREATE((mob_quests + i)->messages, struct quest_message_data, nummsgs + 1);
          (mob_quests + i)->messages[nummsgs].keywords = strdup(value);
        } else if (strcmp(field, "knowledge") == 0) {
          line[0] = '\0';
          (mob_quests + i)->knowledge = fread_string(quest_file, line);
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'M':
        if (strcmp(field, "maxlevel") == 0) {
          (mob_quests + i)->maxlevel = numval;
        } else if (strcmp(field, "message") == 0) {
          line[0] = '\0';
          (mob_quests + i)->messages[nummsgs].message = fread_string(quest_file, line);
          nummsgs++;
          (mob_quests + i)->maxmsgs = nummsgs;
        } else {
          sprintf(buf2, "Unknown Quest field [%s]", field);
          stderr_log(buf2);
        }
        break;
      case 'N':
        if (strcmp(field, "needs") == 0) {
          RECREATE((mob_quests + i)->needs, struct quest_needs_data, numneeds + 1);
          (mob_quests + i)->needs[numneeds].destroy = 1;
          (mob_quests + i)->needs[numneeds].participants = NULL;
          (mob_quests + i)->needs[numneeds].type = search_block(value, needs_list, FALSE);
          (mob_quests + i)->needs[numneeds].complete = 0;
          (mob_quests + i)->needs[numneeds].needs_complete_msg = NULL;
          (mob_quests + i)->needs[numneeds].need_more_msg = NULL;
        } else if (strcmp(field, "need_more_msg") == 0) {
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
void parse_quest(FILE *quest_f, int nr)
{
  static char line[256];
  static int i = 0, j;
  int retval = 0, t[7];
  char f1[128], buf2[MAX_STRING_LENGTH];
  aquest_table[i].vnum = nr;
  aquest_table[i].qm = NOBODY;
  aquest_table[i].name = NULL;
  aquest_table[i].desc = NULL;
  aquest_table[i].info = NULL;
  aquest_table[i].done = NULL;
  aquest_table[i].quit = NULL;
  aquest_table[i].flags = 0;
  aquest_table[i].type = -1;
  aquest_table[i].target = -1;
  aquest_table[i].prereq = NOTHING;
  for (j = 0; j < 7; j++)
    aquest_table[i].value[j] = 0;
  aquest_table[i].prev_quest = NOTHING;
  aquest_table[i].next_quest = NOTHING;
  aquest_table[i].func = NULL;

  aquest_table[i].gold_reward = 0;
  aquest_table[i].exp_reward  = 0;
  aquest_table[i].obj_reward  = NOTHING;

  /* begin to parse the data */
  aquest_table[i].name = fread_string(quest_f, buf2);
  aquest_table[i].desc = fread_string(quest_f, buf2);
  aquest_table[i].info = fread_string(quest_f, buf2);
  aquest_table[i].done = fread_string(quest_f, buf2);
  aquest_table[i].quit = fread_string(quest_f, buf2);
  if (!get_line(quest_f, line) ||
      (retval = sscanf(line, " %d %d %s %d %d %d %d",
             t, t+1, f1, t+2, t+3, t + 4, t + 5)) != 7) {
    log("Format error in numeric line (expected 7, got %d), %s\n",
        retval, line);
    exit(1);
  }
  aquest_table[i].type       = t[0];
  aquest_table[i].qm         = (real_mobile(t[1]) == NOBODY) ? NOBODY : t[1];
  aquest_table[i].flags      = asciiflag_conv(f1);
  aquest_table[i].target     = (t[2] == -1) ? NOTHING : t[2];
  aquest_table[i].prev_quest = (t[3] == -1) ? NOTHING : t[3];
  aquest_table[i].next_quest = (t[4] == -1) ? NOTHING : t[4];
  aquest_table[i].prereq     = (t[5] == -1) ? NOTHING : t[5];
  if (!get_line(quest_f, line) ||
      (retval = sscanf(line, " %d %d %d %d %d %d %d",
          t, t+1, t+2, t+3, t+4, t + 5, t + 6)) != 7) {
    log("Format error in numeric line (expected 7, got %d), %s\n",
        retval, line);
    exit(1);
  }
  for (j = 0; j < 7; j++)
    aquest_table[i].value[j] = t[j];

  if (!get_line(quest_f, line) ||
      (retval = sscanf(line, " %d %d %d",
             t, t+1, t+2)) != 3) {
    log("Format error in numeric (rewards) line (expected 3, got %d), %s\n",
        retval, line);
    exit(1);
  }

  aquest_table[i].gold_reward = t[0];
  aquest_table[i].exp_reward  = t[1];
  aquest_table[i].obj_reward  = (t[2] == -1) ? NOTHING : t[2];

  for (;;) {
    if (!get_line(quest_f, line)) {
      log("Format error in %s\n", line);
      exit(1);
    }
    switch(*line) {
    case 'S':
      total_quests = ++i;
      return;
      break;
    }
  }
} /* parse_quest */
Ejemplo n.º 25
0
/*
 * Alert: As of bpl14, this function returns the following codes:
 *	< 0	Victim died.
 *	= 0	No damage.
 *	> 0	How much damage done.
 */
int damage(struct char_data * ch, struct char_data * victim, int dam, int attacktype)
{
  if (GET_POS(victim) <= POS_DEAD) {
    log("SYSERR: Attempt to damage corpse '%s' in room #%d by '%s'.",
		GET_NAME(victim), GET_ROOM_VNUM(IN_ROOM(victim)), GET_NAME(ch));
    die(victim, ch);
    return (0);			/* -je, 7/7/92 */
  }

  /* peaceful rooms */
  if (ch->nr != real_mobile(DG_CASTER_PROXY) &&
      ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
    send_to_char("This room just has such a peaceful, easy feeling...\r\n", ch);
    return (0);
  }

  /* shopkeeper protection */
  if (!ok_damage_shopkeeper(ch, victim))
    return (0);

  /* You can't damage an immortal! */
  if (!IS_NPC(victim) && (GET_LEVEL(victim) >= LVL_IMMORT))
    dam = 0;

  if (victim != ch) {
    /* Start the attacker fighting the victim */
    if (char_within_range_of_vict(ch, victim) && GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL))
      set_fighting(ch, victim);

    /* Start the victim fighting the attacker */
    if (char_within_range_of_vict(victim, ch) && GET_POS(victim) > POS_STUNNED && (FIGHTING(victim) == NULL)) {
      set_fighting(victim, ch);
      if (MOB_FLAGGED(victim, MOB_MEMORY) && !IS_NPC(ch))
	remember(victim, ch);
    }
  }

  /* If you attack a pet, it hates your guts */
  if (victim->master == ch)
    stop_follower(victim);

  /* If the attacker is invisible, he becomes visible */
  if (AFF_FLAGGED(ch, AFF_INVISIBLE | AFF_HIDE))
    appear(ch);

  /* Cut damage in half if victim has sanct, to a minimum 1 */
  if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2)
    dam /= 2;

  /* Check for PK if this is not a PK MUD */
  if (!pk_allowed) {
    check_killer(ch, victim);
    if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim))
      dam = 0;
  }

  /* Set the maximum damage per round and subtract the hit points */
  dam = MAX(MIN(dam, 900), 0);
  GET_HIT(victim) -= dam;

  /* Gain exp for the hit */
  if (ch != victim)
    gain_exp(ch, GET_LEVEL(victim) * dam);

  update_pos(victim);

  /*
   * skill_message sends a message from the messages file in lib/misc.
   * dam_message just sends a generic "You hit $n extremely hard.".
   * skill_message is preferable to dam_message because it is more
   * descriptive.
   * 
   * If we are _not_ attacking with a weapon (i.e. a spell), always use
   * skill_message. If we are attacking with a weapon: If this is a miss or a
   * death blow, send a skill_message if one exists; if not, default to a
   * dam_message. Otherwise, always send a dam_message.
   */
  if (!IS_WEAPON(attacktype))
    skill_message(dam, ch, victim, attacktype);
  else {
    if (GET_POS(victim) == POS_DEAD || dam == 0) {
      if (!skill_message(dam, ch, victim, attacktype))
	dam_message(dam, ch, victim, attacktype);
    } else {
      dam_message(dam, ch, victim, attacktype);
    }
  }

  /* Use send_to_char -- act() doesn't send message if you are DEAD. */
  switch (GET_POS(victim)) {
  case POS_MORTALLYW:
    act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, TO_ROOM);
    send_to_char("You are mortally wounded, and will die soon, if not aided.\r\n", victim);
    break;
  case POS_INCAP:
    act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, TO_ROOM);
    send_to_char("You are incapacitated an will slowly die, if not aided.\r\n", victim);
    break;
  case POS_STUNNED:
    act("$n is stunned, but will probably regain consciousness again.", TRUE, victim, 0, 0, TO_ROOM);
    send_to_char("You're stunned, but will probably regain consciousness again.\r\n", victim);
    break;
  case POS_DEAD:
    act("$n is dead!  R.I.P.", FALSE, victim, 0, 0, TO_ROOM);
    send_to_char("You are dead!  Sorry...\r\n", victim);
    break;

  default:			/* >= POSITION SLEEPING */
    if (dam > (GET_MAX_HIT(victim) / 4))
      send_to_char("That really did HURT!\r\n", victim);

    if (GET_HIT(victim) < (GET_MAX_HIT(victim) / 4)) {
      sprintf(buf2, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n",
	      CCRED(victim, C_SPR), CCNRM(victim, C_SPR));
      send_to_char(buf2, victim);
      if (ch != victim && MOB_FLAGGED(victim, MOB_WIMPY))
	do_flee(victim, NULL, 0, 0);
    }
    if (!IS_NPC(victim) && GET_WIMP_LEV(victim) && (victim != ch) &&
	GET_HIT(victim) < GET_WIMP_LEV(victim) && GET_HIT(victim) > 0) {
      send_to_char("You wimp out, and attempt to flee!\r\n", victim);
      do_flee(victim, NULL, 0, 0);
    }
    break;
  }

  /* Help out poor linkless people who are attacked */
  if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) {
    do_flee(victim, NULL, 0, 0);
    if (!FIGHTING(victim)) {
      act("$n is rescued by divine forces.", FALSE, victim, 0, 0, TO_ROOM);
      GET_WAS_IN(victim) = IN_ROOM(victim);
      char_from_room(victim);
      char_to_room(victim, 0);
    }
  }

  /* stop someone from fighting if they're stunned or worse */
  if ((GET_POS(victim) <= POS_STUNNED) && (FIGHTING(victim) != NULL))
    stop_fighting(victim);

  /* Uh oh.  Victim died. */
  if (GET_POS(victim) == POS_DEAD) {
    if ((ch != victim) && (IS_NPC(victim) || victim->desc)) {
      if (AFF_FLAGGED(ch, AFF_GROUP))
	group_gain(ch, victim);
      else
        solo_gain(ch, victim);
    }

    if (!IS_NPC(victim)) {
      sprintf(buf2, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch),
	      world[IN_ROOM(victim)].name);
      mudlog(buf2, BRF, LVL_IMMORT, TRUE);
      if (MOB_FLAGGED(ch, MOB_MEMORY))
	forget(ch, victim);
    }
    die(victim, ch);
    return (-1);
  }
  return (dam);
}
Ejemplo n.º 26
0
void sedit_parse(struct descriptor_data *d, char *arg)
{
  int i;

  if (OLC_MODE(d) > SEDIT_NUMERICAL_RESPONSE) {
    if (!isdigit(arg[0]) && ((*arg == '-') && (!isdigit(arg[1])))) {
      write_to_output(d, "Field must be numerical, try again : ");
      return;
    }
  }
  switch (OLC_MODE(d)) {
/*-------------------------------------------------------------------*/
  case SEDIT_CONFIRM_SAVESTRING:
    switch (*arg) {
    case 'y':
    case 'Y':
      sedit_save_internally(d);
      mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE,
        "OLC: %s edits shop %d", GET_NAME(d->character), OLC_NUM(d));
      if (CONFIG_OLC_SAVE) {
      sedit_save_to_disk(real_zone_by_thing(OLC_NUM(d)));
      write_to_output(d, "Shop saved to disk.\r\n");
      } else
      write_to_output(d, "Shop saved to memory.\r\n");
      cleanup_olc(d, CLEANUP_STRUCTS);
      return;
    case 'n':
    case 'N':
      cleanup_olc(d, CLEANUP_ALL);
      return;
    default:
      write_to_output(d, "Invalid choice!\r\nDo you wish to save your changes? : ");
      return;
    }
    break;

/*-------------------------------------------------------------------*/
  case SEDIT_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) = SEDIT_CONFIRM_SAVESTRING;
      } else
	cleanup_olc(d, CLEANUP_ALL);
      return;
    case '0':
      OLC_MODE(d) = SEDIT_KEEPER;
      write_to_output(d, "Enter vnum number of shop keeper : ");
      return;
    case '1':
      OLC_MODE(d) = SEDIT_OPEN1;
      i++;
      break;
    case '2':
      OLC_MODE(d) = SEDIT_CLOSE1;
      i++;
      break;
    case '3':
      OLC_MODE(d) = SEDIT_OPEN2;
      i++;
      break;
    case '4':
      OLC_MODE(d) = SEDIT_CLOSE2;
      i++;
      break;
    case '5':
      OLC_MODE(d) = SEDIT_BUY_PROFIT;
      i++;
      break;
    case '6':
      OLC_MODE(d) = SEDIT_SELL_PROFIT;
      i++;
      break;
    case '7':
      OLC_MODE(d) = SEDIT_NOITEM1;
      i--;
      break;
    case '8':
      OLC_MODE(d) = SEDIT_NOITEM2;
      i--;
      break;
    case '9':
      OLC_MODE(d) = SEDIT_NOCASH1;
      i--;
      break;
    case 'a':
    case 'A':
      OLC_MODE(d) = SEDIT_NOCASH2;
      i--;
      break;
    case 'b':
    case 'B':
      OLC_MODE(d) = SEDIT_NOBUY;
      i--;
      break;
    case 'c':
    case 'C':
      OLC_MODE(d) = SEDIT_BUY;
      i--;
      break;
    case 'd':
    case 'D':
      OLC_MODE(d) = SEDIT_SELL;
      i--;
      break;
    case 'e':
    case 'E':
      sedit_no_trade_menu(d);
      return;
    case 'f':
    case 'F':
      sedit_shop_flags_menu(d);
      return;
    case 'r':
    case 'R':
      sedit_rooms_menu(d);
      return;
    case 'p':
    case 'P':
      sedit_products_menu(d);
      return;
    case 't':
    case 'T':
      sedit_namelist_menu(d);
      return;
    default:
      sedit_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 SEDIT_NAMELIST_MENU:
    switch (*arg) {
    case 'a':
    case 'A':
      sedit_types_menu(d);
      return;
    case 'd':
    case 'D':
      write_to_output(d, "\r\nDelete which entry? : ");
      OLC_MODE(d) = SEDIT_DELETE_TYPE;
      return;
    case 'q':
    case 'Q':
      break;
    }
    break;
/*-------------------------------------------------------------------*/
  case SEDIT_PRODUCTS_MENU:
    switch (*arg) {
    case 'a':
    case 'A':
      write_to_output(d, "\r\nEnter new product vnum number : ");
      OLC_MODE(d) = SEDIT_NEW_PRODUCT;
      return;
    case 'd':
    case 'D':
      write_to_output(d, "\r\nDelete which product? : ");
      OLC_MODE(d) = SEDIT_DELETE_PRODUCT;
      return;
    case 'q':
    case 'Q':
      break;
    }
    break;
/*-------------------------------------------------------------------*/
  case SEDIT_ROOMS_MENU:
    switch (*arg) {
    case 'a':
    case 'A':
      write_to_output(d, "\r\nEnter new room vnum number : ");
      OLC_MODE(d) = SEDIT_NEW_ROOM;
      return;
    case 'c':
    case 'C':
      sedit_compact_rooms_menu(d);
      return;
    case 'l':
    case 'L':
      sedit_rooms_menu(d);
      return;
    case 'd':
    case 'D':
      write_to_output(d, "\r\nDelete which room? : ");
      OLC_MODE(d) = SEDIT_DELETE_ROOM;
      return;
    case 'q':
    case 'Q':
      break;
    }
    break;
/*-------------------------------------------------------------------*/
    /*
     * String edits.
     */
  case SEDIT_NOITEM1:
    if (genolc_checkstring(d, arg))
      modify_string(&S_NOITEM1(OLC_SHOP(d)), arg);
    break;
  case SEDIT_NOITEM2:
    if (genolc_checkstring(d, arg))
      modify_string(&S_NOITEM2(OLC_SHOP(d)), arg);
    break;
  case SEDIT_NOCASH1:
    if (genolc_checkstring(d, arg))
      modify_string(&S_NOCASH1(OLC_SHOP(d)), arg);
    break;
  case SEDIT_NOCASH2:
    if (genolc_checkstring(d, arg))
      modify_string(&S_NOCASH2(OLC_SHOP(d)), arg);
    break;
  case SEDIT_NOBUY:
    if (genolc_checkstring(d, arg))
      modify_string(&S_NOBUY(OLC_SHOP(d)), arg);
    break;
  case SEDIT_BUY:
    if (genolc_checkstring(d, arg))
      modify_string(&S_BUY(OLC_SHOP(d)), arg);
    break;
  case SEDIT_SELL:
    if (genolc_checkstring(d, arg))
      modify_string(&S_SELL(OLC_SHOP(d)), arg);
    break;
  case SEDIT_NAMELIST:
    if (genolc_checkstring(d, arg)) {
      struct shop_buy_data new_entry;

      BUY_TYPE(new_entry) = OLC_VAL(d);
      BUY_WORD(new_entry) = strdup(arg);
      add_to_type_list(&(S_NAMELISTS(OLC_SHOP(d))), &new_entry);
    }
    sedit_namelist_menu(d);
    return;

/*-------------------------------------------------------------------*/
    /*
     * Numerical responses.
     */
  case SEDIT_KEEPER:
    i = atoi(arg);
    if ((i = atoi(arg)) != -1)
      if ((i = real_mobile(i)) == NOBODY) {
	write_to_output(d, "That mobile does not exist, try again : ");
	return;
      }
    S_KEEPER(OLC_SHOP(d)) = i;
    if (i == -1)
      break;
    /*
     * Fiddle with special procs.
     */
    S_FUNC(OLC_SHOP(d)) = mob_index[i].func != shop_keeper ? mob_index[i].func : NULL;
    mob_index[i].func = shop_keeper;
    break;
  case SEDIT_OPEN1:
    S_OPEN1(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28);
    break;
  case SEDIT_OPEN2:
    S_OPEN2(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28);
    break;
  case SEDIT_CLOSE1:
    S_CLOSE1(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28);
    break;
  case SEDIT_CLOSE2:
    S_CLOSE2(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28);
    break;
  case SEDIT_BUY_PROFIT:
    sscanf(arg, "%f", &S_BUYPROFIT(OLC_SHOP(d)));
    break;
  case SEDIT_SELL_PROFIT:
    sscanf(arg, "%f", &S_SELLPROFIT(OLC_SHOP(d)));
    break;
  case SEDIT_TYPE_MENU:
    OLC_VAL(d) = LIMIT(atoi(arg), 0, NUM_ITEM_TYPES - 1);
    write_to_output(d, "Enter namelist (return for none) :-\r\n] ");
    OLC_MODE(d) = SEDIT_NAMELIST;
    return;
  case SEDIT_DELETE_TYPE:
    remove_from_type_list(&(S_NAMELISTS(OLC_SHOP(d))), atoi(arg));
    sedit_namelist_menu(d);
    return;
  case SEDIT_NEW_PRODUCT:
    if ((i = atoi(arg)) != -1)
      if ((i = real_object(i)) == NOTHING) {
	write_to_output(d, "That object does not exist, try again : ");
	return;
      }
    if (i > 0)
      add_to_int_list(&(S_PRODUCTS(OLC_SHOP(d))), i);
    sedit_products_menu(d);
    return;
  case SEDIT_DELETE_PRODUCT:
    remove_from_int_list(&(S_PRODUCTS(OLC_SHOP(d))), atoi(arg));
    sedit_products_menu(d);
    return;
  case SEDIT_NEW_ROOM:
    if ((i = atoi(arg)) != -1)
      if ((i = real_room(i)) == NOWHERE) {
	write_to_output(d, "That room does not exist, try again : ");
	return;
      }
    if (i >= 0)
      add_to_int_list(&(S_ROOMS(OLC_SHOP(d))), atoi(arg));
    sedit_rooms_menu(d);
    return;
  case SEDIT_DELETE_ROOM:
    remove_from_int_list(&(S_ROOMS(OLC_SHOP(d))), atoi(arg));
    sedit_rooms_menu(d);
    return;
  case SEDIT_SHOP_FLAGS:
    if ((i = LIMIT(atoi(arg), 0, NUM_SHOP_FLAGS)) > 0) {
      TOGGLE_BIT(S_BITVECTOR(OLC_SHOP(d)), 1 << (i - 1));
      sedit_shop_flags_menu(d);
      return;
    }
    break;
  case SEDIT_NOTRADE:
    if ((i = LIMIT(atoi(arg), 0, NUM_TRADERS)) > 0) {
      TOGGLE_BIT(S_NOTRADE(OLC_SHOP(d)), 1 << (i - 1));
      sedit_no_trade_menu(d);
      return;
    }
    break;

/*-------------------------------------------------------------------*/
  default:
    /*
     * We should never get here.
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: sedit_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) = 1;
  sedit_disp_menu(d);
}
Ejemplo n.º 27
0
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);
}
Ejemplo n.º 28
0
int save_mobiles(zone_rnum rznum)
{
  zone_vnum vznum;
  FILE *mobfd;
  room_vnum i;
  mob_rnum rmob;
  int written;
  char mobfname[64], usedfname[64];

#if CIRCLE_UNSIGNED_INDEX
  if (rznum == NOWHERE || rznum > top_of_zone_table) {
#else
  if (rznum < 0 || rznum > top_of_zone_table) {
#endif
    log("SYSERR: GenOLC: save_mobiles: Invalid real zone number %d. (0-%d)", rznum, top_of_zone_table);
    return FALSE;
  }

  vznum = zone_table[rznum].number;
  snprintf(mobfname, sizeof(mobfname), "%s%d.new", MOB_PREFIX, vznum);
  if ((mobfd = fopen(mobfname, "w")) == NULL) {
    mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: Cannot open mob file for writing.");
    return FALSE;
  }

  for (i = genolc_zone_bottom(rznum); i <= zone_table[rznum].top; i++) {
    if ((rmob = real_mobile(i)) == NOBODY)
      continue;
    check_mobile_strings(&mob_proto[rmob]);
    if (write_mobile_record(i, &mob_proto[rmob], mobfd) < 0)
      log("SYSERR: GenOLC: Error writing mobile #%d.", i);
  }
  fputs("$\n", mobfd);
  written = ftell(mobfd);
  fclose(mobfd);
  snprintf(usedfname, sizeof(usedfname), "%s%d.mob", MOB_PREFIX, vznum);
  remove(usedfname);
  rename(mobfname, usedfname);

  if (in_save_list(vznum, SL_MOB))
    remove_from_save_list(vznum, SL_MOB);
  log("GenOLC: '%s' saved, %d bytes written.", usedfname, written);
  return written;
}

int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  if (GET_ATTACK(mob) != 0)
    fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob));
  if (GET_STR(mob) != 11)
    fprintf(fd, "Str: %d\n", GET_STR(mob));
  if (GET_ADD(mob) != 0)
    fprintf(fd, "StrAdd: %d\n", GET_ADD(mob));
  if (GET_DEX(mob) != 11)
    fprintf(fd, "Dex: %d\n", GET_DEX(mob));
  if (GET_INT(mob) != 11)
    fprintf(fd, "Int: %d\n", GET_INT(mob));
  if (GET_WIS(mob) != 11)
    fprintf(fd, "Wis: %d\n", GET_WIS(mob));
  if (GET_CON(mob) != 11)
    fprintf(fd, "Con: %d\n", GET_CON(mob));
  if (GET_CHA(mob) != 11)
    fprintf(fd, "Cha: %d\n", GET_CHA(mob));
  if (GET_SAVE(mob, SAVING_PARA) != 0)
    fprintf(fd, "SavingPara: %d\n", GET_SAVE(mob, SAVING_PARA));
  if (GET_SAVE(mob, SAVING_ROD) != 0)
    fprintf(fd, "SavingRod: %d\n", GET_SAVE(mob, SAVING_ROD));
  if (GET_SAVE(mob, SAVING_PETRI) != 0)
    fprintf(fd, "SavingPetri: %d\n", GET_SAVE(mob, SAVING_PETRI));
  if (GET_SAVE(mob, SAVING_BREATH) != 0)
    fprintf(fd, "SavingBreath: %d\n", GET_SAVE(mob, SAVING_BREATH));
  if (GET_SAVE(mob, SAVING_SPELL) != 0)
    fprintf(fd, "SavingSpell: %d\n", GET_SAVE(mob, SAVING_SPELL));
  fputs("E\n", fd);
  return TRUE;
}

int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
  char ldesc[MAX_STRING_LENGTH];
  char ddesc[MAX_STRING_LENGTH];
  char buf[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));

  int n = snprintf(buf, MAX_STRING_LENGTH, "#%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
  );

  if(n < MAX_STRING_LENGTH) {
    fprintf(fd, "%s", convert_from_tabs(buf));
  
    fprintf(fd, "%d %d %d %d %d %d %d %d %d E\n"
        "%d %d %d %dd%d+%d %dd%d+%d\n",
        MOB_FLAGS(mob)[0], MOB_FLAGS(mob)[1],
        MOB_FLAGS(mob)[2], MOB_FLAGS(mob)[3],
        AFF_FLAGS(mob)[0], AFF_FLAGS(mob)[1],
        AFF_FLAGS(mob)[2], AFF_FLAGS(mob)[3],
        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
  } else {
    mudlog(BRF,LVL_BUILDER,TRUE,
           "SYSERR: Could not save mobile #%d due to size (%d > maximum of %d)",
           mvnum, n, MAX_STRING_LENGTH);
  }
  
  return TRUE;
}