示例#1
0
/*
 *  mag_materials:
 *  Checks for up to 3 vnums (spell reagents) in the player's inventory.
 *
 * No spells implemented in Circle 3.0 use mag_materials, but you can use
 * it to implement your own spells which require ingredients (i.e., some
 * heal spell which requires a rare herb or some such.)
 */
int mag_materials(struct char_data * ch, int item0, int item1, int item2, int extract, int verbose)
{
  struct obj_data *tobj = NULL;
  struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;

  for (tobj = ch->carrying; tobj; tobj = tobj->next) {
    if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) {
      obj0 = tobj;
      item0 = -1;
    } else if ((item1 > 0) && (GET_OBJ_VNUM(tobj) == item1)) {
      obj1 = tobj;
      item1 = -1;
    } else if ((item2 > 0) && (GET_OBJ_VNUM(tobj) == item2)) {
      obj2 = tobj;
      item2 = -1;
    }
  }
  if ((item0 > 0) || (item1 > 0) || (item2 > 0)) {
    if (verbose) {
      switch (number(0, 2)) {
        case 0:
          send_to_char("A wart sprouts on your nose.\r\n", ch);
          break;
        case 1:
          send_to_char("Your hair falls out in clumps.\r\n", ch);
          break;
        case 2:
          send_to_char("A huge corn develops on your big toe.\r\n", ch);
          break;
      }
    }
    return (FALSE);
  }
  if (extract) {
    if (item0 < 0) {
      obj_from_char(obj0);
      extract_obj(obj0);
    }
    if (item1 < 0) {
      obj_from_char(obj1);
      extract_obj(obj1);
    }
    if (item2 < 0) {
      obj_from_char(obj2);
      extract_obj(obj2);
    }
  }
  if (verbose) {
    send_to_char("A puff of smoke rises from your pack.\r\n", ch);
    act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM);
  }
  return (TRUE);
}
示例#2
0
文件: handler.c 项目: Calebros/aol
/* Extract an object from the world */
void extract_obj(struct obj_data * obj)
{
  struct obj_data *temp;

  if (obj->worn_by != NULL)
    if (unequip_char(obj->worn_by, obj->worn_on) != obj)
      log("SYSERR: Inconsistent worn_by and worn_on pointers!!");
  if (obj->in_room != NOWHERE)
    obj_from_room(obj);
  else if (obj->carried_by)
    obj_from_char(obj);
  else if (obj->in_obj)
    obj_from_obj(obj);

  /* Get rid of the contents of the object, as well. */
  while (obj->contains)
    extract_obj(obj->contains);

  REMOVE_FROM_LIST(obj, object_list, next);

  if (GET_OBJ_RNUM(obj) >= 0)
    (obj_index[GET_OBJ_RNUM(obj)].number)--;

  if (SCRIPT(obj))
    extract_script(SCRIPT(obj));

  free_obj(obj);
}
示例#3
0
/*
 * Disarm a creature.
 * Caller must check for successful attack.
 */
void disarm( CHAR_DATA *ch, CHAR_DATA *victim )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
	return;

    if ( IS_OBJ_STAT(obj,ITEM_NOREMOVE))
    {
	act("$S weapon won't budge!",ch,NULL,victim,TO_CHAR, 1);
	act("$n tries to disarm you, but your weapon won't budge!",
	    ch,NULL,victim,TO_VICT, 0);
	act("$n tries to disarm $N, but fails.",ch,NULL,victim,TO_NOTVICT, 0);
	return;
    }

    act( "$n DISARMS you and sends your weapon flying!",
	 ch, NULL, victim, TO_VICT, 1 );
    act( "You disarm $N!",  ch, NULL, victim, TO_CHAR, 1 );
    act( "$n disarms $N!",  ch, NULL, victim, TO_NOTVICT, 0 );

    obj_from_char( obj );
    if ( IS_OBJ_STAT(obj,ITEM_NODROP) || IS_OBJ_STAT(obj,ITEM_INVENTORY) )
	obj_to_char( obj, victim );
    else
    {
	obj_to_room( obj, victim->in_room );
	if (IS_NPC(victim) && victim->wait == 0 && can_see_obj(victim,obj))
	    get_obj(victim,obj,NULL);
    }

    return;
}
示例#4
0
/*
 * Lets the mobile to strip an object or all objects from the victim.
 * Useful for removing e.g. quest objects from a character.
 *
 * Syntax: mob remove [victim] [object vnum|'all']
 */
