Пример #1
0
int chat_makeop( int unum, char *msg )
{
  char *newop = nextword(&msg);
  int rnum = users[unum].room;
  int recunum;
  if (!OPERATOR(unum)) {
    send_to_unum(unum, "*** You're not operator\n", -1);
    return 0;
  }
  if ((recunum = chatid_to_indx(newop)) == -1) {
    /* no such user */
    sprintf(genbuf, "*** No such chatid '%s'\n", newop);
    send_to_unum(unum, genbuf, -1);
    return 0;
  }    
  if (unum == recunum) {
    sprintf(genbuf, "*** You're already op\n");
    send_to_unum(unum, genbuf, -1);
    return 0;
  }
  if (rnum != users[recunum].room) {
    sprintf(genbuf, "*** '%s' is not in this room\n", users[recunum].chatid);
    send_to_unum(unum, genbuf, -1);
    return 0;
  }
  users[unum].flags &= ~FLG_CHATOP;
  users[recunum].flags |= FLG_CHATOP;
  sprintf(genbuf, "*** %s gave Op to %s\n", users[unum].chatid,
          users[recunum].chatid);
  send_to_room(rnum, genbuf, -1);  
  return 0;  
}  
Пример #2
0
void exit_room( int unum, int disp, char *msg )
{
  int oldrnum = users[unum].room;
  if (oldrnum != -1) {
    if (--rooms[oldrnum].occupants) {
      switch (disp) {
      case EXIT_LOGOUT:
        sprintf(genbuf, "*** %s has left the room", users[unum].chatid);
        if (msg && *msg) {
          strcat(genbuf, ": ");
          strncat(genbuf, msg, CHATLINE_TEXT_MAX);
          strcat(genbuf, "\n");
        }
 	break;
      case EXIT_LOSTCONN:
        sprintf(genbuf, "*** %s has been disconnected\n", users[unum].chatid);
	break;
      case EXIT_KICK:
        sprintf(genbuf, "*** %s has been kicked out ", users[unum].chatid);
        if (msg && *msg) {
          strcat(genbuf, "(");
          strncat(genbuf, msg, CHATLINE_TEXT_MAX-(strlen(genbuf)+3));
          strcat(genbuf, ")");
        }
        break;
      }
      send_to_room(oldrnum, genbuf, unum);
    }
  }
  users[unum].flags &= ~FLG_CHATOP;
  users[unum].room = -1;
}
Пример #3
0
int destroy_player(c_player *p)
{
	c_online *p_online = p->get_online();
	if (p->is_has_room()) {
        c_room *p_room = p->get_room();
        uint8_t user_seat = p->get_seat();
        p_room->del_player(user_seat);
		p->leave_room();

        DEBUG_TLOG("player leave room, u=%u, olid=%u, room=%u",
				p->m_id, p_online->m_id, p_room->get_room_id());

        if (p_room->is_empty()) {
            p_online->destroy_room(p_room);
            return 0;
        }

        btlsw_pvp_abnormal_leave_room_out out;

        out.online_id = p_online->m_id;
        out.room_id = p_room->get_room_id();
        out.host_seat = p_room->get_host_seat();
        out.host_id = p_room->get_host_id();
        out.user_id = p->m_id;
        out.user_seat = user_seat;

        btlsw_proto_t header;
        init_proto_head(&header, 0, sizeof(header), btlsw_pvp_abnormal_leave_room_cmd, 0, 0);
        send_to_room(p_room, &header, &out);
    }
	p_online->del_player(p);	
    delete p;
    return 0;
}
Пример #4
0
int chat_broadcast( int unum, char *msg )
{
  if (!MANAGER(unum)) {
    send_to_unum(unum, "*** You can't do that\n", -1);
    return 0;
  }
  if (*msg == '\0') {
    send_to_unum(unum, "*** No message given\n", -1);
    return 0;
  }
  sprintf(genbuf, "*** Broadcast message from %s:\n", users[unum].chatid);
  send_to_room(ROOM_ALL, genbuf, -1);
  strcpy(genbuf, "*** ");
  strncat(genbuf, msg, CHATLINE_TEXT_MAX);
  send_to_room(ROOM_ALL, genbuf, -1);
  return 0;
}  
Пример #5
0
void death_cry(struct char_data *ch)
{
  int door;

  act("Your blood freezes as you hear $n's death cry.", FALSE, ch, 0, 0, CommTarget::TO_ROOM);

  for (door = 0; door < NUM_OF_DIRS; door++)
    if (CAN_GO(ch, door))
      send_to_room(world[IN_ROOM(ch)].dir_option[door]->to_room, "Your blood freezes as you hear someone's death cry.\r\n");
}
Пример #6
0
int chat_allmsg( int unum, char *msg )
{
  if (*msg) {
    put_chatid(unum, genbuf);
    strncat(genbuf, msg, CHATLINE_TEXT_MAX);
    strcat(genbuf, "\n");
    send_to_room(users[unum].room, genbuf, unum);
  }
  return 0;  
}  
Пример #7
0
int int chat_think( int unum, char *msg )
{
  if (*msg) {
    strcpy(genbuf, users[unum].chatid);
    strcat(genbuf, " . o O ( ");
    strncat(genbuf, msg, CHATLINE_TEXT_MAX);
    strcat(genbuf, " )\n");
    send_to_room(users[unum].room, genbuf, unum);
  }
  return 0;
}
Пример #8
0
int chat_roll_dice( int unum, char *msg )
{
  static int seeded;
  int ndice = 2;
  int die = 6;
  int total = 0;
  int i, roll;
  char diebuf[8];
  char *rollspec = nextword(&msg);
  char *d;
  if (!seeded) {
    srand((int)time(NULL));
    seeded++;
  }
  if ((d = strchr(rollspec, 'd')) != NULL) {
    *d = '\0';
    die = atoi(d+1);
  }
  if (*rollspec != '\0') {
    ndice = atoi(rollspec);
  }
  if (ndice < 0 || ndice > 10) {
    send_to_unum(unum, "*** May only roll from 1 to 10 dice\n", -1);
    return 0;
  }
  if (die < 2 || die > 100) {
    send_to_unum(unum, "*** Die must have from 2 to 100 sides\n", -1);
    return 0;
  }
  strcpy(genbuf, "*** ");
  strcat(genbuf, users[unum].chatid);
  strcat(genbuf, " rolled (");
  for (i=0; i<ndice; i++) {
    roll = diceroll(die);
    if (i > 0) strcat(genbuf, ", ");
    sprintf(diebuf, "%d", roll);
    strcat(genbuf, diebuf);
    total += roll;        
  }
  strcat(genbuf, ") = ");
  sprintf(diebuf, "%d", total);
  strcat(genbuf, diebuf);
  strcat(genbuf, " on ");
  sprintf(diebuf, "%dd%d", ndice, die);
  strcat(genbuf, diebuf);
  strcat(genbuf, "\n");
  send_to_room(users[unum].room, genbuf, unum);
  return 0;  
}  
Пример #9
0
int enter_room( int unum, char *room, char *msg )
{
  int rnum = roomid_to_indx(room);
  int op = 0;
  register int i;
  if (rnum == -1) {
    /* new room */
    for (i=1; i<bbs_max_users; i++) {
      if (rooms[i].occupants == 0) {
        rnum = i;
        if (rooms[rnum].invites == NULL) {
          rooms[rnum].invites = (char *)malloc(bbs_max_users);
          if (rooms[rnum].invites == NULL) {
            send_to_unum(unum, "*** Not enough memory\n", -1);
            return 0;
          }
        }
        memset(rooms[rnum].invites, 0, bbs_max_users);
        strncpy(rooms[rnum].name, room, NAMELEN);
        rooms[rnum].name[NAMELEN] = '\0';
        rooms[rnum].flags = 0;
        op++;
        break;
      }
    }
    if (rnum == -1) {
      send_to_unum(unum, "*** No more rooms available\n", -1);
      return 0;
    }
  }
  if (!MANAGER(unum))
    if (LOCKED(rnum) && rooms[rnum].invites[unum] == 0) {
      send_to_unum(unum, "*** Cannot enter locked room without a key\n", -1);
      return 0;
    }

  exit_room(unum, EXIT_LOGOUT, msg);
  users[unum].room = rnum;
  if (op) users[unum].flags |= FLG_CHATOP;
  rooms[rnum].occupants++;
  rooms[rnum].invites[unum] = 0;
  sprintf(genbuf, "*** %s has entered room '%s'\n", 
          users[unum].chatid, rooms[rnum].name);
  send_to_room(rnum, genbuf, unum);
  return 0;
}
Пример #10
0
int chat_setroom( int unum, char *msg )
{
  char *modestr = nextword(&msg);
  int rnum = users[unum].room;
  int sign = 1;
  int flag;
  char *fstr;
  if (!OPERATOR(unum)) {
    send_to_unum(unum, "*** You're not operator\n", -1);
    return 0;
  }
  if (*modestr == '+') modestr++;
  else if (*modestr == '-') {
    modestr++;
    sign = 0;
  }
  if (*modestr == '\0') {
    send_to_unum(unum, "*** No flags specified\n", -1);
    return 0;
  }
  while (*modestr) {
    flag = 0;
    switch (*modestr) {
    case 'l': case 'L':
      flag = ROOM_LOCKED;
      fstr = "Locked";
      break;
    case 's': case 'S':
      flag = ROOM_SECRET;
      fstr = "Secret";
      break;
    default:
      sprintf(genbuf, "*** Unknown flag '%c'\n", *modestr);
      send_to_unum(unum, genbuf, -1);
    }
    if (flag && ((rooms[rnum].flags & flag) != sign*flag)) {
      rooms[rnum].flags ^= flag;
      sprintf(genbuf, "*** Mode change by %s to%s%s\n",
              users[unum].chatid, sign ? " " : " NOT ", fstr);
      send_to_room(rnum, genbuf, -1);
    }
    modestr++;
  }  
  return 0;  
}  
Пример #11
0
chat_nick( int unum, char *msg )
{
  char *chatid = nextword(&msg);
  int othernum;
  if (!is_valid_chatid(chatid)) {
    send_to_unum(unum, "*** Invalid chatid\n", -1);
    return 0;
  }
  if (strlen(chatid) > CHATID_MAX) chatid[CHATID_MAX] = '\0';
  othernum = chatid_to_indx(chatid);
  if (othernum != -1 && othernum != unum) {
    send_to_unum(unum, "*** Chatid is in use\n", -1);
    return 0;
  }    
  sprintf(genbuf, "*** %s is now known as ", users[unum].chatid);
  strcpy(users[unum].chatid, chatid);
  strcat(genbuf, users[unum].chatid);
  strcat(genbuf, "\n");
  send_to_room(users[unum].room, genbuf, unum);
  sprintf(genbuf, "**C %s", users[unum].chatid);
  send_to_unum(unum, genbuf, -1);
  return 0;
}
Пример #12
0
/* do_simple_move assumes
 *    1. That there is no master and no followers.
 *    2. That the direction exists.
 *
 *   Returns :
 *   1 : If succes.
 *   0 : If fail
 */
