Esempio n. 1
0
void do_equipment( CHAR_DATA* ch, const char* argument)
{
   OBJ_DATA *obj;
   int iWear;
   bool found;

   set_char_color( AT_RED, ch );
   send_to_char( "You are using:\r\n", ch );
   found = FALSE;
   set_char_color( AT_OBJECT, ch );
   for( iWear = 0; iWear < MAX_WEAR; iWear++ )
   {
      for( obj = ch->first_carrying; obj; obj = obj->next_content )
         if( obj->wear_loc == iWear )
         {
            if( ( !IS_NPC( ch ) ) && ( ch->race > 0 ) && ( ch->race < MAX_PC_RACE ) )
               send_to_char( race_table[ch->race]->where_name[iWear], ch );
            else
               send_to_char( where_name[iWear], ch );

            if( can_see_obj( ch, obj ) )
            {
               send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
               send_to_char( "\r\n", ch );
            }
            else
               send_to_char( "something.\r\n", ch );
            found = TRUE;
         }
   }

   if( !found )
      send_to_char( "Nothing.\r\n", ch );
}
void show_char_to_char_2(struct char_data *victim, struct char_data *ch)
{
    struct gameobject *obj;
    struct dynamic_skill *skill_peek;
    int iWear;
    bool found;

    if (can_see(victim, ch)) {
	if (ch == victim) {
	    act("$n glances at $mself.", ch, NULL, NULL, TO_ROOM);
	} else {
	    act("$n glances at you.", ch, NULL, victim, TO_VICT);
	    act("$n glances at $N.", ch, NULL, victim, TO_NOTVICT);
	}
    }

    show_damage_display(ch, victim);

    found = false;
    for (iWear = 0; where_name[iWear].wear_loc >= 0; iWear++) {
	if ((obj = get_eq_char(victim, where_name[iWear].wear_loc)) != NULL
		&& can_see_obj(ch, obj)) {
	    if (!found) {
		send_to_char("\n\r", ch);
		act("$N is using:", ch, NULL, victim, TO_CHAR);
		found = true;
	    }
	    send_to_char(where_name[iWear].desc, ch);
	    send_to_char("(", ch);
	    send_to_char(format_obj_to_char(obj, ch, true), ch);
	    send_to_char(")", ch);
	    send_to_char("\n\r", ch);
	}
    }

    if (victim != ch && !IS_NPC(ch)
	    && (skill_peek = gsp_peek) != NULL
	    && number_percent() < get_learned_percent(ch, skill_peek)) {
	send_to_char("\n\rYou peek at the inventory:\n\r", ch);
	check_improve(ch, skill_peek, true, 4);
	show_list_to_char(victim->carrying, ch, true, true);
    }

    return;
}
void look_equipment(struct char_data *ch) {
    struct gameobject *obj;
    int iWear;

    send_to_char("`&  You are using: \n\r ------------------``\n\r", ch);
    for (iWear = 0; where_name[iWear].wear_loc >= 0; iWear++) {
	if ((obj = get_eq_char(ch, where_name[iWear].wear_loc)) == NULL) {
	    if (!(IS_SET(ch->act, PLR_AUTOEQ)))
		continue;

	    send_to_char("`1", ch);
	    send_to_char(where_name[iWear].desc, ch);

	    if (where_name[iWear].wear_loc == WEAR_THIRD) {
		send_to_char("`1     --Not Available--``\r\n", ch);
	    } else {
		if ((where_name[iWear].wear_loc == WEAR_FINGER_L2)) {
		    send_to_char("`1     --Not Available--``\r\n", ch);
		} else {
		    if ((where_name[iWear].wear_loc == WEAR_FINGER_R2)) {
			send_to_char("`1     --Not Available--``\r\n", ch);
		    } else {
			send_to_char("`1     --Empty--``\r\n", ch);
		    }
		}
	    }
	    continue;
	}

	send_to_char("`7", ch);
	send_to_char(where_name[iWear].desc, ch);
	send_to_char("`&", ch);
	if (can_see_obj(ch, obj)) {
	    send_to_char("`&", ch);
	    send_to_char(format_obj_to_char(obj, ch, true), ch);
	    send_to_char("``\n\r", ch);
	} else {
	    send_to_char("`&something.\n\r", ch);
	}
    }

    send_to_char("`8", ch);
}
/*
 * Show a list to a character.
 * Can coalesce duplicated items.
 */
