Exemplo n.º 1
0
/*search the entire world for an object, and return a pointer  */
struct obj_data *get_obj_vis(struct char_data *ch, char *name)
{
    struct obj_data *i;
    int j, number;
    char tmpname[MAX_INPUT_LENGTH];
    char *tmp;

    /* scan items carried */
    if ( ( i = get_obj_in_list_vis(ch, name, ch->carrying) ) != NULL )
	return(i);

    /* scan room */
    if ( ( i = get_obj_in_list_vis(ch, name, world[ch->in_room].contents) )
    != NULL )
	return(i);

    strcpy(tmpname,name);
    tmp = tmpname;
    if ( ( number = get_number(&tmp) ) == 0 )
	return(0);

    /* ok.. no luck yet. scan the entire obj list   */
    for (i = object_list, j = 1; i && (j <= number); i = i->next)
	if (isname(tmp, i->name))
	    if (CAN_SEE_OBJ(ch, i)) {
		if (j == number)
		    return(i);
		j++;
	    }
    return(0);
}
Exemplo n.º 2
0
/* search the entire world for an object, and return a pointer  */
struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *number)
{
  struct obj_data *i;
  int num;

  if (!number) {
    number = &num;
    num = get_number(&name);
  }

  if (*number == 0)
    return (NULL);

  /* scan items carried */
  if ((i = get_obj_in_list_vis(ch, name, number, ch->carrying)) != NULL)
    return (i);

  /* scan room */
  if ((i = get_obj_in_list_vis(ch, name, number, world[IN_ROOM(ch)].contents)) != NULL)
    return (i);

  /* ok.. no luck yet. scan the entire obj list   */
  for (i = object_list; i && *number; i = i->next)
    if (isname(name, i->name))
      if (CAN_SEE_OBJ(ch, i))
	if (--(*number) == 0)
	  return (i);

  return (NULL);
}
Exemplo n.º 3
0
/* search the entire world for an object, and return a pointer  */
struct obj_data *get_obj_vis(struct char_data * ch, char *name)
{
  struct obj_data *i;
  int j = 0, number;
  char tmpname[MAX_INPUT_LENGTH];
  char *tmp = tmpname;

  /* scan items carried */
  if ((i = get_obj_in_list_vis(ch, name, ch->carrying)))
    return i;

  /* scan room */
  if ((i = get_obj_in_list_vis(ch, name, world[ch->in_room].contents)))
    return i;

  strcpy(tmp, name);
  if (!(number = get_number(&tmp)))
  {
    number = 1;
    tmp = name;
  }

  /* ok.. no luck yet. scan the entire obj list   */
  for (i = object_list; i && (j <= number); i = i->next)
    if (isname(tmp, i->name))
      if (CAN_SEE_OBJ(ch, i))
	if (++j == number)
	  return i;

  return NULL;
}
Exemplo n.º 4
0
/* Generic Find, designed to find any object orcharacter.
 *  *arg     is the pointer containing the string to be searched for.
 *           This string doesn't have to be a single word, the routine
 *           extracts the next word itself.
 *  bitv..   All those bits that you want to "search through".
 *           Bit found will be result of the function
 *  *ch      This is the person that is trying to "find"
 *  **tar_ch Will be NULL if no character was found, otherwise points
 * **tar_obj Will be NULL if no object was found, otherwise points
 *
 * The routine used to return a pointer to the next word in *arg (just
 * like the one_argument routine), but now it returns an integer that
 * describes what it filled in. */
int generic_find(char *arg, bitvector_t bitvector, struct char_data *ch,
		     struct char_data **tar_ch, struct obj_data **tar_obj)
{
  int i, found, number;
  char name_val[MAX_INPUT_LENGTH];
  char *name = name_val;

  *tar_ch = NULL;
  *tar_obj = NULL;

  one_argument(arg, name);

  if (!*name)
    return (0);
  if (!(number = get_number(&name)))
    return (0);

  if (IS_SET(bitvector, FIND_CHAR_ROOM)) {	/* Find person in room */
    if ((*tar_ch = get_char_room_vis(ch, name, &number)) != NULL)
      return (FIND_CHAR_ROOM);
  }

  if (IS_SET(bitvector, FIND_CHAR_WORLD)) {
    if ((*tar_ch = get_char_world_vis(ch, name, &number)) != NULL)
      return (FIND_CHAR_WORLD);
  }

  if (IS_SET(bitvector, FIND_OBJ_EQUIP)) {
    for (found = FALSE, i = 0; i < NUM_WEARS && !found; i++)
      if (GET_EQ(ch, i) && isname(name, GET_EQ(ch, i)->name) && --number == 0) {
	*tar_obj = GET_EQ(ch, i);
	found = TRUE;
      }
    if (found)
      return (FIND_OBJ_EQUIP);
  }

  if (IS_SET(bitvector, FIND_OBJ_INV)) {
    if ((*tar_obj = get_obj_in_list_vis(ch, name, &number, ch->carrying)) != NULL)
      return (FIND_OBJ_INV);
  }

  if (IS_SET(bitvector, FIND_OBJ_ROOM)) {
    if ((*tar_obj = get_obj_in_list_vis(ch, name, &number, world[IN_ROOM(ch)].contents)) != NULL)
      return (FIND_OBJ_ROOM);
  }

  if (IS_SET(bitvector, FIND_OBJ_WORLD)) {
    if ((*tar_obj = get_obj_vis(ch, name, &number)))
      return (FIND_OBJ_WORLD);
  }

  return (0);
}
Exemplo n.º 5
0
int generic_find(char *arg, int bitvector, struct char_data * ch,
		     struct char_data ** tar_ch, struct obj_data ** tar_obj)
{
  int o;
  //int i, found;

  char name[256];

  *tar_ch = NULL;
  *tar_obj = NULL;

  one_argument(arg, name);

  if (!*name)
    return (0);

  if (IS_SET(bitvector, FIND_CHAR_ROOM)) {	/* Find person in room */
    if ((*tar_ch = get_char_vis(ch, name, FIND_CHAR_ROOM))) {
      return (FIND_CHAR_ROOM);
    }
  }
  if (IS_SET(bitvector, FIND_CHAR_WORLD)) {
    if ((*tar_ch = get_char_vis(ch, name, FIND_CHAR_WORLD))) {
      return (FIND_CHAR_WORLD);
    }
  }
  if (IS_SET(bitvector, FIND_OBJ_EQUIP)) {
    if ((*tar_obj = get_object_in_equip_vis(ch, name, ch->equipment, &o))) {
      return (FIND_OBJ_INV);
    }
  }


  if (IS_SET(bitvector, FIND_OBJ_INV)) {
    if ((*tar_obj = get_obj_in_list_vis(ch, name, ch->carrying))) {
      return (FIND_OBJ_INV);
    }
  }
  if (IS_SET(bitvector, FIND_OBJ_ROOM)) {
    if ((*tar_obj = get_obj_in_list_vis(ch, name, world[ch->in_room].contents))) {
      return (FIND_OBJ_ROOM);
    }
  }
  if (IS_SET(bitvector, FIND_OBJ_WORLD)) {
    if ((*tar_obj = get_obj_vis(ch, name))) {
      return (FIND_OBJ_WORLD);
    }
  }
  return (0);
}
Exemplo n.º 6
0
/*search the entire world for an object, and return a pointer  */
struct obj_data *get_obj_vis(struct char_data *ch, char *name)
{
  struct obj_data *i;
  
  /* scan items carried */
  if (i = get_obj_in_list_vis(ch, name, ch->carrying))
    return(i);
  
  /* scan room */
  if (i = get_obj_in_list_vis(ch, name, real_roomp(ch->in_room)->contents))
    return(i);
  
