コード例 #1
0
ファイル: guides.cpp プロジェクト: nuggs/RPI-Engine
void
do_assist (CHAR_DATA * ch, char *argument, int cmd)
{
  CHAR_DATA *tch = NULL;
  int pos = 0, i = 0;
  char buf[MAX_STRING_LENGTH];

  if (!IS_GUIDE (ch) && IS_MORTAL (ch)
      && !IS_SET (ch->plr_flags, NEW_PLAYER_TAG))
    {
      send_to_char
	("Only Guides, staff members, and new characters may use this command.\n",
	 ch);
      return;
    }

  if (!str_cmp (argument, "request"))
    {
      if (str_cmp (ch->room->name, PREGAME_ROOM_NAME))
	{
	  send_to_char
	    ("This command may only be invoked in a pre-game debriefing room.\n",
	     ch);
	  return;
	}
      if (!IS_SET (ch->plr_flags, NEW_PLAYER_TAG))
	{
	  send_to_char
	    ("The assist queue is only available to new characters.\n", ch);
	  return;
	}
      if ((pos = get_queue_position (ch)) != -1)
	{
	  sprintf (buf,
		   "You are already number #6%d#0 in the assist queue.\n",
		   pos);
	  send_to_char (buf, ch);
	  return;
	}
      update_assist_queue (ch, false);
      ch->assist_pos = get_queue_position (ch);
      sprintf (buf, "You are now number #6%d#0 in the assist queue.\n",
	       get_queue_position (ch));
      send_to_char (buf, ch);
      return;
    }
  else if (!str_cmp (argument, "cancel"))
    {
      if ((pos = get_queue_position (ch)) == -1)
	{
	  send_to_char ("You are not currently in the assist queue.\n", ch);
	  return;
	}
      update_assist_queue (ch, true);
      send_to_char ("You have been removed from the assist queue.\n", ch);
      return;
    }
  else if (!str_cmp (argument, "list") || !str_cmp (argument, "queue"))
    {
      if (!IS_GUIDE (ch) && IS_MORTAL (ch))
	{
	  send_to_char
	    ("Only Guides and staff members may see the assist queue.\n", ch);
	  return;
	}
      if (!assist_queue)
	{
	  send_to_char ("The assist queue is currently empty.\n", ch);
	  return;
	}
      sprintf (buf, "#6Currently waiting in the assist queue:#0\n\n");
      for (tch = assist_queue; tch; tch = tch->next_assist)
	{
	  i++;
	  sprintf (buf + strlen (buf), "  %2d. %s\n", i, tch->pc->account_name);
	}
      send_to_char (buf, ch);
      return;
    }
  else if (!str_cmp (argument, "answer"))
    {
      if (!IS_GUIDE (ch) && IS_MORTAL (ch))
	{
	  send_to_char
	    ("Only Guides and staff members may answer assist requests.\n",
	     ch);
	  return;
	}
      if (IS_GUIDE (ch) && !IS_SET (ch->flags, FLAG_GUEST))
	{
	  send_to_char
	    ("You may only answer assist requests via your Guest login.\n",
	     ch);
	  return;
	}
      if (!(tch = assist_queue))
	{
	  send_to_char
	    ("There is currently no-one waiting in the assist queue.\n", ch);
	  return;
	}
      act ("Your request for assistance has been answered!", true, tch, 0, 0,
	   TO_CHAR);

      if (tch->in_room != ch->in_room)
	{
	  tch->was_in_room = tch->in_room;
	  send_to_char ("\n", tch);
	  act ("$n vanishes in a subtle glimmer of light.", true, ch, 0, 0,
	       TO_ROOM | _ACT_FORMAT);
	  char_from_room (ch);
	  char_to_room (ch, tch->in_room);
	  act ("$n appears in a subtle glimmer of light.", true, ch, 0, 0,
	       TO_ROOM | _ACT_FORMAT);
	  send_to_char ("\n", ch);
	  act
	    ("The world around you fades away in a glimmer of light and you feel yourself whisked instantly to $N's location.",
	     false, ch, 0, tch, TO_CHAR | _ACT_FORMAT);
	  send_to_char ("\n", ch);
	}
      else
	send_to_char ("\n", ch);

      update_assist_queue (tch, true);

      send_to_char ("\n", ch);

      do_look (ch, "", 0);

      return;
    }
  else if (!str_cmp (argument, "return"))
    {
      if (!IS_GUIDE (ch) || !IS_SET (ch->flags, FLAG_GUEST))
	{
	  send_to_char ("This command is only for Guide guest logins.\n", ch);
	  return;
	}
      if (ch->in_room == OOC_LOUNGE)
	{
	  send_to_char ("You're already in Club Endore!\n", ch);
	  return;
	}
      act ("$n vanishes in a subtle glimmer of light.", true, ch, 0, 0,
	   TO_ROOM | _ACT_FORMAT);
      char_from_room (ch);
      char_to_room (ch, OOC_LOUNGE);
      act ("$n appears in a subtle glimmer of light.", true, ch, 0, 0,
	   TO_ROOM | _ACT_FORMAT);
      send_to_char ("\n", ch);
      act
	("The world around you fades away in a glimmer of light and you feel yourself whisked instantly back to Club Endore.",
	 false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
      send_to_char ("\n", ch);
      do_look (ch, "", 0);
      return;
    }
  else if (*argument)
    {
      send_to_char ("See #6HELP ASSIST#0 for command usage.\n", ch);
      return;
    }

  if ((pos = get_queue_position (ch)) != -1)
    {
      sprintf (buf, "You are currently number #6%d#0 in the assist queue.\n",
	       pos);
      send_to_char (buf, ch);
      return;
    }
  else
    send_to_char ("You are not currently in the assist queue.\n", ch);

  return;
}
コード例 #2
0
std::pair<int, std::string> char_data::reportWhere(bool checkClan, int RPP, std::string whichClan) {

	bool underwater = (room->sector_type == SECT_RIVER
		|| room->sector_type == SECT_LAKE
		|| room->sector_type == SECT_OCEAN
		|| room->sector_type == SECT_REEF
		|| room->sector_type == SECT_UNDERWATER);

	int characterNameColour = 0;

	if ((pc && pc->level > 0 && !fighting)) {
		characterNameColour = 5;
	}
	else if (fighting) {
		characterNameColour = 1;
	}
	else if (underwater) {
		characterNameColour = 4;
	}
	else if (IS_SET (flags, FLAG_ISADMIN)) {
		characterNameColour = 6;
	}
	else if (IS_SET (plr_flags, NEW_PLAYER_TAG)) {
		characterNameColour = 2;
	}
	else if (IS_GUIDE (this)) { //If the person is a guide
		characterNameColour = 3;
	}
	else {
		characterNameColour = 0;
	}

	char characterState = '_';

	switch (GET_POS (this)) {
		case POSITION_DEAD:
		case POSITION_MORTALLYW:
			characterState = 'X';
			break;
		case POSITION_UNCONSCIOUS:
		case POSITION_STUNNED:
			characterState = 'U';
			break;
		case POSITION_SLEEPING:
			characterState = 's';
			break;
		default:
			if (!IS_NPC (this) && !desc && !pc->admin_loaded) {
				characterState = 'L';
			}
			else if (IS_SET (act, PLR_QUIET) && !IS_NPC (this)) {
				characterState = 'e';
			}
			else if (get_affect (this, MAGIC_HIDDEN)) {
				characterState = 'h';
			}
			else if (desc && desc->idle) {
				characterState = 'i';
			}
	}

	std::stringstream reportStream;

	reportStream << "#" << characterNameColour;

	int blankLineSize = 15;  // 15 characters alloted to display the name, down from 17
	if (tname)
	  {
	    blankLineSize -= strlen(tname);
	  }

	if (blankLineSize < 1) {
	  std::string tempString = tname;  //never true on null string, as it would still be 15
		reportStream << tempString.substr(0,15);
	}
	else {
	  reportStream << ((tname) ? tname : "(null)");
		for (size_t i = 0; i < blankLineSize; i++) {
			reportStream << " ";
		}
	}

	if (RPP < 0) {
		if (aur < 10) {
			reportStream << "#3[ " << aur << "]";
		}
		else {
			reportStream << "#3[" << aur << "]";
		}
	}
	else if (RPP < 10) {
		reportStream << "#3[ " << RPP << "]";
	}
	else {
		reportStream << "#3[" << RPP << "]";
	}

	reportStream << " #0" << characterState;
	reportStream << (getNaughtyFlag() ? "#1!" : "#0_");	// Flag to watch player for bad behaviour
	reportStream << (getRPFlag() ? "#2R" : "#0_");	// Flag to watch player for possible award
	reportStream << (getPlotFlag() ? "#3P" : "#0_") << " ";	// Flag to indicate player is in a plot

	char roomBuffer[MAX_STRING_LENGTH];

	// [rnum and char name]
	sprintf (roomBuffer, "#2[%6d]#6 %s#0", room->nVirtual, room->name);
	reportStream << roomBuffer;

	return std::make_pair(room->nVirtual, reportStream.str());
}