void show_list_to_char(struct gameobject *list, struct char_data *ch, bool fShort, bool fShowNothing)
{
    struct gameobject *obj;
    char buf[13000];
    char **prgpstrShow;
    char *pstrShow;
    int *prgnShow;
    int nShow;
    int iShow;
    unsigned int count;
    bool fCombine;

    if (ch->desc == NULL)
	return;

    /*
     * Alloc space for output lines.
     */

    count = 0;
    for (obj = list; obj != NULL; obj = obj->next_content)
	count++;


    prgpstrShow = alloc_mem(count * (unsigned int)sizeof(char *));
    prgnShow = alloc_mem(count * (unsigned int)sizeof(int));

    nShow = 0;

    /*
     * Format the list of objects.
     */
    for (obj = list; obj != NULL; obj = obj->next_content) {
	if (obj->wear_loc == WEAR_NONE && can_see_obj(ch, obj)) {
	    pstrShow = format_obj_to_char(obj, ch, fShort);

	    fCombine = false;

	    if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE)) {
		/*
		 * Look for duplicates, case sensitive.
		 * Matches tend to be near end so run loop backwords.
		 */
		for (iShow = nShow - 1; iShow >= 0; iShow--) {
		    if (!strcmp(prgpstrShow[iShow], pstrShow)) {
			prgnShow[iShow]++;
			fCombine = true;
			break;
		    }
		}
	    }

	    /*
	     * Couldn't combine, or didn't want to.
	     */
	    if (!fCombine) {
		prgpstrShow[nShow] = str_dup(pstrShow);
		prgnShow[nShow] = 1;
		nShow++;

		if (nShow > 125) {
		    send_to_char("Tell whoever it is you are looking at to drop some crap.\n\r", ch);
		    send_to_char("Maximum number of items in a list exceeded.\n\r", ch);
		    return;
		}
	    }
	}
    }

    /*
     * Output the formatted list.
     */
    for (iShow = 0; iShow < nShow; iShow++) {
	if (prgpstrShow[iShow][0] == '\0') {
	    free_string(prgpstrShow[iShow]);
	    continue;
	}

	if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE)) {
	    if (prgnShow[iShow] != 1) {
		sprintf(buf, "(%3d) ", prgnShow[iShow]);
		send_to_char(buf, ch);
	    } else {
		send_to_char("      ", ch);
	    }
	}
	page_to_char(prgpstrShow[iShow], ch);
	send_to_char("\n\r", ch);
	free_string(prgpstrShow[iShow]);
    }

    if (fShowNothing && nShow == 0) {
	if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE))
	    send_to_char("     ", ch);

	send_to_char("Nothing.\n\r", ch);
    }

    /*
     * Clean up.
     */
    free_mem(prgpstrShow, count * (int)sizeof(char *));
    free_mem(prgnShow, count * (int)sizeof(int));

    return;
}
Esempio n. 5
0
void do_equipment( CHAR_DATA * ch, const char *argument )
{
   OBJ_DATA *obj;
   int iWear, dam;
   bool found;
   char buf[MAX_STRING_LENGTH];

   set_char_color( AT_RED, ch );
   send_to_char( "You are using:\r\n", ch );
   found = FALSE;
   set_char_color( AT_OBJECT, ch );
   for( iWear = 0; iWear < MAX_WEAR; iWear++ )
   {
      for( obj = ch->first_carrying; obj; obj = obj->next_content )
         if( obj->wear_loc == iWear )
         {
            send_to_char( where_name[iWear], ch );
            if( can_see_obj( ch, obj ) )
            {
               send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
               strcpy( buf, "" );
               switch ( obj->item_type )
               {
                  default:
                     break;

                  case ITEM_BACTA:
                     ch_printf( ch, " %d", obj->value[0] );
                     break;

                  case ITEM_ARMOR:
                     if( obj->value[1] == 0 )
                        obj->value[1] = obj->value[0];
                     if( obj->value[1] == 0 )
                        obj->value[1] = 1;
                     dam = ( short )( ( obj->value[0] * 10 ) / obj->value[1] );
                     if( dam >= 10 )
                        strcat( buf, " (superb) " );
                     else if( dam >= 7 )
                        strcat( buf, " (good) " );
                     else if( dam >= 5 )
                        strcat( buf, " (worn) " );
                     else if( dam >= 3 )
                        strcat( buf, " (poor) " );
                     else if( dam >= 1 )
                        strcat( buf, " (awful) " );
                     else if( dam == 0 )
                        strcat( buf, " (broken) " );
                     send_to_char( buf, ch );
                     break;

                  case ITEM_WEAPON:
                     dam = INIT_WEAPON_CONDITION - obj->value[0];
                     if( dam < 2 )
                        strcat( buf, " (superb) " );
                     else if( dam < 4 )
                        strcat( buf, " (good) " );
                     else if( dam < 7 )
                        strcat( buf, " (worn) " );
                     else if( dam < 10 )
                        strcat( buf, " (poor) " );
                     else if( dam < 12 )
                        strcat( buf, " (awful) " );
                     else if( dam == 12 )
                        strcat( buf, " (broken) " );
                     send_to_char( buf, ch );
                     if( obj->value[3] == WEAPON_BLASTER )
                     {
                        if( obj->blaster_setting == BLASTER_FULL )
                           ch_printf( ch, "FULL" );
                        else if( obj->blaster_setting == BLASTER_HIGH )
                           ch_printf( ch, "HIGH" );
                        else if( obj->blaster_setting == BLASTER_NORMAL )
                           ch_printf( ch, "NORMAL" );
                        else if( obj->blaster_setting == BLASTER_HALF )
                           ch_printf( ch, "HALF" );
                        else if( obj->blaster_setting == BLASTER_LOW )
                           ch_printf( ch, "LOW" );
                        else if( obj->blaster_setting == BLASTER_STUN )
                           ch_printf( ch, "STUN" );
                        ch_printf( ch, " %d", obj->value[4] );
                     }
                     else if( ( obj->value[3] == WEAPON_LIGHTSABER ||
                                obj->value[3] == WEAPON_VIBRO_BLADE
                                || obj->value[3] == WEAPON_FORCE_PIKE || obj->value[3] == WEAPON_BOWCASTER ) )
                     {
                        ch_printf( ch, "%d", obj->value[4] );
                     }
                     break;
               }
               send_to_char( "\r\n", ch );
            }
            else
               send_to_char( "something.\r\n", ch );
            found = TRUE;
         }
   }

   if( !found )
      send_to_char( "Nothing.\r\n", ch );

   return;
}