Пример #1
0
int
is_ok_char(struct char_data * keeper, struct char_data * ch, int shop_nr)
{
  char buf[200];

  if (!(CAN_SEE(keeper, ch)))
    {
      do_say(keeper, MSG_NO_SEE_CHAR, cmd_say, 0);
      return (FALSE);
    }
  if (IS_GOD(ch))
    return (TRUE);

  if ((IS_GOOD(ch) && NOTRADE_GOOD(shop_nr)) ||
      (IS_EVIL(ch) && NOTRADE_EVIL(shop_nr)) ||
      (IS_NEUTRAL(ch) && NOTRADE_NEUTRAL(shop_nr)))
    {
      sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_ALIGN);
      do_tell(keeper, buf, cmd_tell, 0);
      return (FALSE);
    }
  if (IS_NPC(ch))
    return (TRUE);

  if ((IS_MAGIC_USER(ch) && NOTRADE_MAGIC_USER(shop_nr)) ||
      (IS_CLERIC(ch) && NOTRADE_CLERIC(shop_nr)) ||
      (IS_THIEF(ch) && NOTRADE_THIEF(shop_nr)) ||
      (IS_WARRIOR(ch) && NOTRADE_WARRIOR(shop_nr)))
    {
      sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_CLASS);
      do_tell(keeper, buf, cmd_tell, 0);
      return (FALSE);
    }
  return (TRUE);
}
Пример #2
0
int is_tell_ok(CHAR_DATA * ch, CHAR_DATA * vict)
{
	if (ch == vict)
	{
		send_to_char("Вы начали потихоньку разговаривать с самим собой.\r\n", ch);
		return (FALSE);
	}
	else if (!IS_NPC(ch) && PLR_FLAGGED(ch, PLR_DUMB))
	{
		send_to_char("Вам запрещено обращаться к другим игрокам.\r\n", ch);
		return (FALSE);
	}
	else if (!IS_NPC(vict) && !vict->desc)  	/* linkless */
	{
		act("$N потерял$G связь в этот момент.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
		return (FALSE);
	}
	else if (PLR_FLAGGED(vict, PLR_WRITING))
	{
		act("$N пишет сообщение - повторите попозже.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
		return (FALSE);
	}

	if (IS_GOD(ch) || Privilege::check_flag(ch, Privilege::KRODER))
		return (TRUE);

	if (ROOM_FLAGGED(ch->in_room, ROOM_SOUNDPROOF))
		send_to_char("Стены заглушили Ваши слова.\r\n", ch);
	else if ((!IS_NPC(vict) &&
			  (PRF_FLAGGED(vict, PRF_NOTELL) || ignores(vict, ch, IGNORE_TELL))) ||
			 ROOM_FLAGGED(vict->in_room, ROOM_SOUNDPROOF))
		act("$N не сможет Вас услышать.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
	else if (GET_POS(vict) < POS_RESTING || AFF_FLAGGED(vict, AFF_DEAFNESS))
		act("$N Вас не услышит.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
	else
		return (TRUE);

	return (FALSE);
}
Пример #3
0
void underwater_check(void)
{
	DESCRIPTOR_DATA *d;
	for (d = descriptor_list; d; d = d->next)
	{
		if (d->character
			&& SECT(d->character->in_room) == SECT_UNDERWATER
			&& !IS_GOD(d->character)
			&& !AFF_FLAGGED(d->character, AFF_WATERBREATH))
		{
			sprintf(buf, "Player %s died under water (room %d)",
				GET_NAME(d->character), GET_ROOM_VNUM(d->character->in_room));

			Damage dmg(SimpleDmg(TYPE_WATERDEATH), MAX(1, GET_REAL_MAX_HIT(d->character) >> 2), FightSystem::UNDEF_DMG);
			dmg.flags.set(FightSystem::NO_FLEE);

			if (dmg.process(d->character, d->character) < 0)
			{
				log("%s",buf);
			}
		}
	}
Пример #4
0
void
shopping_buy(char *arg, struct char_data *ch,
         struct char_data *keeper, int shop_nr)
{
  char tempstr[200], buf[MAX_STRING_LENGTH];
  struct obj_data *obj, *last_obj = NULL;
  int goldamt = 0, buynum, bought = 0;

  if (!(is_ok(keeper, ch, shop_nr)))
    return;

  if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper))
    sort_keeper_objs(keeper, shop_nr);

  if ((buynum = transaction_amt(arg)) < 0)
    {
      sprintf(buf, "%s A negative amount?  Try selling me something.",
          GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);
      return;
    }
  if (!(*arg) || !(buynum))
    {
      sprintf(buf, "%s What do you want to buy??", GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);
      return;
    }
  if (!(obj = get_purchase_obj(ch, arg, keeper, shop_nr, TRUE)))
    return;

  if ((buy_price(ch, obj, shop_nr) > GET_GOLD(ch)) && !IS_GOD(ch))
    {
      sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);

      switch (SHOP_BROKE_TEMPER(shop_nr))
    {
    case 0:
      do_action(keeper, GET_NAME(ch), cmd_puke, 0);
      return;
    case 1:
      do_echo(keeper, "smokes on his joint.", cmd_emote, SCMD_EMOTE);
      return;
    default:
      return;
    }
    }
  if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch)))
    {
      sprintf(buf, "%s: You can't carry any more items.\n\r",
          fname(obj->name));
      send_to_char(buf, ch);
      return;
    }
  if ((IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj)) > CAN_CARRY_W(ch))
    {
      sprintf(buf, "%s: You can't carry that much weight.\n\r",
          fname(obj->name));
      send_to_char(buf, ch);
      return;
    }
  while ((obj) && ((GET_GOLD(ch) >= buy_price(ch, obj, shop_nr)) || IS_GOD(ch))
     && (IS_CARRYING_N(ch) < CAN_CARRY_N(ch)) && (bought < buynum)
     && (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) <= CAN_CARRY_W(ch)))
    {
      bought++;
      /* Test if producing shop ! */
      if (shop_producing(obj, shop_nr))
    obj = read_object(GET_OBJ_RNUM(obj), REAL);
      else
    {
      obj_from_char(obj);
      SHOP_SORT(shop_nr)--;
    }
      obj_to_char(obj, ch);

      goldamt += buy_price(ch, obj, shop_nr);
      if (!IS_GOD(ch))
    GET_GOLD(ch) -= buy_price(ch, obj, shop_nr);

      last_obj = obj;
      obj = get_purchase_obj(ch, arg, keeper, shop_nr, FALSE);
      if (!same_obj(obj, last_obj))
    break;
    }

  if (bought < buynum)
    {
      if (!obj || !same_obj(last_obj, obj))
    sprintf(buf, "%s I only have %d to sell you.", GET_NAME(ch), bought);
      else if (GET_GOLD(ch) < buy_price(ch, obj, shop_nr))
    sprintf(buf, "%s You can only afford %d.", GET_NAME(ch), bought);
      else if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch))
    sprintf(buf, "%s You can only hold %d.", GET_NAME(ch), bought);
      else if (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) > CAN_CARRY_W(ch))
    sprintf(buf, "%s You can only carry %d.", GET_NAME(ch), bought);
      else
    sprintf(buf, "%s Something screwy only gave you %d.", GET_NAME(ch),
        bought);
      do_tell(keeper, buf, cmd_tell, 0);
    }
  if (!IS_GOD(ch))
    GET_GOLD(keeper) += goldamt;

  sprintf(tempstr, "%s", times_message(ch->carrying, 0, bought));
  sprintf(buf, "$n buys %s.", tempstr);
  act(buf, FALSE, ch, obj, 0, TO_ROOM);

  sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), goldamt);
  do_tell(keeper, buf, cmd_tell, 0);
  sprintf(buf, "You now have %s.\n\r", tempstr);
  send_to_char(buf, ch);

  if (SHOP_USES_BANK(shop_nr))
    if (GET_GOLD(keeper) > MAX_OUTSIDE_BANK)
      {
    SHOP_BANK(shop_nr) += (GET_GOLD(keeper) - MAX_OUTSIDE_BANK);
    GET_GOLD(keeper) = MAX_OUTSIDE_BANK;
      }
}