  return get_obj_vis_world(ch, name, NULL);
}
Exemplo n.º 7
0
void do_wear(struct char_data *ch, char *argument, int cmd) {
char arg1[MAX_STRING_LENGTH];
char arg2[MAX_STRING_LENGTH];
char buf[256];
char buffer[MAX_STRING_LENGTH];
struct obj_data *obj_object;
int keyword;
static char *keywords[] = {
	"finger",
	"neck",
	"body",
	"head",
	"legs",
	"feet",
	"hands",
	"arms",
	"about",
	"waist",
	"wrist",
	"shield",
	"\n"
};

	argument_interpreter(argument, arg1, arg2);
	if (*arg1) {
		obj_object = get_obj_in_list_vis(ch, arg1, ch->carrying);
		if (obj_object) {
			if (*arg2) {
				keyword = search_block(arg2, keywords, FALSE); /* Partial Match */
				if (keyword == -1) {
					sprintf(buf, "%s is an unknown body location.\n\r", arg2);
					send_to_char(buf, ch);
				} else {
					wear(ch, obj_object, keyword+1);
				}
			} else {
				keyword = -2;
        if (CAN_WEAR(obj_object,ITEM_WEAR_SHIELD)) keyword = 14;
				if (CAN_WEAR(obj_object,ITEM_WEAR_FINGER)) keyword = 1;
				if (CAN_WEAR(obj_object,ITEM_WEAR_NECK)) keyword = 2;
				if (CAN_WEAR(obj_object,ITEM_WEAR_WRIST)) keyword = 11;
				if (CAN_WEAR(obj_object,ITEM_WEAR_WAISTE)) keyword = 10;
				if (CAN_WEAR(obj_object,ITEM_WEAR_ARMS)) keyword = 8;
				if (CAN_WEAR(obj_object,ITEM_WEAR_HANDS)) keyword = 7;
				if (CAN_WEAR(obj_object,ITEM_WEAR_FEET)) keyword = 6;
				if (CAN_WEAR(obj_object,ITEM_WEAR_LEGS)) keyword = 5;
				if (CAN_WEAR(obj_object,ITEM_WEAR_ABOUT)) keyword = 9;
				if (CAN_WEAR(obj_object,ITEM_WEAR_HEAD)) keyword = 4;
				if (CAN_WEAR(obj_object,ITEM_WEAR_BODY)) keyword = 3;

				wear(ch, obj_object, keyword);
			}
		} else {
			sprintf(buffer, "You do not seem to have the '%s'.\n\r",arg1);
			send_to_char(buffer,ch);
		}
	} else {
		send_to_char("Wear what?\n\r", ch);
	}
}
Exemplo n.º 8
0
void shopping_value( const char *arg, struct char_data *ch, 
                    struct char_data *keeper, int shop_nr)
{
  char argm[100], buf[MAX_STRING_LENGTH];
  struct obj_data *temp1;
  int i;
  float mult = 0;
  
  if(!(is_ok(keeper,ch,shop_nr)))
    return;

