Ejemplo n.º 1
0
static const char *prep_find_entity_vnum(struct char_data *ch, const char *argument, char *arg, const char *entity,
                                         void (*help_entity_properties_fn)(struct char_data *ch),
                                         void (*entity_empty_fn)(struct char_data *ch, const char *arg, struct buf_type *buffer))
{
    if (ch == NULL || IS_NPC(ch))
        return NULL;

    if (argument[0] == '\0') {
        char buf[200];
        snprintf(buf, 200, "\n\r%s: Find what?\n\r", entity);
        send_to_char(buf, ch);
        return NULL;
    }

    argument = one_argument(argument, arg);
    if (arg[0] == '?' || !str_prefix(arg, "help")) {
        show_help(ch->desc, (char *)entity, NULL);
        return NULL;
    }

    if (!str_prefix(arg, "list")) {
        (*help_entity_properties_fn)(ch);
        return NULL;
    } else
        if (!str_prefix(arg, "empty")) {
            struct buf_type *buffer = new_buf();
            argument = one_argument(argument, arg);
            (*entity_empty_fn)(ch, arg, buffer);
            page_to_char(buf_string(buffer), ch);
            free_buf(buffer);
            return NULL;
        }

    return argument;
}
Ejemplo n.º 2
0
/*
 * Displays the source code of a given MOBprogram
 *
 * Syntax: mpdump [vnum]
 */
void do_mpdump(CHAR_DATA * ch, char *argument)
{
    char buf[MAX_INPUT_LENGTH];
    MPROG_CODE *mprg;

    one_argument(argument, buf);
    if ((mprg = get_mprog_index(atoi(buf))) == NULL) {
	send_to_char("No such MOBprogram.\n\r", ch);
	return;
    }
    page_to_char(mprg->code, ch);
}
Ejemplo n.º 3
0
Archivo: send.c Proyecto: verias/SRMud
void do_replay (CHAR_DATA *ch, char *argument)
{
    if (IS_NPC(ch))
    {
	send_to_char("You can't replay.\n\r",ch);
	return;
    }

    if (buf_string(ch->pcdata->buffer)[0] == '\0')
    {
	send_to_char("You have no tells to replay.\n\r",ch);
	return;
    }

    page_to_char(buf_string(ch->pcdata->buffer),ch);
    clear_buf(ch->pcdata->buffer);
}
Ejemplo n.º 4
0
static void help_mvnum_properties(struct char_data *ch)
{
    struct buf_type *buffer = new_buf();
    char buf[MAX_INPUT_LENGTH];
    int iter;

    add_buf(buffer, "`#QUERY``: mvnum: searchable property list\n\r");
    for (iter = 0; mob_idx_flags[iter].var[0] != '\0'; iter++) {
        sprintf(buf, "%-18.17s", mob_idx_flags[iter].var);
        add_buf(buffer, buf);
        if ((iter % 2) == 1)
            add_buf(buffer, "\n\r");
    }
    add_buf(buffer, "\n\r");
    page_to_char(buf_string(buffer), ch);
    free_buf(buffer);
}
Ejemplo n.º 5
0
void do_matlist(CHAR_DATA *ch, char *argument) {
	MAT_TYPE *mat, *mat_next;
	BUFFER *output = new_buf();
	int col = 0;
	for(mat = mat_list; mat; mat = mat_next) {
		mat_next = mat->next;

		add_buf(output, Format("%-15s", mat->name) );
		if(++col == 5) {
			col = 0;
			add_buf(output, "\n\r");
		}
	}
	page_to_char(buf_string(output), ch);
	free_buf(output);
	return;
}
Ejemplo n.º 6
0
void
do_mplist (CHAR_DATA * ch, char *argument)
{
  int count;
  MPROG_CODE *mprg;
  char buf[MAX_STRING_LENGTH];
  BUFFER *buffer;
  buffer = new_buf ();

  for (count = 1, mprg = mprog_list; mprg != NULL; mprg = mprg->next)
    {
      sprintf (buf, "[%3d] %5d\n\r", count, mprg->vnum);
      add_buf (buffer, buf);
      count++;
    }
  page_to_char (buf_string (buffer), ch);
  free_buf (buffer);
  return;
}
Ejemplo n.º 7
0
void do_omni( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    char buf2[MAX_STRING_LENGTH];
    BUFFER *output;
    DESCRIPTOR_DATA *d;
    int immmatch;
    int mortmatch;
    int hptemp;  
 /*
 * Initalize Variables.
 */

    immmatch = 0;
       mortmatch = 0;
    buf[0] = '\0';
    output = new_buf();

 /*          
 * Count and output */
      sprintf(buf,"\n\r{B---{WI{wm{Wm{wo{Wr{wt{Wa{wl{Ws{B----{x\n\r");
        add_buf(output,buf);
        sprintf( buf, "{WN{wa{Wm{we           {WL{we{Wv{we{Wl   {WW{wi{Wz      {WI{wn{Wc{wo{Wg    {WG{wh{Wo{ws{Wt    {W[{wV{Wn{wu{Wm{W]{x\n\r");      
        add_buf(output,buf);
    for ( d = descriptor_list; d != NULL; d = d->next )
    {
        CHAR_DATA *wch;

        if ( d->connected != CON_PLAYING || !can_see( ch, d->character ) )    
            continue;

        wch   = ( d->original != NULL ) ? d->original : d->character;

        if (!can_see(ch,wch)  || wch->level < 102)
            continue;

        immmatch++;

        sprintf( buf, "{R%-14s %-3d     %-3d      %-3d      %-3d      [%-3d]{x\n\r",
                        wch->name,
                        wch->level,
                        wch->invis_level,
                        wch->incog_level,
			   wch->ghost_level,
                        wch->in_room->vnum);
                        add_buf(output,buf);
    }


 /*
 * Count and output the Morts.
 */
        sprintf( buf, " \n\r {B----{YM{yo{Yr{yt{Ya{yl{Ys{B----{x\n\r");
        add_buf(output,buf);
        sprintf( buf, "{WN{wa{Wm{we           {WG{wo{Wd      {WR{wa{Wc{we{W/{wC{Wl{wa{Ws{ws  {WP{wo{Ws{wi{Wt{wi{Wo{wn      {WL{we{Wv   {w%%{Wh{wp{Ws    {w[{WV{wn{Wu{wm{W]{x\n\r");   

        add_buf(output,buf);
        hptemp = 0;

   for ( d = descriptor_list; d != NULL; d = d->next )    
    {
        CHAR_DATA *wch;
        char const *class;

        if ( d->connected != CON_PLAYING || !can_see( ch, d->character ) )
            continue;

        wch   = ( d->original != NULL ) ? d->original : d->character;

        if (!can_see(ch,wch) || wch->level > ch->level || wch->level > 101)   
            continue;

        mortmatch++;
        if ((wch->max_hit != wch->hit) && (wch->hit > 0))
                hptemp = (wch->hit*100)/wch->max_hit;
        else if (wch->max_hit == wch->hit)
                hptemp = 100;
        else if (wch->hit < 0)
                hptemp = 0;    

        class = class_table[wch->class].who_name;

        sprintf( buf, "{G%-14s %-7s  %6.6s/%3.3s  %-10s    %-3d   %-3d%%    [%-3d]{x\n\r",
                wch->name,
                IS_GOOD(wch)? "Good" : IS_EVIL(wch) ? "Evil" : "Neutral",
                wch->race < MAX_PC_RACE ? pc_race_table[wch->race].who_name : " ",
                class,
                capitalize( position_table[wch->position].name) ,
                wch->level,
                hptemp,
                wch->in_room->vnum);
        add_buf(output,buf);
    }

/*
 * Tally the counts and send the whole list out.
 */
   sprintf( buf2, "\n\r{CIMMs found: {w%d{x\n\r", immmatch );
    add_buf(output,buf2);
    sprintf( buf2, "{CMorts found: {y%d{x\n\r", mortmatch );    
    add_buf(output,buf2);
    page_to_char( buf_string(output), ch );
    free_buf(output);
    return;
}                          
Ejemplo n.º 8
0
/**
 * owhere <var> <value>
 */