void do_mpremove(CHAR_DATA * ch, char *argument)
{
    CHAR_DATA *victim;
    OBJ_DATA *obj, *obj_next;
    sh_int vnum = 0;
    bool fAll = FALSE;
    char arg[MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg);
    if ((victim = get_char_room(ch, arg)) == NULL)
	return;

    one_argument(argument, arg);
    if (!str_cmp(arg, "all"))
	fAll = TRUE;
    else if (!is_number(arg)) {
	bug("MpRemove: Invalid object from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    } else
	vnum = atoi(arg);

    for (obj = victim->carrying; obj; obj = obj_next) {
	obj_next = obj->next_content;
	if (fAll || obj->pIndexData->vnum == vnum) {
	    unequip_char(ch, obj);
	    obj_from_char(obj);
	    extract_obj(obj);
	}
    }
}
示例#5
0
/*
 * Lets the mobile to transfer an object. The object must be in the same
 * room with the mobile.
 *
 * Syntax: mob otransfer [item name] [location]
 */
void do_mpotransfer(CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj;
    ROOM_INDEX_DATA *location;
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg);
    if (arg[0] == '\0') {
	bug("MpOTransfer - Missing argument from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    one_argument(argument, buf);
    if ((location = find_location(ch, buf)) == NULL) {
	bug("MpOTransfer - No such location from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if ((obj = get_obj_here(ch, arg)) == NULL)
	return;
    if (obj->carried_by == NULL)
	obj_from_room(obj);
    else {
	if (obj->wear_loc != WEAR_NONE)
	    unequip_char(ch, obj);
	obj_from_char(obj);
    }
    obj_to_room(obj, location);
}
void take_obj_list(struct char_data *ch,struct obj_data *o,int *amount,struct char_data *give_to)
{
  char buf[MAX_STRING_LENGTH];

  if (*amount<=0 && !o) return;
  if (o->contains)
    take_obj_list(ch,o->contains,amount,give_to);
  else if (o->next_content)
    take_obj_list(ch,o->next_content,amount,give_to);
  else {
    if (o->carried_by)
      obj_from_char(o);
    if (o->in_obj)
      obj_from_obj(o);
    *amount -= o->obj_flags.cost;
    sendf(ch,"Your %s is taken.\n",o->short_description);
    if (give_to)
      sendf(give_to,"You take his %s.\n",o->short_description);
    if (give_to) {
      sprintf(buf,"FINE: %d take from %s",o->virtual,GET_NAME(ch));
      slog(buf);
      obj_to_char(o,give_to);
      o->held_for=mystrdup(GET_NAME(ch));
    } else {
      sprintf(buf,"LINK: %d take from %s",o->virtual,GET_NAME(ch));
      slog(buf);
      extract_obj(o);
    }
  }
示例#7
0
文件: shop.c 项目: rparet/darkpawns
void
sort_keeper_objs(struct char_data * keeper, int shop_nr)
{
  struct obj_data *list = 0, *temp;

  while (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper))
    {
      temp = keeper->carrying;
      obj_from_char(temp);
      temp->next_content = list;
      list = temp;
    }

  while (list)
    {
      temp = list;
      list = list->next_content;
      if ((shop_producing(temp, shop_nr)) &&
      !(get_obj_in_list_num(GET_OBJ_RNUM(temp), keeper->carrying)))
    {
      obj_to_char(temp, keeper);
      SHOP_SORT(shop_nr)++;
    } else
      (void) slide_obj(temp, keeper, shop_nr);
    }
}
示例#8
0
文件: handler.c 项目: Lundessa/raven3
/* Extract an object from the world */
void extract_obj(struct obj_data *obj)
{
  struct char_data *ch, *next = NULL;
  struct obj_data *temp;

  if (obj->worn_by != NULL)
    if (unequip_char(obj->worn_by, obj->worn_on) != obj)
      log("SYSERR: Inconsistent worn_by and worn_on pointers!!");
  if (IN_ROOM(obj) != NOWHERE)
    obj_from_room(obj);
  else if (obj->carried_by)
    obj_from_char(obj);
  else if (obj->in_obj)
    obj_from_obj(obj);

  if (OBJ_SAT_IN_BY(obj)){
    for (ch = OBJ_SAT_IN_BY(obj); OBJ_SAT_IN_BY(obj); ch = next){
      if (!NEXT_SITTING(ch))
        OBJ_SAT_IN_BY(obj) = NULL;
      else
        OBJ_SAT_IN_BY(obj) = (next = NEXT_SITTING(ch));
      SITTING(ch) = NULL;
      NEXT_SITTING(ch) = NULL;
    }
  }

  /* Get rid of the contents of the object, as well. */
  while (obj->contains)
    extract_obj(obj->contains);

  REMOVE_FROM_LIST(obj, object_list, next);

  if (GET_OBJ_RNUM(obj) != NOTHING)
    (obj_index[GET_OBJ_RNUM(obj)].number)--;

  if (SCRIPT(obj))
    extract_script(obj, OBJ_TRIGGER);

  if (obj->events != NULL) {
	  if (obj->events->iSize > 0) {
		struct event * pEvent;

		while ((pEvent = simple_list(obj->events)) != NULL)
		  event_cancel(pEvent);
	  }
	  free_list(obj->events);
    obj->events = NULL;
  }

  if (GET_OBJ_RNUM(obj) == NOTHING || obj->proto_script != obj_proto[GET_OBJ_RNUM(obj)].proto_script)
    free_proto_script(obj, OBJ_TRIGGER);

  free_obj(obj);
}
示例#9
0
文件: handler.c 项目: MUDOmnibus/Rom1
/* Extract an object from the world */
void extract_obj(struct obj_data *obj)
{
    struct obj_data *temp1, *temp2;

    if(obj->in_room != NOWHERE)
	obj_from_room(obj);
    else if(obj->carried_by)
	obj_from_char(obj);
    else if(obj->in_obj)
    {
	temp1 = obj->in_obj;
	if(temp1->contains == obj)   /* head of list */
	    temp1->contains = obj->next_content;
	else
	{
	    for( temp2 = temp1->contains ;
		temp2 && (temp2->next_content != obj);
		temp2 = temp2->next_content );

	    if(temp2) {
		temp2->next_content =
		    obj->next_content; }
	}
    }

    for( ; obj->contains; extract_obj(obj->contains))
	; 
	/* leaves nothing ! */

    if (object_list == obj )       /* head of list */
	object_list = obj->next;
    else
    {
	for(temp1 = object_list; 
	    temp1 && (temp1->next != obj);
	    temp1 = temp1->next)
	    ;
	
	if(temp1)
	    temp1->next = obj->next;
    }

    if(obj->item_number>=0)
	(obj_index[obj->item_number].number)--;
    free_obj(obj);
}
示例#10
0
void weight_change_object(struct obj_data *obj, int weight)
{
	struct obj_data *tmp_obj;
	struct char_data *tmp_ch;

	if (obj->in_room != NOWHERE) {
		GET_OBJ_WEIGHT(obj) += weight;
	} else if (tmp_ch = obj->carried_by) {
		obj_from_char(obj);
		GET_OBJ_WEIGHT(obj) += weight;
		obj_to_char(obj, tmp_ch);
	} else if (tmp_obj = obj->in_obj) {
		obj_from_obj(obj);
		GET_OBJ_WEIGHT(obj) += weight;
		obj_to_obj(obj, tmp_obj);
	} else {
		log("Unknown attempt to subtract weight from an object.");
	}
}
示例#11
0
void MakeScrap(struct char_data *ch, struct obj_data *obj)
{
  char buf[256];
  struct obj_data *t, *x;
  int pos;


  if (!ch || !obj || (ch->in_room == NOWHERE))
    return;

  act("$p falls to the ground in scraps.", TRUE, ch, obj, 0, TO_CHAR);
  act("$p falls to the ground in scraps.", TRUE, ch, obj, 0, TO_ROOM);

  t = read_object(9, VIRTUAL);
  if (!t)
    return;

  sprintf(buf, "Scraps from %s&n lie in a pile",
	  obj->short_description);
  t->description = str_dup(buf);
  t->short_description = str_dup("a pile of scraps");

  if (obj->carried_by) {
    obj_from_char(obj);
  } else if (obj->worn_by) {
    for (pos = 0; pos < NUM_WEARS; pos++)
      if (ch->equipment[pos] == obj)
	break;
    if (pos >= NUM_WEARS) {
      log("SYSERR: MakeScrap(), can't find worn object in equip");
      exit(1);
    }
    obj = unequip_char(ch, pos);
  }
  obj_to_room(t, ch->in_room);
  while (obj->contains) {
    x = obj->contains;
    obj_from_obj(x);
    obj_to_room(x, ch->in_room);
  }
  extract_obj(obj);
}
示例#12
0
/*
 * Extract an obj from the world.
 */
void Object::extract_obj ()
{
  Object *obj_content;

  if (in_room != NULL)
    obj_from_room ();
  else if (carried_by != NULL)
    obj_from_char ();
  else if (in_obj != NULL)
    obj_from_obj ();

  ObjIter o, next;
  for (o = contains.begin(); o != contains.end(); o = next) {
    obj_content = *o;
    next = ++o;
    obj_content->extract_obj();
  }

  deepobnext = object_list.erase(find(object_list.begin(), object_list.end(), this));

  AffIter af;
  for (af = affected.begin(); af != affected.end(); af++) {
    delete *af;
  }
  affected.clear();

  std::list<ExtraDescription *>::iterator ed;
  for (ed = extra_descr.begin(); ed != extra_descr.end(); ed++) {
    delete *ed;
  }
  extra_descr.clear();

  --pIndexData->count;
  delete this;
  return;
}
示例#13
0
/*
 * Donate Command
 */
void do_donate(CHAR_DATA *ch, char *argument) {
    char Object_Name[MAX_INPUT_LENGTH];
    ROOM_INDEX_DATA *xRoom;
    OBJ_DATA *xObject;
    int DONATION_ROOM;
    argument = one_argument(argument, Object_Name);
    if(Object_Name == '\0') {
        send_to_char("Donate WHAT Object?", ch);
        return;
    }
    if((xObject = get_obj_carry(ch, Object_Name)) == NULL) {
        send_to_char("You can't donate that item! You have not got it!", ch);
        return;
    }
    switch(xObject->item_type) {
    case ITEM_WEAPON :
        DONATION_ROOM = DONATION_ROOM_WEAPON;
        break;
    case ITEM_ARMOR  :
        DONATION_ROOM = DONATION_ROOM_ARMOR;
        break;
    default :
        DONATION_ROOM = DONATION_ROOM_REST;
        break;
    }
    if((xRoom = get_room_index(DONATION_ROOM)) == NULL) {
        bug("Donate Room Does Not Exist : %d", DONATION_ROOM);
        return;
    }
    act("$p vanishes from your hands in a pink mist.", ch, xObject, NULL, TO_CHAR);
    act("$p vanishes from $n's hands in a pink mist.", ch, xObject, NULL, TO_ROOM);
    obj_from_char(xObject);
    obj_to_room(xObject, xRoom);
    act("$p appears in a pink mist in the room.", ch, xObject, NULL, TO_ROOM);
    return;
}
示例#14
0
文件: shops.c 项目: smthbh/SWFotE-Mud
void do_sell( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *keeper;
    OBJ_DATA *obj;
    int cost;

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char( "Sell what?\n\r", ch );
	return;
    }

    if ( ( keeper = find_keeper( ch ) ) == NULL )
	return;

    if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
    {
	act( AT_TELL, "$n tells you 'You don't have that item.'", keeper, NULL, ch, TO_VICT );
	ch->reply = keeper;
	return;
    }
    /* Bug report and solution thanks to [email protected] */
    if ( !can_see_obj( keeper, obj) ) 
    {
        send_to_char("What are you trying to sell me? I don't buy thin air!\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 ( obj->timer > 0 )
    {
	act( AT_TELL, "$n tells you, '$p is depreciating in value too quickly...'", keeper, obj, ch, TO_VICT );
	return;
    }

    if ( ( cost = get_cost( ch, keeper, obj, FALSE ) ) <= 0 )
    {
	act( AT_ACTION, "$n looks uninterested in $p.", keeper, obj, ch, TO_VICT );
	return;
    }

    if ( cost > keeper->gold )
    {
	act( AT_TELL, "$n makes a credit transaction.", keeper, obj, ch, TO_VICT );
        lower_economy( ch->in_room->area, cost-keeper->gold );
    }
    
    separate_obj( obj );
    act( AT_ACTION, "$n sells $p.", ch, obj, NULL, TO_ROOM );
    sprintf( buf, "You sell $p for %d credit%s.",
	cost, cost == 1 ? "" : "s" );
    act( AT_ACTION, buf, ch, obj, NULL, TO_CHAR );
    ch->gold     += cost;
    keeper->gold -= cost;
    if ( keeper->gold < 0 )
	keeper->gold = 0;

    if ( obj->item_type == ITEM_TRASH )
	extract_obj( obj );
    else  if ( IS_SET( obj->extra_flags , ITEM_CONTRABAND) )
   {
       long ch_exp;
       
       ch_exp = UMIN( obj->cost*10 , ( exp_level( ch->skill_level[SMUGGLING_ABILITY]+1) - exp_level( ch->skill_level[SMUGGLING_ABILITY])  ) / 10  );
       ch_printf( ch, "You receive %ld smuggling experience for unloading your contraband.\n\r " , ch_exp );
       gain_exp( ch, ch_exp , SMUGGLING_ABILITY );
       if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE )
	 extract_obj( obj );
       else
       {
         REMOVE_BIT( obj->extra_flags , ITEM_CONTRABAND );
         obj_from_char( obj );
         obj_to_char( obj, keeper );
       }
   }
    else if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE )
	extract_obj( obj );
    else
    {
	obj_from_char( obj );
	obj_to_char( obj, keeper );
    }

    return;
}
示例#15
0
文件: shop.c 项目: rparet/darkpawns
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;
      }
}
示例#16
0
文件: shop.c 项目: frasten/openleu
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;
}
示例#17
0
文件: shop.c 项目: frasten/openleu
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; 
}
示例#18
0
void wear(struct char_data *ch, struct obj_data *obj_object, int keyword)
{
	char buffer[MAX_STRING_LENGTH];

	switch(keyword) {
		case 0: {  /* LIGHT SOURCE */
			if (ch->equipment[WEAR_LIGHT])
				send_to_char("You are already holding a light source.\n\r", ch);
			else {
				send_to_char("Ok.\n\r", ch);
				perform_wear(ch,obj_object,keyword);
				obj_from_char(obj_object);
				equip_char(ch,obj_object, WEAR_LIGHT);
				if (obj_object->obj_flags.value[2])
					world[ch->in_room].light++;
			}
		} break;

		case 1: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_FINGER)) {
				if ((ch->equipment[WEAR_FINGER_L]) && (ch->equipment[WEAR_FINGER_R])) {
					send_to_char(
						"You are already wearing something on your fingers.\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					if (ch->equipment[WEAR_FINGER_L]) {
						sprintf(buffer, "You put the %s on your right finger.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_FINGER_R);
					} else {
						sprintf(buffer, "You put the %s on your left finger.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_FINGER_L);
					}
				}
			} else {
				send_to_char("You can't wear that on your finger.\n\r", ch);
			}
		} break;
		case 2: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_NECK)) {
				if ((ch->equipment[WEAR_NECK_1]) && (ch->equipment[WEAR_NECK_2])) {
					send_to_char("You can't wear any more around your neck.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					if (ch->equipment[WEAR_NECK_1]) {
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_NECK_2);
					} else {
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WEAR_NECK_1);
					}
				}
			} else {
							send_to_char("You can't wear that around your neck.\n\r", ch);
			}
		} break;
		case 3: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_BODY)) {
				if (ch->equipment[WEAR_BODY]) {
					send_to_char("You already wear something on your body.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch,  obj_object, WEAR_BODY);
				}
			} else {
				send_to_char("You can't wear that on your body.\n\r", ch);
			}
		} break;
		case 4: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_HEAD)) {
				if (ch->equipment[WEAR_HEAD]) {
					send_to_char("You already wear something on your head.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_HEAD);
				}
			} else {
				send_to_char("You can't wear that on your head.\n\r", ch);
			}
		} break;
		case 5: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_LEGS)) {
				if (ch->equipment[WEAR_LEGS]) {
					send_to_char("You already wear something on your legs.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_LEGS);
				}
			} else {
				send_to_char("You can't wear that on your legs.\n\r", ch);
			}
		} break;
		case 6: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_FEET)) {
				if (ch->equipment[WEAR_FEET]) {
					send_to_char("You already wear something on your feet.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_FEET);
				}
			} else {
				send_to_char("You can't wear that on your feet.\n\r", ch);
			}
		} break;
		case 7: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_HANDS)) {
				if (ch->equipment[WEAR_HANDS]) {
					send_to_char("You already wear something on your hands.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_HANDS);
				}
			} else {
				send_to_char("You can't wear that on your hands.\n\r", ch);
			}
		} break;
		case 8: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_ARMS)) {
				if (ch->equipment[WEAR_ARMS]) {
					send_to_char("You already wear something on your arms.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_ARMS);
				}
			} else {
				send_to_char("You can't wear that on your arms.\n\r", ch);
			}
		} break;
		case 9: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_ABOUT)) {
				if (ch->equipment[WEAR_ABOUT]) {
					send_to_char("You already wear something about your body.\n\r", ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_ABOUT);
				}
			} else {
				send_to_char("You can't wear that about your body.\n\r", ch);
			}
		} break;
		case 10: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_WAISTE)) {
				if (ch->equipment[WEAR_WAISTE]) {
					send_to_char("You already wear something about your waiste.\n\r",
						ch);
				} else {
					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch,  obj_object, WEAR_WAISTE);
				}
			} else {
				send_to_char("You can't wear that about your waist.\n\r", ch);
			}
		} break;
		case 11: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_WRIST)) {
				if ((ch->equipment[WEAR_WRIST_L]) && (ch->equipment[WEAR_WRIST_R])) {
					send_to_char(
						"You already wear something around both your wrists.\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					if (ch->equipment[WEAR_WRIST_L]) {
						sprintf(buffer, "You wear the %s around your right wrist.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						equip_char(ch,  obj_object, WEAR_WRIST_R);
					} else {
						sprintf(buffer, "You wear the %s around your left wrist.\n\r", 
							fname(obj_object->name));
						send_to_char(buffer, ch);
						equip_char(ch, obj_object, WEAR_WRIST_L);
					}
				}
			} else {
				send_to_char("You can't wear that around your wrist.\n\r", ch);
			}
		} break;

		case 12:
			if (CAN_WEAR(obj_object,ITEM_WIELD)) {
				if (ch->equipment[WIELD]) {
					send_to_char("You are already wielding something.\n\r", ch);
				} else {
					/* Cleric execption has been removed, and is temporarily placed */
					/* at the end of this file                                      */

					if (GET_OBJ_WEIGHT(obj_object) >
					    str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) {
						send_to_char("It is too heavy for you to use.\n\r",ch);
					} else {
						send_to_char("OK.\n\r", ch);
						perform_wear(ch,obj_object,keyword);
						obj_from_char(obj_object);
						equip_char(ch, obj_object, WIELD);
					}
				}
			} else {
				send_to_char("You can't wield that.\n\r", ch);
			}
			break;

		case 13:
			if (CAN_WEAR(obj_object,ITEM_HOLD)) {
				if (ch->equipment[HOLD]) {
					send_to_char("You are already holding something.\n\r", ch);
				} else {
					/* Cleric execption has been removed, and is temporarily placed */
					/* at the end of this file                                      */

					send_to_char("OK.\n\r", ch);
					perform_wear(ch,obj_object,keyword);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, HOLD);
				}
			} else {
				send_to_char("You can't hold this.\n\r", ch);
			}
			break;
		case 14: {
			if (CAN_WEAR(obj_object,ITEM_WEAR_SHIELD)) {
				if ((ch->equipment[WEAR_SHIELD])) {
					send_to_char(
						"You are already using a shield\n\r", ch);
				} else {
					perform_wear(ch,obj_object,keyword);
					sprintf(buffer, "You start using the %s.\n\r", 
						fname(obj_object->name));
					send_to_char(buffer, ch);
					obj_from_char(obj_object);
					equip_char(ch, obj_object, WEAR_SHIELD);
				}
			} else {
				send_to_char("You can't use that as a shield.\n\r", ch);
			}
		} break;
		case -1: {
			sprintf(buffer,"Wear %s where?.\n\r", fname(obj_object->name));
			send_to_char(buffer, ch);
		} break;
		case -2: {
			sprintf(buffer,"You can't wear the %s.\n\r", fname(obj_object->name));
			send_to_char(buffer, ch);
		} break;
		default: {
			log("Unknown type called in wear.");
		} break;
	}
}
示例#19
0
/* Extract a ch completely from the world, and leave his stuff behind */
void extract_char_smarter(struct char_data *ch, int save_room)
{
  struct obj_data *i;
  struct char_data *k, *next_char;
  struct descriptor_data *t_desc;
  int l, was_in, j;

  extern long mob_count;  
  extern struct char_data *combat_list;
  
  void do_save(struct char_data *ch, char *argument, int cmd);
  void do_return(struct char_data *ch, char *argument, int cmd);
  
  void die_follower(struct char_data *ch);

  if(IS_SET(ch->specials.act, ACT_FIGURINE) && ch->link)
     extract_obj(ch->link);
  
  if(!IS_NPC(ch) && !ch->desc)	{
    for(t_desc = descriptor_list; t_desc; t_desc = t_desc->next)
      if(t_desc->original==ch)
	do_return(t_desc->character, "", 0);
  }
  
  if (ch->in_room == NOWHERE) {
    logE("NOWHERE extracting char. (handler.c, extract_char)");
    /*
     **  problem from linkdeath
     */
    char_to_room(ch, 4);  /* 4 == all purpose store */
  }
  
  if (ch->followers || ch->master)
    die_follower(ch);
  
  if(ch->desc) {
    /* Forget snooping */
    if ((ch->desc->snoop.snooping) && (ch->desc->snoop.snooping->desc))
      ch->desc->snoop.snooping->desc->snoop.snoop_by = 0;
    
    if (ch->desc->snoop.snoop_by) {
      send_to_char("Your victim is no longer among us.\n\r",
		   ch->desc->snoop.snoop_by);
      if (ch->desc->snoop.snoop_by->desc)
      ch->desc->snoop.snoop_by->desc->snoop.snooping = 0;
    }
    
    ch->desc->snoop.snooping = ch->desc->snoop.snoop_by = 0;
  }
  
  if (ch->carrying)	{
    /* transfer ch's objects to room */
    
    if (!IS_IMMORTAL(ch)) {

      while(ch->carrying) {
	i=ch->carrying;
	obj_from_char(i);
	obj_to_room(i, ch->in_room);
	check_falling_obj(i, ch->in_room);

      }
    } else {

      send_to_char("Here, you dropped some stuff, let me help you get rid of that.\n\r",ch);

      /*
	equipment too
	*/
      for (j=0; j<MAX_WEAR; j++) {
	if (ch->equipment[j])
	  obj_to_char(unequip_char(ch, j), ch);
      }      

      while (ch->carrying) {
         i = ch->carrying;
	 obj_from_char(i);
	 extract_obj(i);
      }
    }
    
  }
  
  if (ch->specials.fighting)
    stop_fighting(ch);
  
  for (k = combat_list; k ; k = next_char)	{
    next_char = k->next_fighting;
    if (k->specials.fighting == ch)
      stop_fighting(k);
  }

  if (MOUNTED(ch)) {
    Dismount(ch, MOUNTED(ch), POSITION_STANDING);    
  }

  if (RIDDEN(ch)) {
    Dismount(RIDDEN(ch), ch, POSITION_STANDING);
  }
  
  /* Must remove from room before removing the equipment! */
  was_in = ch->in_room;
  char_from_room(ch);
  
  /* clear equipment_list */
  for (l = 0; l < MAX_WEAR; l++)
    if (ch->equipment[l])
      obj_to_room(unequip_char(ch,l), was_in);
  
  
  if (IS_NPC(ch)) {
    for (k=character_list; k; k=k->next) {
      if (k->specials.hunting)
	if (k->specials.hunting == ch) {
	  k->specials.hunting = 0;
	}
      if (Hates(k, ch)) {
	RemHated(k, ch);
      }
      if (Fears(k, ch)) {
	RemFeared(k, ch);
      }
      if (k->orig == ch) {
	k->orig = 0;
      }
    }          
  } else {
    for (k=character_list; k; k=k->next) {
      if (k->specials.hunting)
	if (k->specials.hunting == ch) {
	  k->specials.hunting = 0;
	}
      if (Hates(k, ch)) {
	ZeroHatred(k, ch);
      }
      if (Fears(k, ch)) {
	ZeroFeared(k, ch);
      }
      if (k->orig == ch) {
	k->orig = 0;
      }
    }
    
  }
  /* pull the char from the list */
  
  if (ch == character_list)  
    character_list = ch->next;
  else   {
    for(k = character_list; (k) && (k->next != ch); k = k->next);
    if(k)
      k->next = ch->next;
    else {
      logE("Trying to remove ?? from character_list.(handler.c,extract_char)");
      exit(0);
    }
  }

  if (ch->specials.gname)
    free(ch->specials.gname);
  
  GET_AC(ch) = 100;
  
  if (ch->desc)	{
    if (ch->desc->original)
      do_return(ch, "", 0);
    if (!strcmp(GET_NAME(ch), "Odin's heroic minion")) {
      free(GET_NAME(ch));
      GET_NAME(ch) = strdup("111111");
    }
    save_char(ch, save_room);
  }
  

  t_desc = ch->desc;

  if(ch->term) {
    ScreenOff(ch);
    ch->term = 0;
  }

  if (IS_NPC(ch)) 	{
    if (ch->nr > -1) /* if mobile */
      mob_index[ch->nr].number--;
    FreeHates(ch);
    FreeFears(ch);
    mob_count--;
    free_char(ch);
  }
  
  if (t_desc) {
    t_desc->connected = CON_SLCT;
    SEND_TO_Q(MENU, t_desc);
  }
}
void sit(struct char_data *ch, struct gameobject *on)
{
    // TODO - it is currently possible to defeat object pickup restrictions by
    // sitting on them. Need to extract can_get_obj from get_obj and use it!

    // Impassible positions.
    switch (ch->position) {
	case POS_SITTING:
	    if (on == NULL || on == ch->on) {
		send_to_char("You are already sitting down.\n\r", ch);
		return;
	    }
	    break;

	case POS_FIGHTING:
	    send_to_char("Maybe you should finish this fight first?\n\r", ch);
	    return;

	case POS_SLEEPING:
	    if (IS_AFFECTED(ch, AFF_SLEEP)) {
		send_to_char("You can't wake up!\n\r", ch);
		return;
	    }
	    break;
    }

    // Validate target object, if any.
    if (on != NULL) {
	if (!is_situpon(on)) {
	    send_to_char("You can't sit on that.\n\r", ch);
	    return;
	}

	if (ch->position == POS_SLEEPING && on != ch->on) {
	    send_to_char("You'll need to wake up to find it.\n\r", ch);
	    return;
	}

	if (on->carried_by != NULL && on->carried_by != ch) {
	    act_new("The $p is being held by someone!", ch, on, NULL, TO_CHAR, POS_DEAD, false);
	    return;
	}

	if (on->in_obj != NULL) {
	    if (on->in_obj->in_room != ch->in_room) {
		send_to_char("What? Where?\n\r", ch);
		return;
	    }
	}

	if (ch->on != on && (long)count_users(on) >= on->value[0]) {
	    act_new("There's no more room on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
	    return;
	}
    }

    // Sit down, possibly on and object.
    ch->position = POS_SITTING;
    if (on != NULL) {
	ch->on = on;

	if (on->carried_by == ch) {
	    obj_from_char(on);
	    obj_to_room(on, ch->in_room);
	} else if (on->in_obj != NULL) {
	    obj_from_obj(on);
	    obj_to_room(on, ch->in_room);
	}
    }

    // Notify
    switch (ch->position) {
	default:
	    if (on == NULL) {
		send_to_char("You sit down.\n\r", ch);
		act("$n sits down on the ground.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act("You sit down at $p.", ch, on, NULL, TO_CHAR);
		act("$n sits down at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act("You sit on $p.", ch, on, NULL, TO_CHAR);
		act("$n sits on $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act("You sit down in $p.", ch, on, NULL, TO_CHAR);
		act("$n sits down in $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
	case POS_SLEEPING:
	    if (on == NULL) {
		send_to_char("You wake and sit up.\n\r", ch);
		act("$n wakes and sits up.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act_new("You wake and sit at $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act_new("You wake and sit on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits at $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act_new("You wake and sit in $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits in $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
	case POS_RESTING:
	    if (on == NULL) {
		send_to_char("You stop resting.\n\r", ch);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act("You sit at $p.", ch, on, NULL, TO_CHAR);
		act("$n sits at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act("You sit on $p.", ch, on, NULL, TO_CHAR);
		act("$n sits on $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
    }
}
示例#21
0
void do_plantbug( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *victim;
   BUG_DATA *pbug;
   BUG_DATA *cbug;
   OBJ_DATA *obj;
   bool checkbug = FALSE;
   int schance;

   if( IS_NPC( ch ) )
      return;

   if( ( victim = get_char_room( ch, argument ) ) == NULL )
   {
      send_to_char( "They aren't here.\n\r", ch );
      return;
   }

   if( IS_NPC( victim ) )
   {
      send_to_char( "You can't bug NPC's!\n\r", ch );
      return;
   }

   if( IS_IMMORTAL( victim ) )
   {
      send_to_char( "Don't try to plant bugs on immortals.\n\r", ch );
      return;
   }

   if( in_arena( ch ) )
   {
      send_to_char( "You're here to FIGHT, not spy.\n\r", ch );
      return;
   }

   if( ch == victim )
   {
      send_to_char( "You can't bug yourself!\n\r", ch );
      return;
   }

   for( obj = ch->last_carrying; obj; obj = obj->prev_content )
      if( obj->item_type == ITEM_BUG )
         checkbug = TRUE;

   if( checkbug == FALSE )
   {
      send_to_char( "You don't have any bugs to plant.\n\r", ch );
      return;
   }

   for( cbug = victim->first_bug; cbug; cbug = cbug->next_in_bug )
      if( !str_cmp( ch->name, cbug->name ) )
      {
         send_to_char( "You have already planted a bug on this person.\n\r", ch );
         return;
      }

   schance = number_percent(  ) - UMIN( 0, ( get_curr_lck( ch ) - 14 ) ) + UMIN( 0, ( get_curr_lck( victim ) - 13 ) );

   if( schance < ch->pcdata->learned[gsn_plantbug] )
   {
      act( AT_WHITE, "You carefully reach into $N's pocket and place a bug.", ch, NULL, victim, TO_CHAR );
      CREATE( pbug, BUG_DATA, 1 );
      pbug->name = ch->name;
      LINK( pbug, victim->first_bug, victim->last_bug, next_in_bug, prev_in_bug );
      learn_from_success( ch, gsn_plantbug );

      for( obj = ch->last_carrying; obj; obj = obj->prev_content )
      {
         if( obj->item_type == ITEM_BUG )
         {
            separate_obj( obj );
            obj_from_char( obj );
            extract_obj( obj );
            break;
         }
      }
      return;
   }
   else
   {
      send_to_char( "&RYou try to find a pocket to plant the bug in but fail!\n\r", ch );
      learn_from_failure( ch, gsn_plantbug );
      if( number_bits( 0 ) == 0 )
         ch_printf( victim, "You feel a slight brush against your pocket to find %s's hand there.\n\r", PERS( ch, victim ) );
      return;
   }
}
示例#22
0
void do_unbind( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *obj;
   bool checkbinders = FALSE;
   char buf[MAX_STRING_LENGTH];
   CHAR_DATA *victim;

   if( IS_NPC( ch ) )
   {
      send_to_char( "You're a mob.\n\r", ch );
      return;
   }

   if( argument[0] == '\0' )
   {
      send_to_char( "Syntax: Unbind <victim>\n\r", ch );
      return;
   }

   if( ( victim = get_char_room( ch, argument ) ) == NULL )
   {
      send_to_char( "They aren't here.\n\r", ch );
      return;
   }

   if( victim == ch )
   {
      send_to_char( "You can not unbind yourself!\n\r", ch );
      return;
   }

   if( IS_NPC( victim ) )
   {
      send_to_char( "You can only unbind players.\n\r", ch );
      return;
   }

   if( IS_SET( ch->pcdata->act2, ACT_BOUND ) )
   {
      send_to_char( "Nice try. You're bound yourself!\n\r", ch );
      return;
   }

   if( !IS_SET( victim->pcdata->act2, ACT_BOUND ) )
   {
      send_to_char( "But they're not bound.\n\r", ch );
      return;
   }


   obj = get_eq_char( victim, WEAR_BOTH_WRISTS );
   if( obj )
      unequip_char( victim, obj );
   else
   {
      send_to_char( "Something went wrong. get an imm.\n\r", ch );
      sprintf( buf, "%s unbinding %s: has no bothwrists object!", ch->name, victim->name );
      bug( buf );
      return;
   }

   for( obj = victim->last_carrying; obj; obj = obj->prev_content )
      if( obj->item_type == ITEM_BINDERS )
      {
         checkbinders = TRUE;
         break;
      }

   if( checkbinders == FALSE )
   {
      bug( "Unbind: no binders in victims inventory." );
      send_to_char( "Something went wrong. get an imm.\n\r", ch );
      return;
   }

   separate_obj( obj );
   obj_from_char( obj );
   obj_to_char( obj, ch );
   act( AT_WHITE, "You quickly unbind $N's wrists.", ch, NULL, victim, TO_CHAR );
   act( AT_WHITE, "$n quickly unbinds your wrists.", ch, NULL, victim, TO_VICT );
   act( AT_WHITE, "$n quickly unbinds $N's wrists.", ch, NULL, victim, TO_NOTVICT );
   REMOVE_BIT( victim->pcdata->act2, ACT_BOUND );
}
示例#23
0
void do_disarm(struct char_data *ch, char *argument, int cmd)
{
  char name[30];
  int percent;
  struct char_data *victim;
  struct obj_data *w;
  int chance;
  int cost;

  if (check_peaceful(ch,"You feel too peaceful to contemplate violence.\n\r"))
    return;
  
  only_argument(argument, name);
  if (!(victim = get_char_room_vis(ch, name))) 
  {
    if (ch->specials.fighting) 
    {
      victim = ch->specials.fighting;
    }
    else
    {
      send_to_char("Disarm who?\n\r", ch);
      return;
    }
  }
  
  if (victim == ch) 
  {
    send_to_char("Aren't we funny today...\n\r", ch);
    return;
  }

  if(!CheckKill(ch,victim)) return;

  if(ch->attackers > 3) 
  {
    send_to_char("There is no room to disarm!\n\r", ch);
    return;
  }

  if(victim->attackers > 3)
  {
    send_to_char("There is no room to disarm!\n\r",ch);
    return;
  }

  cost = 25 - (GET_LEVEL(ch,BestFightingClass(ch))/10);

  if(GET_MANA(ch)<cost)
  {
    send_to_char("You trip and fall while trying to disarm.\n\r",ch);
    return;
  }

  percent=number(1,101); /* 101% is a complete failure */
  percent -= dex_app[GET_DEX(ch)].reaction;
  percent += dex_app[GET_DEX(victim)].reaction;

  if(!ch->equipment[WIELD] && !ch->equipment[WIELD_TWOH]) 
  {
    percent -= 50;
  }

  if(percent > ch->skills[SKILL_DISARM].learned) 
  {
    /*   failure   */

    GET_MANA(ch) -= 10;
    act("You try to disarm $N, but fail miserably.",TRUE,ch,0,victim,TO_CHAR);
    if((ch->equipment[WIELD]) && (number(1,10) > 8))
    {
        send_to_char("Your weapon flies from your hand while trying!\n\r",ch);
	w = unequip_char(ch,WIELD);
	obj_from_char(w);
	obj_to_room(w,ch->in_room);
	act("$n tries to disarm $N, but $n loses his weapon!",TRUE,ch,0,victim,TO_ROOM);
    }
    else
    if((ch->equipment[WIELD_TWOH]) && (number(1,10) > 9))
    {
        send_to_char("Your weapon slips from your hands while trying!\n\r",ch);
	w = unequip_char(ch,WIELD_TWOH);
	obj_from_char(w);
	obj_to_room(w,ch->in_room);
	act("$n tries to disarm $N, but $n loses his weapon!",TRUE,ch,0,victim,TO_ROOM);
    }
    GET_POS(ch) = POSITION_SITTING;

    if((IS_NPC(victim)) && (GET_POS(victim) > POSITION_SLEEPING) && (!victim->specials.fighting)) 
    {
      set_fighting(victim, ch);
    }
    WAIT_STATE(ch, PULSE_VIOLENCE*2);
  }
  else
  {
    if(victim->equipment[WIELD]) 
    {
      GET_MANA(ch) -= 25;
      w = unequip_char(victim, WIELD);
      act("$n makes an impressive fighting move.",TRUE, ch, 0, 0, TO_ROOM);
      act("You send $p flying from $N's grasp.", TRUE, ch, w, victim, TO_CHAR);
      act("$p flies from your grasp.", TRUE, ch, w, victim, TO_VICT);
      obj_from_char(w);
      obj_to_room(w, victim->in_room);
      if(ch->skills[SKILL_DISARM].learned < 50)
	ch->skills[SKILL_DISARM].learned += 2;
    }
    else
    if(victim->equipment[WIELD_TWOH])
    {
      GET_MANA(ch) -= cost;
      if(IS_NPC(victim))
	chance = 70;
      else
        chance = victim->skills[SKILL_TWO_HANDED].learned; 

      percent=number(1,101); /* 101% is a complete failure */
      if(percent > chance)
      {
        w = unequip_char(victim, WIELD_TWOH);
        act("$n makes a very impressive fighting move.",TRUE, ch, 0, 0, TO_ROOM);
        act("You send $p flying from $N's grasp.", TRUE, ch, w, victim, TO_CHAR);
        act("$p flies from your grasp.", TRUE, ch, w, victim, TO_VICT);
        obj_from_char(w);
        obj_to_room(w, victim->in_room);
        if(ch->skills[SKILL_DISARM].learned < 50)
	  ch->skills[SKILL_DISARM].learned += 4;
      }
      else
      {
        act("You try to disarm $N, but fail miserably.",TRUE,ch,0,victim,TO_CHAR);
      }
    }
    else
    {
      act("You try to disarm $N, but $E doesn't have a weapon.", 
	  TRUE, ch, 0, victim, TO_CHAR);
      act("$n makes an impressive fighting move, but does little more.",
	  TRUE, ch, 0, 0, TO_ROOM);
    }

    if ((IS_NPC(victim)) && (GET_POS(victim) > POSITION_SLEEPING) &&
        (!victim->specials.fighting)) {
      set_fighting(victim, ch);
    }
    WAIT_STATE(ch, PULSE_VIOLENCE*1);
  }  
}
示例#24
0
文件: shop.c 项目: rparet/darkpawns
void
shopping_sell(char *arg, struct char_data * ch,
          struct char_data * keeper, int shop_nr)
{
  char tempstr[200], buf[MAX_STRING_LENGTH], name[200];
  char shortd[MAX_STRING_LENGTH];
  struct obj_data *obj, *tag = 0;
  int sellnum, sold = 0, goldamt = 0;

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

  if ((sellnum = transaction_amt(arg)) < 0)
    {
      sprintf(buf, "%s A negative amount?  Try buying something.",
          GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);
      return;
    }
  if (!(*arg) || !(sellnum))
    {
      sprintf(buf, "%s What do you want to sell??", GET_NAME(ch));
      do_tell(keeper, buf, cmd_tell, 0);
      return;
    }
  one_argument(arg, name);
  if (!(obj = get_selling_obj(ch, name, keeper, shop_nr, TRUE)))
    return;

  strcpy(shortd, obj->short_description);

  if (GET_GOLD(keeper) + SHOP_BANK(shop_nr) < sell_price(ch, obj, shop_nr)) {
    sprintf(buf, shop_index[shop_nr].missing_cash1, GET_NAME(ch));
    do_tell(keeper, buf, cmd_tell, 0);
    return;
  }
  while ((obj) && (GET_GOLD(keeper) + SHOP_BANK(shop_nr) >=
           sell_price(ch, obj, shop_nr)) && (sold < sellnum))
    {
      sold++;

      goldamt += sell_price(ch, obj, shop_nr);
      GET_GOLD(keeper) -= sell_price(ch, obj, shop_nr);

      obj_from_char(obj);
      tag = slide_obj(obj, keeper, shop_nr);
      obj = get_selling_obj(ch, name, keeper, shop_nr, FALSE);
    }

  if (sold < sellnum)
    {
      if (!obj)
    sprintf(buf, "%s You only have %d of those.", GET_NAME(ch), sold);
      else if (GET_GOLD(keeper) + SHOP_BANK(shop_nr) <
           sell_price(ch, obj, shop_nr))
    sprintf(buf, "%s I can only afford to buy %d of those.",
        GET_NAME(ch), sold);
      else
    sprintf(buf, "%s Something really screwy made me buy %d.",
        GET_NAME(ch), sold);

      do_tell(keeper, buf, cmd_tell, 0);
    }
  GET_GOLD(ch) += goldamt;
  strcpy(tempstr, times_message(0, shortd, sold));
  sprintf(buf, "$n sells %s.", tempstr);
  act(buf, FALSE, ch, obj, 0, TO_ROOM);

  sprintf(buf, shop_index[shop_nr].message_sell, GET_NAME(ch), goldamt);
  do_tell(keeper, buf, cmd_tell, 0);
  sprintf(buf, "The shopkeeper now has %s.\n\r", tempstr);
  send_to_char(buf, ch);


  if (GET_GOLD(keeper) < MIN_OUTSIDE_BANK)
    {
      goldamt = MIN(MAX_OUTSIDE_BANK - GET_GOLD(keeper), SHOP_BANK(shop_nr));
      SHOP_BANK(shop_nr) -= goldamt;
      GET_GOLD(keeper) += goldamt;
    }
}
示例#25
0
文件: shops.c 项目: smthbh/SWFotE-Mud
void do_buy( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    int maxgold;
    bool debit;
    OBJ_DATA *obj;    

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char( "Buy what?\n\r", ch );
	return;
    }

    if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) )
    {
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *pet;
	ROOM_INDEX_DATA *pRoomIndexNext;
	ROOM_INDEX_DATA *in_room;

   if ( argument[0] == '\0' )
      debit = FALSE;
   else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
   {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
     if ( has_card == TRUE )
      debit = TRUE;
     else
     {
       send_to_char( "You don't even have your card with you!\n\r", ch );
       return;    
     }    
    }

	if ( IS_NPC(ch) )
	    return;

	pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 );
	if ( !pRoomIndexNext )
	{
	    bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum );
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	in_room     = ch->in_room;
	ch->in_room = pRoomIndexNext;
	pet         = get_char_room( ch, arg );
	ch->in_room = in_room;

	if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) )
	{
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE)
	{
	    send_to_char( "You can't afford it.\n\r", ch );
	    return;
	}
	else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE )
	{
	  send_to_char( "You dont have enough money in your bank account for it.\n\r", ch );
          return;    
        } 

	maxgold = 10 * pet->top_level * pet->top_level;
        if ( debit == FALSE )
	  ch->gold	-= maxgold; /* this was already here, btw */
	else
	  ch->pcdata->bank  -= maxgold;

	boost_economy( ch->in_room->area, maxgold );
	pet		= create_mobile( pet->pIndexData );
	SET_BIT(pet->act, ACT_PET);
	SET_BIT(pet->affected_by, AFF_CHARM);

	argument = one_argument( argument, arg );
	if ( arg[0] != '\0' )
	{
	    sprintf( buf, "%s %s", pet->name, arg );
	    STRFREE( pet->name );
	    pet->name = STRALLOC( buf );
	}

	sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r",
	    pet->description, ch->name );
	STRFREE( pet->description );
	pet->description = STRALLOC( buf );

	char_to_room( pet, ch->in_room );
	add_follower( pet, ch );
	send_to_char( "Enjoy your pet.\n\r", ch );
    	act( AT_ACTION, "$n bought $N as a pet.", ch, NULL, pet, TO_ROOM );
	return;
    }
    else
    {
	CHAR_DATA *keeper;
	int cost;
	int noi = 1;		/* Number of items */
	sh_int mnoi = 20;	/* Max number of items to be bought at once */

	if ( ( keeper = find_keeper( ch ) ) == NULL )
	    return;

	maxgold = keeper->top_level * 10;

	if ( is_number( arg ) )
	{
	    noi = atoi( arg );
	    argument = one_argument( argument, arg );
	    if ( noi > mnoi )
	    {
		act( AT_TELL, "$n tells you 'I don't sell that many items at"
		  " once.'", keeper, NULL, ch, TO_VICT );
		ch->reply = keeper;
		return;
	    }
	}

    if ( argument[0] == '\0' )
      debit = FALSE;
    else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
    {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
      if ( has_card == TRUE )
       debit = TRUE;
      else
      {
        send_to_char( "You don't even have your card with you!\n\r", ch );
        return;    
      }    
     }  

	obj  = get_obj_carry( keeper, arg );
	
	if ( !obj && arg[0] == '#' )
        {     
              int onum, oref;
              bool ofound = FALSE;
              
              onum =0;
              oref = atoi(arg+1);
              for ( obj = keeper->last_carrying; obj; obj = obj->prev_content )
	      { 
	        if ( obj->wear_loc == WEAR_NONE
	        &&   can_see_obj( ch, obj ) )
	            onum++;
                if ( onum == oref ) 
                {
                    ofound = TRUE;
                    break;
                }
                else if ( onum > oref )
                   break;
	      }
	      if (!ofound)
	         obj = NULL;
        }
	if (keeper->home != NULL && obj->cost > 0)
          cost= obj->cost;
	cost = ( get_cost( ch, keeper, obj, TRUE ) * noi );

	if( !IS_NPC(ch) && ch->pcdata->learned[gsn_bargain] > 0 && ch->pcdata->learned[gsn_bargain] > number_percent())
	 {
	   ch_printf(ch,"You are able to bargain from %d credits to %d credits!\n\r", cost, (cost/3)+(cost/2));
	   cost = (cost/3) + (cost/2);
	   if(number_percent() > 50)
	    learn_from_success(ch, gsn_bargain);
	 }

	if ( cost <= 0 || !can_see_obj( ch, obj ) )
	{
	    act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'",
		keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}

	if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) )
	{
	    interpret( keeper, "laugh" );
	    act( AT_TELL, "$n tells you 'I don't have enough of those in stock"
	     " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
	if ( ch->gold < cost && debit == FALSE)
	{
	    act( AT_TELL, "$n tells you 'You can't afford to buy $p.'",
		keeper, obj, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
        if ( ch->pcdata->bank < cost && debit == TRUE)
	{
	    send_to_char( "You are almost slide your card through, but you remember you don't have enough money!\n\r", ch );
	    return;	    
        }  

	if ( IS_SET(obj->extra_flags, ITEM_PROTOTYPE) 
             && get_trust( ch ) < LEVEL_IMMORTAL )
	{
	    act( AT_TELL, "$n tells you 'This is a only a prototype!  I can't sell you that...'", 
		keeper, NULL, ch, TO_VICT );
      	    ch->reply = keeper;
	    return;
	}

	if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
	{
	    send_to_char( "You can't carry that many items.\n\r", ch );
	    return;
	}

	if ( ch->carry_weight + ( get_obj_weight( obj ) * noi )
		+ (noi > 1 ? 2 : 0) > can_carry_w( ch ) )
	{
	    send_to_char( "You can't carry that much weight.\n\r", ch );
	    return;
	}

	if ( noi == 1 )
	{
	    if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) )  
	       separate_obj( obj );
	    act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM );
    	    act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR );
	}
        else
	{
	    sprintf( arg, "$n buys %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM );
	    sprintf( arg, "You buy %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR );
	    act( AT_ACTION, "$N puts them into a bag and hands it to you.",
		ch, NULL, keeper, TO_CHAR );
	}

        if ( debit == FALSE )
	  ch->gold     -= cost; /* this line was already here, btw */
        else if ( debit == TRUE )
          ch->pcdata->bank     -= cost;
	keeper->gold += cost;

	if ( keeper->gold > maxgold )
	{
	    boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 );
	    keeper->gold = maxgold/2;
	    act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM );
	}

	if ( IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
	{
	    OBJ_DATA *buy_obj, *bag;

	    buy_obj = create_object( obj->pIndexData, obj->level );

	    /*
	     * Due to grouped objects and carry limitations in SMAUG
	     * The shopkeeper gives you a bag with multiple-buy,
	     * and also, only one object needs be created with a count
	     * set to the number bought.		-Thoric
	     */
	    if ( noi > 1 )
	    {
		bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ), 1 );
		/* perfect size bag ;) */
		bag->value[0] = bag->weight + (buy_obj->weight * noi);
		buy_obj->count = noi;
		obj->pIndexData->count += (noi - 1);
		numobjsloaded += (noi - 1);
		obj_to_obj( buy_obj, bag );
		obj_to_char( bag, ch );
	    }
	    else
		obj_to_char( buy_obj, ch );
	}
        else
	{
	    obj_from_char( obj );
	    obj_to_char( obj, ch );
	}

	return;
    }
}
示例#26
0
文件: handler.c 项目: Calebros/aol
/* Extract a ch completely from the world, and leave his stuff behind */
void extract_char(struct char_data * ch)
{
  struct char_data *k, *temp;
  struct descriptor_data *t_desc;
  struct obj_data *obj;
  int i, freed = 0;
  //int j;

  extern struct char_data *combat_list;

  ACMD(do_return);

  void die_follower(struct char_data * ch);


  if (!IS_NPC(ch) && !ch->desc) {
    for (t_desc = descriptor_list; t_desc; t_desc = t_desc->next) {
      if (t_desc->original == ch) {
	do_return(t_desc->character, "", 0, 0);
      }
    }
  }

  if (ch->in_room == NOWHERE) {
    log("SYSERR: NOWHERE extracting char. (handler.c, extract_char)");
    exit(1);
  }

  if (ch->followers || ch->master) {
    die_follower(ch);
  }

  if (RIDING(ch) || RIDDEN_BY(ch))
   dismount_char(ch);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FISHING);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FISH_ON);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_DIGGING);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_DIG_ON);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FIRE_ON);

   REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);

   //REMOVE_BIT(PRF_FLAGS(ch), PRF_DISGUISE);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_MAGE);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_MONK);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_KNIGHT);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_CLERIC);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_BARD);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_BEGGAR);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_COURIER);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT);

  /* Forget snooping, if applicable */
  if (ch->desc) {
    if (ch->desc->snooping) {
      ch->desc->snooping->snoop_by = NULL;
      ch->desc->snooping = NULL;
    }

    if (ch->desc->snoop_by) {
      SEND_TO_Q("Your victim is no longer among us.\r\n",
		ch->desc->snoop_by);
      ch->desc->snoop_by->snooping = NULL;
      ch->desc->snoop_by = NULL;
    }
  }

  /* transfer objects to room, if any */
  while (ch->carrying) {
    obj = ch->carrying;
    obj_from_char(obj);
    obj_to_room(obj, ch->in_room);
  }

  /* transfer equipment to room, if any */
  for (i = 0; i < NUM_WEARS; i++) {
    if (GET_EQ(ch, i)) {
      obj_to_room(unequip_char(ch, i), ch->in_room);
    }
  }

  if (FIGHTING(ch)) {
    stop_fighting(ch);
  }

  for (k = combat_list; k; k = temp) {
    temp = k->next_fighting;
    if (FIGHTING(k) == ch) {
      stop_fighting(k);
    }
  }

  char_from_room(ch);

  /* pull the char from the list */
  REMOVE_FROM_LIST(ch, character_list, next);

  if (ch->desc && ch->desc->original) {
    do_return(ch, NULL, 0, 0);
  }

  if (!IS_NPC(ch)) {
    save_char(ch, NOWHERE);
    Crash_delete_crashfile(ch);
  } else {
    if (GET_MOB_RNUM(ch) > -1) {     /* if mobile */
      mob_index[GET_MOB_RNUM(ch)].number--;
    }
    clearMemory(ch);		/* Only NPC's can have memory */

    if (SCRIPT(ch)) {
      extract_script(SCRIPT(ch));
    }

    free_char(ch);
    freed = 1;
  }

  if (!freed && ch->desc != NULL) {
    STATE(ch->desc) = CON_MENU;
    SEND_TO_Q(MENU, ch->desc);
  } else {  /* if a player gets purged from within the game */
    if (ch->master || ch->followers)
      die_follower(ch);
    if (!freed) {
      free_char(ch);
    }
  }
}
示例#27
0
/*
 * return values:
 * 0 - successful load, keep char in rent room.
 * 1 - load failure or load of crash items -- put char in temple.
 * 2 - rented equipment lost (no $)
 */
