Posted by
| Dace K
Canada (169 posts) Bio
|
Message
| Not all that much has been changed from stock, aside from the deletion of a few cases, and cases 'h', 'm', and 'A'. The error code ALWAYS happens either before, in place of, or after the first time %h or %m is called. There is never an error elsewhere in the string, or if %A is called first.
void display_prompt( DESCRIPTOR_DATA *d )
{
CHAR_DATA *ch = d->character;
CHAR_DATA *och = (d->original ? d->original : d->character);
CHAR_DATA *victim;
OBJ_DATA *obj;
bool ansi = (!IS_NPC(och) && xIS_SET(och->act, PLR_ANSI));
const char *prompt;
/*const char *helpstart = "<Type HELP START>";*/
char buf[MAX_STRING_LENGTH];
char *pbuf = buf;
int pstat, percent;
if ( !ch )
{
bug( "display_prompt: NULL ch" );
return;
}
/* if ( !IS_NPC(ch) && !IS_SET(ch->pcdata->flags, PCFLAG_HELPSTART ) )
prompt = helpstart;*/
else if ( !IS_NPC(ch) && ch->substate != SUB_NONE && ch->pcdata->subprompt
&& ch->pcdata->subprompt[0] != '\0' )
prompt = ch->pcdata->subprompt;
else if (IS_NPC (ch) || (!ch->fighting && (!ch->pcdata->prompt || !*ch->pcdata->prompt) ) )
prompt = default_prompt (ch);
else if ( ch->fighting )
{
if ( !ch->pcdata->fprompt || !*ch->pcdata->fprompt )
prompt = default_fprompt ( ch );
else
prompt = ch->pcdata->fprompt;
}
else
prompt = ch->pcdata->prompt;
if ( ansi )
{
strcpy( pbuf, ANSI_RESET );
d->prevcolor = 0x08;
pbuf += 4;
}
/* Clear out old color stuff */
for ( ; *prompt; prompt++ )
{
/*
* '%' = prompt commands
* Note: foreground changes will revert background to 0 (black)
*/
if( *prompt != '%' )
{
*(pbuf++) = *prompt;
continue;
}
++prompt;
if ( !*prompt )
break;
if ( *prompt == *(prompt-1) )
{
*(pbuf++) = *prompt;
continue;
}
switch(*(prompt-1))
{
default:
bug( "Display_prompt: bad command char '%c'.", *(prompt-1) );
break;
case '%':
*pbuf = '\0';
pstat = 0x80000000;
switch(*prompt)
{
case '%':
*pbuf++ = '%';
*pbuf = '\0';
break;
case 'A':
if ( (obj = get_eq_char( ch, WEAR_WIELD )) && obj->item_type == ITEM_FIREWEAPON)
sprintf(pbuf, "%d",obj->value[2]);
else
strcpy(pbuf, "N/A");
break;
case 'h':
if (ch->max_hit > 0)
percent = (100 * ch->hit ) / ch->max_hit;
else
percent = -1;
if (percent >= 60)
sprintf (pbuf, "\033[1;32m%d%%", percent);
else if (percent >= 40 && percent < 60)
sprintf (pbuf, "\033[1;33m%d%%", percent);
else if (percent >= 20 && percent < 40)
sprintf (pbuf, "\033[1;34m%d%%", percent);
else
sprintf (pbuf, "\033[1;31m%d%%", percent);
break;
case 'm':
if (ch->max_mana > 0)
percent = (100 * ch->mana ) / ch->max_mana;
else
percent = -1;
if (percent >= 60)
sprintf (pbuf, "\033[1;32m%d%%", percent);
else if (percent >= 40 && percent < 60)
sprintf (pbuf, "\033[1;33m%d%%", percent);
else if (percent >= 20 && percent < 40)
sprintf (pbuf, "\033[1;34m%d%%", percent);
else
sprintf (pbuf, "\033[1;31m%d%%", percent);
break;
case 'N': /* Tank */
if ( !IS_IMMORTAL(ch) ) break;
if ( !ch->fighting || ( victim = ch->fighting->who ) == NULL )
strcpy( pbuf, "N/A" );
else if(!victim->fighting||(victim=victim->fighting->who)==NULL)
strcpy( pbuf, "N/A" );
else {
if ( ch == victim )
strcpy ( pbuf, "You" );
else if ( IS_NPC(victim) )
strcpy ( pbuf, victim->short_descr );
else
strcpy ( pbuf, victim->name );
pbuf[0] = UPPER( pbuf[0] );
}
break;
case 'n':
if ( !IS_IMMORTAL(ch) ) break;
if (!ch->fighting || (victim = ch->fighting->who) == NULL )
strcpy( pbuf, "N/A" );
else {
if ( ch == victim )
strcpy ( pbuf, "You" );
else if ( IS_NPC(victim) )
strcpy ( pbuf, victim->short_descr );
else
strcpy ( pbuf, victim->name );
pbuf[0] = UPPER( pbuf[0] );
}
break;
case 'T':
if ( time_info.hour < 5 ) strcpy( pbuf, "night" );
else if ( time_info.hour < 6 ) strcpy( pbuf, "dawn" );
else if ( time_info.hour < 19 ) strcpy( pbuf, "day" );
else if ( time_info.hour < 21 ) strcpy( pbuf, "dusk" );
else strcpy( pbuf, "night" );
break;
|
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com | Top |
|