score.txt
snippets · 12.8 KB · 2010-03-30
Score: a new score display released into the public domain.
Download « Back to the snippets list
**********************************************************************************
* Since I felt the need to release something into the public domain considering *
* the amount of snippets I've found useful, I thought my version of the score *
* command would be a good starting point. The one that comes with stock ROM is *
* just horrible, it is useful for completely newbie coders (like me) to replace *
* the stock score command or just use as an example of how to do it. *
* *
* Note that you will more than likely have to remove a number of fields to get *
* this to work correctly in stock ROM. In my MUD I have pre-titles, clan ranks, *
* and a subdue system. Apart from removing those fields, if you are using stock *
* ROM just find "void do_score" in act_info.c and replace with this one. If you *
* do not have Lopes ColoUr code installed, then remove any instances of the *
* colour codes (any { followed by one letter, e.g {Y ). *
* *
* I take no special credit for this code, since it is basically just formatting *
* and there is nothing new. Thanks go to the original creators of the score *
* command. If you wish to use this score command... feel free! I dont require *
* any emails, additions to snippets or thank-you files, or anything. Enjoy! *
* *
* Aarelan, Head Coder of The Winds of Loran. *
**********************************************************************************
/* The complete score command looks like this:
=================================================================
Aarelan, Leader of the Church of Pelor.
=================================================================
Level: 60 Age: 17 Played: 12 hours.
Title: Arch-Priest Clan: Immortal Clan Rank: Head Coder
=================================================================
Race: Half-Elf Sex: male Class: Cleric
Str: 25(25) Int: 25(25) Wis: 25(25) Dex: 25(25) Con: 25(25)
=================================================================
HP: 32548 of 32548 MANA: 31353 of 31353 MOVE: 32046 of 32046
Practices: 681 Trains: 344
=================================================================
Items: 24 of 1000 Weight: 99 of 1000000 pounds.
Gold: 43 Silver: 2345
=================================================================
Alignment: 996 You are angelic.
=================================================================
Wimpy: 0 hit points.
You are standing.
=================================================================
Armor: pierce: -65 bash: -67 slash: -67 magic: -51
You are very well-armored against piercing.
You are very well-armored against bashing.
You are very well-armored against slashing.
You are very well-armored against magic.
=================================================================
Holy Light: on
You will subdue in combat.
Hitroll: 506 Damroll: 509
*/
void do_score (CHAR_DATA * ch, char *argument)
{
char buf[MAX_STRING_LENGTH];
int i;
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf,
"{G%s%s.{x\n\r",
ch->name,
IS_NPC (ch) ? "" : ch->pcdata->title);
send_to_char (buf, ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf, "Level: {Y%d{x Age: {Y%d{x Played: {Y%d{x hours.\n\r",
ch->level, get_age (ch),
(ch->played + (int) (current_time - ch->logon)) / 3600);
send_to_char (buf, ch);
if (get_trust (ch) != ch->level)
{
sprintf (buf, "You are trusted at level %d.\n\r", get_trust (ch));
send_to_char (buf, ch);
}
sprintf (buf, "Title: {Y%s{x Clan: {Y%s{x Clan Rank: {Y%s{x\n\r",
IS_NPC (ch) ? "" : ch->pcdata->pretit,
clan_table[ch->clan].name, player_rank(ch) );
send_to_char (buf, ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf, "Race: {Y%s{x Sex: {Y%s{x Class: {Y%s{x\n\r",
race_table[ch->race].name,
ch->sex == 0 ? "sexless" : ch->sex == 1 ? "male" : "female",
IS_NPC (ch) ? "mobile" : class_table[ch->class].name);
send_to_char (buf, ch);
sprintf (buf,
"Str: {Y%d{x({R%d{x) Int: {Y%d{x({R%d{x) Wis: {Y%d{x({R%d{x) Dex: {Y%d{x({R%d{x) Con: {Y%d{x({R%d{x)\n\r",
ch->perm_stat[STAT_STR],
get_curr_stat (ch, STAT_STR),
ch->perm_stat[STAT_INT],
get_curr_stat (ch, STAT_INT),
ch->perm_stat[STAT_WIS],
get_curr_stat (ch, STAT_WIS),
ch->perm_stat[STAT_DEX],
get_curr_stat (ch, STAT_DEX),
ch->perm_stat[STAT_CON], get_curr_stat (ch, STAT_CON));
send_to_char (buf, ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf,
"HP: {Y%d{x of {R%d{x MANA: {Y%d{x of {R%d{x MOVE: {Y%d{x of {R%d{x\n\r",
ch->hit, ch->max_hit,
ch->mana, ch->max_mana, ch->move, ch->max_move);
send_to_char (buf, ch);
sprintf (buf,
"Practices: {Y%d{x Trains: {Y%d{x\n\r",
ch->practice, ch->train);
send_to_char (buf, ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf,
"Items: {Y%d{x of {R%d{x Weight: {Y%ld{x of {Y%d{x pounds.\n\r",
ch->carry_number, can_carry_n (ch),
get_carry_weight (ch) / 10, can_carry_w (ch) / 10);
send_to_char (buf, ch);
sprintf (buf,
"Gold: {Y%ld{x Silver: {W%ld{x\n\r",
ch->gold, ch->silver);
send_to_char (buf, ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
/* RT shows exp to level */
if (!IS_NPC (ch) && ch->level < LEVEL_HERO)
{
sprintf (buf,
"Experience: {Y%d{x Next level: {Y%d{x\n\r",
ch->exp,
((ch->level + 1) * exp_per_level (ch, ch->pcdata->points) -
ch->exp));
send_to_char (buf, ch);
}
if (ch->level >= 10)
{
sprintf (buf, "Alignment: {Y%d{x ", ch->alignment);
send_to_char (buf, ch);
}
send_to_char ("You are ", ch);
if (ch->alignment > 900)
send_to_char ("{Yangelic.{x\n\r", ch);
else if (ch->alignment > 700)
send_to_char ("{Ysaintly.{x\n\r", ch);
else if (ch->alignment > 350)
send_to_char ("{Ygood.{x\n\r", ch);
else if (ch->alignment > 100)
send_to_char ("{Wkind.{x\n\r", ch);
else if (ch->alignment > -100)
send_to_char ("{Wneutral.{x\n\r", ch);
else if (ch->alignment > -350)
send_to_char ("{Wmean.{x\n\r", ch);
else if (ch->alignment > -700)
send_to_char ("{Revil.{x\n\r", ch);
else if (ch->alignment > -900)
send_to_char ("{Rdemonic.{x\n\r", ch);
else
send_to_char ("{Rsatanic.{x\n\r", ch);
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
sprintf (buf, "Wimpy: {Y%d{x hit points.\n\r", ch->wimpy);
send_to_char (buf, ch);
if (!IS_NPC (ch) && ch->pcdata->condition[COND_DRUNK] > 10)
send_to_char ("You are drunk.\n\r", ch);
if (!IS_NPC (ch) && ch->pcdata->condition[COND_THIRST] == 0)
send_to_char ("You are thirsty.\n\r", ch);
if (!IS_NPC (ch) && ch->pcdata->condition[COND_HUNGER] == 0)
send_to_char ("You are hungry.\n\r", ch);
switch (ch->position)
{
case POS_DEAD:
send_to_char ("You are DEAD!!\n\r", ch);
break;
case POS_MORTAL:
send_to_char ("You are mortally wounded.\n\r", ch);
break;
case POS_INCAP:
send_to_char ("You are incapacitated.\n\r", ch);
break;
case POS_STUNNED:
send_to_char ("You are stunned.\n\r", ch);
break;
case POS_SUBDUE:
send_to_char ("You have been subdued!\n\r", ch);
break;
case POS_SLEEPING:
send_to_char ("You are sleeping.\n\r", ch);
break;
case POS_RESTING:
send_to_char ("You are resting.\n\r", ch);
break;
case POS_SITTING:
send_to_char ("You are sitting.\n\r", ch);
break;
case POS_STANDING:
send_to_char ("You are standing.\n\r", ch);
break;
case POS_FIGHTING:
send_to_char ("You are fighting.\n\r", ch);
break;
}
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
/* print AC values */
if (ch->level >= 25)
{
sprintf (buf, "Armor: pierce: {Y%d{x bash: {Y%d{x slash: {Y%d{x magic: {Y%d{x\n\r",
GET_AC (ch, AC_PIERCE),
GET_AC (ch, AC_BASH),
GET_AC (ch, AC_SLASH), GET_AC (ch, AC_EXOTIC));
send_to_char (buf, ch);
}
for (i = 0; i < 4; i++)
{
char *temp;
switch (i)
{
case (AC_PIERCE):
temp = "piercing";
break;
case (AC_BASH):
temp = "bashing";
break;
case (AC_SLASH):
temp = "slashing";
break;
case (AC_EXOTIC):
temp = "magic";
break;
default:
temp = "error";
break;
}
send_to_char ("You are ", ch);
if (GET_AC (ch, i) >= 200)
sprintf (buf, "hopelessly vulnerable to %s.\n\r", temp);
else if (GET_AC (ch, i) >= 175)
sprintf (buf, "defenseless against %s.\n\r", temp);
else if (GET_AC (ch, i) >= 150)
sprintf (buf, "barely protected from %s.\n\r", temp);
else if (GET_AC (ch, i) >= 125)
sprintf (buf, "slightly armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= 75)
sprintf (buf, "somewhat armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= 0)
sprintf (buf, "armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= -50)
sprintf (buf, "well-armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= -100)
sprintf (buf, "very well-armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= -150)
sprintf (buf, "heavily armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= -200)
sprintf (buf, "superbly armored against %s.\n\r", temp);
else if (GET_AC (ch, i) >= -250)
sprintf (buf, "almost invulnerable to %s.\n\r", temp);
else
sprintf (buf, "divinely armored against %s.\n\r", temp);
send_to_char (buf, ch);
}
sprintf (buf,
"{B================================================================={x\n\r");
send_to_char (buf, ch);
/* RT wizinvis and holy light */
if (IS_IMMORTAL (ch))
{
send_to_char ("Holy Light: ", ch);
if (IS_SET (ch->act, PLR_HOLYLIGHT))
send_to_char ("{Yon{x", ch);
else
send_to_char ("{Roff{x", ch);
if (ch->invis_level)
{
sprintf (buf, " Invisible: level {Y%d{x", ch->invis_level);
send_to_char (buf, ch);
}
if (ch->incog_level)
{
sprintf (buf, " Incognito: level {Y%d{x", ch->incog_level);
send_to_char (buf, ch);
}
send_to_char ("\n\r", ch);
}
if(!IS_SET(ch->act, PLR_SUBDUE))
{
send_to_char("{wYou will {Rkill{w in combat.{W\n\r", ch );
}
else
{
send_to_char("{wYou will {Ysubdue{w in combat.{W\n\r", ch );
}
if (ch->level >= 15)
{
sprintf (buf, "Hitroll: {Y%d{x Damroll: {Y%d{x\n\r",
GET_HITROLL (ch), GET_DAMROLL (ch));
send_to_char (buf, ch);
}
if (IS_SET (ch->comm, COMM_SHOW_AFFECTS))
do_function (ch, &do_affects, "");
}