|
Damage Message Code [by d. Hall] |
|
|
|
Posted Wednesday, August 12th @ 11:25:50 PM, by George Greer in the Utils dept.
Added Dec 8, 1997. Click the link below to read it or download it.
From: "d. hall" <dhall@APK.NET>
Subject: Damage messages
Notes:
CharType is a typedef struct char_data
ObjType is a typedef struct obj_data
cache_t is a typedef char cache_t[__CACHE_SIZE]
istrlist is a personal lib function I wrote which has variable
arguments and strcats all arguments to the first.
I use {variable-type}Type since I can have Emacs font-lock
highlight them.
CGRN and CNRM, etc... are a personal color system.
Adjust to taste, please let sit for 5 minutes to cool before
serving.
d.
typedef struct damage_message_type {
char *to_room;
char *to_char;
char *to_vict;
} DamMesgType;
static DamMesgType dam_weapon[] = {
// use #w for singular (i.e. "slash") and #W for plural (i.e. "slashes")
{ "$n grazes $N with $s #w", // 0: 1
"You graze $N with your #w",
"$n grazes you with $s #w" },
{ "$n barely #W $N", // 1: 2
"You barely #w $N",
"$n barely #W you" },
{ "$n lightly #W $N", // 2: 3
"You lightly #W $N",
"$n lightly #W you" },
{ "$n #W $N", // 3: 4-7
"You #w $N",
"$n #W you" },
{ "$n #W $N hard", // 4: 8-11
"You #w $N hard",
"$n #W you hard" },
{ "$n #W $N rather hard", // 5: 12-13
"You #w $N rather hard",
"$n #W you rather hard" },
{ "$n #W $N very hard", // 6: 14-17
"You #w $N very hard",
"$n #W you very hard" },
{ "$n #W $N extremely hard", // 7: 18-21
"You #w $N extremely hard",
"$n #W you extremely hard" },
{ "$n massacres $N with $s #w", // 8: 22-25
"You massacre $N with your #w",
"$n massacres you with $s #w" },
{ "$n annihilates $N with $s #w", // 9: > 25
"You annihilate $N with your #w",
"$n annihilates you with $s #w" }
};
static DamMesgType dam_amount[] = {
{ "$E hardly notices.", // 0: 1%
"$E hardly notices.",
"you hardly notice." },
{ "barely hurts $M.", // 1: 2%
"barely hurts $M.",
"barely hurts you." },
{ "slightly wounds $M.", // 2: 5%
"slightly wounds $M.",
"slightly wounds you." },
{ "wounds $M.", // 3: 10%
"wounds $M.",
"wounds you." },
{ "severely wounds $M.", // 4: 20%
"severely wounds $M.",
"severely wounds you." },
{ "maims $M.", // 5: 30%
"maims $M.",
"maims you." },
{ "seriously maims $M!", // 6: 45%
"seriously maims $M!",
"seriously maims you!" },
{ "cripples $M!", // 7: 60%
"cripples $M!",
"cripples you!" },
{ "completely cripples $M!", // 8: 80%
"completely cripples $M!",
"completely cripples you!" },
{ "totally ANNIHILATES $M!!", // 9: 100%
"totally ANNIHILATES $M!!",
"totally ANNIHILATES you!!" }
};
/* message for doing damage with a weapon */
void dam_message (int damage, CharType *ch, CharType *vict, int w_type)
{
static cache_t message;
int amount_index, weapon_index, percent;
w_type -= TYPE_HIT; // Change to base of table with text */
percent = (damage * 100 / GET_MAX_HIT (vict));
if (percent <= 1) amount_index = 0;
else if (percent <= 2) amount_index = 1;
else if (percent <= 5) amount_index = 2;
else if (percent <= 10) amount_index = 3;
else if (percent <= 20) amount_index = 4;
else if (percent <= 30) amount_index = 5;
else if (percent <= 45) amount_index = 6;
else if (percent <= 60) amount_index = 7;
else if (percent <= 80) amount_index = 8;
else amount_index = 9;
if (damage <= 1) weapon_index = 0;
else if (damage <= 2) weapon_index = 1;
else if (damage <= 3) weapon_index = 2;
else if (damage <= 7) weapon_index = 3;
else if (damage <= 11) weapon_index = 4;
else if (damage <= 13) weapon_index = 5;
else if (damage <= 17) weapon_index = 6;
else if (damage <= 21) weapon_index = 7;
else if (damage <= 25) weapon_index = 8;
else weapon_index = 9;
// message to onlookers
*message = '\0'; // Reset the message cache
istrlist (3, message,
replace_string (dam_weapon[weapon_index].to_room,
attack_hit_text[w_type].singular,
attack_hit_text[w_type].plural),
", which ",
dam_amount[amount_index].to_room);
act (message, FALSE, ch, NULL, vict, TO_NOTVICT);
// message to damager
*message = '\0'; // Reset the message cache
istrlist (5, message,
CGRN (ch),
replace_string (dam_weapon[weapon_index].to_char,
attack_hit_text[w_type].singular,
attack_hit_text[w_type].plural),
", which ",
dam_amount[amount_index].to_room,
CNRM (ch));
act (message, FALSE, ch, NULL, vict, TO_CHAR);
// message to damagee
*message = '\0'; // Reset the message cache
istrlist (5, message,
CRED (vict),
replace_string (dam_weapon[weapon_index].to_vict,
attack_hit_text[w_type].singular,
attack_hit_text[w_type].plural),
", which ",
dam_amount[amount_index].to_room,
CNRM (vict));
act (message, FALSE, ch, NULL, vict, TO_VICT | TO_SLEEP);
}
<< Counting Objects [by John Evans] | Reply | View as text | Flattened | Deathcount code [by Adam Beytin] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|