Only in src.dev: .accepted diff -u src/act.h src.dev/act.h --- src/act.h 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/act.h 2012-11-13 16:19:59.000000000 -0600 @@ -51,6 +51,7 @@ * Begin Functions and defines for act.informative.c ****************************************************************************/ /* Utility Functions */ +void diag_char_to_char(struct char_data *victim, struct char_data *ch); /** @todo Move to a utility library */ char *find_exdesc(char *word, struct extra_descr_data *list); /** @todo Move to a mud centric string utility library */ @@ -221,11 +222,12 @@ #define SCMD_AUTOMAP 25 #define SCMD_AUTOKEY 26 #define SCMD_AUTODOOR 27 -#define SCMD_COLOR 28 -#define SCMD_SYSLOG 29 -#define SCMD_WIMPY 30 -#define SCMD_PAGELENGTH 31 -#define SCMD_SCREENWIDTH 32 +#define SCMD_MELEE_HEALTH_MSGS 28 +#define SCMD_COLOR 29 +#define SCMD_SYSLOG 30 +#define SCMD_WIMPY 31 +#define SCMD_PAGELENGTH 32 +#define SCMD_SCREENWIDTH 33 /* do_quit */ ACMD(do_quit); diff -u src/act.informative.c src.dev/act.informative.c --- src/act.informative.c 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/act.informative.c 2012-11-13 18:42:38.000000000 -0600 @@ -29,8 +29,6 @@ #include "asciimap.h" /* prototypes of local functions */ -/* do_diagnose utility functions */ -static void diag_char_to_char(struct char_data *i, struct char_data *ch); /* do_look and do_examine utility functions */ static void do_auto_exits(struct char_data *ch); static void list_char_to_char(struct char_data *list, struct char_data *ch); @@ -219,34 +217,74 @@ send_to_char(ch, " Nothing.\r\n"); } -static void diag_char_to_char(struct char_data *i, struct char_data *ch) +void diag_char_to_char(struct char_data *victim, struct char_data *ch) { struct { - byte percent; - const char *text; + byte percent; + const char *self, *other, *text; } diagnosis[] = { - { 100, "is in excellent condition." }, - { 90, "has a few scratches." }, - { 75, "has some small wounds and bruises." }, - { 50, "has quite a few wounds." }, - { 30, "has some big nasty wounds and scratches." }, - { 15, "looks pretty hurt." }, - { 0, "is in awful condition." }, - { -1, "is bleeding awfully from big wounds." }, + { 100, "are", "is", "in excellent condition." }, + { 90, "have", "has", "a few scratches." }, + { 75, "have", "has", "some small wounds and bruises." }, + { 50, "have", "has", "quite a few wounds." }, + { 30, "have", "has", "some big nasty wounds and scratches." }, + { 15, "are", "looks", "pretty hurt." }, + { 0, "are", "is", "in awful condition." }, + { -1, "are", "is", "bleeding awfully from big wounds." }, }; - int percent, ar_index; - const char *pers = PERS(i, ch); + int ar_index; - if (GET_MAX_HIT(i) > 0) - percent = (100 * GET_HIT(i)) / GET_MAX_HIT(i); + /* use a fighting victim's melee health message number */ + if (FIGHTING(victim) != NULL) ar_index = victim->melee_health_message; + // remember: POS_FIGHTING and FIGHTING(...) are distinct else - percent = -1; /* How could MAX_HIT be < 1?? */ + { + int percent; - for (ar_index = 0; diagnosis[ar_index].percent >= 0; ar_index++) - if (percent >= diagnosis[ar_index].percent) - break; + if (GET_MAX_HIT(victim) > 0) + percent = (100 * GET_HIT(victim)) / GET_MAX_HIT(victim); + else + percent = -1; /* How could MAX_HIT be < 1?? */ - send_to_char(ch, "%c%s %s\r\n", UPPER(*pers), pers + 1, diagnosis[ar_index].text); + for (ar_index = 0; diagnosis[ar_index].percent >= 0; ar_index++) + if (percent >= diagnosis[ar_index].percent) + break; + } + /* show victim own health */ + if (ch == victim) + { + send_to_char(ch, "You %s %s\r\n", diagnosis[ar_index].self, diagnosis[ar_index].text); + return; + } + /* show normal ch victim's health */ + if (ch != victim->master) + { + const char *pers = PERS(victim, ch); + send_to_char(ch, "%c%s %s %s\r\n", UPPER(*pers), pers + 1, diagnosis[ar_index].other, + diagnosis[ar_index].text); + return; + } + /* let master know */ + const char *pers = PERS(victim, ch); + if (GET_POS(ch) == POS_SLEEPING) + { + send_to_char(ch, "You dream about %s ", pers); + if (ar_index > 0 || ar_index < 5) + send_to_char(ch, "having %s", diagnosis[ar_index].text); + if (ar_index == 0 || ar_index > 5) + send_to_char(ch, "%s", diagnosis[ar_index].text); + if (ar_index == 5) + send_to_char(ch, "looking %s", diagnosis[ar_index].text); + return; + } + if (IN_ROOM(ch) != IN_ROOM(victim)) + { + send_to_char(ch, "You sense %s %s %s\r\n", pers, diagnosis[ar_index].other, + diagnosis[ar_index].text); + return; + } + send_to_char(ch, "%c%s %s %s\r\n", UPPER(*pers), pers + 1, diagnosis[ar_index].other, + diagnosis[ar_index].text); } static void look_at_char(struct char_data *i, struct char_data *ch) @@ -259,7 +297,8 @@ if (i->player.description) send_to_char(ch, "%s", i->player.description); else - act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT); + (ch == i) ? send_to_char(ch, "You see nothing special about yourself.\r\n") + : act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT); diag_char_to_char(i, ch); @@ -722,13 +761,19 @@ } if (!*arg) /* "look" alone, without an argument at all */ look_at_room(ch, 1); + else if (!str_cmp(arg, "self")) + look_at_target(ch, GET_NAME(ch)); else if (is_abbrev(arg, "in")) look_in_obj(ch, arg2); /* did the char type 'look ?' */ else if ((look_type = search_block(arg, dirs, FALSE)) >= 0) look_in_direction(ch, look_type); else if (is_abbrev(arg, "at")) - look_at_target(ch, arg2); + { + if (!str_cmp(arg2, "self")) + look_at_target(ch, GET_NAME(ch)); + else look_at_target(ch, arg2); + } else if (is_abbrev(arg, "around")) { struct extra_descr_data *i; @@ -1911,6 +1956,9 @@ {"autodoor", PRF_AUTODOOR, 0, "You will now need to specify a door direction when opening, closing and unlocking.\r\n", "You will now find the next available door when opening, closing or unlocking.\r\n"}, + {"healthmsg", PRF_MELEE_HEALTH_MSGS, 0, + "You will now see melee health messages.\r\n", + "You will no longer see melee health messages.\r\n"}, {"color", 0, 0, "\n", "\n"}, {"syslog", 0, LVL_IMMORT, "\n", "\n"}, {"wimpy", 0, 0, "\n", "\n"}, @@ -2031,6 +2079,7 @@ ONOFF(PRF_FLAGGED(ch, PRF_AUTOKEY)), ONOFF(PRF_FLAGGED(ch, PRF_AUTODOOR)), + ONOFF(PRF_FLAGGED(ch, PRF_MELEE_HEALTH_MSGS)), types[COLOR_LEV(ch)]); return; } Only in src.dev: act.informative.c~ diff -u src/act.other.c src.dev/act.other.c --- src/act.other.c 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/act.other.c 2012-11-13 16:19:59.000000000 -0600 @@ -749,7 +749,9 @@ {"Autokey disabled.\r\n", "Autokey enabled.\r\n"}, {"Autodoor disabled.\r\n", - "Autodoor enabled.\r\n"} + "Autodoor enabled.\r\n"}, + {"Melee health messages disabled.\r\n", + "Melee health messages enabled.\r\n"} }; if (IS_NPC(ch)) @@ -860,6 +862,9 @@ case SCMD_AUTODOOR: result = PRF_TOG_CHK(ch, PRF_AUTODOOR); break; + case SCMD_MELEE_HEALTH_MSGS: + result = PRF_TOG_CHK(ch, PRF_MELEE_HEALTH_MSGS); + break; default: log("SYSERR: Unknown subcmd %d in do_gen_toggle.", subcmd); return; Only in src.dev: conf.h diff -u src/constants.c src.dev/constants.c --- src/constants.c 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/constants.c 2012-11-13 16:19:59.000000000 -0600 @@ -252,6 +252,7 @@ "AUTOMAP", "AUTOKEY", "AUTODOOR", + "HEALTHMSG", "\n" }; Only in src.dev: depend diff -u src/fight.c src.dev/fight.c --- src/fight.c 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/fight.c 2012-11-13 18:36:07.000000000 -0600 @@ -593,6 +593,21 @@ attack_hit_text[w_type].singular, attack_hit_text[w_type].plural); act(buf, FALSE, ch, NULL, victim, TO_VICT | TO_SLEEP); send_to_char(victim, CCNRM(victim, C_CMP)); + + /* if victim's health message has changed */ + if (victim->melee_health_message != victim->prior_melee_health_message) + { + /* show it to PCs in the room who want to see it and are in the fight or + the victim's master */ + for (ch = world[IN_ROOM(victim)].people; ch; ch = ch->next_in_room) + if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_MELEE_HEALTH_MSGS) + && (ch == victim || FIGHTING(ch) == victim || FIGHTING(ch) == FIGHTING(victim) + || ch == victim->master)) + diag_char_to_char(victim, ch); + /* let victims' masters in another room know */ + if ((victim->master) && IN_ROOM(victim) != IN_ROOM(victim->master)) + diag_char_to_char(victim, victim->master); + } } /* message for doing damage with a spell or skill. Also used for weapon @@ -735,16 +750,39 @@ dam = 0; } - /* Set the maximum damage per round and subtract the hit points */ + /* Set the maximum damage per round */ dam = MAX(MIN(dam, 100), 0); - GET_HIT(victim) -= dam; - - /* Gain exp for the hit */ - if (ch != victim) - gain_exp(ch, GET_LEVEL(victim) * dam); - - update_pos(victim); + if (dam > 0) + { + /* store victim's health message before damage */ + int health_percent; + health_percent = (100 * GET_HIT(victim)/GET_MAX_HIT(victim)); + if (health_percent >= 100) victim->prior_melee_health_message = 0; + else if (health_percent >= 90) victim->prior_melee_health_message = 1; + else if (health_percent >= 75) victim->prior_melee_health_message = 2; + else if (health_percent >= 50) victim->prior_melee_health_message = 3; + else if (health_percent >= 30) victim->prior_melee_health_message = 4; + else if (health_percent >= 15) victim->prior_melee_health_message = 5; + else victim->prior_melee_health_message = 6; + + /* subtract the hit points */ + GET_HIT(victim) -= dam; + + /* store victim's health message after damage */ + health_percent = 100 * GET_HIT(victim)/GET_MAX_HIT(victim); + if (health_percent >= 90) victim->melee_health_message = 1; + else if (health_percent >= 75) victim->melee_health_message = 2; + else if (health_percent >= 50) victim->melee_health_message = 3; + else if (health_percent >= 30) victim->melee_health_message = 4; + else if (health_percent >= 15) victim->melee_health_message = 5; + else victim->melee_health_message = 6; + + /* Gain exp for the hit */ + if (ch != victim) + gain_exp(ch, GET_LEVEL(victim) * dam); + } + update_pos(victim); /* skill_message sends a message from the messages file in lib/misc. * dam_message just sends a generic "You hit $n extremely hard.". * skill_message is preferable to dam_message because it is more Only in src.dev: fight.c~ diff -u src/interpreter.c src.dev/interpreter.c --- src/interpreter.c 2012-04-04 18:13:22.000000000 -0500 +++ src.dev/interpreter.c 2012-11-13 16:19:59.000000000 -0600 @@ -181,6 +181,7 @@ { "holler" , "holler" , POS_RESTING , do_gen_comm , 1, SCMD_HOLLER }, { "holylight", "holy" , POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_HOLYLIGHT }, { "house" , "house" , POS_RESTING , do_house , 0, 0 }, + { "healthmsg", "he" , POS_DEAD , do_gen_tog, 0, SCMD_MELEE_HEALTH_MSGS }, { "inventory", "i" , POS_DEAD , do_inventory, 0, 0 }, { "identify" , "id" , POS_STANDING, do_not_here , 1, 0 }, Only in src.dev: Makefile diff -u src/structs.h src.dev/structs.h --- src/structs.h 2012-04-04 18:11:23.000000000 -0500 +++ src.dev/structs.h 2012-11-13 16:19:59.000000000 -0600 @@ -266,8 +266,9 @@ #define PRF_AUTOMAP 31 /**< Show map at the side of room descs */ #define PRF_AUTOKEY 32 /**< Automatically unlock locked doors when opening */ #define PRF_AUTODOOR 33 /**< Use the next available door */ +#define PRF_MELEE_HEALTH_MSGS 34 /**< Show melee health messages */ /** Total number of available PRF flags */ -#define NUM_PRF_FLAGS 34 +#define NUM_PRF_FLAGS 35 /* Affect bits: used in char_data.char_specials.saved.affected_by */ /* WARNING: In the world files, NEVER set the bits marked "R" ("Reserved") */ @@ -1007,6 +1008,8 @@ room_rnum in_room; /**< Current location (real room number) */ room_rnum was_in_room; /**< Previous location for linkdead people */ int wait; /**< wait for how many loops before taking action. */ + sh_int melee_health_message; + sh_int prior_melee_health_message; struct char_player_data player; /**< General PC/NPC data */ struct char_ability_data real_abils; /**< Abilities without modifiers */ Common subdirectories: src/util and src.dev/util