void do_owhere(struct char_data *ch, const char *argument)
{
    struct buf_type *buffer;
    OBJ_CMP_FN *cmp_fn;
    char buf[MAX_INPUT_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    int iter;

    if (ch == NULL || IS_NPC(ch))
        return;

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

    cmp_fn = NULL;
    one_argument(argument, arg);

    if (argument[0] == '?' || !str_prefix(argument, "help")) {
        show_help(ch->desc, "owhere", NULL);
        return;
    }

    buffer = new_buf();
    if (!str_prefix(argument, "list")) {
        add_buf(buffer, "owhere: searchable property list\n\r");
        for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) {
            sprintf(buf, "%-18.17s", obj_flags[iter].var);
            add_buf(buffer, buf);
            if ((iter % 2) == 1)
                add_buf(buffer, "\n\r");
        }
        add_buf(buffer, "\n\r");
        page_to_char(buf_string(buffer), ch);
        return;
    }

    sprintf(buf, "`#QUERY``: owhere %s\n\r\n\r", argument);
    add_buf(buffer, buf);

    for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) {
        if (!str_prefix(arg, obj_flags[iter].var)) {
            cmp_fn = (OBJ_CMP_FN *)obj_flags[iter].fn;
            argument = one_argument(argument, arg);
            break;
        }
    }

    if (cmp_fn == NULL)
        cmp_fn = obj_cmp_name;


    if (argument[0] == '?' || argument[0] == '\0') {
        clear_buf(buffer);
        sprintf(buf, "`#SYNTAX``:\n\r    owhere %s <value>:\n\r\n\r", arg);
        add_buf(buffer, buf);

        (*cmp_fn)(object_iterator_start(&object_empty_filter), argument, buffer);
        page_to_char(buf_string(buffer), ch);
    } else {
        struct gameobject *obj, *opending;
        struct gameobject *in_obj;
        char *clr1;
        char *clr2;
        int number;

        number = 0;

        opending = object_iterator_start(&object_empty_filter);
        while ((obj = opending) != NULL) {
            opending = object_iterator(obj, &object_empty_filter);

            if (can_see_obj(ch, obj)
                && (*cmp_fn)(obj, argument, NULL)) {
                number++;
                if (number == 1) {
                    sprintf(buf, "#   vnum   name                        where                      room\n\r");
                    add_buf(buffer, buf);
                    sprintf(buf, "=== ====== =========================== ========================== =====\n\r");

                    add_buf(buffer, buf);
                }

                for (in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj)
                    continue;

                if (in_obj->carried_by != NULL
                    && can_see(ch, in_obj->carried_by)
                    && in_obj->carried_by->in_room != NULL) {
                    clr1 = uncolor_str(obj->short_descr);
                    clr2 = uncolor_str(PERS(in_obj->carried_by, ch));
                    sprintf(buf, "%-3d %-7ld  %-26.26s  %-25.25s  %-7ld\n\r",
                            number,
                            obj->objprototype->vnum,
                            clr1,
                            clr2,
                            in_obj->carried_by->in_room->vnum);
                    free_string(clr1);
                    free_string(clr2);
                } else if (in_obj->in_room != NULL && can_see_room(ch, in_obj->in_room)) {
                    clr1 = uncolor_str(obj->short_descr);
                    clr2 = uncolor_str(in_obj->in_room->name);

                    sprintf(buf, "%-3d %-7ld  %-26.26s  %-25.25s  %-7ld\n\r",
                            number,
                            obj->objprototype->vnum,
                            clr1,
                            clr2,
                            in_obj->in_room->vnum);
                    free_string(clr1);
                    free_string(clr2);
                } else {
                    clr1 = uncolor_str(obj->short_descr);

                    sprintf(buf, "%-3d %-7ld  %-26.26s\n\r",
                            number,
                            obj->objprototype->vnum,
                            clr1);
                    free_string(clr1);
                }

                buf[0] = UPPER(buf[0]);
                add_buf(buffer, buf);

                if (number >= MAX_RETURN)
                    break;
            }
        }


        if (number == 0)
            send_to_char("Nothing like that in heaven or earth.\n\r", ch);
        else
            page_to_char(buf_string(buffer), ch);
    }

    free_buf(buffer);
}
Ejemplo n.º 9
0
void do_ban(CHAR_DATA *ch, char *argument)
{
    char buf[MSL];
	char arg1[MSL], arg2[MSL], arg3[MSL], arg4[MSL], date[MSL];
    BUFFER *buffer;
    int ban_type=0,host_type=0,res,duration=0;
	CRow row;
	
	argument = one_argument(argument,arg1);
    argument = one_argument(argument,arg2);
	argument = one_argument(argument,arg3);
	argument = one_argument(argument,arg4);
	
	if (arg1[0] != '\0' && !str_prefix(arg1,"show"))
    {
		res = RS.SQL.Select("bans.*,DATE_FORMAT(date,\'%%m/%%d/%%Y\') FROM bans ORDER BY duration DESC");
		if(res)
		{
			buffer = new_buf();
			
			sprintf(buf,"%-25s\t%-10s\t%-10s\t%-10s\t%-10s\t%-10s\n\r", "Site", "By", "Type", "Date", "Duration", "Reason");
			add_buf(buffer,buf);
			while(!RS.SQL.End())
			{
				row = RS.SQL.GetRow();
			
				sprintf(buf,"%-25s\t%-10s\t%-10s\t%-10s\t%-10s\t%-10s\n\r",row[0],row[1],(atoi(row[5]) > 0) ? "Newbie" : "All",row[7],row[4],row[2]);
				
				add_buf(buffer,buf);
			}
			
			page_to_char( buf_string(buffer), ch );
			free_buf(buffer);
		}
		else
			send_to_char("There are no current bans placed.\n\r", ch);
        return;
    }

    if (arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0' || arg4[0] == '\0')
	{
		do_ban(ch,"show");
		send_to_char("Syntax:    ban <site> <ip/host> <newbie/all> <duration> <reason>    (-1 duration is permanent)\n\r"\
							"           unban <site>\n\r"\
							"           ban show\n\r",ch);
		return;
	}

	if (!str_prefix(arg2,"ip"))
		host_type = NBAN_IP;
	else if (!str_prefix(arg2,"host"))
		host_type = NBAN_HOST;
	else
		return do_ban(ch,"");

    if (!str_prefix(arg3,"all"))
		ban_type = NBAN_ALL;
    else if (!str_prefix(arg3,"newbie"))
		ban_type = NBAN_NEWBIE;
    else
		return do_ban(ch,"");

	duration = atoi(arg4);

	strftime(date, 200, "%Y-%m-%d", localtime(&current_time));

	res = RS.SQL.Insert("bans VALUES(\'%s\',\'%s\',\'%s\',\'%s\',%d,%d,%d)",
			arg1,ch->true_name,argument,date,duration,ban_type,host_type);
	if(res)
		return send_to_char("Ban added.\n\r", ch);
	else
		return send_to_char("Ban failed, error..yell at Morglum.\n\r", ch);
}
Ejemplo n.º 10
0
void ban_site( CHAR_DATA *ch, char *argument )
{
	char date[ 50 ];
	struct tm *btime;
    char buf[ MAX_STRING_LENGTH ], buf2[ MAX_STRING_LENGTH ], buf3[ MAX_STRING_LENGTH ];
    char arg1[ MAX_INPUT_LENGTH ], arg2[ MAX_INPUT_LENGTH ], arg3[ MAX_INPUT_LENGTH ];
    char *name;
    BUFFER *buffer;
    BAN_DATA *pban, *prev;
    bool prefix = FALSE, suffix = FALSE;
    int type;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    if ( arg1[ 0 ] == '\0' )
    {
        if ( ban_list == NULL )
        {
            send_to_char( "Nie ma ¿adnych banów.\n\r", ch );
            return ;
        }
        buffer = new_buf();

        add_buf( buffer, "{CAdres                                       Kto        Typ{x\n\r" );
        for ( pban = ban_list;pban != NULL;pban = pban->next )
        {
            sprintf( buf2, "%s%s%s",
                     IS_SET( pban->ban_flags, BAN_PREFIX ) ? "*" : "",
                     pban->site,
                     IS_SET( pban->ban_flags, BAN_SUFFIX ) ? "*" : "" );

            btime = localtime( &pban->date_stamp );
            strftime( date, 20, "%d-%m-%Y %H:%M:%S", btime );

            if ( pban->period <= 0 )
                sprintf( buf3, "od %s na sta³e", date );
            else if ( pban->period == 1 )
                sprintf( buf3, "od %s na 1 dzieñ", date );
            else
                sprintf( buf3, "od %s na %d dni", date, pban->period );

            sprintf( buf, "{Y%-40s{x    %-10s %-7s\n\r{CCzas{x: %s\n\r{CPowód{x: %s\n\r",
                     buf2, pban->person,
                     IS_SET( pban->ban_flags, BAN_NEWBIES ) ? "newbies" :
                     IS_SET( pban->ban_flags, BAN_PERMIT ) ? "permit" :
                     IS_SET( pban->ban_flags, BAN_ALL ) ? "all"	: "",
                     buf3,
                     IS_NULLSTR(pban->reason) ? "nie podano" : pban->reason );
            add_buf( buffer, buf );
            if ( pban->next )
            add_buf( buffer, "\n\r" );
        }

        add_buf( buffer, "\n\rDodanie nowego bana:\n\r" );
        add_buf( buffer, "permban [*]<adres>[*] all|newbies|permit <ile dni> [<powod>]\n\r" );
        add_buf( buffer, "- podanie 0 przy liczbie dni oznacza ban na sta³e\n\r" );
        page_to_char( buf_string( buffer ), ch );
        free_buf( buffer );
        return ;
    }

    /* find out what type of ban */
    if ( !str_prefix( arg2, "permit" ) )
        type = BAN_PERMIT;
    else if ( !str_prefix( arg2, "newbies" ) )
        type = BAN_NEWBIES;
    else if ( !str_prefix( arg2, "all" ) )
        type = BAN_ALL;
    else
    {
        send_to_char( "Dopuszczalne typy bana to: all, newbies, permit.\n\r", ch );
        return ;
    }

    name = arg1;

    if ( name[ 0 ] == '*' )
    {
        prefix = TRUE;
        name++;
    }

    if ( name[ strlen( name ) - 1 ] == '*' )
    {
        suffix = TRUE;
        name[ strlen( name ) - 1 ] = '\0';
    }

    if ( strlen( name ) == 0 )
    {
        send_to_char( "Nie poda³e¶ adresu do zbanowania.\n\r", ch );
        return ;
    }

    if ( arg3[0] == '\0' || !is_number( arg3 ) )
    {
        send_to_char( "Podaj liczbê dni przez jak± ma trwaæ ban (0 - ca³y czas).\n\r", ch );
        return;
    }

    prev = NULL;
    for ( pban = ban_list; pban != NULL; prev = pban, pban = pban->next )
    {
        if ( !str_cmp( name, pban->site ) )
        {
            if ( prev == NULL )
                ban_list = pban->next;
            else
                prev->next = pban->next;
            free_ban( pban );
        }
    }

    pban = new_ban();
    pban->site   = str_dup( name );
    pban->person = str_dup( ch->name );
    pban->date_stamp = current_time;
    pban->period = UMAX( 0, atoi( arg3 ) );
    pban->reason = str_dup( argument );

    /* set ban type */
    pban->ban_flags = type;

    if ( prefix )
        SET_BIT( pban->ban_flags, BAN_PREFIX );
    if ( suffix )
        SET_BIT( pban->ban_flags, BAN_SUFFIX );

    pban->next = ban_list;
    ban_list = pban;
    save_bans();
    sprintf( buf, "Adres %s zosta³ dodany do listy banów.\n\r", pban->site );
    send_to_char( buf, ch );
    return ;
}
Ejemplo n.º 11
0
void do_play(CHAR_DATA *ch, char *argument)
{
    OBJ_DATA *juke;
    char *str,arg[MAX_INPUT_LENGTH];
    int song,i;
    bool global = FALSE;

    str = one_argument(argument,arg);

    for (juke = ch->in_room->contents; juke != NULL; juke = juke->next_content)
	if (juke->item_type == ITEM_JUKEBOX && can_see_obj(ch,juke))
	    break;

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

    if (juke == NULL)
    {
	send_to_char("You see nothing to play.\n\r",ch);
	return;
    }

    if (!str_cmp(arg,"list"))
    {
	BUFFER *buffer;
  	char buf[MSL]={'\0'};
	int col = 0;
	bool artist = FALSE, match = FALSE;

	buffer = new_buf();
	argument = str;
	argument = one_argument(argument,arg);

	if (!str_cmp(arg,"artist"))
	    artist = TRUE;

	if (argument[0] != '\0')
	    match = TRUE;

	sprintf(buf,"%s has the following songs available:\n\r",
	    juke->short_descr);
	add_buf(buffer,capitalize(buf));

	for (i = 0; i < MAX_SONGS; i++)
	{
	    if (song_table[i].name == NULL)
		break;

	    if (artist && (!match 
	    || 		   !str_prefix(argument,song_table[i].group)))
		sprintf(buf,"%-39s %-39s\n\r",
		    song_table[i].group,song_table[i].name);
	    else if (!artist && (!match 
	    || 	 		 !str_prefix(argument,song_table[i].name)))
	    	sprintf(buf,"%-35s ",song_table[i].name);
	    else
		continue;
	    add_buf(buffer,buf);
	    if (!artist && ++col % 2 == 0)
		add_buf(buffer,"\n\r");
        }
        if (!artist && col % 2 != 0)
	    add_buf(buffer,"\n\r");

	page_to_char(buf_string(buffer),ch);
	free_buf(buffer);
	return;
    }

    if (!str_cmp(arg,"loud"))
    {
        argument = str;
        global = TRUE;
    }

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

    if ((global && channel_songs[MAX_GLOBAL] > -1) 
    ||  (!global && juke->value[4] > -1))
    {
        send_to_char("The jukebox is full up right now.\n\r",ch);
        return;
    }

    for (song = 0; song < MAX_SONGS; song++)
    {
	if (song_table[song].name == NULL)
	{
	    send_to_char("That song isn't available.\n\r",ch);
	    return;
	}
	if (!str_prefix(argument,song_table[song].name))
	    break;
    }

    if (song >= MAX_SONGS)
    {
	send_to_char("That song isn't available.\n\r",ch);
	return;
    }

    send_to_char("Coming right up.\n\r",ch);

    if (global)
    {
	for (i = 1; i <= MAX_GLOBAL; i++)
	    if (channel_songs[i] < 0)
	    {
		if (i == 1)
		    channel_songs[0] = -1;
		channel_songs[i] = song;
		return;
	    }
    }
    else 
    {
	for (i = 1; i < 5; i++)
	    if (juke->value[i] < 0)
	    {
		if (i == 1)
		    juke->value[0] = -1;
		juke->value[i] = song;
		return;
	     }
    }
}
Ejemplo n.º 12
0
void replay(struct char_data *ch) {
    page_to_char(buf_string(ch->pcdata->buffer), ch);
    clear_buf(ch->pcdata->buffer);
    return;
}
Ejemplo n.º 13
0
//********************KONIEC PRZYTRZYMUJACYCH*******************//
//to jest do_owhere() tylko zmodyfikowany na potrzeby do_astat()
void awhere( CHAR_DATA *ch, char *argument )
{
	char buf[ MAX_INPUT_LENGTH ];
	BUFFER *buffer = NULL;
	OBJ_DATA *obj;
	OBJ_DATA *in_obj;
	bool found;
	int vnum = -1;

	found = FALSE;

	buffer = new_buf();

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

	if ( is_number( argument ) )
		vnum = atoi( argument );

	for ( obj = object_list; obj != NULL; obj = obj->next )
	{
		if ( vnum > 0 )
		{
			if ( !can_see_obj( ch, obj ) || obj->pIndexData->vnum != vnum )
				continue;
		}
		else
		{
			if ( !can_see_obj( ch, obj ) || !is_name( argument, obj->name ) )
				continue;
		}

		found = TRUE;

		for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj );

		if ( in_obj->carried_by != NULL && can_see( ch, in_obj->carried_by )
		     && in_obj->carried_by->in_room != NULL )
			sprintf( buf, " %s jest noszone przez %s [Room %d]\n\r",
			         obj->short_descr, PERS( in_obj->carried_by, ch ),
			         in_obj->carried_by->in_room->vnum );
		else if ( in_obj->in_room != NULL && can_see_room( ch, in_obj->in_room ) )
			sprintf( buf, " %s jest w %s [Room %d]\n\r",
			         obj->short_descr, in_obj->in_room->name,
			         in_obj->in_room->vnum );
		else
			sprintf( buf, " %s jest gdzies\n\r", obj->short_descr );

		sprintf( buf, "%s", capitalize( buf ) );
		add_buf( buffer, buf );

	}

	if ( !found )
		send_to_char( "	Niczego takiego nie ma aktualnie w grze.\n\r", ch );
	else
		page_to_char( buf_string( buffer ), ch );

	free_buf( buffer );
}
Ejemplo n.º 14
0
void parse_note( CHAR_DATA *ch, char *argument, int type )
{
	char arg[MAX_INPUT_LENGTH];
	NOTE_DATA *pnote;
	NOTE_DATA **list;
	char *list_name;
	int vnum = 0;
	int anum = 0;

	if ( IS_NPC(ch) )
		return;

	switch(type)
	{
		default:
		return;
		case NOTE_NOTE:
		list = &note_list;
		list_name = "notes";
		break;
		case NOTE_IDEA:
		list = &idea_list;
		list_name = "ideas";
		break;
		case NOTE_PENALTY:
		list = &penalty_list;
		list_name = "penalties";
		break;
		case NOTE_NEWS:
		list = &news_list;
		list_name = "news";
		break;
		case NOTE_CHANGES:
		list = &changes_list;
		list_name = "changes";
		break;
	}

	argument = one_argument( argument, arg );
	smash_tilde( argument );

	if ( arg[0] == '\0' || !str_prefix( arg, "read" ) )
	{
		bool fAll;

		if ( !str_cmp( argument, "all" ) )
		{
			fAll = TRUE;
			anum = 0;
		}

		else if ( argument[0] == '\0' || !str_prefix(argument, "next"))
		/* read next unread note */
		{
			vnum = 0;
			for ( pnote = *list; pnote != NULL; pnote = pnote->next)
			{
				if (!hide_note(ch,pnote))
				{
					send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
						vnum,
						pnote->sender,
						pnote->subject,
						pnote->date,
						pnote->to_list), ch );
					page_to_char( pnote->text, ch );
					update_read(ch,pnote);
					return;
				}
				else if (is_note_to(ch,pnote))
					vnum++;
			}
			send_to_char( Format("You have no unread %s.\n\r",list_name),ch);
			return;
		}

		else if ( is_number( argument ) )
		{
			fAll = FALSE;
			anum = atoi( argument );
		}
		else
		{
			send_to_char( "Read which number?\n\r", ch );
			return;
		}

		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) )
			{
				send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
					vnum - 1,
					pnote->sender,
					pnote->subject,
					pnote->date,
					pnote->to_list), ch );
				page_to_char( pnote->text, ch );
				update_read(ch,pnote);
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.\n\r",list_name),ch);
		return;
	}

	if ( !str_prefix( arg, "list" ) )
	{
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) )
			{
				send_to_char( Format("[%3d%s] %s: %s\n\r",
					vnum, hide_note(ch,pnote) ? " " : "N", 
					pnote->sender, pnote->subject), ch );
				vnum++;
			}
		}
		if (!vnum)
		{
			switch(type)
			{
				case NOTE_NOTE:	
				send_to_char("There are no notes for you.\n\r",ch);
				break;
				case NOTE_IDEA:
				send_to_char("There are no ideas for you.\n\r",ch);
				break;
				case NOTE_PENALTY:
				send_to_char("There are no penalties for you.\n\r",ch);
				break;
				case NOTE_NEWS:
				send_to_char("There is no news for you.\n\r",ch);
				break;
				case NOTE_CHANGES:
				send_to_char("There are no changes for you.\n\r",ch);
				break;
			}
		}
		return;
	}

	if ( !str_prefix( arg, "remove" ) )
	{
		if ( !is_number( argument ) )
		{
			send_to_char( "Note remove which number?\n\r", ch );
			return;
		}

		anum = atoi( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && vnum++ == anum )
			{
				note_remove( ch, pnote, FALSE );
				send_to_char( "Ok.\n\r", ch );
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.",list_name),ch);
		return;
	}

	if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1)
	{
		if ( !is_number( argument ) )
		{
			send_to_char( "Note delete which number?\n\r", ch );
			return;
		}

		anum = atoi( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && vnum++ == anum )
			{
				note_remove( ch, pnote,TRUE );
				send_to_char( "Ok.\n\r", ch );
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.",list_name),ch);
		return;
	}

	if (!str_prefix(arg,"catchup"))
	{
		switch(type)
		{
			case NOTE_NOTE:	
			ch->pcdata->last_note = current_time;
			break;
			case NOTE_IDEA:
			ch->pcdata->last_idea = current_time;
			break;
			case NOTE_PENALTY:
			ch->pcdata->last_penalty = current_time;
			break;
			case NOTE_NEWS:
			ch->pcdata->last_news = current_time;
			break;
			case NOTE_CHANGES:
			ch->pcdata->last_changes = current_time;
			break;
		}
		return;
	}

	/* below this point only certain people can edit notes */
	if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL))
		||  (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR)))
	{
		send_to_char( Format("You aren't high enough level to write %s.",list_name),ch);
		return;
	}

	if ( !str_cmp ( arg, "new" ) || !str_cmp ( arg, "write" ) ) {
		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			send_to_char ( "You already have a different note in progress.\n\r", ch );
			return;
		}
		ch->desc->connected = CON_NOTE_TO;
		send_to_char ( "Address this message to whom: (all, staff, <name>) ", ch );
		return;
	}

	send_to_char( "You can't do that.\n\r", ch );
	return;
}
Ejemplo n.º 15
0
void friend_list( CHAR_DATA *ch, char *argument )
{
	FRIEND_LIST *wsk;
	char buf[ MAX_STRING_LENGTH ];
	BUFFER *output;
	output = new_buf();
	char *name;
	char *opis;
	time_t czas;
	bool introduced;
	
    if ( !ch || IS_NPC( ch ) ) return;

	name = strdup( " " );
	opis = strdup( "#!#" );

	if ( !ch ) return;

	if ( argument[0] != '\0' )
	{
		if ( friend_exist( ch, argument, name, opis, &czas, &introduced ) )
		{
			print_char( ch, "%s, to imiê brzmi jako¶ znajomo.\n\r", name );
			if ( strcmp( opis, "#!#" ) )
			{
				print_char( ch, "Z tym imieniem kojarzy ci siê: %s.\n\r", opis );
			}
			//current_time - czas ) / 360 => czas znajomosci w godzinach
			// TIME_TO_FORGET_FRIEND * 24 => czas do zapomnienia w godzinach bo TIME_TO... jest w dniach
			if ( ( ( current_time - czas ) / 3600 ) > ( ( TIME_TO_FORGET_FRIEND * 24 ) * 2 ) / 3 )
			{
				print_char( ch, "Zaczynasz powoli zapominaæ t± osobê.\n\r");
			}
		} else {
			print_char( ch, "Nie mo¿esz sobie przypomnieæ %s.\n\r", argument );
		}
		return;
	}

	send_to_char( "\n\r{gOsoby, które znasz\n\r--------------------------\n\r{x", ch );
	for( wsk = ch->pcdata->friends; wsk; wsk = wsk->next )
	{
		//current_time - czas ) / 360 => czas znajomosci w godzinach
		// TIME_TO_FORGET_FRIEND * 24 => czas do zapomnienia w godzinach bo TIME_TO... jest w dniach
		if ( ( ( current_time - wsk->czas ) / 3600 ) > ( ( TIME_TO_FORGET_FRIEND * 24 ) * 2 ) / 3)
		{
			sprintf( buf, "{s*{x" );
			add_buf( output, buf );
		}
		sprintf( buf, "{g%s{x", wsk->name );
		add_buf( output, buf );
		sprintf( buf, "	%c 		 	", wsk->introduced? 'v':'x' );
		add_buf( output, buf );
		sprintf( buf, "{G%s{x\n\r", wsk->opis );
		add_buf( output, buf );
	}
	page_to_char( buf_string( output ), ch );
	send_to_char( "{g--------------------------\n\r{x", ch );
	free_buf( output );
	return;
}
Ejemplo n.º 16
0
void 
do_slist (CHAR_DATA * ch, char *argy)
{
  SPELL_DATA *spellstuff[500];
  char buf[STD_LENGTH];
  SPELL_DATA *spell;
  int sn;
  int mnum = 0;
  int level;
  char bbb[40];
  short slot;
  DEFINE_COMMAND ("slist", do_slist, POSITION_DEAD, 1, LOG_NORMAL, "This command lists spells/skills.")

    if (argy[0] == '\0' || argy == "")
    {
      send_to_char ("'slist spells': list all spells in the game.\n\r'slist skills': list all skills in the game.\n\r'slist prof' lists all of the proficiencies in the game.\n\r", ch);
      return;
    }
  if (!str_cmp (argy, "spells"))
    slot = 1;
  else if (!str_cmp (argy, "skills"))
    slot = 0;
  else if (!str_cmp (argy, "prof") || !str_cmp(argy, "proficiencies"))
    slot = 2;
  else
    {
      if ((spell = skill_lookup (argy, -1)) == NULL)
	{
	  send_to_char ("Valid argys are 'spells' or 'skills' or 'prof' ...or slist <specific spell/skill>.\n\r", ch);
	  return;
	}
      do_info_sp_sk (ch, spell);
      return;
    }
  
  hugebuf_o[0] = '\0';
  switch(slot)
    {
    case 0:
      strcat(hugebuf_o, "Skills available:\n\rLv Skills\n\r----------\n\r");
      break;
    case 1:
      strcat(hugebuf_o, "Spells available:\n\rLv Spells\n\r----------\n\r");
      break;
    case 2:
      strcat(hugebuf_o, "Proficiencies available:\n\rLv Proficiencies\n\r----------\n\r");
      break;
    }

  for (sn = 0; sn < SKILL_COUNT; sn++)
    {
      if ((spell = skill_lookup (NULL, sn)) == NULL)
	continue;
      if (spell->slot != slot)
	continue;
      spellstuff[mnum] = spell;
      mnum++;
    }

  for (level = 0; level <= 110; level++)
    {
      for (sn = 0; sn < mnum; sn++)
	{
	  spell = spellstuff[sn];
	  if (spell->spell_level != level)
	    continue;
	      sprintf (buf, "\x1b[0;35m(\x1b[0;32m%2d\x1b[0;35m) ",level);
	      strcat (hugebuf_o, buf);
          if(IS_SET(spell->spell_bits, SPELL_ALL_IN_ROOM))
             sprintf(buf, "\x1b[1;31mA ");
          else
             sprintf(buf, "  ");
          strcat (hugebuf_o, buf);
	  {
	    bool found = FALSE;
	    int i;
	    for (i = 0; str_cmp(mana_data[i].what_you_type, "end_of_list") && !found; i ++)
	      {
		if (spell->mana_type == mana_data[i].flagname)
		  {
		    char bufff[50];
		    sprintf (bufff, "%s%s\x1b[0;37m", mana_data[i].color, mana_data[i].letter);
		    strcpy(bbb, bufff);
		    found = TRUE;
		  }
	      }
	    if (!found)
	      strcpy(bbb, " ");
	  }
	  if (slot == 1)
	    sprintf (buf, "\x1b[1;36m%-21s %s \x1b[1;30m(\x1b[1;37m%2d\x1b[1;30m)\x1b[0;37m ",    spell->spell_funky_name, bbb, spell->mana);
	  else
	    sprintf (buf, "\x1b[1;36m%-20s  ", spell->spell_funky_name);
	  strcat (hugebuf_o, buf);
	  if (spell->prereq_1 && str_cmp(spell->prereq_1, "none") &&
str_cmp(spell->prereq_1, "None"))
           {
             sprintf (buf, "\x1b[0;36m%-18s", spell->prereq_1);
             strcat (hugebuf_o, buf);
           }
	  if (spell->prereq_2 && str_cmp(spell->prereq_2, "none") &&
str_cmp(spell->prereq_2,"None"))
           {
             sprintf (buf, "\x1b[0;36m%-18s", spell->prereq_2);
             strcat (hugebuf_o, buf);
           }
        strcat (hugebuf_o, "\n\r");
       }
    }
  strcat (hugebuf_o, "\x1b[0;37m");
  page_to_char (hugebuf_o, ch);
  return;
}
Ejemplo n.º 17
0
void 
do_spells (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char bbb[50];
  char hg[300];
  SPELL_DATA *spell;
  bool fnd = FALSE;
  int sn;
  int col;
  DEFINE_COMMAND ("spells", do_spells, POSITION_DEAD, 0, LOG_NORMAL, "This command shows you all the spells you currently know.")
    hugebuf_o[0] = '\0';
  if (IS_MOB (ch))
    {
      send_to_char ("You do not know how to cast spells!\n\r", ch);
      return;
    }

  hugebuf_o[0] = '\0';
  col = 0;
  for (sn = 0; sn < SKILL_COUNT; sn++)
    {
      if ((spell = skill_lookup (NULL, sn)) == NULL)
	continue;
      if ((LEVEL (ch) < spell->spell_level)
	  || (spell->spell_level > 80))
	continue;
      if (spell->slot != 1)
	continue;
      if (ch->pcdata->learned[sn] == -100)
	continue;
      fnd = TRUE;
     
      {
	bool found = FALSE;
	int i;
	for (i = 0; str_cmp(mana_data[i].what_you_type, "end_of_list") && !found; i ++)
	  {
	    if (spell->mana_type == mana_data[i].flagname)
	      {
		char buf[50];
		sprintf (buf, "%s%s\x1b[0;37m", mana_data[i].color, mana_data[i].letter);
		strcpy(bbb, buf);
		found = TRUE;
	      }
	  }
	if (!found)
	  strcpy(bbb, " ");
      }
      
      strcpy (hg, how_good (ch, sn));
      if (LEVEL (ch) >= 100)
	sprintf (buf, "%s %3dM (%3d) %-20s ",
	    bbb, ((2 + LEVEL (ch) - spell->spell_level == 0) ? spell->mana :
		  (UMAX (spell->mana,
			 100 / (2 + LEVEL (ch) - spell->spell_level)))),
		 ch->pcdata->learned[sn], spell->spell_funky_name);
      else
	sprintf (buf, "%s %3dM %10s %-20s ",
	    bbb, ((2 + LEVEL (ch) - spell->spell_level == 0) ? spell->mana :
	 (UMAX (spell->mana, 100 / (2 + LEVEL (ch) - spell->spell_level)))),
		 hg, spell->spell_funky_name);
      strcat (hugebuf_o, buf);
      if (++col % 2 == 0)
	strcat (hugebuf_o, "\n\r");
    }

  if (col % 2 != 0)
    strcat (hugebuf_o, "\n\r");
  if (!fnd)
    strcpy (hugebuf_o, "You know no spells at the moment.\n\r");
  page_to_char (hugebuf_o, ch);
  return;
}
Ejemplo n.º 18
0
void 
do_practice (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char hg[500];
  bool found;
  int sn;
  int cnttt;
  SPELL_DATA *spell;
  CHAR_DATA *mob;
  int adept;
  DEFINE_COMMAND ("practice", do_practice, POSITION_STANDING, 0, LOG_NORMAL, "This command can be used to list all skills/spells you know, or, at a practitioner, can be used to practice a spell or skill.")
    hugebuf_o[0] = '\0';
  cnttt = 0;
  if (IS_MOB (ch))
    return;
  
  for (mob = ch->in_room->more->people; mob != NULL; mob = mob->next_in_room)
    {
      if (IS_MOB (mob) && IS_SET (mob->act, ACT_PRACTICE) && mob->pIndexData->opt)
	break;
    }

  if (mob != NULL && (!IS_SET (mob->act, ACT_PRACTICE) || IS_PLAYER (mob)))
    {
      if (argy[0] != '\0')
	{
	  send_to_char ("You cannot practice here!\n\r", ch);
	  return;
	}
    }
  if (mob == NULL && argy[0] == '\0')
    {
      int col;
      int oldtrack;
      int oldtrap;
      int oldpick;
      sprintf (hugebuf_o, "You have knowledge in the following:\n\r\n\r");
      sprintf (hugebuf_o,"\x1B[1;37mYou have knowledge in the following:\x1B[37;0m\n\r");
      sprintf (hugebuf_o+strlen(hugebuf_o),"\x1B[1;34m------------------------------------\x1B[37;0m\n\r");
      col = 0;
      
      oldtrack = ch->pcdata->learned[gsn_track]; 
      if (is_member (ch, GUILD_RANGER))
	ch->pcdata->learned[gsn_track] = 100;
      oldtrap = ch->pcdata->learned[gsn_trapset]; 
      if (is_member (ch, GUILD_RANGER) && is_member(ch, GUILD_THIEFG) &&
	  is_member(ch, GUILD_TINKER))
	ch->pcdata->learned[gsn_trapset] = 100;
      oldpick = ch->pcdata->learned[gsn_pick_lock];
      if (is_member (ch, GUILD_THIEFG))
	ch->pcdata->learned[gsn_pick_lock] = 100;
      ch->pcdata->learned[gsn_sneak] += ch->pcdata->plus_sneak;
      ch->pcdata->learned[gsn_hide] += ch->pcdata->plus_hide;
      for (sn = 0; sn < SKILL_COUNT; sn++)
	{
	  if ((spell = skill_lookup (NULL, sn)) == NULL)
	    continue;
	  if ((LEVEL (ch) < spell->spell_level)
	      || (ch->pcdata->learned[sn] < -1))
	    continue;
	  strcpy (hg, how_good (ch, sn));
	  if (LEVEL (ch) >= 100)
	    sprintf (buf, "%22s %3d%% ", spell->spell_funky_name,
		     ch->pcdata->learned[sn]);
	  else
	    sprintf (buf, " %22s %10s", spell->spell_funky_name, hg);
	  strcat (hugebuf_o, buf);
	  if (++col % 2 == 0)
	    strcat (hugebuf_o, "\n\r");
	}
      ch->pcdata->learned[gsn_track] = oldtrack;
      ch->pcdata->learned[gsn_trapset] = oldtrap;
      ch->pcdata->learned[gsn_pick_lock] = oldpick;
      ch->pcdata->learned[gsn_sneak] -= ch->pcdata->plus_sneak;
      ch->pcdata->learned[gsn_hide] -= ch->pcdata->plus_hide;
      if (col % 2 != 0)
	strcat (hugebuf_o, "\n\r");
      sprintf (buf, "\n\rYou have %d practices and %d learns left.\x1B[0m\n\r",
	       ch->pcdata->practice, ch->pcdata->learn);
      strcat (hugebuf_o, buf);
      page_to_char (hugebuf_o, ch);
      return;
    }

  if (!IS_AWAKE (ch))
    {
      send_to_char ("In your dreams?  Good luck!\n\r", ch);
      return;
    }

  if (argy[0] == '\0')
    {
      int col;
      int oldtrack; 
      int oldtrap;
      int oldpick;
      hugebuf_o[0] = '\0';
      send_to_char("\x1B[1;37mYou have knowledge in the following:\x1B[37;0m\n\r", ch);
      send_to_char("\x1B[1;34m------------------------------------\x1B[37;0m\n\r", ch);
      found = FALSE;
      col = 0;
      if (mob == NULL || IS_PLAYER (mob))
	return;
      oldpick = ch->pcdata->learned[gsn_pick_lock];
      if (is_member (ch, GUILD_THIEFG))
	ch->pcdata->learned[gsn_pick_lock] = 100;
      oldtrack = ch->pcdata->learned[gsn_track];
      if (is_member (ch, GUILD_RANGER) && is_member(ch, GUILD_THIEFG) &&
is_member(ch, GUILD_TINKER))
	ch->pcdata->learned[gsn_trapset] = 100;
      oldtrap = ch->pcdata->learned[gsn_trapset]; 
      if (is_member (ch, GUILD_RANGER))
	ch->pcdata->learned[gsn_track] = 100;
      ch->pcdata->learned[gsn_sneak] += ch->pcdata->plus_sneak;
      ch->pcdata->learned[gsn_hide] += ch->pcdata->plus_hide;
      for (sn = 0; sn <= 28; sn++)
	{
	  if (mob->pIndexData->opt->skltaught[sn] > 0 &&
	      (spell = skill_lookup (NULL, mob->pIndexData->opt->skltaught[sn])) != NULL)
	    {
	    
	      if (LEVEL (ch) >= spell->spell_level)
		{
		  char hg[300];
		  found = TRUE;
		  strcpy (hg, how_good (ch, spell->gsn));
		  sprintf (buf, " %22s %10s", spell->spell_funky_name, hg);
		  strcat (hugebuf_o, buf);
		  if (++col % 2 == 0)
		    strcat (hugebuf_o, "\n\r");
		}
	    }
	}
      ch->pcdata->learned[gsn_trapset] = oldtrap;
      ch->pcdata->learned[gsn_track] = oldtrack;
      ch->pcdata->learned[gsn_pick_lock] = oldpick;
      ch->pcdata->learned[gsn_sneak] -= ch->pcdata->plus_sneak;
      ch->pcdata->learned[gsn_hide] -= ch->pcdata->plus_hide;
      if (!found)
	strcat (hugebuf_o, "Nothing.\n\r");
      if (col % 2 != 0)
	strcat (hugebuf_o, "\n\r");
      sprintf (buf, "\n\rYou have %d practice sessions left.\n\r",
	       ch->pcdata->practice);
      strcat (hugebuf_o, buf);
      page_to_char (hugebuf_o, ch);
      return;
    }

  spell = skill_lookup (argy, -1);
  if (spell == NULL)
    {
      send_to_char ("What's that?\n\r", ch);
      return;
    }

  if (spell == NULL
      || (IS_PLAYER (ch)
	  && (LEVEL (ch) < spell->spell_level ||
	      ch->pcdata->learned[spell->gsn] == -100)))
    {
      if (spell->gsn > 0 && spell->gsn < SKILL_COUNT && ch->pcdata->learned[spell->gsn] == -100)
	{
	  do_learn (ch, argy);
	  if (ch->pcdata->learned[spell->gsn] == -100)
	    {
	      send_to_char ("For some reason or another, you could not LEARN this spell/skill.\n\r", ch);
	      send_to_char ("Perhaps you are out of learns?  Type 'learn' for more information.\n\r", ch);
	      return;
	    }
	  goto lerned_it;
	}

      send_to_char ("I have no knowledge in that area.\n\r", ch);
      return;
    }
lerned_it:
  if (mob == NULL)
    return;
  while (cnttt <= 30)
    {
      if (IS_MOB (mob) && mob->pIndexData->opt->skltaught[cnttt] == spell->gsn)
	{
	  cnttt = 50;
	  break;
	}
      cnttt++;
    }

  if (cnttt != 50)
    {
      send_to_char ("I have too little knowledge in that area to help you practice.\n\r", ch);
      return;
    }

  
  if (ch->pcdata->practice < 1)
    {
      send_to_char ("You have no practice sessions left!\n\r", ch);
      return;
    }

  if (spell->slot != 0)
    adept = pow.max_prac_spells;
  else
    adept = pow.max_prac_skills;
  if (spell->slot == 0)
    {
      if(get_curr_dex (ch) < spell->min_wis)
	{
	  adept -= (spell->min_wis - get_curr_dex (ch)) * 8;
	}
      if(get_curr_str (ch) < spell->min_int)
	{
	  adept -= (spell->min_int - get_curr_str (ch)) * 8;
	  if (adept < 20)
	    adept = 20;
	}
    }
  else if (spell->slot == 1)
    { 
      if (get_curr_wis (ch) < spell->min_wis)
	{
	  adept -= (spell->min_wis - get_curr_wis (ch)) * 8;
	}
      if (get_curr_int (ch) < spell->min_int)
	{
	  adept -= (spell->min_int - get_curr_int (ch)) * 8;
	  if (adept < 20)
	    adept = 20;
	}
    }
  else if (spell->slot == 2)
    {
      if (get_curr_dex (ch) < spell->min_wis)
	{
	  adept -= (spell->min_wis - get_curr_dex (ch)) * 8;
	}
      if (get_curr_int (ch) < spell->min_int)
	{
	  adept -= (spell->min_int - get_curr_int (ch)) * 8;
	  if (adept < 20)
	    adept = 20;
	}
    }
  
  if (IS_PLAYER (ch))
    {
      SPELL_DATA *spl;
      if (spell->prereq_1 != NULL && (spl = skill_lookup(spell->prereq_1, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq)
	{
	  sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name);
	  send_to_char (buf, ch);
	  return;
	}
      if (spell->prereq_2 != NULL && (spl = skill_lookup(spell->prereq_2, -1)) != NULL && ch->pcdata->learned[spl->gsn] < pow.prereq)
	{
	  sprintf (buf, "You need to be skilled in %s first.\n\r", spl->spell_funky_name);
	  send_to_char (buf, ch);
	  return;
	}
    }
  
  if (ch->pcdata->learned[spell->gsn] >= adept)
    {
      sprintf (buf, "You are already quite good at %s.\n\r", spell->spell_funky_name);
      send_to_char (buf, ch);
      return;
    }
  if (spell->guilds != 0)
    {
      int i;
      for (i = 0; str_cmp(guild_data[i].what_you_type, "end_of_list"); i++)
	{
	  if(IS_SET(spell->guilds, guild_data[i].mob_guildmaster_bit) && !IS_SET(ch->pcdata->guilds, guild_data[i].mob_guildmaster_bit))
	    {
	      send_to_char("You do not have the proper guilds to practice this!\n\r", ch);
	      return;
	    }
	}
    }

    
      ch->pcdata->practice--;
      if (spell->slot == 1)
	ch->pcdata->learned[spell->gsn] += int_app[get_curr_int (ch) - 1].learn;
      if (spell->slot != 1)
	ch->pcdata->learned[spell->gsn] += int_app[get_curr_int (ch) - 1].learn - 1;
      if (ch->pcdata->learned[spell->gsn] < adept)
	{
	  act ("You practice $T.",
	       ch, NULL, spell->spell_funky_name, TO_CHAR);
	}
      else
	{
	  ch->pcdata->learned[spell->gsn] = adept;
	  act ("You now have a good understanding of $T.",
	       ch, NULL, spell->spell_funky_name, TO_CHAR);
	  if (spell->gsn > 549 && IS_PLAYER(ch) && !str_cmp(race_info[ch->pcdata->race].name, "orc") && adept == pow.max_prac_skills)
	    ch->pcdata->learned[spell->gsn]+= 15;
	}
    

  return;
}
Ejemplo n.º 19
0
void 
do_skill (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char hg[300];
  SPELL_DATA *spell;
  int sn;
  int col;
  int oldtrack;
  int oldtrap;
  int oldpick;
  DEFINE_COMMAND ("skills", do_skill, POSITION_DEAD, 0, LOG_NORMAL, "This command shows you what skills you know, if any.")

    if (IS_MOB (ch))
    return;
  hugebuf_o[0] = '\0';
  send_to_char ("\x1B[1;37mYou have knowledge in the following skills:\x1B[37;0m\n\r", ch);
  send_to_char ("\x1B[1;34m-------------------------------------------\x1B[37;0m\n\r", ch);
  col = 0;
  oldtrack = ch->pcdata->learned[gsn_track];
  oldtrap = ch->pcdata->learned[gsn_trapset];
  oldpick = ch->pcdata->learned[gsn_pick_lock];
  if (is_member (ch, GUILD_THIEFG))
    ch->pcdata->learned[gsn_pick_lock] = 100;
  if (is_member (ch, GUILD_RANGER) && is_member(ch, GUILD_THIEFG) &&
is_member(ch, GUILD_TINKER))
    ch->pcdata->learned[gsn_trapset] = 100;
 if (is_member (ch, GUILD_RANGER))
    ch->pcdata->learned[gsn_track] = 100; 
  ch->pcdata->learned[gsn_sneak] += ch->pcdata->plus_sneak;
  ch->pcdata->learned[gsn_hide] += ch->pcdata->plus_hide;
  for (sn = 0; sn < SKILL_COUNT; sn++)
    {
      spell = skill_lookup (NULL, sn);
      if (spell == NULL)
	continue;
      if ((LEVEL (ch) < spell->spell_level)
	  || (ch->pcdata->learned[sn] == -100) || spell->slot == 1)
	continue;
      strcpy (hg, how_good (ch, sn));
      if (LEVEL (ch) >= 100)
	sprintf (buf, "%s%22s %3d%%\x1b[0;37m ",(spell->slot == 2 ? "\x1b[1;36m" : ""), spell->spell_funky_name, ch->pcdata->learned[sn]);
      else
	sprintf (buf, "%s%22s %10s",(spell->slot == 2 ? "\x1b[1;36m" :
"\x1b[0;37m"), spell->spell_funky_name, hg);
      strcat (hugebuf_o, buf);
      if (++col % 2 == 0)
	strcat (hugebuf_o, "\n\r");
    }

  ch->pcdata->learned[gsn_track] = oldtrack; 
  ch->pcdata->learned[gsn_trapset] = oldtrap;
  ch->pcdata->learned[gsn_pick_lock] = oldpick;
  ch->pcdata->learned[gsn_sneak] -= ch->pcdata->plus_sneak;
  ch->pcdata->learned[gsn_hide] -= ch->pcdata->plus_hide;
  if (col % 2 != 0)
    strcat (hugebuf_o, "\n\r");
  sprintf (buf, "\n\rYou have %d practice sessions left.\n\r",
	   ch->pcdata->practice);
  strcat (hugebuf_o, buf);
  page_to_char (hugebuf_o, ch);
  return;
}
Ejemplo n.º 20
0
void do_spells(CHAR_DATA *ch, char *argument)
{
    BUFFER *buffer;
    char arg[MAX_INPUT_LENGTH];
    char spell_list[LEVEL_HERO + 1][MAX_STRING_LENGTH];
    char spell_columns[LEVEL_HERO + 1];
    int sn, level, min_lev = 1, max_lev = LEVEL_HERO, mana;
    bool fAll = FALSE, found = FALSE;
    char buf[MAX_STRING_LENGTH];

    if (IS_NPC(ch))
      return;
    if(ch->Class()->ctype!=CLASS_CASTER)
    {
	send_to_char("Your class knows no spells.\n\r",ch);
	return;
    }
    if (argument[0] != '\0')
    {
	fAll = TRUE;

	if (str_prefix(argument,"all"))
	{
	    argument = one_argument(argument,arg);
	    if (!is_number(arg))
	    {
		send_to_char("Arguments must be numerical or all.\n\r",ch);
		return;
	    }
	    max_lev = atoi(arg);

	    if (max_lev < 1 || max_lev > LEVEL_HERO)
	    {
		sprintf(buf,"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		send_to_char(buf,ch);
		return;
	    }

	    if (argument[0] != '\0')
	    {
		argument = one_argument(argument,arg);
		if (!is_number(arg))
		{
		    send_to_char("Arguments must be numerical or all.\n\r",ch);
		    return;
		}
		min_lev = max_lev;
		max_lev = atoi(arg);

		if (max_lev < 1 || max_lev > LEVEL_HERO)
		{
		    sprintf(buf,
			"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		    send_to_char(buf,ch);
		    return;
		}

		if (min_lev > max_lev)
		{
		    send_to_char("That would be silly.\n\r",ch);
		    return;
		}
	    }
	}
    }


    /* initialize data */
    for (level = 0; level < LEVEL_HERO + 1; level++)
    {
        spell_columns[level] = 0;
        spell_list[level][0] = '\0';
    }

    for (sn = 0; sn < MAX_SKILL; sn++)
    {
        if (skill_table[sn].name == NULL )
	    break;

	if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun != spell_null
	&&  ch->pcdata->learned[sn] > 0
	&&  (skill_table[sn].ctype==CMD_SPELL || skill_table[sn].ctype==CMD_BOTH))
        {
	    found = TRUE;
	    level = skill_table[sn].skill_level[ch->Class()->GetIndex()];
	    if (ch->level < level)
	    	sprintf(buf,"%-18s n/a      ", skill_table[sn].name);
	    else
	    {
        mana = UMAX(skill_table[sn].min_mana,
		    100/(2 + ch->level - level));
            sprintf(buf,"%-18s  %3d mana  ",skill_table[sn].name,mana);
	    }

	    if (spell_list[level][0] == '\0')
          	sprintf(spell_list[level],"\n\rLevel %2d: %s",level,buf);
	    else /* append */
	    {
          	if ( ++spell_columns[level] % 2 == 0)
		    strcat(spell_list[level],"\n\r          ");
          	strcat(spell_list[level],buf);
	    }
	}
    }

    /* return results */

    if (!found)
    {
      	send_to_char("No spells found.\n\r",ch);
      	return;
    }

    buffer = new_buf();
    for (level = 0; level < LEVEL_HERO + 1; level++)
      	if (spell_list[level][0] != '\0')
	    add_buf(buffer,spell_list[level]);
    add_buf(buffer,"\n\r");
    page_to_char(buf_string(buffer),ch);
    free_buf(buffer);
}
Ejemplo n.º 21
0
void do_skills(CHAR_DATA *ch, char *argument)
{
    BUFFER *buffer;
    char arg[MAX_INPUT_LENGTH];
    char skill_list[LEVEL_HERO + 1][MAX_STRING_LENGTH];
    char skill_columns[LEVEL_HERO + 1];
    int sn, level, min_lev = 1, max_lev = LEVEL_HERO,p,gn,style_skill;
    bool fAll = FALSE, found = FALSE, hide_skill=FALSE;
    char buf[MAX_STRING_LENGTH];

    if (IS_NPC(ch))
      return;

    if (argument[0] != '\0')
    {
	fAll = TRUE;

	argument = one_argument(argument,arg);

	if (is_number(arg))
	{
	    if (!is_number(arg))
	    {
		send_to_char("Arguments must be numerical or name of skill.\n\r",ch);
		return;
	    }
	    max_lev = atoi(arg);

	    if (max_lev < 1 || max_lev > LEVEL_HERO)
	    {
		sprintf(buf,"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		send_to_char(buf,ch);
		return;
	    }

	    if (argument[0] != '\0')
	    {
		argument = one_argument(argument,arg);
		if (!is_number(arg))
		{
		    send_to_char("Arguments must be numerical or name of skill.\n\r",ch);
		    return;
		}
		min_lev = max_lev;
		max_lev = atoi(arg);

		if (max_lev < 1 || max_lev > LEVEL_HERO)
		{
		    sprintf(buf,
			"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		    send_to_char(buf,ch);
		    return;
		}

		if (min_lev > max_lev)
		{
		    send_to_char("That would be silly.\n\r",ch);
		    return;
		}
	    }
	} else {

		if ((sn = skill_lookup(arg)) < 0)
			return send_to_char("No such skill or spell.\n\r", ch);
		
		if (ch->pcdata->learned[sn] == 0 ||
		   (ch->level < skill_table[sn].skill_level[ch->Class()->GetIndex()]) ||
           ((sn == gsn_gladiator_skill   ||
		     sn == gsn_barbarian_skill   ||
		     sn == gsn_duelist_skill     ||
		     sn == gsn_skirmisher_skill  ||
		     sn == gsn_dragoon_skill     ||
		     sn == gsn_tactician_skill) && ch->level < AVATAR)) {
			send_to_char("You are not learned in that.\n\r",ch);
		}
		else
		{
			sprintf(buf, "Your skill in '%s' is %d%%.\n\r",
			skill_table[sn].name, ch->pcdata->learned[sn]);
			send_to_char(buf, ch);
		}
		return;
	}
    }



    /* initialize data */
    for (level = 0; level < LEVEL_HERO + 1; level++)
    {
        skill_columns[level] = 0;
        skill_list[level][0] = '\0';
    }

    for (sn = 0; sn < MAX_SKILL; sn++)
    {
        if (skill_table[sn].name == NULL )
	    break;

		hide_skill=FALSE;
        /*if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  (fAll || level <= ch->level)
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun == spell_null
        &&  ch->pcdata->learned[sn] > 0)*/
	if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun == spell_null
	&&  ch->pcdata->learned[sn] > 0)
        {

        for(p=0; p<MAX_STYLE_SKILL; p++)
        {
        	if(!str_prefix(style_percent[p].name, skill_table[sn].name))
        	{
        		gn = gn_skill_lookup(sn);
        		if(gn > 1)
        		{
        			style_skill = skill_lookup( group_table[gn].name );
        			if(ch->pcdata->learned[style_skill] < style_percent[p].percent)
        				hide_skill=TRUE;
					if(hide_skill) break;
				}
	    	}
	    }

        if ( sn == gsn_gladiator_skill || sn == gsn_duelist_skill ||
		     sn == gsn_barbarian_skill || sn == gsn_dragoon_skill ||
		     sn == gsn_skirmisher_skill || sn == gsn_tactician_skill)
			hide_skill=TRUE;
		
		found = TRUE;
	    level = skill_table[sn].skill_level[ch->Class()->GetIndex()];
		if(!hide_skill)
		{
			if (ch->level < level)
	    		sprintf(buf,"%-18s n/a      ", skill_table[sn].name);
	    	else
	    		sprintf(buf,"%-18s %3d%%      ",skill_table[sn].name,
		    			ch->pcdata->learned[sn]);

	   		if (skill_list[level][0] == '\0')
          		sprintf(skill_list[level],"\n\rLevel %2d: %s",level,buf);
	    	else /* append */
	    	{
          		if ( ++skill_columns[level] % 2 == 0)
		    	strcat(skill_list[level],"\n\r          ");
          		strcat(skill_list[level],buf);
	    	}

		}
	}
    }

    /* return results */

    if (!found)
    {
      	send_to_char("No skills found.\n\r",ch);
      	return;
    }

    buffer = new_buf();
    for (level = 0; level < LEVEL_HERO + 1; level++)
      	if (skill_list[level][0] != '\0')
	    add_buf(buffer,skill_list[level]);
    add_buf(buffer,"\n\r");
    page_to_char(buf_string(buffer),ch);
    free_buf(buffer);
}
Ejemplo n.º 22
0
/** mvnum <var> <value> */
void do_mvnum(struct char_data *ch, const char *argument)
{
    static char arg[MAX_INPUT_LENGTH];
    const char *original_argument = argument;

    argument = prep_find_entity_vnum(ch, argument, arg, "mvnum", &help_mvnum_properties, &mvnum_find_empty);
    if (argument != NULL) {
        {
            struct buf_type *buffer;
            MOB_IDX_CMP_FN *cmp_fn = NULL;
            char buf[MAX_INPUT_LENGTH];
            long low_vnum, high_vnum;
            long iter;

            buffer = new_buf();
            sprintf(buf, "`#QUERY``: mvnum %s\n\r\n\r", original_argument);
            add_buf(buffer, buf);

            for (iter = 0; mob_idx_flags[iter].var[0] != '\0'; iter++) {
                if (!str_prefix(arg, mob_idx_flags[iter].var)) {
                    cmp_fn = (MOB_IDX_CMP_FN *)mob_idx_flags[iter].fn;
                    argument = one_argument(argument, arg);
                    break;
                }
            }

            if (cmp_fn == NULL)
                cmp_fn = mob_idx_cmp_name;

            argument = get_search_vnum_range(ch, argument, arg, buffer, &high_vnum, &low_vnum);

            if (arg[0] == '?' || arg[0] == '\0') {
                clear_buf(buffer);
                sprintf(buf, "`#SYNTAX``:\n\r       mvnum %s <value>:\n\r\n\r", arg);
                add_buf(buffer, buf);

                (*cmp_fn)(get_mob_index(MOB_VNUM_PIG), argument, buffer);
                page_to_char(buf_string(buffer), ch);
            } else {
                struct mob_index_data *mob;
                char *clr1;
                int number = 0;
                long count = 0;

                for (iter = low_vnum; iter <= high_vnum && count < top_mob_index; iter++) {
                    if ((mob = get_mob_index(iter)) != NULL) {
                        count++;

                        if ((*cmp_fn)(mob, arg, NULL)) {
                            number++;

                            if (number == 1) {
                                add_buf(buffer, "#   vnum   name\n\r");
                                add_buf(buffer, "=== ====== =======================================\n\r");
                            }

                            clr1 = uncolor_str(mob->short_descr);
                            sprintf(buf, "%-3d %-7ld  %-38.38s\n\r",
                                    number,
                                    mob->vnum,
                                    clr1);
                            free_string(clr1);

                            add_buf(buffer, buf);

                            if (number >= MAX_RETURN)
                                break;
                        }
                    }
                }

                if (number == 0)
                    send_to_char("Nothing like that in heaven or earth.\n\r", ch);
                else
                    page_to_char(buf_string(buffer), ch);
            }

            free_buf(buffer);
        }
    }
}
Ejemplo n.º 23
0
void parse_note( CHAR_DATA *ch, char *argument, int type )
{
    BUFFER *buffer;
    char buf[MAX_STRING_LENGTH], query[MSL];
    char arg[MAX_INPUT_LENGTH];
    MYSQL_RES *res;
    MYSQL_ROW row;
    char *list_name;
    int vnum;
    int anum;

    switch(type)
    {
	default:
	    return;
        case NOTE_NOTE:
	    list_name = "notes";
            break;
        case NOTE_IDEA:
	    list_name = "ideas";
            break;
        case NOTE_PENALTY:
	    list_name = "penalties";
            break;
        case NOTE_NEWS:
	    list_name = "news";
            break;
        case NOTE_CHANGES:
	    list_name = "changes";
            break;
    }

    argument = one_argument( argument, arg );
    smash_tilde( argument );

    if ( arg[0] == '\0' || !str_prefix( arg, "read" ) )
    {
        bool fAll;

        if ( !str_cmp( argument, "all" ) )
        {
            fAll = TRUE;
            anum = 0;
        }

        else if ( argument[0] == '\0' || !str_prefix(argument, "next"))
        /* read next unread note */
        {
            vnum = 0;
	    sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	    res	= one_query_res(query);
            while((row=mysql_fetch_row(res)))
            {
                if (!hide_note(ch,row))
                {
                    sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
                        vnum, row[1], row[4], row[2], row[3]);
                    send_to_char( buf, ch );
                    page_to_char( row[5], ch );
                    update_read(ch,atol(row[6]),atoi(row[0]));
		    mysql_free_result(res);
                    return;
                }
		else if(is_note_to(ch,row[1],row[3]))
		    vnum++;
            }
	    sprintf(buf,"You have no unread %s.\n\r",list_name);
	    send_to_char(buf,ch);
	    mysql_free_result(res);
            return;
        }

        else if ( is_number( argument ) )
        {
            fAll = FALSE;
            anum = atoi( argument );
        }
        else
        {
            send_to_char( "Read which number?\n\r", ch );
            return;
        }

        vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
        {
            if (is_note_to(ch,row[1],row[3]) && (vnum++ == anum))
            {
                sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
                        anum, row[1], row[4], row[2], row[3]);
                send_to_char( buf, ch );
                page_to_char( row[5], ch );
		update_read(ch,atol(row[6]),atoi(row[0]));
		mysql_free_result(res);
                return;
            }
        }

	sprintf(buf,"There aren't that many %s.\n\r",list_name);
	send_to_char(buf,ch);
	mysql_free_result(res);
        return;
    }

    if ( !str_prefix( arg, "list" ) )
    {
	vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);

        while((row=mysql_fetch_row(res)))
	{
	    if (is_note_to(ch,row[1],row[3]))
	    {
		sprintf( buf, "[%3d%s] %s: %s\n\r",
		    vnum, hide_note(ch,row) ? " " : "N",
		    row[1], row[4]);
		send_to_char( buf, ch );
		vnum++;
	    }
	}
	if (!vnum)
	{
	    switch(type)
	    {
		case NOTE_NOTE:	
		    send_to_char("There are no notes for you.\n\r",ch);
		    break;
		case NOTE_IDEA:
		    send_to_char("There are no ideas for you.\n\r",ch);
		    break;
		case NOTE_PENALTY:
		    send_to_char("There are no penalties for you.\n\r",ch);
		    break;
		case NOTE_NEWS:
		    send_to_char("There is no news for you.\n\r",ch);
		    break;
		case NOTE_CHANGES:
		    send_to_char("There are no changes for you.\n\r",ch);
		    break;
	    }
	}
	mysql_free_result(res);
	return;
    }

    if ( !str_prefix( arg, "remove" ) )
    {
        if ( !is_number( argument ) )
            return send_to_char( "Note remove which number?\n\r", ch );


        anum = atoi( argument );
        vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
	{
            if (!str_cmp(ch->true_name, row[1]) && vnum++ == anum )
            {
                sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]);
		one_query(query);
                send_to_char( "Ok.\n\r", ch );
		mysql_free_result(res);
                return;
            }
        }

	send_to_char("You must provide the number of a note you have written to remove.\n\r",ch);
	mysql_free_result(res);
        return;
    }

    if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 2)
    {
        if ( !is_number( argument ) )
            return send_to_char( "Note delete which number?\n\r", ch );

        anum = atoi( argument );
        vnum = 0;
        sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
	{
            if ( is_note_to( ch,row[1],row[3] ) && vnum++ == anum )
            {
                sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]);
		one_query(query);
		send_to_char("Ok.\n\r",ch);
		mysql_free_result(res);
		return;
            }
        }

 	sprintf(buf,"There aren't that many %s.\n\r",list_name);
	send_to_char(buf,ch);
	mysql_free_result(res);
        return;
    }

    /* below this point only certain people can edit notes */
    if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL))
    ||  (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR)))
    {
	sprintf(buf,"You aren't high enough level to write %s.",list_name);
	send_to_char(buf,ch);
	return;
    }

    if ( !str_cmp( arg, "+" ) )
    {
	note_attach( ch,type );
	if (ch->pnote->type != type)
	    return send_to_char("You already have a different note in progress.\n\r",ch);

	if (strlen(ch->pnote->text)+strlen(argument) >= 4096)
	    return send_to_char( "Note too long.\n\r", ch );

 	buffer = new_buf();

	add_buf(buffer,ch->pnote->text);
	add_buf(buffer,argument);
	add_buf(buffer,"\n\r");
	free_pstring( ch->pnote->text );
	ch->pnote->text = palloc_string( buf_string(buffer) );
	free_buf(buffer);
	send_to_char( "Ok.\n\r", ch );
	return;
    }

    if (!str_cmp(arg,"-"))
    {
 	int len;
	bool found = FALSE;

	note_attach(ch,type);
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0')
	    return send_to_char("No lines left to remove.\n\r",ch);

	strcpy(buf,ch->pnote->text);

	for (len = strlen(buf); len > 0; len--)
 	{
	    if (buf[len] == '\r')
	    {
		if (!found)  /* back it up */
		{
		    if (len > 0)
			len--;
		    found = TRUE;
		}
		else /* found the second one */
		{
		    buf[len + 1] = '\0';
		    free_pstring(ch->pnote->text);
		    ch->pnote->text = palloc_string(buf);
		    return;
		}
	    }
	}
	buf[0] = '\0';
	free_pstring(ch->pnote->text);
	ch->pnote->text = palloc_string(buf);
	return;
    }

    if ( !str_prefix( arg, "subject" ) )
    {
	note_attach( ch,type );
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	free_pstring( ch->pnote->subject );
	ch->pnote->subject = palloc_string( argument );
	send_to_char( "Ok.\n\r", ch );
	return;
    }

    if ( !str_prefix( arg, "to" ) )
    {
	note_attach( ch,type );
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	if (is_name("all", argument)
	&& !IS_IMMORTAL(ch)
	&& !IS_HEROIMM(ch)
	&& !(ch->pcdata->induct == CABAL_LEADER))
		return	send_to_char("Sorry, you can't do that!\n\r",ch);
	if (is_number(argument) && !IS_IMMORTAL(ch))
		return send_to_char("You can't do that.\n\r",ch);	
	free_pstring( ch->pnote->to_list );
	ch->pnote->to_list = palloc_string( argument );
	send_to_char( "Ok.\n\r", ch );
	return;
	}

    if ( !str_prefix( arg, "clear" ) )
    {
	if ( ch->pnote != NULL )
	{
	    free_note(ch->pnote);
	    ch->pnote = NULL;
	}

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

    if ( !str_prefix( arg, "show" ) )
    {
	if ( ch->pnote == NULL )
	    return send_to_char( "You have no note in progress.\n\r", ch );

	if (ch->pnote->type != type)
	    return send_to_char("You aren't working on that kind of note.\n\r",ch);

	sprintf( buf, "%s: %s\n\rTo: %s\n\r",
	    ch->pnote->sender,
	    ch->pnote->subject,
	    ch->pnote->to_list
	    );
	send_to_char( buf, ch );
	send_to_char( ch->pnote->text, ch );
	return;
    }

    if ( !str_prefix( arg, "post" ) || !str_prefix(arg, "send"))
    {
	char *strtime;

	if ( ch->pnote == NULL )
	    return send_to_char( "You have no note in progress.\n\r", ch );

        if (ch->pnote->type != type)
            return send_to_char("You aren't working on that kind of note.\n\r",ch);

	if (!str_cmp(ch->pnote->to_list,""))
	    return send_to_char("You need to provide a recipient (name, all, or immortal).\n\r", ch);

	if (!str_cmp(ch->pnote->subject,""))
	    return send_to_char("You need to provide a subject.\n\r",ch);
	if (is_affected_prof(ch, "note_written") && !IS_IMMORTAL(ch))
	    return send_to_char("You have written a note too recently.\n\r",ch);
	ch->pnote->next			= NULL;
	strtime				= ctime( &current_time );
	strtime[strlen(strtime)-1]	= '\0';
	ch->pnote->date			= palloc_string( strtime );
	ch->pnote->date_stamp		= current_time;

	append_note(ch->pnote);
	ch->pnote = NULL;
	send_to_char("Note sent.\n\r",ch);
	add_prof_affect(ch, "note_written", 4, TRUE);
	return;
    }

    send_to_char( "You can't do that.\n\r", ch );
    return;
}
Ejemplo n.º 24
0
/** mwhere <var> <value> */
void do_mwhere(struct char_data *ch, const char *argument)
{
    struct buf_type *buffer;
    CHAR_CMP_FN *cmp_fn;
    char buf[MAX_INPUT_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    int iter;

    if (ch == NULL || IS_NPC(ch))
        return;

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


    if (argument[0] == '?' || !str_prefix(argument, "help")) {
        show_help(ch->desc, "mwhere", NULL);
        return;
    }

    buffer = new_buf();
    if (!str_prefix(argument, "list")) {
        add_buf(buffer, "mwhere: searchable property list\n\r");
        for (iter = 0; char_flags[iter].var[0] != '\0'; iter++) {
            sprintf(buf, "%-18.17s", char_flags[iter].var);
            add_buf(buffer, buf);
            if ((iter % 2) == 1)
                add_buf(buffer, "\n\r");
        }
        add_buf(buffer, "\n\r");
        page_to_char(buf_string(buffer), ch);
        return;
    }

    sprintf(buf, "`#QUERY``: mwhere %s\n\r\n\r", argument);
    add_buf(buffer, buf);

    if (argument[0] == '\0') {
        cmp_fn = char_cmp_name;
    } else {
        cmp_fn = NULL;
        one_argument(argument, arg);

        for (iter = 0; char_flags[iter].var[0] != '\0'; iter++) {
            if (!str_prefix(arg, char_flags[iter].var)) {
                cmp_fn = (CHAR_CMP_FN *)char_flags[iter].fn;
                argument = one_argument(argument, arg);
                break;
            }
        }

        if (cmp_fn == NULL)
            cmp_fn = char_cmp_name;
    }

    if (argument[0] == '?' || argument[0] == '\0') {
        clear_buf(buffer);
        sprintf(buf, "`#SYNTAX``:\n\r"
                "       mwhere %s <value>:\n\r\n\r", arg);
        add_buf(buffer, buf);

        (*cmp_fn)(char_list, argument, buffer);
        page_to_char(buf_string(buffer), ch);
    } else {
        struct char_data *vch;
        char *clr1;
        char *clr2;
        int number;

        number = 0;
        for (vch = char_list; vch != NULL; vch = vch->next) {
            if (can_see(ch, vch)
                && vch->in_room != NULL
                && (*cmp_fn)(vch, argument, NULL)) {
                number++;

                if (number == 1) {
                    sprintf(buf, "#   vnum   name                        where                      room\n\r");
                    add_buf(buffer, buf);
                    sprintf(buf, "=== ====== =========================== ========================== =====\n\r");

                    add_buf(buffer, buf);
                }

                clr1 = uncolor_str(IS_NPC(vch) ? vch->short_descr : vch->name);
                clr2 = uncolor_str(vch->in_room->name);
                sprintf(buf, "%-3d %-7ld  %-26.26s  %-25.25s  %-7ld\n\r",
                        number,
                        IS_NPC(vch) ? vch->mob_idx->vnum : 0,
                        clr1,
                        clr2,
                        vch->in_room->vnum);
                free_string(clr1);
                free_string(clr2);

                buf[0] = UPPER(buf[0]);
                add_buf(buffer, buf);

                if (number >= MAX_RETURN)
                    break;
            }
        }


        if (number == 0)
            send_to_char("Nothing like that in heaven or earth.\n\r", ch);
        else
            page_to_char(buf_string(buffer), ch);
    }

    free_buf(buffer);
}
Ejemplo n.º 25
0
/*
 * 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;
}
Ejemplo n.º 26
0
void do_wizlist(CHAR_DATA *ch, char *argument)
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	char arg3[MAX_INPUT_LENGTH];
	char buf[MSL]={'\0'};
	char title[MSL]={'\0'};
	BUFFER *buffer;
	int level = 0;
	WIZ_DATA *pwiz;
	int lngth = 0;
	int amt = 0;
	bool found;

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	argument = one_argument( argument, arg3 );

	if ((arg1[0] != '\0') && (ch->level == MAX_LEVEL))
	{
		if ( !str_prefix( arg1, "add" ) )
		{
			if ( !is_number( arg2 ) || ( arg3[0] == '\0' ) )
			{
				send_to_char( "Syntax: wizlist add <level> <name>\n\r", ch );
				return;
			}
			level = atoi(arg2);
			change_wizlist( ch, TRUE, level, arg3 );
			return;
		}
		if ( !str_prefix( arg1, "delete" ) )
		{
			if ( arg2[0] == '\0' )
			{
				send_to_char( "Syntax: wizlist delete <name>\n\r", ch );
				return;
			}
			change_wizlist( ch, FALSE, 0, arg2 );
			return;
		}
		send_to_char( "Syntax:\n\r", ch );
		send_to_char( " wizlist delete <name>\n\r", ch );
		send_to_char( " wizlist add <level> <name>\n\r", ch );
		return;
	}

	if (wiz_list == NULL)
	{
		send_to_char("No immortals listed at this time.\n\r",ch);
		return;
	}
	buffer = new_buf();
	sprintf(title,"The Gods of Dungeon World");
	sprintf(buf,"___________________________________________________________________________\n\r");
	add_buf(buffer,buf);
	sprintf(buf," /\\_\\%70s\\_\\\n\r", " ");
	add_buf(buffer,buf);
	lngth = (70 - strlen(title))/2;
	for( ; lngth >= 0; lngth--)
	{
		strcat(title, " ");
	}
	sprintf(buf,"|/\\\\_\\\tW%70s\tn\\_\\\n\r", title);
	add_buf(buffer,buf);
	sprintf(buf,"\\_/_|_|%69s|_|\n\r", " ");
	add_buf(buffer,buf);
	for (level = IMPLEMENTOR; level > HERO; level--)
	{
		found = FALSE;
		amt = 0;
		for (pwiz = wiz_list;pwiz != NULL;pwiz = pwiz->next)
		{
			if (pwiz->level == level)
			{
				amt++;
				found = TRUE;
			}
		}
		if (!found)
		{
			if (level == HERO+1)
			{
				sprintf(buf," ___|_|%69s|_|\n\r", " ");
				add_buf(buffer,buf);
			}
			continue;
		}
		sprintf(buf," |_|%37s [%d]%30s|_|\n\r", wiz_titles[IMPLEMENTOR-level], level, " ");
		add_buf(buffer,buf);
		sprintf(buf," |_|\tY%25s******************\tn%29s|_|\n\r", " ", " ");
		add_buf(buffer,buf);
		lngth = 0;
		for (pwiz = wiz_list;pwiz != NULL;pwiz = pwiz->next)
		{
			if (pwiz->level == level)
			{
				if (lngth == 0)
				{
					if (amt > 2)
					{
						sprintf(buf, " |_|%12s%-23s ", pwiz->name, " ");
						add_buf(buffer, buf);
						lngth = 1;
					} 
					else if (amt > 1)
					{
						sprintf(buf, " |_|%21s%-23s ", pwiz->name, " ");
						add_buf(buffer, buf);
						lngth = 1;
					} 
					else
					{
						sprintf(buf, " |_|%30s%-42s|_|\n\r", pwiz->name, " ");
						add_buf(buffer, buf);
						lngth = 0;
					}
				} 
				else if (lngth == 1)
				{
					if (amt > 2)
					{
						sprintf(buf, "%-23s ", pwiz->name);
						add_buf(buffer, buf);
						lngth = 2;
					} 
					else
					{
						sprintf(buf, "%-30s|_|\n\r", pwiz->name);
						add_buf(buffer, buf);
						lngth = 0;
					}
				} 
				else
				{
					sprintf(buf, "%-21s|_|\n\r", pwiz->name);
					add_buf(buffer, buf);
					lngth = 0;
					amt -= 3;
				}
			}
		}
		if (level == HERO+1)
		{
			sprintf(buf," ___|_|%72s|_|\n\r", " ");
		} 
		else
		{
			sprintf(buf," |_|%72s|_|\n\r", " ");
		}
		add_buf(buffer,buf);
	}
	sprintf(buf,"/ \\ |_|%69s|_|\n\r", " ");
	add_buf(buffer,buf);
	sprintf(buf,"|\\//_/%70s/_/\n\r", " ");
	add_buf(buffer,buf);
	sprintf(buf," \\/_/______________________________________________________________________/_/\n\r");
	add_buf(buffer,buf);
	page_to_char( buf_string(buffer), ch );
	free_buf(buffer);
	return;
}
Ejemplo n.º 27
0
void ban_site(CHAR_DATA *ch, char *argument, bool fPerm)
{
    char buf[MAX_STRING_LENGTH],buf2[MAX_STRING_LENGTH];
    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
    char *name;
    BUFFER *buffer;
    BAN_DATA *pban, *prev;
    bool prefix = FALSE,suffix = FALSE;
    int type;

    argument = one_argument(argument,arg1);
    argument = one_argument(argument,arg2);

    if ( arg1[0] == '\0' )
    {
	if (ban_list == NULL)
	{
	    send_to_char("No sites banned at this time.\n\r",ch);
	    return;
  	}
	buffer = new_buf();

        add_buf(buffer,"Banned sites  level  type     status\n\r");
        for (pban = ban_list;pban != NULL;pban = pban->next)
        {
	    sprintf(buf2,"%s%s%s",
		IS_SET(pban->ban_flags,BAN_PREFIX) ? "*" : "",
		pban->name,
		IS_SET(pban->ban_flags,BAN_SUFFIX) ? "*" : "");
	    sprintf(buf,"%-12s    %-3d  %-7s  %s\n\r",
		buf2, pban->level,
		IS_SET(pban->ban_flags,BAN_NEWBIES) ? "newbies" :
		IS_SET(pban->ban_flags,BAN_MULTI)   ? "multi" :
		IS_SET(pban->ban_flags,BAN_PERMIT)  ? "permit"  :
		IS_SET(pban->ban_flags,BAN_ALL)     ? "all"	: "",
	    	IS_SET(pban->ban_flags,BAN_PERMANENT) ? "perm" : "temp");
	    add_buf(buffer,buf);
        }

        page_to_char( buf_string(buffer), ch );
	free_buf(buffer);
        return;
    }

    /* find out what type of ban */
    if (arg2[0] == '\0' || !str_prefix(arg2,"all"))
	type = BAN_ALL;
    else if (!str_prefix(arg2,"newbies"))
	type = BAN_NEWBIES;
    else if (!str_prefix(arg2,"multi"))
	type = BAN_MULTI;
    else if (!str_prefix(arg2,"permit"))
	type = BAN_PERMIT;
    else
    {
	send_to_char("Acceptable ban types are all, newbies, and permit, and multi.\n\r",
	    ch); 
	return;
    }

    name = arg1;

    if (name[0] == '*')
    {
	prefix = TRUE;
	name++;
    }

    if (name[strlen(name) - 1] == '*')
    {
	suffix = TRUE;
	name[strlen(name) - 1] = '\0';
    }

    if (strlen(name) == 0)
    {
	send_to_char("You have to ban SOMETHING.\n\r",ch);
	return;
    }

    prev = NULL;
    for ( pban = ban_list; pban != NULL; prev = pban, pban = pban->next )
    {
        if (!str_cmp(name,pban->name))
        {
	    if (pban->level > get_trust(ch))
	    {
            	send_to_char( "That ban was set by a higher power.\n\r", ch );
            	return;
	    }
	    else
	    {
		if (prev == NULL)
		    ban_list = pban->next;
		else
		    prev->next = pban->next;
		free_ban(pban);
	    }
        }
    }

    pban = new_ban();
    pban->name = str_dup(name);
    pban->level = get_trust(ch);

    /* set ban type */
    pban->ban_flags = type;

    if (prefix)
	SET_BIT(pban->ban_flags,BAN_PREFIX);
    if (suffix)
	SET_BIT(pban->ban_flags,BAN_SUFFIX);
    if (fPerm)
	SET_BIT(pban->ban_flags,BAN_PERMANENT);

    pban->next  = ban_list;
    ban_list    = pban;
    save_bans();
    sprintf(buf,"%s has been banned.\n\r",pban->name);
    send_to_char( buf, ch );
    return;
}
Ejemplo n.º 28
0
/** ovnum <var> <value> */
void do_ovnum(struct char_data *ch, const char *argument)
{
    const char *original_argument = argument;
    static char arg[MAX_INPUT_LENGTH];

    argument = prep_find_entity_vnum(ch, argument, arg, "ovnum", help_ovnum_properties, ovnum_find_empty);
    if (argument != NULL) {
        struct buf_type *buffer = new_buf();
        OBJ_IDX_CMP_FN *cmp_fn = NULL;
        long low_vnum, high_vnum;
        char buf[MAX_INPUT_LENGTH];
        long iter;

        sprintf(buf, "`#QUERY``: ovnum %s\n\r\n\r", original_argument);
        add_buf(buffer, buf);

        for (iter = 0; objprototype_flags[iter].var[0] != '\0'; iter++) {
            if (!str_prefix(arg, objprototype_flags[iter].var)) {
                cmp_fn = (OBJ_IDX_CMP_FN *)objprototype_flags[iter].fn;
                argument = one_argument(argument, arg);
                break;
            }
        }

        if (cmp_fn == NULL)
            cmp_fn = objprototype_cmp_name;

        argument = get_search_vnum_range(ch, argument, arg, buffer, &high_vnum, &low_vnum);

        if (arg[0] == '?' || arg[0] == '\0') {
            clear_buf(buffer);
            sprintf(buf, "`#SYNTAX``:\n\r       ovnum %s <value>:\n\r\n\r", arg);
            add_buf(buffer, buf);

            (*cmp_fn)(objectprototype_getbyvnum(OBJ_VNUM_MAP), arg, buffer);
            page_to_char(buf_string(buffer), ch);
        } else {
            struct objectprototype *current;
            struct objectprototype *pending;
            char *clr1;
            int number = 0;
            long count = 0;

            pending = objectprototype_iterator_start(&objectprototype_empty_filter);
            while ((current = pending) != NULL) {
                pending = objectprototype_iterator(current, &objectprototype_empty_filter);

                count++;

                if ((*cmp_fn)(current, arg, NULL)) {
                    number++;

                    if (number == 1) {
                        sprintf(buf, "#   vnum   name\n\r");
                        add_buf(buffer, buf);
                        sprintf(buf, "=== ====== =======================================\n\r");

                        add_buf(buffer, buf);
                    }

                    clr1 = uncolor_str(current->short_descr);
                    sprintf(buf, "%-3d %-7ld  %-38.38s\n\r", number, current->vnum, clr1);
                    free_string(clr1);

                    add_buf(buffer, buf);

                    if (number >= MAX_RETURN)
                        break;
                }
            }

            if (number == 0)
                send_to_char("Nothing like that in heaven or earth.\n\r", ch);
            else
                page_to_char(buf_string(buffer), ch);
        }

        free_buf(buffer);
    }
}
Ejemplo n.º 29
0
	    wiz_last->next = pwiz;
	wiz_last = pwiz;
    }
}