int Crash_load(struct char_data * ch)
{
  FILE *fl;
  char fname[MAX_STRING_LENGTH];
  struct obj_file_elem object;
  struct rent_info rent;
  int    cost, orig_rent_code, num_objs = 0, j;
  float  num_of_days;
  struct obj_data *obj, *obj2, *cont_row[MAX_BAG_ROWS];
  int    location;

  /* Empty all of the container lists (you never know ...) */
  for (j = 0; j < MAX_BAG_ROWS; j++)
    cont_row[j] = NULL;

  if (!get_filename(GET_NAME(ch), fname, CRASH_FILE))
    return 1;

  if (!(fl = fopen(fname, "r+b"))) {
    if (errno != ENOENT) {      /* if it fails, NOT because of no file */
      sprintf(buf1, "SYSERR: READING OBJECT FILE %s (5)", fname);
      perror(buf1);
      send_to_char("\r\n********************* NOTICE *********************\r\n"
		   "There was a problem loading your objects from disk.\r\n"
		   "Contact a God for assistance.\r\n", ch);
    }
    sprintf(buf, "%s entering game with NO equipment.", GET_NAME(ch));
    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    return 1;
  }
  if (!feof(fl))
    fread(&rent, sizeof(struct rent_info), 1, fl);
  else {
    plog("SYSERR: Crash_load: %s's rent file was empty!", GET_NAME(ch));
    return 1;
  }

  if (rent.rentcode == RENT_RENTED || rent.rentcode == RENT_TIMEDOUT) {
    num_of_days = (float) (time(0) - rent.time) / SECS_PER_REAL_DAY;
    cost = (int) (rent.net_cost_per_diem * num_of_days);
    if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
      fclose(fl);
      sprintf(buf, "%s entering game, rented equipment lost (no $).",
	      GET_NAME(ch));
      mudlog(buf, BRF, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
      Crash_crashsave(ch);
      return 2;
    } else {
      GET_BANK_GOLD(ch) -= MAX((long)cost - GET_GOLD(ch), 0L);
      GET_GOLD(ch) = MAX((long)GET_GOLD(ch) - cost, 0L);
      save_char(ch, NOWHERE);
    }
  }
  switch (orig_rent_code = rent.rentcode) {
  case RENT_RENTED:
    sprintf(buf, "%s un-renting and entering game.", GET_NAME(ch));
    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    break;
  case RENT_CRASH:
    sprintf(buf, "%s retrieving crash-saved items and entering game.", GET_NAME(ch));
    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    break;
  case RENT_CRYO:
    sprintf(buf, "%s un-cryo'ing and entering game.", GET_NAME(ch));
    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    break;
  case RENT_FORCED:
  case RENT_TIMEDOUT:
    sprintf(buf, "%s retrieving force-saved items and entering game.", GET_NAME(ch));
    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    break;
  default:
    sprintf(buf, "WARNING: %s entering game with undefined rent code.", GET_NAME(ch));
    mudlog(buf, BRF, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    break;
  }

  while (!feof(fl)) {
    fread(&object, sizeof(struct obj_file_elem), 1, fl);
    if (ferror(fl)) {
      perror("Reading crash file: Crash_load.");
      fclose(fl);
      return 1;
    }

    if (feof(fl))
      break;

    ++num_objs;
    if ( (obj = Obj_from_store(object, &location)) == NULL )
      continue;

    auto_equip( ch, obj, location );

    /*
     * What to do with a new loaded item:
     *
     * If there's a list with location less than 1 below this, then its
     * container has disappeared from the file so we put the list back into
     * the character's inventory. (Equipped items are 0 here.)
     *
     * If there's a list of contents with location of 1 below this, then we
     * check if it is a container:
     *   - Yes: Get it from the character, fill it, and give it back so we
     *          have the correct weight.
     *   -  No: The container is missing so we put everything back into the
     *          character's inventory.
     *
     * For items with negative location, we check if there is already a list
     * of contents with the same location.  If so, we put it there and if not,
     * we start a new list.
     *
     * Since location for contents is < 0, the list indices are switched to
     * non-negative.
     *
     * This looks ugly, but it works.
     */
    if (location > 0) {		/* Equipped */
      for (j = MAX_BAG_ROWS - 1; j > 0; j--) {
        if (cont_row[j]) {	/* No container, back to inventory. */
          for (; cont_row[j]; cont_row[j] = obj2) {
            obj2 = cont_row[j]->next_content;
            obj_to_char(cont_row[j], ch);
          }
          cont_row[j] = NULL;
        }
      }
      if (cont_row[0]) {	/* Content list existing. */
        if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) {
	/* Remove object, fill it, equip again. */
          obj = unequip_char(ch, location - 1);
          obj->contains = NULL;	/* Should be NULL anyway, but just in case. */
          for (; cont_row[0]; cont_row[0] = obj2) {
            obj2 = cont_row[0]->next_content;
            obj_to_obj(cont_row[0], obj);
          }
          equip_char(ch, obj, location - 1);
        } else {			/* Object isn't container, empty the list. */
          for (; cont_row[0]; cont_row[0] = obj2) {
            obj2 = cont_row[0]->next_content;
            obj_to_char(cont_row[0], ch);
          }
          cont_row[0] = NULL;
        }
      }
    } else {	/* location <= 0 */
      for (j = MAX_BAG_ROWS - 1; j > -location; j--) {
        if (cont_row[j]) {	/* No container, back to inventory. */
          for (; cont_row[j]; cont_row[j] = obj2) {
            obj2 = cont_row[j]->next_content;
            obj_to_char(cont_row[j], ch);
          }
          cont_row[j] = NULL;
        }
      }
      if (j == -location && cont_row[j]) {	/* Content list exists. */
        if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) {
		/* Take the item, fill it, and give it back. */
          obj_from_char(obj);
          obj->contains = NULL;
          for (; cont_row[j]; cont_row[j] = obj2) {
            obj2 = cont_row[j]->next_content;
            obj_to_obj(cont_row[j], obj);
          }
          obj_to_char(obj, ch);	/* Add to inventory first. */
        } else {	/* Object isn't container, empty content list. */
          for (; cont_row[j]; cont_row[j] = obj2) {
            obj2 = cont_row[j]->next_content;
            obj_to_char(cont_row[j], ch);
          }
          cont_row[j] = NULL;
        }
      }
      if (location < 0 && location >= -MAX_BAG_ROWS) {
        /*
         * Let the object be part of the content list but put it at the
         * list's end.  Thus having the items in the same order as before
         * the character rented.
         */
        obj_from_char(obj);
        if ((obj2 = cont_row[-location - 1]) != NULL) {
          while (obj2->next_content)
            obj2 = obj2->next_content;
          obj2->next_content = obj;
        } else
          cont_row[-location - 1] = obj;
      }
    }
  }

  /* Little hoarding check. -gg 3/1/98 */
  sprintf(fname, "%s (level %d) has %d object%s (max %d).",
          GET_NAME(ch), GET_LEVEL(ch), num_objs,
          num_objs != 1 ? "s" : "", max_obj_save);
  mudlog(fname, NRM, MAX(GET_INVIS_LEV(ch), LVL_GOD), TRUE);

  /* turn this into a crash file by re-writing the control block */
  rent.rentcode = RENT_CRASH;
  rent.time = time(0);
  rewind(fl);
  Crash_write_rentcode(ch, fl, &rent);

  fclose(fl);

  if ((orig_rent_code == RENT_RENTED) || (orig_rent_code == RENT_CRYO))
    return (0);
  else
    return (1);
}
示例#28
0
文件: swordtech.c 项目: borlak/umgw
void do_swordtech(CHAR_DATA * ch, char *argument)
{
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *victim = 0;
	OBJ_DATA *obj;
	AFFECT_DATA af;
	long chance;

	if(!ch || IS_NPC(ch))
		return;

	if(!IS_CLASS(ch, CLASS_HIGHLANDER))
	{
		send_to_char("You are not one of the chosen.\n\r", ch);
		return;
	}

	if(!argument || argument[0] == '\0')
	{
		send_to_char("What type of swordtech manuever do you want to attempt?\n\r", ch);
		send_to_char("Types are: fury, disarm, berserk, stun, decapitate, concentrate\n\r", ch);
		return;
	}

	if((obj = get_eq_char(ch, WEAR_WIELD)) == 0 || obj->pIndexData->vnum != 29695)
	{
		send_to_char("You must be wielding your Katana to do a swordtech manuever.\n\r", ch);
		return;
	}

	if(is_affected(ch, gsn_swordtech))
	{
		send_to_char("You are not ready for another swordtech manuever yet!\n\r", ch);
		return;
	}

	if(ch->move < 850)
	{
		send_to_char("You need 850 movement points to do a swordtech manuever!\n\r", ch);
		return;
	}

	ch->move -= 600;

	if(ch->pcdata->stats[UNI_GEN] == 1)
		chance = 55;
	else if(ch->pcdata->stats[UNI_GEN] == 2)
		chance = 35;
	else
		chance = 0;

	chance += 35;

	act("{G$n holds $p in front of $m and a spiral of silver energy swirls around $s body.{x", ch, obj, 0, TO_ROOM);
	act("{GYou holds $p in front of you and a spiral of silver energy swirls around your body.{x",
	    ch, obj, 0, TO_CHAR);

	if(chance < number_percent())
	{
		af.type = gsn_swordtech;
		af.duration = 3 + ch->pcdata->stats[UNI_GEN];
		af.modifier = 0;
		af.location = 0;
		af.bitvector = 0;
		affect_to_char(ch, &af);

		act("{gYou fail the manuever and the energy leaves you.{x", ch, 0, 0, TO_CHAR);
		act("{g$n fails the manuever and the energy leaves $m.{x", ch, 0, 0, TO_ROOM);
		return;
	}

	if(!str_prefix(argument, "berserk")
	   || !str_prefix(argument, "bezerk") || !str_prefix(argument, "beserk") || !str_prefix(argument, "berzerk"))
	{
		af.type = gsn_swordtech;
		af.duration = 5 + ((3 - ch->pcdata->stats[UNI_GEN]) * 2);
		af.modifier = 0;
		af.location = 0;
		af.bitvector = STECH_BERSERK;
		affect_to_char(ch, &af);
		act("You go berserk!", ch, 0, 0, TO_CHAR);
		act("$n goes berserk!", ch, 0, 0, TO_ROOM);
		return;
	}

	if(!str_prefix(argument, "concentrate"))
	{
		af.type = gsn_swordtech;
		af.duration = 5 + ((3 - ch->pcdata->stats[UNI_GEN]) * 2);
		af.modifier = 0;
		af.location = 0;
		af.bitvector = STECH_CONCENTRATE;
		affect_to_char(ch, &af);
		act("A deep calm overcomes you and you begin examining your opponent very carefully.", ch, 0, 0,
		    TO_CHAR);
		act("$n appears to get very calm and more alertive.", ch, 0, 0, TO_ROOM);
		return;
	}

	if(!str_prefix(argument, "decapitate"))
	{
		if((victim = ch->fighting) == 0)
		{
			send_to_char("You have to be fighting to do this manuever.\n\r", ch);
			return;
		}
		if(IS_NPC(victim) || number_percent() < 50)
		{
			act("You bring your sword up for a masterful swing and......miss horribly.", ch, 0, victim,
			    TO_CHAR);
			act("$n brings $s sword up for a masterful swing and......misses $N's head by a mile.", ch, 0,
			    victim, TO_NOTVICT);
			act("$n brings $s sword up for a masterful swing and......misses your head by a mile.", ch, 0,
			    victim, TO_VICT);
			act("You drop your weapons!", ch, 0, 0, TO_CHAR);
			act("$n drops $s weapons!", ch, 0, 0, TO_ROOM);
			obj_from_char(obj);
			obj_to_room(obj, ch->in_room);
			if((obj = get_eq_char(ch, WEAR_HOLD)) != 0)
			{
				obj_from_char(obj);
				obj_to_room(obj, ch->in_room);
			}
			return;
		}
		act("You bring your sword up for a masterful swing and whack $N's head clean off!", ch, 0, victim,
		    TO_CHAR);
		act("$n brings $s sword up for a masterful swing and whacks $N's head clean off!", ch, 0, victim,
		    TO_NOTVICT);
		act("$n brings $s sword up for a masterful swing and......you are now missing a head?!", ch, 0, victim,
		    TO_VICT);
		sprintf(buf, "{B%s swordtech decapitates %s!  Ooooh that's gotta hurt!{X", ch->name, victim->name);
		do_info(ch, buf);
		behead(victim);
		return;
	}

	if(!str_prefix(argument, "stun"))
	{
		if((victim = ch->fighting) == 0)
		{
			send_to_char("You have to be fighting to do this manuever.\n\r", ch);
			return;
		}
		act("You knock the hell out of $N's head with the side of your sword!", ch, 0, victim, TO_CHAR);
		act("$n knocks the hell out of $N's head with the side of $s sword!", ch, 0, victim, TO_NOTVICT);
		act("$n knocks the hell out of your head with the side of $s sword!", ch, 0, victim, TO_VICT);
		WAIT_STATE(victim, number_range(24, 60));
		return;
	}

	if(!str_prefix(argument, "fury"))
	{
		if((victim = ch->fighting) == 0)
		{
			send_to_char("You have to be fighting to do this manuever.\n\r", ch);
			return;
		}
		af.type = gsn_swordtech;
		af.duration = 3 + (ch->pcdata->stats[UNI_GEN] * 2);
		af.modifier = APPLY_STR;
		af.location = 0;
		af.bitvector = STECH_FURY;
		affect_to_char(ch, &af);
		act("You attack in a wild fury!", ch, 0, 0, TO_CHAR);
		act("$n attacks in a wild fury!", ch, 0, 0, TO_ROOM);
		multi_hit(ch, ch->fighting, TYPE_UNDEFINED);
		multi_hit(ch, ch->fighting, TYPE_UNDEFINED);
		multi_hit(ch, ch->fighting, TYPE_UNDEFINED);
		return;
	}

	if(!str_prefix(argument, "disarm"))
	{
		if((victim = ch->fighting) == 0 && !ch->in_room)
		{
			send_to_char("You have to be fighting to do this manuever.\n\r", ch);
			return;
		}
		if(IS_NPC(victim))
		{
			send_to_char("Not on NPC's.\n\r", ch);
			return;
		}
		if((obj = get_eq_char(victim, WEAR_WIELD)) == 0)
		{
			send_to_char("They aren't wielding a weapon!\n\r", ch);
			return;
		}
		obj_from_char(obj);
		obj_to_room(obj, ch->in_room);
		af.type = gsn_swordtech;
		af.duration = 5 + (ch->pcdata->stats[UNI_GEN] * 2);
		af.modifier = 0;
		af.location = 0;
		af.bitvector = STECH_DISARM;
		affect_to_char(ch, &af);
		act("$n disarms YOU!", ch, 0, victim, TO_VICT);
		act("$n disarms $N!", ch, 0, victim, TO_NOTVICT);
		act("You disarm $N!", ch, 0, victim, TO_CHAR);
		return;
	}

	send_to_char("Nothing happens.\n\r", ch);
}
示例#29
0
void read_obj_file( char *dirname, char *filename )
{
   ROOM_INDEX_DATA *room;
   FILE *fp;
   char fname[256];
   int vnum;

   vnum = atoi( filename );

   if( ( room = get_room_index( vnum ) ) == NULL )
   {
      bug( "read_obj_file: ARGH! Missing room index for %d!", vnum );
      return;
   }

   snprintf( fname, 256, "%s%s", dirname, filename );
   if( ( fp = fopen( fname, "r" ) ) != NULL )
   {
      short iNest;
      bool found;
      OBJ_DATA *tobj, *tobj_next;

      rset_supermob( room );
      for( iNest = 0; iNest < MAX_NEST; iNest++ )
         rgObjNest[iNest] = NULL;

      found = TRUE;
      for( ;; )
      {
         char letter;
         const char *word;

         letter = fread_letter( fp );
         if( letter == '*' )
         {
            fread_to_eol( fp );
            continue;
         }

         if( letter != '#' )
         {
            bug( "%s", "read_obj_file: # not found." );
            break;
         }

         word = fread_word( fp );
         if( !str_cmp( word, "OBJECT" ) ) /* Objects  */
            fread_obj( supermob, fp, OS_CARRY );
         else if( !str_cmp( word, "END" ) )  /* Done     */
            break;
         else
         {
            bug( "read_obj_file: bad section: %s", word );
            break;
         }
      }
      FCLOSE( fp );
      unlink( fname );
      for( tobj = supermob->first_carrying; tobj; tobj = tobj_next )
      {
         tobj_next = tobj->next_content;
#ifdef OVERLANDCODE
         if( IS_OBJ_STAT( tobj, ITEM_ONMAP ) )
         {
            SET_ACT_FLAG( supermob, ACT_ONMAP );
            supermob->map = tobj->map;
            supermob->x = tobj->x;
            supermob->y = tobj->y;
         }
#endif
         obj_from_char( tobj );
#ifndef OVERLANDCODE
         obj_to_room( tobj, room );
#else
         obj_to_room( tobj, room, supermob );
         REMOVE_ACT_FLAG( supermob, ACT_ONMAP );
         supermob->map = -1;
         supermob->x = -1;
         supermob->y = -1;
#endif
      }
      release_supermob(  );
   }
   else
      log_string( "Cannot open obj file" );

   return;
}
示例#30
0
void do_bind( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *obj;
   OBJ_DATA *tobj;
   int schance;
   CHAR_DATA *victim;
   bool checkbinders = FALSE;

   if( argument[0] == '\0' )
   {
      send_to_char( "Syntax: Bind <victim>\n\r", ch );
      return;
   }

   if( ( victim = get_char_room( ch, argument ) ) == NULL )
   {
      send_to_char( "They are not here.\n\r", ch );
      return;
   }

   if( victim == ch )
   {
      send_to_char( "You can not bind yourself!\n\r", ch );
      return;
   }

   if( IS_NPC( victim ) )
   {
      send_to_char( "You can only bind players.\n\r", ch );
      return;
   }

   if( IS_SET( victim->pcdata->act2, ACT_BOUND ) )
   {
      send_to_char( "They've already been bound!\n\r", ch );
      return;
   }

   for( obj = ch->last_carrying; obj; obj = obj->prev_content )
      if( obj->item_type == ITEM_BINDERS )
      {
         checkbinders = TRUE;
         break;
      }

   if( checkbinders == FALSE )
   {
      send_to_char( "You don't have any binders to bind them with.\n\r", ch );
      return;
   }

   if( victim->position != POS_STUNNED && victim->position != POS_SLEEPING )
   {
      send_to_char( "They need to be stunned or asleep.\n\r", ch );
      return;
   }

   schance = ( int )( ch->pcdata->learned[gsn_bind] );

   if( number_percent(  ) < schance )
   {
      separate_obj( obj );
      obj_from_char( obj );
      obj_to_char( obj, victim );
      act( AT_WHITE, "You quickly bind $N's wrists.", ch, NULL, victim, TO_CHAR );
      act( AT_WHITE, "$n quickly binds your wrists.", ch, NULL, victim, TO_VICT );
      act( AT_WHITE, "$n quickly binds $N's wrists.", ch, NULL, victim, TO_NOTVICT );
      tobj = get_eq_char( ch, WEAR_BOTH_WRISTS );
      if( tobj )
         unequip_char( ch, tobj );

      equip_char( victim, obj, WEAR_BOTH_WRISTS );
      SET_BIT( victim->pcdata->act2, ACT_BOUND );
      learn_from_success( ch, gsn_bind );
   }
   else
   {
      send_to_char( "You peer at the binders, curious upon how to use them.\n\r", ch );
      learn_from_failure( ch, gsn_bind );
   }

   return;
}