nightmare4_fluffos_v1/
nightmare4_fluffos_v1/bin/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/ChangeLog.old/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/Win32/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/compat/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/compat/simuls/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/include/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/clone/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/command/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/data/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/etc/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/include/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/inherit/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/inherit/master/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/log/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/single/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/single/tests/compiler/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/single/tests/efuns/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/single/tests/operators/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/testsuite/u/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/tmp/
nightmare4_fluffos_v1/fluffos-2.9-ds2.14/windows/
nightmare4_fluffos_v1/lib/cfg/
nightmare4_fluffos_v1/lib/cmds/admins/
nightmare4_fluffos_v1/lib/cmds/common/
nightmare4_fluffos_v1/lib/cmds/creators/include/
nightmare4_fluffos_v1/lib/cmds/creators/include/SCCS/
nightmare4_fluffos_v1/lib/cmds/hm/
nightmare4_fluffos_v1/lib/daemon/services/
nightmare4_fluffos_v1/lib/doc/
nightmare4_fluffos_v1/lib/doc/faq/
nightmare4_fluffos_v1/lib/doc/help/classes/
nightmare4_fluffos_v1/lib/doc/help/creators/
nightmare4_fluffos_v1/lib/doc/help/hm/
nightmare4_fluffos_v1/lib/doc/help/players/
nightmare4_fluffos_v1/lib/doc/help/races/
nightmare4_fluffos_v1/lib/doc/help/religion/
nightmare4_fluffos_v1/lib/doc/mudlib/
nightmare4_fluffos_v1/lib/doc/mudlib/cfg/
nightmare4_fluffos_v1/lib/domains/Ylsrim/
nightmare4_fluffos_v1/lib/domains/Ylsrim/adm/
nightmare4_fluffos_v1/lib/domains/Ylsrim/armour/
nightmare4_fluffos_v1/lib/domains/Ylsrim/fish/
nightmare4_fluffos_v1/lib/domains/Ylsrim/meal/
nightmare4_fluffos_v1/lib/domains/Ylsrim/npc/
nightmare4_fluffos_v1/lib/domains/Ylsrim/virtual/
nightmare4_fluffos_v1/lib/domains/Ylsrim/weapon/
nightmare4_fluffos_v1/lib/domains/Ylsrim/xtra/
nightmare4_fluffos_v1/lib/lib/comp/
nightmare4_fluffos_v1/lib/lib/lvs/
nightmare4_fluffos_v1/lib/lib/std/
nightmare4_fluffos_v1/lib/lib/user/
nightmare4_fluffos_v1/lib/news/
nightmare4_fluffos_v1/lib/obj/
nightmare4_fluffos_v1/lib/obj/include/
nightmare4_fluffos_v1/lib/save/
nightmare4_fluffos_v1/lib/save/kills/a/
nightmare4_fluffos_v1/lib/save/kills/b/
nightmare4_fluffos_v1/lib/save/kills/f/
nightmare4_fluffos_v1/lib/save/kills/m/
nightmare4_fluffos_v1/lib/save/kills/q/
nightmare4_fluffos_v1/lib/save/kills/r/
nightmare4_fluffos_v1/lib/secure/cfg/
nightmare4_fluffos_v1/lib/secure/cfg/classes/
nightmare4_fluffos_v1/lib/secure/cfg/races/SCCS/
nightmare4_fluffos_v1/lib/secure/cmds/creators/include/
nightmare4_fluffos_v1/lib/secure/cmds/players/
nightmare4_fluffos_v1/lib/secure/cmds/players/include/
nightmare4_fluffos_v1/lib/secure/daemon/include/
nightmare4_fluffos_v1/lib/secure/lib/
nightmare4_fluffos_v1/lib/secure/lib/include/
nightmare4_fluffos_v1/lib/secure/lib/net/
nightmare4_fluffos_v1/lib/secure/lib/std/
nightmare4_fluffos_v1/lib/secure/obj/
nightmare4_fluffos_v1/lib/secure/obj/include/
nightmare4_fluffos_v1/lib/secure/save/
nightmare4_fluffos_v1/lib/secure/save/boards/
nightmare4_fluffos_v1/lib/secure/save/votes/
nightmare4_fluffos_v1/lib/spells/
nightmare4_fluffos_v1/lib/verbs/admins/include/
nightmare4_fluffos_v1/lib/verbs/common/
nightmare4_fluffos_v1/lib/verbs/common/include/
nightmare4_fluffos_v1/lib/verbs/creators/
nightmare4_fluffos_v1/lib/verbs/creators/include/
nightmare4_fluffos_v1/lib/verbs/players/include/SCCS/
nightmare4_fluffos_v1/lib/verbs/rooms/
nightmare4_fluffos_v1/lib/verbs/rooms/include/
nightmare4_fluffos_v1/lib/www/
nightmare4_fluffos_v1/old/
nightmare4_fluffos_v1/old/tools/
nightmare4_fluffos_v1/win32/
/*    /cmds/player/body.c
 *    from the Nightmare IV LPC Library
 *    gives player a report based on limb damage
 *    created by Blitz@Nightmare IV
 */
 