int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{
  room_rnum was_in;
  struct char_data *i;
  /*
   * Check for special routines (North is 1 in command list, but 0 here) Note
   * -- only check if following; this avoids 'double spec-proc' bug
   */
  if (need_specials_check && special(ch, dir + 1, "")) { 
    return (0);
  }

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

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

  if((IS_CARRYING_W(ch) > (CAN_CARRY_W(ch) * 2) && GET_LEVEL(ch) < LVL_GOD && !IS_NPC(ch))) {
    send_to_char("You are to heavy to move! Drop something!\r\n", ch);
    return (0);
  }
  
  if(IS_NPC_FISH(ch)) {
    if(SECT(EXIT(ch, dir)->to_room) != SECT_BRIDGE && SECT(EXIT(ch, dir)->to_room) != SECT_WATER_SWIM && SECT(EXIT(ch, dir)->to_room) !=  SECT_WATER_NOSWIM) {
//       sprintf(buf, "%s %d", dirs[dir], SECT(EXIT(ch, dir)->to_room));
//       mobsay(ch, buf);
       return FALSE;

     }
     if(GET_MOB_VNUM(ch) < 1500 && ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_SALT_FISH)) {
       return FALSE;
     }
   }

  if (SECT(EXIT(ch, dir)->to_room) != SECT_FOREST) {
    if (IS_NPC_WOLF(ch) || IS_NPC_CRAB(ch) || IS_NPC_SKELETON(ch)) {
       return (0);
   }
  }

  /* move points needed is avg. move loss for src and destination sect type */
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_TUNNEL) &&
      num_pc_in_room(&(world[EXIT(ch, dir)->to_room])) > 1) {
    send_to_char("There isn't enough room there for more than one person!\r\n", ch);
    return (0);
  }
  /* Mortals and low level gods cannot enter greater god rooms. */
  if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_GODROOM) &&
	GET_LEVEL(ch) < LVL_GRGOD) {
    send_to_char("You aren't godly enough to use that room!\r\n", ch);
    return (0);
  }


  /* Now we know we're allow to go into the room. */

  if(AFF_FLAGGED(ch, AFF_FISHING) || GET_FISHON(ch)) {
    REMOVE_BIT(AFF_FLAGS(ch), AFF_FISHING);
    GET_FISHON(ch) = 0;
    GET_REELIN(ch) = 0;
    send_to_char("You stop fishing.\r\n", ch);
    act("$n stops fishing.", FALSE, ch, 0, 0, TO_ROOM);
  }

  if (!AFF_FLAGGED(ch, AFF_SNEAK) && !AFF_FLAGGED(ch, AFF_INVISIBLE)) {
    if(IS_NPC(ch)) { 
      switch(GET_RACE(ch)) {
        case RACE_NPC_MAMMAL:
        case RACE_NPC_HIGHHUMAN:
        case RACE_NPC_GOBLIN:
        case RACE_NPC_PIG:
        case RACE_NPC_WOLF:
        case RACE_NPC_CHICKEN:
          sprintf(buf2, "$n walks %s.", dirs[dir]);
          break;
        case RACE_NPC_AVIAN:
          sprintf(buf2, "$n flits %s.", dirs[dir]); 
          break;
        case RACE_NPC_SHEEP:
        case RACE_NPC_GOAT:
          sprintf(buf2, "$n walks %s.", dirs[dir]);
          break;
        case RACE_NPC_SKELETON:
          sprintf(buf2, "$n shambles %s.", dirs[dir]);
          break;
        case RACE_NPC_COW:
          sprintf(buf2, "$n walks %s.", dirs[dir]);
          break;
        case RACE_NPC_CRAB:
          sprintf(buf2, "$n scurries %s.", dirs[dir]);
          break;
        case RACE_NPC_FISH:
          sprintf(buf2, "$n swims %s.", dirs[dir]);
          break;
        case RACE_NPC_INSECT:
          sprintf(buf2, "$n buzzes %s.", dirs[dir]);
          break;
        default:
          sprintf(buf2, "$n leaves %s.", dirs[dir]);
          break;
      }
    }
    else {
       sprintf(buf2, "$n leaves %s.", dirs[dir]);
    }
    if(SECT(ch->in_room) == SECT_WATER_SWIM && !IS_NPC_FISH(ch)) {
       sprintf(buf2, "$n splashes through the water, heading %s.", dirs[dir]);
    }
    act(buf2, FALSE, ch, 0, 0, TO_ROOM);
  }
  was_in = ch->in_room;


  char_from_room(ch);
  char_to_room(ch, world[was_in].dir_option[dir]->to_room);

  if (!AFF_FLAGGED(ch, AFF_SNEAK)) {
    if(!AFF_FLAGGED(ch, AFF_INVISIBLE)) {
      act("$n has arrived.", FALSE, ch, 0, 0, TO_ROOM);
    }
  }
  if (ch->desc != NULL)
    look_at_room(ch, 0);

  if(IS_NPC_CRAB(ch) || IS_NPC_LIVESTOCK(ch)) {
    for (i = world[ch->in_room].people; i; i = i->next_in_room) {
    
       if(IS_NPC_WOLF(i) && IS_NPC_CRAB(ch)) {
            sprintf(buf, "%s sees %s and tries to run!\r\n", GET_NAME(ch), GET_NAME(i));
            send_to_room(buf, ch->in_room);
            if(!number(0, 2)) {
              do_flee(ch, NULL, 0, 0);
            }
            if(i->in_room == ch->in_room && !number(0, 2)) {
              hit(i, ch, TYPE_UNDEFINED);
            }
      }
      if((IS_NPC_SKELETON(i) || IS_NPC_WOLF(i)) && IS_NPC_LIVESTOCK(ch)) {
          if(ch->master) {
            sprintf(buf, "%s sees %s and %s in absolute terror!\r\n", GET_NAME(ch), GET_NAME(i), livestock_afraid_vocals[(int)GET_RACE(ch)]);
            send_to_room(buf, ch->in_room);
            if(!number(0, 2)) {
              do_flee(ch, NULL, 0, 0);
            }
            if(i->in_room == ch->in_room && !number(0, 2)) {
              hit(i, ch, TYPE_UNDEFINED);
            }
          }
      }
    }
    return (1);
  }
  if (ROOM_FLAGGED(ch->in_room, ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) {
    log_death_trap(ch);
    death_cry(ch);
    extract_char(ch);
    return (0);
  }
  return (1);
}
Пример #13
0
void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd)
{

  struct obj_data *o;
  char buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
  size_t len;
  room_rnum other_room = NOWHERE;
  struct room_direction_data *back = NULL;

  if (!door_mtrigger(ch, scmd, door))
    return;

  if (!door_wtrigger(ch, scmd, door))
    return;

  len = snprintf(buf, sizeof(buf), "$n %ss ", cmd_door[scmd]);
  if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
    if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
      if (back->to_room != IN_ROOM(ch))
	back = NULL;

  switch (scmd) {
  case SCMD_OPEN:
    OPEN_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      OPEN_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", OK);
    break;

  case SCMD_CLOSE:
    CLOSE_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      CLOSE_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", OK);
    break;

  case SCMD_LOCK:
    LOCK_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      LOCK_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "*Click*\r\n");
    break;

  case SCMD_UNLOCK: // Rewrote Apr 2012
    if (GET_LEVEL(ch) >= LVL_GOD) { // LEVEL GOD + can unlock all doors
      UNLOCK_DOOR(IN_ROOM(ch), obj, door);
      if (back)
        UNLOCK_DOOR(other_room, obj, rev_dir[door]);
        send_to_char(ch, "*Click*\r\n");
        return;
    }

    if ((o = has_key(ch, DOOR_KEY(ch, obj, door)))) { // Assign o to the key, if ch has it
      UNLOCK_DOOR(IN_ROOM(ch), obj, door);
      if (back) UNLOCK_DOOR(other_room, o, rev_dir[door]); // this unlocks the door in the other direction
      send_to_char(ch, "*Click*\r\n");
      if ((GET_OBJ_VAL(o, 0) != 9999) && (GET_OBJ_VAL(o, 0) > 0)) // Check for key charges
      	GET_OBJ_VAL(o, 0)--; // take a charge from the key
      if (GET_OBJ_VAL(o, 0) <= 0) {
      	extract_obj(o); // take key if the last charge is used
        snprintf(buf2, sizeof(buf), "%s suddenly vanishes from sight!", o->short_description);
      	act(buf2, FALSE, ch, 0, 0, TO_CHAR);
      	}
    }
  break;

  case SCMD_PICK:
    TOGGLE_LOCK(IN_ROOM(ch), obj, door);
    if (back)
      TOGGLE_LOCK(other_room, obj, rev_dir[door]);
    send_to_char(ch, "The lock quickly yields to your skills.\r\n");
    len = strlcpy(buf, "$n skillfully picks the lock on ", sizeof(buf));
    break;
   default:
    break;
  }

  /* Notify the room. */
  if (len < sizeof(buf))
    snprintf(buf + len, sizeof(buf) - len, "%s%s.",	obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
  if (!obj || IN_ROOM(obj) != NOWHERE)
    act(buf, FALSE, ch, obj, obj ? 0 : EXIT(ch, door)->keyword, TO_ROOM);

  /* Notify the other room */
  if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
      send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.",
		back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
		scmd == SCMD_CLOSE ? "d" : "ed");
}
Пример #14
0
static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd)
{
  char buf[MAX_STRING_LENGTH];
  size_t len;
  room_rnum other_room = NOWHERE;
  struct room_direction_data *back = NULL;

  if (!door_mtrigger(ch, scmd, door))
    return;

  if (!door_wtrigger(ch, scmd, door))
    return;

  len = snprintf(buf, sizeof(buf), "$n %ss ", cmd_door[scmd]);
  if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
    if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
      if (back->to_room != IN_ROOM(ch))
        back = NULL;

  switch (scmd) {
  case SCMD_OPEN:
    OPEN_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      OPEN_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", CONFIG_OK);
    break;

  case SCMD_CLOSE:
    CLOSE_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      CLOSE_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", CONFIG_OK);
    break;

  case SCMD_LOCK:
    LOCK_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      LOCK_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "*Click*\r\n");
    break;

  case SCMD_UNLOCK:
    UNLOCK_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      UNLOCK_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "*Click*\r\n");
    break;

  case SCMD_PICK:
    TOGGLE_LOCK(IN_ROOM(ch), obj, door);
    if (back)
      TOGGLE_LOCK(other_room, obj, rev_dir[door]);
    send_to_char(ch, "The lock quickly yields to your skills.\r\n");
    len = strlcpy(buf, "$n skillfully picks the lock on ", sizeof(buf));
    break;
  }

  /* Notify the room. */
  if (len < sizeof(buf))
    snprintf(buf + len, sizeof(buf) - len, "%s%s.",
      obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
  if (!obj || IN_ROOM(obj) != NOWHERE)
    act(buf, FALSE, ch, obj, obj ? 0 : EXIT(ch, door)->keyword, TO_ROOM);

  /* Notify the other room */
  if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
      send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.\r\n",
        back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
        scmd == SCMD_CLOSE ? "d" : "ed");
}
Пример #15
0
void do_cdonate( CHAR_DATA *ch, char *arg )
{
    OBJ_DATA *container;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    char      arg1 [ MAX_INPUT_LENGTH ];

    if ( !is_clan( ch ) )
    {
	send_to_char( "You aren't a clansman!\n\r", ch );
	return;
    }

    arg = one_argument( arg, arg1 );

    if ( arg1[0] == '\0' )
    {
	send_to_char( "Donate to your clan what?\n\r", ch );
	return;
    }

    for ( container = object_list; container; container = container->next )
    {
        if ( can_see_obj( ch, container )
	    && container->pIndexData->vnum == ch->pcdata->clan->donation )
	    break;
    }

    if ( !container )
    {
	send_to_char( "The donation pit is missing from the world.\n\r", ch );
	return;
    }

    if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
    {
	if ( !( obj = get_obj_carry( ch, arg1 ) ) )
	{
	    send_to_char( "You do not have that item.\n\r", ch );
	    return;
	}

	if ( !can_drop_obj( ch, obj ) )
	{
	    send_to_char( "You can't let go of it.\n\r", ch );
	    return;
	}
	
	if ( get_obj_weight( obj ) + get_obj_weight( container ) 
	  > container->value[0] )
	{
	    send_to_char( "It won't fit.\n\r", ch );
	    return;
	}

	if ( obj->item_type == ITEM_TRASH
	    || obj->item_type == ITEM_FOOD
	    || obj->item_type == ITEM_KEY
	    || obj->item_type == ITEM_PILL )
	{
	    act( "You send $p flying to the $P.", ch, obj, container,
		TO_CHAR );
	    extract_obj( obj );
	    return;
	}

	obj_from_char( obj );
	obj_to_obj( obj, container );
	act( "$n sends $p flying to the $P.", ch, obj, container, TO_ROOM );
	act( "You send $p flying to the $P.", ch, obj, container, TO_CHAR );
	send_to_room( "A loud clank is heard from the pit!",
		     container->in_room );
    }
    else
    {
	for ( obj = ch->carrying; obj; obj = obj_next )
	{
	    obj_next = obj->next_content;

	    if ( obj->deleted )
		continue;

	    if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) )
		&& can_see_obj( ch, obj )
		&& obj->wear_loc == WEAR_NONE
		&& obj != container
		&& can_drop_obj( ch, obj )
		&& get_obj_weight( obj ) + get_obj_weight( container )
		<= container->value[0] )
	    {

	        if ( obj->item_type == ITEM_TRASH
		    || obj->item_type == ITEM_FOOD
		    || obj->item_type == ITEM_KEY
		    || obj->item_type == ITEM_PILL )
		{
		    act( "You send $p flying to the $P.", ch, obj, container,
			TO_CHAR );
		    extract_obj( obj );
		    continue;
		}

		obj_from_char( obj );
		obj_to_obj( obj, container );
		act( "$n sends $p flying to the $P.", ch, obj, container,
		    TO_ROOM );
		act( "You send $p flying to the $P.", ch, obj, container,
		    TO_CHAR );
		send_to_room( "A loud clank is heard from the pit!\n\r",
		     container->in_room );

		ch->pcdata->clan->score += 1;
	    }
	}
    }

    return;

}