  if(keeper->generic != 0)
     for(i = 0; i <= MAX_TRADE; i++) {
       if(keeper->generic == FAMINE)
          if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
            mult = shop_multiplier; /* we're in a famine, we sell food, so we */
            break;             /* our prices to hell ;-) -DM */ 
          }
       if(keeper->generic == DWARVES_STRIKE)
          if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
          mult = shop_multiplier;
          break;
       }        
     }
  
  only_argument(arg, argm);
  
  if(!(*argm))    {
      sprintf(buf,"%s What do you want me to evaluate??",
              GET_NAME(ch));
      do_tell(keeper,buf,19);
      return;
    }
  
  if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))    {
      sprintf(buf,shop_index[shop_nr].no_such_item2,
              GET_NAME(ch));
      do_tell(keeper,buf,19);
      return;
    }
  
  if(!(trade_with(temp1,shop_nr)))    {
      sprintf(buf,
              shop_index[shop_nr].do_not_buy,
              GET_NAME(ch));
      do_tell(keeper,buf,19);
      return;
    }
  
  sprintf(buf,"%s I'll give you %d gold coins for that!",
          GET_NAME(ch),(int) (temp1->obj_flags.cost*
          shop_index[shop_nr].profit_sell +
          ((chr_apply[ (int)GET_CHR(ch) ].reaction * 
          temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)));
  do_tell(keeper,buf,19);
  
  return;
}
Exemplo n.º 9
0
void do_taste(struct char_data *ch, char *argument, int cmd)
{
	struct affected_type af;
	char arg[MAX_STRING_LENGTH];
	char buf[MAX_STRING_LENGTH];
	struct obj_data *temp;

	one_argument(argument,arg);

	if(!(temp = get_obj_in_list_vis(ch,arg,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(temp->obj_flags.type_flag==ITEM_DRINKCON)
	{
		do_sip(ch,argument,0);
		return;
	}

	if(!(temp->obj_flags.type_flag==ITEM_FOOD))
	{
		act("Taste that?!? Your stomach refuses!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	act("$n tastes the $o", FALSE, ch, temp, 0, TO_ROOM);
	act("You taste the $o", FALSE, ch, temp, 0, TO_CHAR);

	gain_condition(ch,FULL,1);

	if(GET_COND(ch,FULL)>20)
		act("You are full.",FALSE,ch,0,0,TO_CHAR);

	if(temp->obj_flags.value[3]&&!IS_AFFECTED(ch,AFF_POISON)) /* The shit was poisoned ! */
	{
		act("Ooups, it did not taste good at all!",FALSE,ch,0,0,TO_CHAR);

		af.type = SPELL_POISON;
		af.duration = 2;
		af.modifier = 0;
		af.location = APPLY_NONE;
		af.bitvector = AFF_POISON;
		affect_to_char(ch,&af);
	}

	temp->obj_flags.value[0]--;

	if(!temp->obj_flags.value[0])	/* Nothing left */
	{
		act("There is nothing left now.",FALSE,ch,0,0,TO_CHAR);
		extract_obj(temp);
	}

	return;

}
Exemplo n.º 10
0
void do_eat(struct char_data *ch, char *argument, int cmd)
{
	char buf[100];
	struct obj_data *temp;
	struct affected_type af;

	one_argument(argument,buf);

	if(!(temp = get_obj_in_list_vis(ch,buf,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if((temp->obj_flags.type_flag != ITEM_FOOD) && (GET_LEVEL(ch) < 22))
	{
		act("Your stomach refuses to eat that!?!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(GET_COND(ch,FULL)>20) /* Stomach full */
	{	
		act("You are to full to eat more!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	act("$n eats $p",TRUE,ch,temp,0,TO_ROOM);
	act("You eat the $o.",FALSE,ch,temp,0,TO_CHAR);

	gain_condition(ch,FULL,temp->obj_flags.value[0]);

	if(GET_COND(ch,FULL)>20)
		act("You are full.",FALSE,ch,0,0,TO_CHAR);

	if(temp->obj_flags.value[3] && (GET_LEVEL(ch) < 21)) /* The shit was poisoned ! */
	{
		act("Ooups, it tasted rather strange ?!!?",FALSE,ch,0,0,TO_CHAR);
		act("$n coughs and utters some strange sounds.",FALSE,ch,0,0,TO_ROOM);

		af.type = SPELL_POISON;
		af.duration = temp->obj_flags.value[0]*2;
		af.modifier = 0;
		af.location = APPLY_NONE;
		af.bitvector = AFF_POISON;
		affect_join(ch,&af, FALSE, FALSE);
	}

	extract_obj(temp);
}
Exemplo n.º 11
0
void shopping_value( char *arg, struct char_data *ch, 
	struct char_data *keeper, int shop_nr)
{
	char argm[100], buf[MAX_STRING_LENGTH];
	struct obj_data *temp1;

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

	one_argument(arg, argm);

	if(!(*argm))
	{
		sprintf(buf,"%s What do you want me to valuate??",
			GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))
	{
		sprintf(buf,shop_index[shop_nr].no_such_item2,
			GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!(trade_with(temp1,shop_nr)))
	{
		sprintf(buf,
		shop_index[shop_nr].do_not_buy,
		GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	sprintf(buf,"%s I'll give you %d gold coins for that!",
		GET_NAME(ch),(int) (temp1->obj_flags.cost*
			shop_index[shop_nr].profit_sell));
	do_tell(keeper,buf,19);

	return;
}
Exemplo n.º 12
0
void do_wield(struct char_data *ch, char *argument, int cmd) {
char arg1[MAX_STRING_LENGTH];
char arg2[MAX_STRING_LENGTH];
char buffer[MAX_STRING_LENGTH];
struct obj_data *obj_object;
int keyword = 12;

	argument_interpreter(argument, arg1, arg2);
	if (*arg1) {
		obj_object = get_obj_in_list_vis(ch, arg1, ch->carrying);
		if (obj_object) {
			wear(ch, obj_object, keyword);
		} else {
			sprintf(buffer, "You do not seem to have the '%s'.\n\r",arg1);
			send_to_char(buffer,ch);
		}
	} else {
		send_to_char("Wield what?\n\r", ch);
	}
}
Exemplo n.º 13
0
struct obj_data *
get_selling_obj(struct char_data * ch, char *name,
        struct char_data * keeper, int shop_nr, int msg)
{
  char buf[MAX_STRING_LENGTH];
  struct obj_data *obj;
  int result;

  if (!(obj = get_obj_in_list_vis(ch, name, ch->carrying)))
    {
      if (msg)
    {
      sprintf(buf, shop_index[shop_nr].no_such_item2, GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);
    }
      return (0);
    }
  if ((result = trade_with(obj, shop_nr)) == OBJECT_OK)
    return (obj);

  switch (result)
    {
    case OBJECT_NOTOK:
      sprintf(buf, shop_index[shop_nr].do_not_buy, GET_NAME(ch));
      break;
    case OBJECT_DEAD:
      sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_USED_WANDSTAFF);
      break;
    default:
      sprintf(buf, "Illegal return value of %d from trade_with() (shop.c)",
          result);
      log("%s", buf);
      sprintf(buf, "%s An error has occurred.", GET_NAME(ch));
      break;
    }
  if (msg)
    do_tell(keeper, buf, cmd_tell, 0);
  return (0);
}
Exemplo n.º 14
0
void do_write (struct char_data *ch, char *argument, int cmd)
{
  struct obj_data *paper = 0, *pen = 0;
  char papername[MAX_INPUT_LENGTH], penname[MAX_INPUT_LENGTH],
    buf[MAX_STRING_LENGTH];

  argument_interpreter (argument, papername, penname);

  if (!ch->desc)
    return;

  if (!*papername) {            /* nothing was delivered */
    send_to_char
      ("Write? with what? ON what? what are you trying to do??\n\r", ch);
    return;
  }
  if (*penname) {               /* there were two arguments */
    if (!(paper = get_obj_in_list_vis (ch, papername, ch->carrying))) {
      sprintf (buf, "You have no %s.\n\r", papername);
      send_to_char (buf, ch);
      return;
    }
    if (!(pen = get_obj_in_list_vis (ch, penname, ch->carrying))) {
      sprintf (buf, "You have no %s.\n\r", papername);
      send_to_char (buf, ch);
      return;
    }
  } else {                      /* there was one arg.let's see what we can find */

    if (!(paper = get_obj_in_list_vis (ch, papername, ch->carrying))) {
      sprintf (buf, "There is no %s in your inventory.\n\r", papername);
      send_to_char (buf, ch);
      return;
    }
    if (paper->obj_flags.type_flag == ITEM_PEN) {       /* oops, a pen.. */
      pen = paper;
      paper = 0;
    } else if (paper->obj_flags.type_flag != ITEM_NOTE) {
      send_to_char ("That thing has nothing to do with writing.\n\r", ch);
      return;
    }

    /* one object was found. Now for the other one. */
    if (!ch->equipment[HOLD]) {
      sprintf (buf, "You can't write with a %s alone.\n\r", papername);
      send_to_char (buf, ch);
      return;
    }
    if (!CAN_SEE_OBJ (ch, ch->equipment[HOLD])) {
      send_to_char ("The stuff in your hand is invisible! Yeech!!\n\r", ch);
      return;
    }

    if (pen)
      paper = ch->equipment[HOLD];
    else
      pen = ch->equipment[HOLD];
  }

  /* ok.. now let's see what kind of stuff we've found */
  if (pen->obj_flags.type_flag != ITEM_PEN) {
    act ("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR);
  } else if (paper->obj_flags.type_flag != ITEM_NOTE) {
    act ("You can't write on $p.", FALSE, ch, paper, 0, TO_CHAR);
  } else if (paper->action_description)
    send_to_char ("There's something written on it already.\n\r", ch);
  else {
    /* we can write - hooray! */

    send_to_char ("Ok.. go ahead and write.. end the note with a @.\n\r", ch);
    act ("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM);
    ch->desc->str = &paper->action_description;
    ch->desc->max_str = MAX_NOTE_LENGTH;
  }
}
Exemplo n.º 15
0
void shopping_sell( const char *arg, struct char_data *ch,
                   struct char_data *keeper,int shop_nr)
{
  char argm[100], buf[MAX_STRING_LENGTH];
  int cost,temp_cost, i;
  struct obj_data *temp1;
  float mult = 0;
  
  if(!(is_ok(keeper,ch,shop_nr)))
    return;

  if(keeper->generic != 0)
     for(i = 0; i <= MAX_TRADE; i++) {
       if(keeper->generic == FAMINE)
          if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
            mult = shop_multiplier; /* we're in a famine, we sell food, so we */
            break;             /* our prices to hell ;-) -DM */ 
          }
       if(keeper->generic == DWARVES_STRIKE)
          if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
          mult = shop_multiplier;
          break;
       }        
     }
  
  only_argument(arg, argm);
  
  if(!(*argm))        {
    sprintf(buf, "%s What do you want to sell??"
            ,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if (!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) {
    sprintf(buf, shop_index[shop_nr].no_such_item2,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if( IS_OBJ_STAT( temp1, ITEM_NODROP ) && !IS_IMMORTAL( ch ) )
  {
     send_to_char("You can't let go of it, it must be CURSED!\n\r", ch);
     return;
  }

  if (!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1)) {
    sprintf(buf,shop_index[shop_nr].do_not_buy,
            GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if( GET_GOLD(keeper)<(int) (temp1->obj_flags.cost*
      shop_index[shop_nr].profit_sell +
      ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
      (mult * temp1->obj_flags.cost)))
  {
    sprintf(buf,shop_index[shop_nr].missing_cash1,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  cost = temp1->obj_flags.cost;
  
  if ((ITEM_TYPE(temp1) == ITEM_WAND) ||
      (ITEM_TYPE(temp1) == ITEM_STAFF))
  {
    if (temp1->obj_flags.value[1])
    {
      cost = (int)( cost * ( (float)temp1->obj_flags.value[2] /
                             (float)temp1->obj_flags.value[1] ) );
    }
    else
    {
      cost = 0;
    }
  } 
  else if (ITEM_TYPE(temp1) == ITEM_ARMOR)
  {
    if (temp1->obj_flags.value[1])
    {
      cost = (int)( cost * ( (float)temp1->obj_flags.value[0] /
                             (float)temp1->obj_flags.value[1] ) );
    }
    else
    {
      cost = 0;
    }
  }
  
  temp1->obj_flags.cost = cost;
  
  act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM);
  temp_cost = (int) (temp1->obj_flags.cost*shop_index[shop_nr].profit_sell +
             ((chr_apply[ (int)GET_CHR(ch) ].reaction *
             temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost));
  if(temp_cost < 0) temp_cost=0;

  sprintf(buf,shop_index[shop_nr].message_sell,GET_NAME(ch),temp_cost);

/* (int) (temp1->obj_flags.cost*        
                shop_index[shop_nr].profit_sell +
                ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)))
; */
  
  do_tell(keeper,buf,19);
  
  sprintf(buf,"The shopkeeper now has %s.\n\r",
          temp1->short_description);
  send_to_char(buf,ch);
  
  if (GET_GOLD(keeper)< temp_cost) {
 /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100))) {
 */
    sprintf(buf,shop_index[shop_nr].missing_cash1 ,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  GET_GOLD(ch) += temp_cost;
    /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
              */
  GET_GOLD(keeper) -= temp_cost;
    /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
              */
  obj_from_char(temp1);
  if (temp1 == NULL) {
    send_to_char("As far as I am concerned, you are out..\n\r",ch);
    return;
  }
  if ((get_obj_in_list(argm,keeper->carrying)) || 
      (GET_ITEM_TYPE(temp1) == ITEM_TRASH)) {
    extract_obj(temp1);
  } else {
    obj_to_char(temp1,keeper);
  }
  return;
}
Exemplo n.º 16
0
void shopping_sell( char *arg, struct char_data *ch,
	 struct char_data *keeper,int shop_nr)
{
	char argm[100], buf[MAX_STRING_LENGTH];
	struct obj_data *temp1;
	struct char_data *temp_char;

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

	one_argument(arg, argm);

	if(!(*argm))
	{
		sprintf(buf,
		"%s What do you want to sell??"
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))
	{
		sprintf(buf,
		shop_index[shop_nr].no_such_item2
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1))
	{
		sprintf(buf,
		shop_index[shop_nr].do_not_buy,
		GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if (GET_GOLD(keeper)<(int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell)) {
		sprintf(buf,shop_index[shop_nr].missing_cash1
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM);

	sprintf(buf,shop_index[shop_nr].message_sell,
		GET_NAME(ch),(int) (temp1->obj_flags.cost*
			shop_index[shop_nr].profit_sell));
	do_tell(keeper,buf,19);
	sprintf(buf,"The shopkeeper now has %s.\n\r",
		temp1->short_description);
	send_to_char(buf,ch);
	GET_GOLD(ch) += (int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell);
	GET_GOLD(keeper) -= (int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell);

	if((get_obj_in_list(argm,keeper->carrying)) || 
   (GET_ITEM_TYPE(temp1) == ITEM_TRASH))
		extract_obj(temp1);
	else
	{
		obj_from_char(temp1);
		obj_to_char(temp1,keeper);
	}

	return;
}
Exemplo n.º 17
0
void sub_write(char *arg, char_data *ch, byte find_invis, int targets)
{
  char str[MAX_INPUT_LENGTH * 2];
  char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
  char *tokens[MAX_INPUT_LENGTH], *s, *p;
  void *otokens[MAX_INPUT_LENGTH];
  char_data *to;
  obj_data *obj;
  int i, tmp;
  int to_sleeping = 1; /* mainly for windows compiles */

  if (!arg)
    return;

  tokens[0] = str;

  for (i = 0, p = arg, s = str; *p;) {
    switch (*p) {
      case '~':
      case '|':
      case '^':
      case '&':
      case '*':
        /* get char_data, move to next token */
        type[i] = *p;
        *s = '\0';
        p = any_one_name(++p, name);
        otokens[i] =
        find_invis ? (void *)get_char_in_room(&world[IN_ROOM(ch)], name) : (void *)get_char_room_vis(ch, name, NULL);
        tokens[++i] = ++s;
      break;

      case '`':
        /* get obj_data, move to next token */
        type[i] = *p;
        *s = '\0';
        p = any_one_name(++p, name);

        if (find_invis) obj = get_obj_in_room(&world[IN_ROOM(ch)], name);
        else if (!(obj = get_obj_in_list_vis(ch, name, NULL, world[IN_ROOM(ch)].contents))) ;
        else if (!(obj = get_obj_in_equip_vis(ch, name, &tmp, ch->equipment))) ;
        else obj = get_obj_in_list_vis(ch, name, NULL, ch->carrying);

        otokens[i] = (void *)obj;
        tokens[++i] = ++s;
      break;

      case '\\':
        p++;
        *s++ = *p++;
      break;

      default:
        *s++ = *p++;
    }
  }

  *s = '\0';
  tokens[++i] = NULL;

  if (IS_SET(targets, TO_CHAR) && SENDOK(ch))
    sub_write_to_char(ch, tokens, otokens, type);

  if (IS_SET(targets, TO_ROOM))
    for (to = world[IN_ROOM(ch)].people;
      to; to = to->next_in_room)
    if (to != ch && SENDOK(to))
      sub_write_to_char(to, tokens, otokens, type);
}
Exemplo n.º 18
0
void shopping_buy( const char *arg, struct char_data *ch,
         struct char_data *keeper, int shop_nr)
{
  char argm[100], buf[MAX_STRING_LENGTH], newarg[100];
  int num = 1;
  struct obj_data *temp1;
  int i;
  float mult = 0;
  
  if(!(is_ok(keeper,ch,shop_nr)))
    return;

  if(keeper->generic != 0)
     for(i = 0; i <= MAX_TRADE; i++) {
       if(keeper->generic == FAMINE)
          if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
            mult = shop_multiplier; /* we're in a famine, we sell food, so we */
            break;             /* our prices to hell ;-) -DM */ 
          }
       if(keeper->generic == DWARVES_STRIKE)
          if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
          mult = shop_multiplier;
          break;
       }        
     }
  
  only_argument(arg, argm);
  if(!(*argm))   {
      sprintf(buf,
              "%s what do you want to buy??"
              ,GET_NAME(ch));
      do_tell(keeper,buf,19);
      return;
    };
  
  if( ( num = getabunch( argm, newarg ) ) != 0 ) 
  {
    strcpy(argm,newarg);
  }
  if (num == 0) num = 1;
  
  if(!( temp1 = 
       get_obj_in_list_vis(ch,argm,keeper->carrying)))    {
      sprintf(buf,
              shop_index[shop_nr].no_such_item1
              ,GET_NAME(ch));
      do_tell(keeper,buf,19);
      return;
    }
  
  if(temp1->obj_flags.cost <= 0)    {
      sprintf(buf,
              shop_index[shop_nr].no_such_item1
              ,GET_NAME(ch));
      do_tell(keeper,buf,19);
      extract_obj(temp1);
      return;
    }
  
  if( GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost*
      shop_index[shop_nr].profit_buy -
      ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100) +
      (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD)    {
    sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch));
    do_tell(keeper,buf,19);
      
    switch(shop_index[shop_nr].temper1)        {
        case 0:
          do_action(keeper,GET_NAME(ch),30);
          return;
        case 1:
          do_emote(keeper,"grins happily",36);
          return;
        default:
          return;
    }
  }
  
  if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch)))
    {
      sprintf(buf,"%s : You can't carry that many items.\n\r", 
              fname(temp1->name));
      send_to_char(buf, ch);
      return;
    }
  
  if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch))
    {
      sprintf(buf,"%s : You can't carry that much weight.\n\r", 
              fname(temp1->name));
      send_to_char(buf, ch);
      return;
    }
  
  act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM);
  
  sprintf(buf, shop_index[shop_nr].message_buy,
          GET_NAME(ch), (int) (num * (temp1->obj_flags.cost*
          shop_index[shop_nr].profit_buy -
          ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + 
          (mult * temp1->obj_flags.cost))));
  
  do_tell(keeper,buf,19);
  
  sprintf(buf,"You now have %s (*%d).\n\r",
          temp1->short_description,num);
  
  send_to_char(buf,ch);
  
  while (num-- > 0) {
    
    if (GetMaxLevel(ch)<DEMIGOD)
      GET_GOLD(ch) -= (int)(temp1->obj_flags.cost*
      shop_index[shop_nr].profit_buy -
      ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100)+
      (mult * temp1->obj_flags.cost));
    
      GET_GOLD(keeper) += (int)(temp1->obj_flags.cost*
                shop_index[shop_nr].profit_buy -
                ((chr_apply[(int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+
                (mult * temp1->obj_flags.cost));
    
    /* Test if producing shop ! */
    if (shop_producing(temp1,shop_nr))
      temp1 = read_object(temp1->item_number, REAL);
    else {
      obj_from_char(temp1);
      if (temp1 == NULL) {
        send_to_char("Sorry, I just ran out of those.\n\r",ch);
        GET_GOLD(ch) += (int)(temp1->obj_flags.cost*
                shop_index[shop_nr].profit_buy -
                ((chr_apply[ (int)GET_CHR(ch) ].reaction * 
                temp1->obj_flags.cost)/100)+
                (mult * temp1->obj_flags.cost));
        return;
      }
    }
    
    obj_to_char(temp1,ch);
    
  }
  return; 
}
Exemplo n.º 19
0
/* toss $n $dice $table for $face */
void
char__do_toss (CHAR_DATA * ch, char *argument, int cmd)
{
    register short int nArg = 0;
    register short int nDiceArg = 0;
    register short int nTableArg = 0;
    register short int nFaceArg = 0;
    register short int nFacet = 0;
    register short int nMaxFacet = 0;
    size_t nIndex = 0;
    register int nCount = 0;

    char *p = NULL;
    char buf[AVG_STRING_LENGTH * 10] = "";
    char arg[5][AVG_STRING_LENGTH / 5] = { "", "", "", "", "" };
    char key[AVG_STRING_LENGTH] = "";
    char strFacet[AVG_STRING_LENGTH] = "";
    char strFacetList[AVG_STRING_LENGTH] = "";
    OBJ_DATA *dice = NULL;
    OBJ_DATA *table = NULL;

    nArg =
        sscanf (argument, "%s %s %s %s %s", arg[0], arg[1], arg[2], arg[3],
                arg[4]);

    if (nArg <= 0)
    {
        send_to_char ("Toss what?\n", ch);
        return;
    }

    nCount = strtol (arg[0], &p, 10);
    if (errno == ERANGE || nCount == 0 || strlen (p) != 0)
    {
        nCount = 0;
    }
    else
    {
        nDiceArg = 1;
    }

    switch (nArg - nDiceArg)
    {
    case 3:
        nFaceArg = (strcmp ("for", arg[nDiceArg + 1]) == 0) ? nDiceArg + 2 : -1;
        break;
    case 4:
        nFaceArg = (strcmp ("for", arg[nDiceArg + 2]) == 0) ? nDiceArg + 3 : -1;	/* NO BREAK HERE goes to next case */
    case 2:
        nTableArg = nDiceArg + 1;
        break;
    default:
        break;
    }

    if (nFaceArg < 0)
    {
        send_to_char ("Toss them how?\n", ch);
        return;
    }

    if (!(dice = get_obj_in_dark (ch, arg[nDiceArg], ch->right_hand)) &&
            !(dice = get_obj_in_dark (ch, arg[nDiceArg], ch->left_hand)))
    {
        sprintf (buf, "You don't have a '%s'.\n", arg[nDiceArg]);
        send_to_char (buf, ch);
        return;
    }
    if (dice->obj_flags.type_flag != ITEM_TOSSABLE
            && dice->obj_flags.type_flag != ITEM_MONEY)
    {
        send_to_char ("Did you mean to #6throw#0 that object?\n", ch);
        return;
    }

    if (dice->count > 12 && (nCount == 0 || nCount > 12))
    {
        send_to_char ("You can't toss that many at once.\n", ch);
        return;
    }

    if (nTableArg && arg[nTableArg][0] &&
            (!(table = get_obj_in_list_vis (ch, arg[nTableArg], ch->room->contents))
             || !IS_TABLE(table)))
    {
        sprintf (buf, "You don't see any furniture like '%s'.\n",
                 arg[nTableArg]);
        send_to_char (buf, ch);
        return;
    }

    obj_from_char (&dice, nCount);

    if (dice->obj_flags.type_flag == ITEM_MONEY)
    {
        strcpy (key, " obverse reverse ");
        nMaxFacet = 2;
    }
    else if (dice->desc_keys)
    {
        sprintf (key, " %s ", dice->desc_keys);
    }
    else
    {
        strcpy (key,
                " one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty ");
    }

    if (nFaceArg && dice->o.od.value[1])
    {
        /*
           nFacet = strtol(arg[nFaceArg],&p,10);
           if ( errno == ERANGE || nFacet == 0 || strlen(p) != 0 ) {
           strcpy(strFacet,strstr(key,arg[nFaceArg]));
           if () {
           }
           else {
           nFacet = 0;
           }
           }
           else {
           }
         */

    }
    nMaxFacet = (nMaxFacet) ? nMaxFacet : dice->o.od.value[0];
    for (nCount = 0; nCount < dice->count; nCount++)
    {

        nFacet = number (1, nMaxFacet);

        for (nIndex = 0; nIndex < strlen (key); nIndex++)
        {
            if (key[nIndex] == ' ' && --nFacet <= 0)
                break;
        }

        sscanf (key + nIndex + 1, "%s %s", strFacet, buf);
        sprintf (strFacetList + strlen (strFacetList), "#6%s%s#0%s",
                 (nMaxFacet == 2) ? "the " : "a ", strFacet,
                 (nCount ==
                  dice->count - 2) ? " and " : ((nCount !=
                                                dice->count - 1) ? ", " : ""));
    }

    sprintf (buf, "You toss $p onto %s%s%s%s. The upright face%s show%s: %s.\n",
             (nTableArg) ? "$P" : "the ground",
             (nFaceArg) ? ", trying for #6a " : "",
             (nFaceArg) ? arg[nFaceArg] : "", (nFaceArg) ? "#0" : "",
             (nCount > 1) ? "s" : "", (nCount > 1) ? "" : "s", strFacetList);
    act (buf, true, ch, dice, table, TO_CHAR | _ACT_FORMAT);

    sprintf (buf, "$n tosses $p onto %s. The upright face%s show%s: %s.\n",
             (nTableArg) ? "$P" : "the ground", (nCount > 1) ? "s" : "",
             (nCount > 1) ? "" : "s", strFacetList);
    act (buf, true, ch, dice, table, TO_ROOM | _ACT_FORMAT);

    if (nTableArg)
    {
        obj_to_obj (dice, table);
    }
    else
    {
        obj_to_room (dice, ch->in_room);
    }
}
Exemplo n.º 20
0
void do_drink(struct char_data *ch, char *argument, int cmd)
{
	char buf[100];
	struct obj_data *temp;
	struct affected_type af;
	int amount,i;


	one_argument(argument,buf);

	if(!(temp = get_obj_in_list_vis(ch,buf,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if (temp->obj_flags.type_flag!=ITEM_DRINKCON)
	{
		act("You can't drink from that!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if((GET_COND(ch,DRUNK)>10)&&(GET_COND(ch,THIRST)>0)) /* The pig is drunk */
	{
		act("You simply fail to reach your mouth!", FALSE, ch, 0, 0, TO_CHAR);
		act("$n tried to drink but missed $s mouth!", TRUE, ch, 0, 0, TO_ROOM);
		return;
	}

	if((GET_COND(ch,FULL)>20)&&(GET_COND(ch,THIRST)>0)) /* Stomach full */
	{
		act("Your stomach can't contain anymore!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

  if (temp->obj_flags.type_flag==ITEM_DRINKCON){
		if(temp->obj_flags.value[1]>0)  /* Not empty */
		{	
			sprintf(buf,"$n drinks %s from $p",drinks[temp->obj_flags.value[2]]);
			act(buf, TRUE, ch, temp, 0, TO_ROOM);
			sprintf(buf,"You drink the %s.\n\r",drinks[temp->obj_flags.value[2]]);
			send_to_char(buf,ch);

			if (drink_aff[temp->obj_flags.value[2]][DRUNK] > 0 )
				amount = (25-GET_COND(ch,THIRST))/drink_aff[temp->obj_flags.value[2]][DRUNK];
			else
		  	amount = number(3,10);

			amount = MIN(amount,temp->obj_flags.value[1]);

			weight_change_object(temp, -amount);  /* Subtract amount */

			gain_condition(ch,DRUNK,(int)((int)drink_aff
				[temp->obj_flags.value[2]][DRUNK]*amount)/4);

			gain_condition(ch,FULL,(int)((int)drink_aff
				[temp->obj_flags.value[2]][FULL]*amount)/4);

			gain_condition(ch,THIRST,(int)((int)drink_aff
				[temp->obj_flags.value[2]][THIRST]*amount)/4);

			if(GET_COND(ch,DRUNK)>10)
				act("You feel drunk.",FALSE,ch,0,0,TO_CHAR);

			if(GET_COND(ch,THIRST)>20)
				act("You do not feel thirsty.",FALSE,ch,0,0,TO_CHAR);

			if(GET_COND(ch,FULL)>20)
				act("You are full.",FALSE,ch,0,0,TO_CHAR);

			if(temp->obj_flags.value[3]) /* The shit was poisoned ! */
			{
				act("Ooups, it tasted rather strange ?!!?",FALSE,ch,0,0,TO_CHAR);
				act("$n chokes and utters some strange sounds.",
				   TRUE,ch,0,0,TO_ROOM);
				af.type = SPELL_POISON;
				af.duration = amount*3;
				af.modifier = 0;
				af.location = APPLY_NONE;
				af.bitvector = AFF_POISON;
				affect_join(ch,&af, FALSE, FALSE);
			}

			/* empty the container, and no longer poison. */
			temp->obj_flags.value[1]-= amount;
			if(!temp->obj_flags.value[1]) {  /* The last bit */
				temp->obj_flags.value[2]=0;
				temp->obj_flags.value[3]=0;
				name_from_drinkcon(temp);
			}
			return;

		}
	}

	act("It's empty already.",FALSE,ch,0,0,TO_CHAR);
	
	return;
}
Exemplo n.º 21
0
void do_sip(struct char_data *ch, char *argument, int cmd)
{
	struct affected_type af;
	char arg[MAX_STRING_LENGTH];
	char buf[MAX_STRING_LENGTH];
	struct obj_data *temp;

	one_argument(argument,arg);

	if(!(temp = get_obj_in_list_vis(ch,arg,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(temp->obj_flags.type_flag!=ITEM_DRINKCON)
	{
		act("You can't sip from that!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(GET_COND(ch,DRUNK)>10) /* The pig is drunk ! */
	{
		act("You simply fail to reach your mouth!",FALSE,ch,0,0,TO_CHAR);
		act("$n tries to sip, but fails!",TRUE,ch,0,0,TO_ROOM);
		return;
	}

	if(!temp->obj_flags.value[1])  /* Empty */
	{
		act("But there is nothing in it?",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	act("$n sips from the $o",TRUE,ch,temp,0,TO_ROOM);
	sprintf(buf,"It tastes like %s.\n\r",drinks[temp->obj_flags.value[2]]);
	send_to_char(buf,ch);

	gain_condition(ch,DRUNK,(int)(drink_aff[temp->obj_flags.value[2]][DRUNK]/4));

	gain_condition(ch,FULL,(int)(drink_aff[temp->obj_flags.value[2]][FULL]/4));

	gain_condition(ch,THIRST,(int)(drink_aff[temp->obj_flags.value[2]][THIRST]/4));

	weight_change_object(temp, -1);  /* Subtract one unit */

	if(GET_COND(ch,DRUNK)>10)
		act("You feel drunk.",FALSE,ch,0,0,TO_CHAR);

	if(GET_COND(ch,THIRST)>20)
		act("You do not feel thirsty.",FALSE,ch,0,0,TO_CHAR);

	if(GET_COND(ch,FULL)>20)
		act("You are full.",FALSE,ch,0,0,TO_CHAR);

	if(temp->obj_flags.value[3]&&!IS_AFFECTED(ch,AFF_POISON)) /* The shit was poisoned ! */
	{
		act("But it also had a strange taste!",FALSE,ch,0,0,TO_CHAR);

		af.type = SPELL_POISON;
		af.duration = 3;
		af.modifier = 0;
		af.location = APPLY_NONE;
		af.bitvector = AFF_POISON;
		affect_to_char(ch,&af);
	}

	temp->obj_flags.value[1]--;

	if(!temp->obj_flags.value[1])  /* The last bit */
	{
		temp->obj_flags.value[2]=0;
		temp->obj_flags.value[3]=0;
		name_from_drinkcon(temp);
	}

	return;

}
Exemplo n.º 22
0
int generic_find(char *arg, int bitvector, struct char_data *ch,
		 struct char_data **tar_ch, struct obj_data **tar_obj)
{
  static char *ignore[] = {
    "the",
    "in",
    "on",
    "at",
    "\n" };
  
  int i;
  char name[256];
  bool found;
  
  found = FALSE;
  
  
  /* Eliminate spaces and "ignore" words */
  while (*arg && !found) {
    
    for(; *arg == ' '; arg++)   ;
    
    for(i=0; (name[i] = *(arg+i)) && (name[i]!=' '); i++)   ;
    name[i] = 0;
    arg+=i;
    if (search_block(name, ignore, TRUE) > -1)
      found = TRUE;
    
  }
  
  if (!name[0])
    return(0);
  
  *tar_ch  = 0;
  *tar_obj = 0;
  
  if (IS_SET(bitvector, FIND_CHAR_ROOM)) {      /* Find person in room */
    if (*tar_ch = get_char_room_vis(ch, name)) {
      return(FIND_CHAR_ROOM);
    }
  }
  
  if (IS_SET(bitvector, FIND_CHAR_WORLD)) {
    if (*tar_ch = get_char_vis(ch, name)) {
      return(FIND_CHAR_WORLD);
    }
  }
  
  if (IS_SET(bitvector, FIND_OBJ_EQUIP)) {
    for(found=FALSE, i=0; i<MAX_WEAR && !found; i++)
      if (ch->equipment[i] && str_cmp(name, ch->equipment[i]->name) == 0) {
	*tar_obj = ch->equipment[i];
	found = TRUE;
      }
    if (found) {
      return(FIND_OBJ_EQUIP);
    }
  }
  
  if (IS_SET(bitvector, FIND_OBJ_INV)) {
    if (IS_SET(bitvector, FIND_OBJ_ROOM)) {
      if (*tar_obj = get_obj_vis_accessible(ch, name)) {
	return(FIND_OBJ_INV);
      }
    } else {
      if (*tar_obj = get_obj_in_list_vis(ch, name, ch->carrying)) {
	return(FIND_OBJ_INV);
      }
    }
  }
  
  if (IS_SET(bitvector, FIND_OBJ_ROOM)) {
    if (*tar_obj = get_obj_in_list_vis(ch, name, real_roomp(ch->in_room)->contents)) {
      return(FIND_OBJ_ROOM);
    }
  }
  
  if (IS_SET(bitvector, FIND_OBJ_WORLD)) {
    if (*tar_obj = get_obj_vis(ch, name)) {
      return(FIND_OBJ_WORLD);
    }
  }
  
  return(0);
}
Exemplo n.º 23
0
void do_pour(struct char_data *ch, char *argument, int cmd)
{
	char arg1[MAX_STRING_LENGTH];
	char arg2[MAX_STRING_LENGTH];
	char buf[MAX_STRING_LENGTH];
	struct obj_data *from_obj;
	struct obj_data *to_obj;
	int amount;

	argument_interpreter(argument, arg1, arg2);

	if(!*arg1) /* No arguments */
	{
		act("What do you want to pour from?",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(!(from_obj = get_obj_in_list_vis(ch,arg1,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(from_obj->obj_flags.type_flag!=ITEM_DRINKCON)
	{
		act("You can't pour from that!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(from_obj->obj_flags.value[1]==0)
	{
		act("The $p is empty.",FALSE, ch,from_obj, 0,TO_CHAR);
		return;
	}

	if(!*arg2)
	{
		act("Where do you want it? Out or in what?",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(!str_cmp(arg2,"out"))
	{
		act("$n empties $p", TRUE, ch,from_obj,0,TO_ROOM);
		act("You empty the $p.", FALSE, ch,from_obj,0,TO_CHAR);

		weight_change_object(from_obj, -from_obj->obj_flags.value[1]); /* Empty */

		from_obj->obj_flags.value[1]=0;
		from_obj->obj_flags.value[2]=0;
		from_obj->obj_flags.value[3]=0;
		name_from_drinkcon(from_obj);
		
		return;

	}

	if(!(to_obj = get_obj_in_list_vis(ch,arg2,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(to_obj->obj_flags.type_flag!=ITEM_DRINKCON)
	{
		act("You can't pour anything into that.",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if((to_obj->obj_flags.value[1]!=0)&&
		(to_obj->obj_flags.value[2]!=from_obj->obj_flags.value[2]))
	{
		act("There is already another liquid in it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(!(to_obj->obj_flags.value[1]<to_obj->obj_flags.value[0]))
	{
		act("There is no room for more.",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	sprintf(buf,"You pour the %s into the %s.",
		drinks[from_obj->obj_flags.value[2]],arg2);
	send_to_char(buf,ch);

	/* New alias */
	if (to_obj->obj_flags.value[1]==0) 
		name_to_drinkcon(to_obj,from_obj->obj_flags.value[2]);

	/* First same type liq. */
	to_obj->obj_flags.value[2]=from_obj->obj_flags.value[2];

	/* Then how much to pour */
	/* if to_obj can contail it all give it all */
	amount = to_obj->obj_flags.value[0]-to_obj->obj_flags.value[1];
	if (amount > from_obj->obj_flags.value[1])
		amount = from_obj->obj_flags.value[1];

	/* take away from from_obj */
	from_obj->obj_flags.value[1]-=amount;
	weight_change_object(from_obj, -amount);

	/* give it to to_obj */
	to_obj->obj_flags.value[1]+=amount;
	weight_change_object(to_obj, amount);

	/* Then the poison boogie */
	to_obj->obj_flags.value[3]=
		(to_obj->obj_flags.value[3]||from_obj->obj_flags.value[3]);

	if(from_obj->obj_flags.value[1]=0)    /* from_obj is empty */
	{
		from_obj->obj_flags.value[1]=0;
		from_obj->obj_flags.value[2]=0;
		from_obj->obj_flags.value[3]=0;
		name_from_drinkcon(from_obj);
	}

	return;
}
Exemplo n.º 24
0
void shopping_buy( char *arg, struct char_data *ch,
	 struct char_data *keeper, int shop_nr)
{
	char argm[100], buf[MAX_STRING_LENGTH];
	struct obj_data *temp1;
	struct char_data *temp_char;

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

	one_argument(arg, argm);
	if(!(*argm))
	{
		sprintf(buf,
		"%s what do you want to buy??"
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	};
	if(!( temp1 = 
		get_obj_in_list_vis(ch,argm,keeper->carrying)))
	{
		sprintf(buf,
		shop_index[shop_nr].no_such_item1
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(temp1->obj_flags.cost <= 0)
	{
		sprintf(buf,
		shop_index[shop_nr].no_such_item1
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		extract_obj(temp1);
		return;
	}

	if(GET_GOLD(ch) < (int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_buy) && GET_LEVEL(ch)<22)
	{
		sprintf(buf,
		shop_index[shop_nr].missing_cash2,
		GET_NAME(ch));
		do_tell(keeper,buf,19);

		switch(shop_index[shop_nr].temper1)
		{
			case 0:
				do_action(keeper,GET_NAME(ch),30);
				return;
			case 1:
				do_emote(keeper,"smokes on his joint",36);
				return;
			default:
				return;
		}
	}
	
	if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch)))
	{
		sprintf(buf,"%s : You can't carry that many items.\n\r", 
			fname(temp1->name));
		send_to_char(buf, ch);
		return;
	}

	if ((IS_CARRYING_W(ch) + temp1->obj_flags.weight) > CAN_CARRY_W(ch))
	{
		sprintf(buf,"%s : You can't carry that much weight.\n\r", 
			fname(temp1->name));
		send_to_char(buf, ch);
		return;
	}


	act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM);

	sprintf(buf,
		shop_index[shop_nr].message_buy,
		GET_NAME(ch),
		(int) (temp1->obj_flags.cost*
			shop_index[shop_nr].profit_buy));
	do_tell(keeper,buf,19);
	sprintf(buf,"You now have %s.\n\r",
		temp1->short_description);
	send_to_char(buf,ch);
   if(GET_LEVEL(ch)<22)
		GET_GOLD(ch) -= (int)(temp1->obj_flags.cost*
			shop_index[shop_nr].profit_buy);

   GET_GOLD(keeper) += (int)(temp1->obj_flags.cost*
      shop_index[shop_nr].profit_buy);

	/* Test if producing shop ! */
	if(shop_producing(temp1,shop_nr))
		temp1 = read_object(temp1->item_number, REAL);
	else
		obj_from_char(temp1);

	obj_to_char(temp1,ch);

	return; 
}
Exemplo n.º 25
0
void sub_write(char *arg, char_data *ch, byte find_invis, int targets)
{
    char str[MAX_INPUT_LENGTH * 2];
    char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
    char *tokens[MAX_INPUT_LENGTH], *s, *p;
    void *otokens[MAX_INPUT_LENGTH];
    char_data *to;
    obj_data *obj;
    int i, tmp;
    int to_sleeping = 1; /* mainly for windows compiles */

    if (!arg)
	return;
    
    tokens[0] = str;
    
    for (i = 0, p = arg, s = str; *p;)
    {
	switch (*p) {
	case '~':
	case '@':
	case '^':
	case '&':
	case '*':
	    /* get char_data, move to next token */
	    type[i] = *p;
	    *s = '\0';
	    p = any_one_name(++p, name);
	    /* 20-10-15 changed the following line due to compiler error 
	    (char_data *)otokens[i] = */
	    otokens[i] =
		find_invis ? get_char(name) : get_char_room_vis(ch, name);
	    tokens[++i] = ++s;
	    break;
	    
	case '`':
	    /* get obj_data, move to next token */
	    type[i] = *p;
	    *s = '\0';
	    p = any_one_name(++p, name);
	    /* 20-10-2015 updated following line due to compiler errors 
	    (obj_data *)otokens[i] =  */
	    otokens[i] = (void*)
		find_invis ? (obj = get_obj(name)) :
		    ((obj = get_obj_in_list_vis(ch, name,
				world[IN_ROOM(ch)].contents)) ? obj :
		     (obj = get_object_in_equip_vis(ch, name,
						    ch->equipment, &tmp)) ?
		     obj :
		     (obj = get_obj_in_list_vis(ch, name, ch->carrying)));
	    /* 20-10-15 Updated the following line due to comp error
	    (obj_data *)otokens[i] = obj; */
	    otokens[i] = (void*) obj;
	    tokens[++i] = ++s;
	    break;

	case '\\':
	    p++;
	    *s++ = *p++;
	    break;
	    
	default:
	    *s++ = *p++;
	}
    }

    *s = '\0';
    tokens[++i] = NULL;

    if (IS_SET(targets, TO_CHAR) && SENDOK(ch))
	sub_write_to_char(ch, tokens, otokens, type);

    if (IS_SET(targets, TO_ROOM))
	for (to = world[IN_ROOM(ch)].people;
	     to; to = to->next_in_room)
	    if (to != ch && SENDOK(to))
		sub_write_to_char(to, tokens, otokens, type);
}
Exemplo n.º 26
0
/* Execute a social command.                                        */
void exec_social(struct char_data *npc, char *cmd, int next_line,
                 int *cur_line, void **thing)
{
  bool ok;

  void do_move(struct char_data *ch, char *argument, int cmd);
  void do_open(struct char_data *ch, char *argument, int cmd);
  void do_lock(struct char_data *ch, char *argument, int cmd);
  void do_unlock(struct char_data *ch, char *argument, int cmd);
  void do_close(struct char_data *ch, char *argument, int cmd);

  if (GET_POS(npc) == POSITION_FIGHTING)
    return;

  ok = TRUE;

  switch (*cmd) {

    case 'G' :
      *cur_line = next_line;
      return;

    case 'g' :
      *cur_line += next_line;
      return;

    case 'e' :
      act(cmd+1, FALSE, npc, *thing, *thing, TO_ROOM);
      break;

    case 'E' :
      act(cmd+1, FALSE, npc, 0, *thing, TO_VICT);
      break;

    case 'B' :
      act(cmd+1, FALSE, npc, 0, *thing, TO_NOTVICT);
      break;

    case 'm' :
      do_move(npc, "", *(cmd+1)-'0'+1);
      break;

    case 'w' :
      if (GET_POS(npc) != POSITION_SLEEPING)
        ok = FALSE;
      else
        GET_POS(npc) = POSITION_STANDING;
      break;

    case 's' :
      if (GET_POS(npc) <= POSITION_SLEEPING)
        ok = FALSE;
      else
        GET_POS(npc) = POSITION_SLEEPING;
      break;

    case 'c' :  /* Find char in room */
      *thing = get_char_room_vis(npc, cmd+1);
      ok = (*thing != 0);
      break;

    case 'o' : /* Find object in room */
      *thing = get_obj_in_list_vis(npc, cmd+1, world[npc->in_room].contents);
      ok = (*thing != 0);
      break;

    case 'r' : /* Test if in a certain room */
      ok = (npc->in_room == atoi(cmd+1));
      break;

    case 'O' : /* Open something */
      do_open(npc, cmd+1, 0);
      break;

    case 'C' : /* Close something */
      do_close(npc, cmd+1, 0);
      break;

    case 'L' : /* Lock something  */
      do_lock(npc, cmd+1, 0);
      break;

    case 'U' : /* UnLock something  */
      do_unlock(npc, cmd+1, 0);
      break;

    case '?' : /* Test a random number */
      if (atoi(cmd+1) <= number(1,100))
        ok = FALSE;
      break;

    default:
      break;
  }  /* End Switch */

  if (ok)
    (*cur_line)++;
  else
    (*cur_line) += next_line;
}
Exemplo n.º 27
0
void sub_write(char *arg, char_data *ch, byte find_invis, int targets) {
	char str[MAX_INPUT_LENGTH * 2];
	char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
	char *tokens[MAX_INPUT_LENGTH], *s, *p;
	void *otokens[MAX_INPUT_LENGTH];
	char_data *to;
	obj_data *obj;
	int i;
	int to_sleeping = 1, is_spammy = 0; /* mainly for windows compiles */

	if (!arg)
		return;

	tokens[0] = str;

	for (i = 0, p = arg, s = str; *p;) {
		switch (*p) {
			case '~':
			case '|':
			case '^':
			// case '&':	// removed this because it conflicts with color codes
			case '*': {
				/* get char_data, move to next token */
				type[i] = *p;
				*s = '\0';
				p = any_one_name(++p, name);
				otokens[i] = find_invis ? get_char_in_room(IN_ROOM(ch), name) : get_char_room_vis(ch, name);
				tokens[++i] = ++s;
				break;
			}

			case '@': {
				/* get obj_data, move to next token */
				type[i] = *p;
				*s = '\0';
				p = any_one_name(++p, name);

				if (find_invis)
					obj = get_obj_in_room(IN_ROOM(ch), name);
				else if (!(obj = get_obj_in_list_vis(ch, name, ROOM_CONTENTS(IN_ROOM(ch))))) {
					// nothing
				}
				else if (!(obj = get_obj_in_equip_vis(ch, name, ch->equipment))) {
					// nothing
				}
				else {
					obj = get_obj_in_list_vis(ch, name, ch->carrying);
				}

				otokens[i] = obj;
				tokens[++i] = ++s;
				break;
			}

			case '\\': {
				p++;
				*s++ = *p++;
				break;
			}

			default: {
				*s++ = *p++;
			}
		}
	}

	*s = '\0';
	tokens[++i] = NULL;

	if (IS_SET(targets, TO_CHAR) && SENDOK(ch) && (AWAKE(ch) || IS_SET(targets, TO_SLEEP)))
		sub_write_to_char(ch, tokens, otokens, type);

	if (IS_SET(targets, TO_ROOM)) {
		for (to = ROOM_PEOPLE(IN_ROOM(ch)); to; to = to->next_in_room) {
			if (to != ch && SENDOK(to) && (AWAKE(to) || IS_SET(targets, TO_SLEEP))) {
				sub_write_to_char(to, tokens, otokens, type);
			}
		}
	}
}
Exemplo n.º 28
0
void sub_write(char *arg, char_data *ch, byte find_invis, int targets)
{
    char str[MAX_INPUT_LENGTH * 2];
    char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
    char *tokens[MAX_INPUT_LENGTH], *s, *p;
    void *otokens[MAX_INPUT_LENGTH];
    char_data *to;
    obj_data *obj;
    int i, tmp;
    int sleep = 1, deaf = 0;

    if (!arg)
	return;
    
    tokens[0] = str;
    
    for (i = 0, p = arg, s = str; *p;)
    {
	switch (*p) {
	case '~':
	case '@':
	case '^':
	case '&':
	case '*':
	    /* get char_data, move to next token */
	    type[i] = *p;
	    *s = '\0';
	    p = any_one_name(++p, name);

        // See comment below.
	    //(char_data *)otokens[i] = find_invis ? get_char(name) : get_char_vis(ch, name, FIND_CHAR_ROOM);

        // I'm not sure why "otokens[i]" was cast to a char_data type.
        // Doing so caused GCC to complain, so I removed it.
        // Bran - '11
	    otokens[i] = find_invis ? get_char(name) : get_char_vis(ch, name, FIND_CHAR_ROOM);
	    tokens[++i] = ++s;
	    break;
	    
	case '`':
	    /* get obj_data, move to next token */
	    type[i] = *p;
	    *s = '\0';
	    p = any_one_name(++p, name);
        //(obj_data *)otokens[i] = find_invis ? (obj = get_obj(name)) : 
        otokens[i] = find_invis ? (obj = get_obj(name)) : 
        ((obj = get_obj_in_list_vis(ch, name, world[IN_ROOM(ch)].contents)) ? obj : 
        (obj = get_object_in_equip_vis(ch, name, ch->equipment, &tmp)) ? obj : 
        (obj = get_obj_in_list_vis(ch, name, ch->carrying)));

        //if (find_invis) obj = get_obj_in_room(&world[IN_ROOM(ch)], name);
        //else if (!(obj = get_obj_in_list_vis(ch, name, world[IN_ROOM(ch)].contents))) ;
        //else if (!(obj = get_object_in_equip_vis(ch, name, &tmp, ch->equipment)));
        //else obj = get_obj_in_list_vis(ch, name, ch->carrying);

	    //(obj_data *)otokens[i] = obj;

        // Once again I'm not sure why this was cast.
        // See comment above.
	    otokens[i] = obj;
	    tokens[++i] = ++s;
	    break;

	case '\\':
	    p++;
	    *s++ = *p++;
	    break;
	    
	default:
	    *s++ = *p++;
	}
    }

    *s = '\0';
    tokens[++i] = NULL;

    if (IS_SET(targets, TO_CHAR) && SENDOK(ch))
	sub_write_to_char(ch, tokens, otokens, type);

    if (IS_SET(targets, TO_ROOM))
	for (to = world[ch->in_room].people;
	     to; to = to->next_in_room)
	    if (to != ch && SENDOK(to))
		sub_write_to_char(to, tokens, otokens, type);
}
Exemplo n.º 29
0
int worm_ritual(struct char_data *ch, int cmd, char *arg)
{
	struct obj_data *scroll, *herbs, *blood;
	struct char_data *tmpch;
	char buf[MAX_INPUT_LENGTH];
	bool found, equipped = FALSE;
	int room;
	static int scroll_nr = -1, herbs_nr = -1, blood_nr = -1, to_room = -1;

	if (scroll_nr < 1) {
		scroll_nr = real_object(5012);
		herbs_nr = real_object(5002);
		blood_nr = real_object(5003);
		to_room = real_room(5040);
	}

	if (cmd != 207)
		return FALSE;

   arg = one_argument(arg,buf);

	if (!(scroll = get_obj_in_list_vis(ch,buf,ch->carrying))) {
		scroll = ch->equipment[HOLD];
		equipped = TRUE;
	}

   /* which scroll */
	found = (scroll && (scroll->item_number == scroll_nr));

	if (!found)
		return FALSE;

	act("$n recites $p.", TRUE, ch, scroll, 0, TO_ROOM);
	act("You recite $p which dissolves.",FALSE,ch,scroll,0,TO_CHAR);

	room = ch->in_room;
	blood = get_obj_in_list_num(blood_nr,world[room].contents);
	herbs = get_obj_in_list_num(herbs_nr,world[room].contents);

	if (!blood || !herbs || (blood->obj_flags.value[1] < 2))
		return TRUE;

   act("$p dissolves into thin air.", TRUE, ch, herbs, 0, TO_ROOM);
	act("$p dissolves into thin air.", TRUE, ch, herbs, 0, TO_CHAR);
	act("$p is emptied from blood.", FALSE, ch, blood, 0, TO_ROOM);
	act("$p is emptied from blood.", FALSE, ch, blood, 0, TO_CHAR);

	obj_from_room(herbs);
	extract_obj(herbs);            /* herbs dissapear */
	blood->obj_flags.value[1] = 0; /* empty for blood */
	blood->obj_flags.weight -= 2;  /* correct weight  */

   if (equipped)
      unequip_char(ch, HOLD);

   extract_obj(scroll);

   act("You feel yanked downwards.....", FALSE, ch, 0, 0, TO_ROOM);
	act("You feel yanked downwards.....", FALSE, ch, 0, 0, TO_CHAR);

	/* Move'em */
	tmpch = world[room].people;
	while (world[room].people){
		char_from_room(tmpch);
		char_to_room(tmpch,to_room);
		tmpch = world[room].people;
	}
	return TRUE;
}