#pragma save_binary

#include <lib.h>
#include <rounds.h>
 
inherit LIB_DAEMON;
 
varargs void eventCheckBody(object ob, object receiver);
 
static void create() {
  daemon::create();
  SetNoClean(1);
  parse_init();
  parse_add_rule("body", "LIV");
  parse_add_rule("body", "");
}
 
static string *DamageDegree = ({
  "is in critical condition!",
  "is battered beyond recognition.",
  "is severely wounded",
  "is terribly damaged.",
  "is in bad shape.",
  "is hurting.",
  "has a few bruises.",
  "is in decent shape.",
  "is in very good shape.",
  "is in excellent shape.",
});
 
int livings_are_remote() { return 1; }
 
mixed can_body() {
  if( creatorp(this_player()) )
    return "Creator syntax: body <living>";
  return 1;
}
 
mixed can_body_liv() {
  if( !creatorp(this_player()) )
    return "Body does not require any arguments.";
  return 1;
}
 
mixed do_body() {
  message("other_action", (string)this_player()->GetName()+" checks "+
          reflexive(this_player())+" for injuries.",
          environment(this_player()), this_player() );
  eventCheckBody(this_player());
  return 1;
}
 
mixed do_body_liv(object ob) {
  eventCheckBody(ob, this_player());
  return 1;
}
 
varargs void eventCheckBody(object ob, object receiver) {
  string ret, name;
  string *limbs;
  mapping mp;
  int i, damage;
  int *key;
 
  mp = ([ ]);
  if( !ob ) return;
  if( !receiver ) receiver = ob;
  i = sizeof(limbs = (string *)ob->GetLimbs());
  while(i--) {
    damage = to_int( percent( (int)ob->GetHealthPoints(limbs[i]),
                              (int)ob->GetMaxHealthPoints(limbs[i]) ));
    if( !mp[damage] ) mp[damage] = ({ limbs[i] });
    else mp[damage] += ({ limbs[i] });
  }
  i = sizeof(key = sort_array(keys(mp), 1));
  name = (ob == receiver ? "Your" : capitalize(possessive(ob)));
  ret = possessive_noun((string)ob->GetCapName()) + " bodily damage "
        "report:\n\n";
  foreach(damage in key) {
    string str;
    string color;
    int x;
    i = sizeof(limbs = mp[damage]);
    while(i--) {
      switch(damage) {
        case 0..3: color = "%^BOLD%^%^RED%^"; break;
        case 4..10: color = "%^RED%^";        break;
        case 11..20: color = "%^YELLOW%^";    break;
        default: color = "";
      }
      if( damage > 97 )
        str = name +" "+ limbs[i] + " is in perfect condition.";
      else if( damage < 4 )
        str = name+" "+ limbs[i] +" is about to fall off!";
      else {
        x = damage / 10;
        if(x>9) x = 9;
        str = name +" "+ limbs[i] +" "+ DamageDegree[x];
      }
      if( creatorp(receiver) )
        ret += sprintf("%s%-45s %s(%d / 100%%)%s\n", color, str, 
               "", damage,"%^RESET%^");
        else ret += (color + str + "%^RESET%^\n");
    }
  }
  if( i = sizeof(limbs = (string *)ob->GetMissingLimbs()) ) {
    ret += "\n"+(ob == receiver ?
           "You are missing " : (string)ob->GetName()+" is missing ");
    switch(i) {
      case 0: break;
      case 1: ret += "a "+limbs[0]+"."; break;
      case 2: ret += "a "+limbs[0]+" and a "+limbs[1]+"."; break;
      default:  ret += "a "+implode(limbs[0..(i-2)], ", ")+" and "
                "a "+limbs[i-1]+".";
    }
  }
  receiver->eventPage(explode(ret, "\n"), "info");
  return;
}
 
string GetHelp(string str) {
  if( creatorp(this_player()) )
    return "Syntax: body LIVING\n\n"
           "This command will display the current limb damage "
           "statistics of the living object named.";
  else
    return "Syntax: body\n\n"
           "This command will display your current limb damage "
           "statistics.  The limbs will be displayed in order "
           "of the most damaged to the least.";
}