| Message |
If you want to play with this, the health bar is at:
http://github.com/nickgammon/plugins/blob/master/Health_Bar_Miniwindow_Telnet.xml
The experience bar is at:
http://github.com/nickgammon/plugins/blob/master/Experience_Bar_Telnet.xml
You need the new "gauge" module:
http://github.com/nickgammon/mushclient/blob/master/lua/gauge.lua
The "show status" code in SmaugFuss is now:
void show_status( CHAR_DATA *ch )
{
if (WANT_TELNET_INFO (ch))
{
CHAR_DATA * victim = NULL;
if (ch->fighting)
victim = ch->fighting->who;
char * pPlayerName;
pPlayerName = fixup_lua_strings (ch->name);
char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof (buf),
"\xFF\xFA\x66" // IAC SB 102
"tt=\"status\";" // transaction type: status
"name=%s;"
"bar={" // status bar info
"HP={cur=%d;max=%d};" // hp points
"Mana={cur=%d;max=%d};" // mana
"Move={cur=%d;max=%d};" // movement
"};" // end bar table
"xp={cur=%d;max=%d};" // experience
"gold=%i;" // gold
"level=%d;" // level
"combat=%s;" // in combat or not
"dead=%s;" // dead?
"poisoned=%s;", // poisoned?
pPlayerName,
ch->hit,
ch->max_hit,
IS_VAMPIRE( ch ) ? 0 : ch->mana,
IS_VAMPIRE( ch ) ? 0 : ch->max_mana,
ch->move,
ch->max_move,
ch->exp,
exp_level( ch, ch->level + 1 ) - ch->exp,
ch->gold,
ch->level,
(ch->fighting && ch->fighting->who) ? "true" : "false",
TRUE_OR_FALSE (char_died( ch )),
TRUE_OR_FALSE (IS_AFFECTED( ch, AFF_POISON ))
);
free (pPlayerName);
if( ch->first_affect )
{
AFFECT_DATA *paf;
SKILLTYPE *sktmp;
char * pAffectName;
strncpy(&buf [strlen (buf)], "buffs={", sizeof (buf) - strlen (buf));
for( paf = ch->first_affect; paf; paf = paf->next )
{
if (sktmp = get_skilltype( paf->type ))
{
pAffectName = fixup_lua_strings (sktmp->name);
snprintf(&buf [strlen (buf)], sizeof (buf) - strlen (buf),
"%s;", pAffectName);
free (pAffectName);
}
} // end for loop
strncpy(&buf [strlen (buf)], "};", sizeof (buf) - strlen (buf));
} // end if any affects
// combat info
if (victim)
{
const char * p = "You";
char * pName;
if (ch != victim)
{
if (IS_NPC( victim ) )
p = victim->short_descr;
else
p = victim->name;
}
pName = fixup_lua_strings (p);
snprintf(&buf [strlen (buf)], sizeof (buf) - strlen (buf),
"victim={name=%s;" // name
"hp=%d;maxhp=%d;" // hp points
"level=%d;" // level
"};",
pName,
victim->hit,
victim->max_hit,
victim->level
);
free (pName);
}
// finish telnet negotiation after the combat info
strncpy(&buf [strlen (buf)], "\xFF\xF0", sizeof (buf) - strlen (buf)); // IAC SE
send_to_char( buf, ch );
}
}
That handles code for buffs (but not debuffs yet).
In read_from_buffer I added a couple of lines to suggest bar colours:
write_to_descriptor(d, "\xFF\xFA\x66 tt=\"version\";version=1.0;\xFF\xF0", 0);
// define bar colours
write_to_descriptor(d, "\xFF\xFA\x66 bar={"
"HP={clr=\"darkgreen\"};" // hp
"Mana={clr=\"mediumblue\"};" // mana
"Move={clr=\"gold\"};" // movement
"};" // end bar
"\xFF\xF0", 0);
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|