void do_wizlist(CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char arg3[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    char title[MAX_STRING_LENGTH];
    BUFFER *buffer;
    int level;
    WIZ_DATA *pwiz;
    int lngth;
    int amt;
    bool found;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

/*
 * Uncomment the following to use the old method of having
 * a fixed wizlist in the rot.are file.
 */

/*
    do_help(ch,"wizlist");
    return;
*/

    if ((arg1[0] != '\0') && (ch->level == MAX_LEVEL))
    {
	if ( !str_prefix( arg1, "add" ) )
	{
	    if ( !is_number( arg2 ) || ( arg3[0] == '\0' ) )
	    {
		send_to_char( "Syntax: wizlist add <level> <name>\n\r", ch );
		return;
	    }
	    level = atoi(arg2);
	    change_wizlist( ch, TRUE, level, arg3 );
	    return;
	}
	if ( !str_prefix( arg1, "delete" ) )
	{
	    if ( arg2[0] == '\0' )
	    {
		send_to_char( "Syntax: wizlist delete <name>\n\r", ch );
		return;
	    }
	    change_wizlist( ch, FALSE, 0, arg2 );
	    return;
	}
	send_to_char( "Syntax:\n\r", ch );
	send_to_char( "       wizlist delete <name>\n\r", ch );
	send_to_char( "       wizlist add <level> <name>\n\r", ch );
	return;
    }

    if (wiz_list == NULL)
    {
	send_to_char("No immortals listed at this time.\n\r",ch);
	return;
    }
    buffer = new_buf();
    sprintf(title,"The Gods of Realms of Thoth");
    sprintf(buf,"{x  ___________________________________________________________________________\n\r");
    add_buf(buffer,buf);
    sprintf(buf,"{x /\\_\\%70s\\_\\\n\r", " ");
    add_buf(buffer,buf);
    lngth = (70 - strlen(title))/2;
    for( ; lngth >= 0; lngth--)
    {
	strcat(title, " ");
    }
    sprintf(buf,"|/\\\\_\\{W%70s{x\\_\\\n\r", title);
    add_buf(buffer,buf);
    sprintf(buf,"{x\\_/_|_|%69s|_|\n\r", " ");
    add_buf(buffer,buf);
    for (level = IMPLEMENTOR; level > HERO; level--)
    {
	found = FALSE;
	amt = 0;
        for (pwiz = wiz_list;pwiz != NULL;pwiz = pwiz->next)
        {
	    if (pwiz->level == level)
	    {
		amt++;
		found = TRUE;
	    }
	}
	if (!found)
	{
	    if (level == HERO+1)
	    {
		sprintf(buf,"{x ___|_|%69s|_|\n\r", " ");
		add_buf(buffer,buf);
	    }
	    continue;
	}
	sprintf(buf,"{x    |_|{R%37s {B[%d]{x%26s|_|\n\r",
	    wiz_titles[IMPLEMENTOR-level], level, " ");
	add_buf(buffer,buf);
	sprintf(buf,"{x    |_|{Y%25s******************{x%26s|_|\n\r",
	    " ", " ");
	add_buf(buffer,buf);
	lngth = 0;
        for (pwiz = wiz_list;pwiz != NULL;pwiz = pwiz->next)
        {
	    if (pwiz->level == level)
	    {
		if (lngth == 0)
		{
		    if (amt > 2)
		    {
			sprintf(buf, "{x    |_|{%s%12s%-17s ",
			    level >= DEMI ? "G" : "C", " ",
			    pwiz->name);
			add_buf(buffer, buf);
			lngth = 1;
		    } else if (amt > 1)
		    {
			sprintf(buf, "{x    |_|{%s%21s%-17s ",
			    level >= DEMI ? "G" : "C", " ",
			    pwiz->name);
			add_buf(buffer, buf);
			lngth = 1;
		    } else
		    {
			sprintf(buf, "{x    |_|{%s%30s%-39s{x|_|\n\r",
			    level >= DEMI ? "G" : "C", " ",
			    pwiz->name);
			add_buf(buffer, buf);
			lngth = 0;
		    }
		} else if (lngth == 1)
		{
		    if (amt > 2)
		    {
			sprintf(buf, "%-17s ",
			    pwiz->name);
			add_buf(buffer, buf);
			lngth = 2;
		    } else
		    {
			sprintf(buf, "%-30s{x|_|\n\r",
			    pwiz->name);
			add_buf(buffer, buf);
			lngth = 0;
		    }
		} else
		{
		    sprintf(buf, "%-21s{x|_|\n\r",
			pwiz->name);
		    add_buf(buffer, buf);
		    lngth = 0;
		    amt -= 3;
		}
	    }
        }
	if (level == HERO+1)
	{
	    sprintf(buf,"{x ___|_|%69s|_|\n\r", " ");
	} else
	{
	    sprintf(buf,"{x    |_|%69s|_|\n\r", " ");
	}
	add_buf(buffer,buf);
    }
    sprintf(buf,"{x/ \\ |_|%69s|_|\n\r", " ");
    add_buf(buffer,buf);
    sprintf(buf,"{x|\\//_/%70s/_/\n\r", " ");
    add_buf(buffer,buf);
    sprintf(buf,"{x \\/_/______________________________________________________________________/_/\n\r");
    add_buf(buffer,buf);
    page_to_char( buf_string(buffer), ch );
    free_buf(buffer);
    return;
}
Ejemplo n.º 30
0
void do_skills(CHAR_DATA *ch, char *argument)
{
	BUFFER *buffer;
	char arg[MIL]={'\0'};
	char skill_list[LEVEL_HERO + 1][MSL];
	char skill_columns[LEVEL_HERO + 1];
	int sn, level, min_lev = 1, max_lev = LEVEL_HERO;
	bool fAll = FALSE, found = FALSE;
	char buf[MSL]={'\0'};
 
	if (IS_NPC(ch))
	  return;

	if (argument[0] != '\0')
	{
	fAll = TRUE;

	if (str_prefix(argument,"all"))
	{
		argument = one_argument(argument,arg);
		if (!is_number(arg))
		{
		send_to_char("Arguments must be numerical or all.\n\r",ch);
		return;
		}
		max_lev = atoi(arg);

		if (max_lev < 1 || max_lev > LEVEL_HERO)
		{
		send_to_char( Format("Levels must be between 1 and %d.\n\r",LEVEL_HERO), ch);
		return;
		}

		if (argument[0] != '\0')
		{
		argument = one_argument(argument,arg);
		if (!is_number(arg))
		{
			send_to_char("Arguments must be numerical or all.\n\r",ch);
			return;
		}
		min_lev = max_lev;
		max_lev = atoi(arg);

		if (max_lev < 1 || max_lev > LEVEL_HERO)
		{
			send_to_char( Format("Levels must be between 1 and %d.\n\r",LEVEL_HERO), ch);
			return;
		}

		if (min_lev > max_lev)
		{
			send_to_char("That would be silly.\n\r",ch);
			return;
		}
		}
	}
	}


	/* initialize data */
	for (level = 0; level < LEVEL_HERO + 1; level++)
	{
		skill_columns[level] = 0;
		skill_list[level][0] = '\0';
	}
 
	for (sn = 0; sn < MAX_SKILL; sn++)
	{
		if (skill_table[sn].name == NULL )
		break;

	if ((level = skill_table[sn].skill_level[ch->iclass]) < LEVEL_HERO + 1
	&&  (fAll || level <= ch->level)
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun == spell_null
	&&  ch->pcdata->learned[sn] > 0)
		{
		found = TRUE;
		level = skill_table[sn].skill_level[ch->iclass];
		if (ch->level < level)
			sprintf(buf,"%-18s n/a      ", skill_table[sn].name);
		else
			sprintf(buf,"%-18s %3d%%      ",skill_table[sn].name,
			ch->pcdata->learned[sn]);
 
		if (skill_list[level][0] == '\0')
			sprintf(skill_list[level],"\n\rLevel %2d: %s",level,buf);
		else /* append */
		{
			if ( ++skill_columns[level] % 2 == 0)
			strcat(skill_list[level],"\n\r          ");
			strcat(skill_list[level],buf);
		}
	}
	}
 
	/* return results */
 
	if (!found)
	{
		send_to_char("No skills found.\n\r",ch);
		return;
	}

	buffer = new_buf();
	for (level = 0; level < LEVEL_HERO + 1; level++)
		if (skill_list[level][0] != '\0')
		add_buf(buffer,skill_list[level]);
	add_buf(buffer,"\n\r");
	page_to_char(buf_string(buffer),ch);
	free_buf(buffer);
}