musicmud-2.1.6/data/
musicmud-2.1.6/data/help/
musicmud-2.1.6/data/policy/
musicmud-2.1.6/data/wild/
musicmud-2.1.6/data/world/
musicmud-2.1.6/doc/
musicmud-2.1.6/src/ident/
musicmud-2.1.6/src/lua/
musicmud-2.1.6/src/lua/include/
musicmud-2.1.6/src/lua/src/lib/
musicmud-2.1.6/src/lua/src/lua/
musicmud-2.1.6/src/lua/src/luac/
#define D_NONE 1
#define D_LOW 5
#define D_MIDLOW 10
#define D_MID 15
#define D_MIDHIGH 20
#define D_HIGH 25
#define D_VERY -1

#define D_ANY -2

#define D_DEATHBLOW -100

#define HAND     (1<<0)
#define HEAD     (1<<1)
#define HEADHAIR (1<<2)
#define TALK     (1<<3)
#define FOOT     (1<<4)
#define PELVIS   (1<<5)
#define JAW      (1<<6) 
#define LEG      (1<<7)
#define NECK     (1<<8)
#define CHEST    (1<<9)
#define ARM      (1<<10)
#define ABDOMEN  (1<<11)
#define EAR      (1<<12)
#define NOSE     (1<<13)
#define EYE      (1<<14)
#define ROBOT    (1<<15)
#define WING     (1<<16)
#define FEATHERS (1<<17)

#define R_ONLAND (1<<16)

const char *part[] = {
  "hand", "head", "head hair", "speech",
  "foot", "pelvis", "jaw", "leg", "neck",
  "chest", "arm", "abdomen", "ear", "nose",
  "eye", "robot", "wing", "feathers"
};

static string explain(int n) {
  string s = "";
  for (int i=0;i<18;i++) {
    if (n & (1 << i)) {
      if (s.length()) s+=", ";
      s += part[i];
    }
  }
  return s;
}

struct combat_msg {
  int maxdam;
  int weapon;
  int attflag;
  int vicflag;
  const char *msg;
  const char *cause;
  const char *corpse;
};


#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))

/* %w weapon short, %W their/your weapon   */

/* This message table is VERY incomplete.

   Unarmed combat is barely started.
   We need various messages against Robots

*/

struct combat_msg cmsg[] = {

{ D_MIDLOW,  W_CUTTING, 0,       ARM,      "%#1's innacurate swing leaves a long, but shallow graze across %a's forearm."},

{ D_MID,     W_CUTTING, 0,       CHEST,    "%#1 %[score/score] a long cut across %a's chest, but fails to penetrate %d ribcage."},

{ D_MIDHIGH, W_CUTTING, 0,       ARM,      "%#1 %[slices/slice] %W across %a's bicep, leaving a long, deep slash."},
{ D_MIDHIGH, W_CUTTING, 0,       LEG,      "%#1 %[slashes/slash] down into %a's calf-muscle, opening a deep wound."},
{ D_MIDHIGH, W_CUTTING, 0,       CHEST,    "%#1's strike to %a's chest leaves only a shallow cut, but cracks a rib."},
{ D_MIDHIGH, W_CUTTING, 0,       ABDOMEN,  "%#1 %[whips/whip] the end of %W into %a's solar plexus, leaving a nasty gash."},
{ D_MIDHIGH, W_CUTTING, 0,       HEAD,     "%#1's %w scores a long slash across %a's head, causing blood to trickle down into %d eyes."},

{ D_HIGH,    W_CUTTING, 0,       LEG,      "%#1 %[swings/swing] %W hard into %a's knee, sinking deep into the tendons and buckling %d leg."},

{ D_VERY,    W_CUTTING, 0,       ABDOMEN,  "%#1's %w sinks deep into %a's guts, spraying blood and inducing a scream of agony from %c."},

{ D_MIDLOW,  W_STABBING,0,       ABDOMEN,  "%#1 %[pokes/poke] %a in the belly with %W, leaving a shallow wound."},

{ D_MID,     W_STABBING,0,       HEAD,     "%#1 %[lunges/lunge] fowards, stabbing %a in the forehead. %#W bounce off the skull, leaving a jagged wound."},

{ D_MIDHIGH, W_STABBING,0,       ARM,      "%#1 %[thrusts/thrust] %W clean through %a's forearm, but doesn't hit anything too serious."},
{ D_MIDHIGH, W_STABBING,0,       LEG,      "%#1 %[stabs/stab] %a right through the calf-muscle, sending %c stumbling backwards."},
{ D_MIDHIGH, W_STABBING,0,       CHEST,    "%#1 %[jabs/stab] %4 %w deep into %a's chest, but amazing misses lungs and heart."},
{ D_MIDHIGH, W_STABBING,0,       ABDOMEN,  "%#1 %[sticks/stick] the tip of %W into %a's belly, producing a nasty wound that quickly begins to leak blood."},
{ D_MIDHIGH, W_STABBING,0,       HEAD,     "%#a barely %[manages/manage] to dodge a thrust by %1, and takes a nasty wound across the side of %d face."},

{ D_HIGH,    W_STABBING,0,       CHEST,    "%#1 %[stabs/stab] %W deep into %a's chest, just scraping along the side of %d lung."},

{ D_VERY,    W_STABBING,0,       LEG,      "%#1 %[drives/drive] %W clean through %a's hip, sending %d staggering backwards spraying blood."},

{ D_NONE,   W_UNARMED, HAND,      ROBOT,    "%#1 %[scuffs/scuff] %a's casing."},
{ D_LOW,    W_UNARMED, FOOT,      ROBOT,    "%#1 %[kicks/kick] %a right in the diodes."},
{ D_MIDLOW, W_UNARMED, HAND,      ROBOT,    "%#1 %[rips/rip] some of %a's wiring."},
{ D_MID,    W_UNARMED, FOOT,      ROBOT,    "%#1 %[damages/damage] %a's motor with a nasty kick."},
{ D_MIDHIGH,W_UNARMED, HAND,      ROBOT,    "%#1 %[punches/punch] %a's batteries."},
{ D_HIGH,   W_UNARMED, HAND,      ROBOT,    "%#1 %[tears/tear] apart %a's visual sensor array."},
{ D_VERY,   W_UNARMED, HAND,      ROBOT,    "%#1 %[shatters/shatter] %a's control unit with a furious punch."},

{ D_NONE,   W_IMPACT, 0,      ROBOT,    "%#1's %w scuffs %a's casing."},
{ D_LOW,    W_IMPACT, 0,      ROBOT,    "%#1's %w hits %a right in the diodes."},
{ D_MIDLOW, W_IMPACT, 0,      ROBOT,    "%#1's rips some of %a's wiring."},
{ D_MID,    W_IMPACT, 0,      ROBOT,    "%#1's %w blow damages %a's motor."},
{ D_MIDHIGH,W_IMPACT, 0,      ROBOT,    "%#1 %[savages/savage] %a's visual sensors with %W."},
{ D_HIGH,   W_IMPACT, 0,      ROBOT,    "%#1 %[delivers/deliver] an impact to %a's batteries with %W."},
{ D_VERY,   W_IMPACT, 0,      ROBOT,    "%#1's %w shatters %a's control unit."},


{ D_NONE, W_CUTTING, 0   ,      ROBOT,  "%#1 %[scratches/scratch] %a's paintwork with %W."},
{ D_NONE,    W_CUTTING, 0,       ROBOT, "%#1 %[swings/swing] with %W, but it bounces off %a's casing."},
{ D_NONE,    W_STABBING,0,       ROBOT, "%#1 %[stabs/stab] %a with %W, but %[is/are] unable to penetrate %a's casing."},

/* XXX - more futile attacks against robots */

{ D_NONE, W_UNARMED, TALK|FOOT, HEAD,     "%#1 %[screams/scream] with anger as %2 "
                                                        "%[misjudges/misjudge] a kick to %a's head."},
{ D_NONE, W_UNARMED, HAND,      HEAD,     "%#1 %[slaps/slap] %a in the face."},
{ D_NONE, W_UNARMED, TALK,      TALK,     "%#1 %[taunts/taunt] %a with a hurtful remark."},
{ D_NONE, W_UNARMED, HAND,      HAND,     "%#1 %[grabs/grab] %a by the wrist and gives %c a chinese burn."},
{ D_NONE, W_UNARMED, HAND,      HEADHAIR, "%#1 %[grabs/grab] a handful of %a's hair and %[yanks/yank] it hard."},

{ D_LOW, W_UNARMED, HAND, NOSE, "%#1 %[tickles/tickle] %a on the nose."},
{ D_LOW, W_UNARMED, HAND, EAR,  "%#1's poorly timed punch grazes %a's ear."},
{ D_LOW, W_UNARMED, FOOT, 0, "%#1's sweeping kick barely managed to touch %a."},
{ D_LOW, W_UNARMED, FOOT, FOOT, "%#1 %[stamps/stamp] on %a's toes."},
{ D_LOW, W_UNARMED, HAND, 0, "%#1 %[shoves/shove] %a, to no effect."},

{ D_MIDLOW, W_UNARMED, FOOT, LEG, "%#1 %[kicks/kick] %a in the shin."},
{ D_MIDLOW, W_UNARMED, HAND, ARM, "%#1 %[wrenches/wrench] %a's arm."},
{ D_MIDLOW, W_UNARMED, FOOT, ABDOMEN, "%#1 %[kicks/kick] %a squarely in the stomach."},
{ D_MIDLOW, W_UNARMED, HAND, EYE    , "%#1 %[rakes/rake] %a's eyes painfully."},
{ D_MIDLOW, W_UNARMED, LEG , JAW    , "%#1 %[knees/knee] %a hard in the jaw."},
{ D_MIDLOW, W_UNARMED, HAND, ARM,     "%#1 %[punches/punch] %a hard in the arm, raising a colourful bruise."},

{ D_MID, W_UNARMED, HAND, EYE, "%#1 %[gouges/gouge] %a's eyes."},
{ D_MID, W_UNARMED, FOOT, HEAD, "%#1 %[leaps/leap] and %[hits/hit] %a with a flying kick."},
{ D_MID, W_UNARMED, HAND, HEAD, "%#1 %[suckers/sucker] %a with a rabbit punch."},
{ D_MID, W_UNARMED, HAND, ABDOMEN, "%#1 %[feints/feint] right, then %[pummels/pummel] %a with a hard left hook."},
{ D_MID, W_UNARMED, HAND, LEG, "%#1 %[boots/boot] %a hard in the knee, knocking %c off balance."},
{ D_MID, W_UNARMED, HAND, JAW, "%#1's punch to %a's mouth manages to break a couple of teeth."},

{ D_MIDHIGH, W_UNARMED, HAND, ABDOMEN, "%#1 %[delivers/deliver] a punishing series of punches to %a's gut."},
{ D_MIDHIGH, W_UNARMED, FOOT, HEAD, "%#1 %[hits/hit] %a with a brutal kick, dazing %c."},
{ D_MIDHIGH, W_UNARMED, HAND, HEAD, "%#1 %[manages/manage] to punch %a hard in the face."},
{ D_MIDHIGH, W_UNARMED, HAND, NECK, "%#1 %[clubs/club] the back of %a's neck, sending %c reeling."},
{ D_MIDHIGH, W_UNARMED, HAND, NOSE, "%#1 %[jabs/jab] %a in the nose, producing a spurt of blood and a cracking noise."},
{ D_MIDHIGH, W_UNARMED, HAND, JAW, "%#1's punch to %a's mouth bursts %d lip in a spray of blood and saliva."},

{ D_HIGH, W_UNARMED, FOOT, LEG, "%1 %[stamps/stamp] hard on %a's knee, forcing %d leg to bend in ways that nature did not intend."},
{ D_HIGH, W_UNARMED, HAND, JAW, "%1 %[smacks/smack] %a hard across the jaw, leaving %c spitting teeth."},
{ D_HIGH, W_UNARMED, HEAD, HEAD, "%1 %[headbutts/headbutt] %a hard in the face, smashing %d nose flat."},
{ D_HIGH, W_UNARMED, FOOT, ABDOMEN, "%1 %[boots/boot] %a in the guts, leaving %c doubled up and gasping for breath."},
{ D_HIGH, W_UNARMED, HAND, EYE, "%1 %[jams/jam] a thumb into one of %a's eyes, crushing it but not ruining it completely."},
{ D_HIGH, W_UNARMED, HAND, ARM, "%1 %[punches/punch] %a hard in the arm, hitting a nerve."},


{ D_VERY, W_UNARMED, FOOT,      LEG,      "%#1 %[stamps/stamp] hard on %a's leg, shattering the kneecap."},
{ D_VERY, W_UNARMED, HAND,      NECK,     "%#1 %[jabs/jab] %a in the throat, compressing %d windpipe and leaving %c gasping for breath."},
{ D_VERY, W_UNARMED, ARM,       HEAD,     "%#1 %[smashes/smash] %4 elbow into %a's temple, sending %c reeling backwards clutching %d head."},
{ D_VERY, W_UNARMED, HAND,      JAW,      "%#1 %[lands/land] a deadly punch on %a's jaw, shattering it like glass."},
{ D_VERY, W_UNARMED, FOOT,      CHEST,    "%#1 %[executes/execute] a perfect crescent kick to %a's side, breaking ribs like twigs."},
{ D_VERY, W_UNARMED, FOOT,      PELVIS,   "%#1 %[boots/boot] %a in the groin, producing a crunch as %d pelvis begins to fracture."},

{ D_LOW,     W_IMPACT,  0,      CHEST,    "%#1 barely %[hits/hit] %a with %W."},
{ D_LOW,     W_IMPACT,  0,      ABDOMEN,  "%#1 %[pokes/poke] %a pathetically with %W."},
{ D_LOW,     W_IMPACT,  0,      LEG,      "%#1's feeble blow bounces off %a's leg."},
{ D_LOW,     W_IMPACT,  0,      HAND,     "%#1 %[bashes/bash] %a's hand, chipping a fingernail."},
{ D_MIDLOW,  W_IMPACT,  0,      HEAD,     "%#a %[is/are] momentarily dazed by a tap to the head from %1's %w."},
{ D_MIDLOW,  W_IMPACT,  0,      ABDOMEN,  "%#1 %[jabs/jab] %a in the guts with %W, winding %c slightly."},
{ D_MIDLOW,  W_IMPACT,  0,      HEAD,     "%#1's blow with %W bounces off %a's skull."},
{ D_MIDLOW,  W_IMPACT,  0,      HAND,     "%#1 %[clips/clip] %a's finger with %W, splitting one of %d knuckles open."},
{ D_MIDLOW,  W_IMPACT,  0,      ARM,      "A weak swing from %1 bounces off %a's elbow."},
{ D_MID,     W_IMPACT,  0,      HEAD,     "%#1 %[swings/swing] wildly, bashing %a on the side of the head."},
{ D_MID,     W_IMPACT,  0,      JAW,      "%#1 %[swings/swing] upwards, striking %a on the chin."},
{ D_MID,     W_IMPACT,  0,      ABDOMEN,  "%#1 %[feints/feint] with %W, then %[punches/punch] %a in the gut."},
{ D_MID,     W_IMPACT,  0,      HAND,     "%#1's %w connects with %a's hand, mangling a finger."},
{ D_MID,     W_IMPACT,  0,      LEG,      "%#1 %[smacks/smack] %W into %a's knee."},
{ D_MID,     W_IMPACT,  0,      ARM,      "%#1 %[lunges/lunge] at %a shoulder, but fail to do much damage."},

{ D_MIDHIGH, W_IMPACT,  0,       CHEST,    "%#1 %[batters/batter] %a with %W."},
{ D_MIDHIGH, W_IMPACT,  0,       HEAD,     "%#1's strike with %W opens a nasty gash on %a's head."},
{ D_MIDHIGH, W_IMPACT,  0,       CHEST,    "%#1 %[smashes/smash] %a in the chest, causing nasty cracking noises."},
{ D_MIDHIGH, W_IMPACT,  0,       ARM,      "%#1 %[bashes/bash] %a with %W, crushing arm muscles and leaving a colourful bruise."},
{ D_MIDHIGH, W_IMPACT,  0,       ABDOMEN,  "%#1 %[jabs/jab] the end of %W into %a's solar plexus, winding %c."},
{ D_MIDHIGH, W_IMPACT,  0,       EAR,      "%#1 %[strikes/strike] %a on the side of %d head, mangling an ear."},

{ D_HIGH,    W_IMPACT,  0,       ARM,      "You hear bones cracking as %1's %w impacts %a's arm with considerable force."},
{ D_HIGH,    W_IMPACT,  0,       PELVIS|LEG,   "%#1 %[whips/whip] %W up between %a's legs, leaving %d eyes watering."},
{ D_HIGH,    W_IMPACT,  0,       CHEST,    "%#1 duck under %a's attack, bashing %W into %d chest and cracking a few ribs."},
{ D_HIGH,    W_IMPACT,  0,       NECK,     "%#1 %[swings/swing] %W into %a's neck, crushing muscles and compressing blood vessels."},
{ D_HIGH,    W_IMPACT,  0,       FOOT,     "%#1's almighty downward swing almost misses %a, but finally hits %d foot bashing it flat."},

{ D_VERY,    W_IMPACT,  0,       HEAD,     "%#1's mighty downward swing with %W leaves a nasty dent in %a's head."},
{ D_VERY,    W_IMPACT,  0,       HEAD,     "%#1 %[bashes/bash] %W into %a's head, breaking a cheekbone and caving in %d face."},
{ D_VERY,    W_IMPACT,  0,       CHEST,    "%#1 %[jabs/jab] the end of %W hard into %a's chest, smashing ribs and compressing a lung."},
{ D_VERY,    W_IMPACT,  0,       LEG,      "The force of %1's %w hitting %a's thigh splits the skin open revealing the ruined muscle beneath."},
{ D_VERY,    W_IMPACT,  0,       HAND,     "%#1's %w impacts %a's hand, crushing the fragile bones into paste."},

{ D_NONE,    W_CUTTING, 0,       HEADHAIR, "%#1 %[swings/swing] too short, and neatly %[trims/trim] %a's fringe."},
{ D_NONE,    W_CUTTING, 0,       CHEST,    "%#1 tried to cut %4 initials into %a's chest, but %[fails/fail] completely."},
{ D_NONE,    W_CUTTING, 0,       ARM,      "%#1's is rather embarassed that %4 feeble cut to %a's arm doesn't even graze %c."},

{ D_LOW,     W_CUTTING, 0,       ARM,      "%#1's poor swordsmanship results in a shallow graze across %a's arm."},
{ D_LOW,     W_CUTTING, 0,       ARM,      "%#1's downward swing goes wide of the mark, and only nicks %a's elbow."},
{ D_LOW,     W_CUTTING, 0,       CHEST,    "%#1 %[leaves/leave] a shallow cut on %a's chest with %W."},
{ D_LOW,     W_CUTTING, 0,       LEG,      "%#1's upward swing goes a bit short, and cuts %a's knee."},
{ D_LOW,     W_CUTTING, 0,       NOSE,     "%#1 just nicks the end of %a's nose with %W."},
{ D_LOW,     W_CUTTING, 0,       HEAD,     "%#1 %[slashes/slash] at %a's face, leaving a shallow cut."},

{ D_MIDLOW,  W_CUTTING, 0,       EAR,      "%#1's %w leaves an ugly cut across %a's ear, impressive but not too serious."},
{ D_MIDLOW,  W_CUTTING, 0,       CHEST,    "%#1's slash cuts across %a's ribcage, leaving a shallow but painful gash."},
{ D_MIDLOW,  W_CUTTING, 0,       HAND,     "%#1 %[smashes/smash] %a's attack to one side, slicing across %d's knuckles."},
{ D_MIDLOW,  W_CUTTING, 0,       LEG,      "%#1 %[ducks/duck] under %a's guard, but %d lunge only manages to scrape %4 leg."},

{ D_MID,     W_CUTTING, 0,       ARM,      "%#1's %w bites into %a's shoulder, leaving a nasty-looking wound."},
{ D_MID,     W_CUTTING, 0,       HAND,     "%#1 %[hacks/hack] at %a's hand, leaving a nasty gash."},
{ D_MID,     W_CUTTING, 0,       HEAD,     "%#a %[jumps/jump] back from %1's deadly slice, but still takes a cut to the face."},
{ D_MID,     W_CUTTING, 0,       FOOT,     "%#1 %[surprises/surprise] %a by suddenly slashing downwards, leaving a deep wound in %4 foot."},

{ D_HIGH,    W_CUTTING, 0,       CHEST,    "%#1's slash to %a's chest bounce off a rib, but still leaves a deep wound from shoulder to belly."},
{ D_HIGH,    W_CUTTING, 0,       ABDOMEN,  "%#1 %[lands/land] a good strike on %a, cutting into the tender flesh of %4 abdomen."},
{ D_HIGH,    W_CUTTING, 0,       HAND,     "Swinging hard with %W, %1 nearly %[manages/manage] to cut %a's hand clean off."},
{ D_HIGH,    W_CUTTING, 0,       ARM,      "%#1 %[hacks/hack] a lump of flesh from %a's arm."},

{ D_VERY,    W_CUTTING, 0,       ARM,      "%#1's %w cuts clean through %a's bicep, striking bone."},
{ D_VERY,    W_CUTTING, 0,       HEAD|EYE,     "%#1 %[slashes/slash] across %a's face, leaving a deep gouge that nearly takes out an eye."},
{ D_VERY,    W_CUTTING, 0,       CHEST,    "%#1 scores a wicked hit on %a's chest, %W slicing though flesh and bone alike."},
{ D_VERY,    W_CUTTING, 0,       LEG,      "%#1's %w cuts deep into %a's thigh, releasing a spray of blood."},

{ D_NONE,    W_STABBING,0,       ABDOMEN,  "%#1 %[pokes/poke] %a with a pitifully weak stab."},
{ D_NONE,    W_STABBING,0,       CHEST,    "%#1 %[tries/try] to slash %4 initials into %a's chest, but just isn't good enough."},
{ D_NONE,    W_STABBING,0,       ARM,      "%#1's poorly timed lunge barely grazes %a."},

{ D_LOW,     W_STABBING,0,       EAR,      "%#1 %[jabs/jab] %a in the ear, neatly piercing it."},
{ D_LOW,     W_STABBING,0,       HAND,     "%#1 %[pokes/poke] %a in the wrist, but to little effect."},
{ D_LOW,     W_STABBING,0,       HEAD,     "%#1 %[tries/try] to stab %a in the head, but just %[grazes/graze] %c scalp."},
{ D_LOW,     W_STABBING,0,       CHEST,    "%#1's seemingly deadly stab doesn't even manage to penetrate %a's sternum."},
{ D_MIDLOW,  W_STABBING,0,       CHEST,    "%#1's attempt to impale %a is thwarted by a rib, but leaves a painful cut."},
{ D_MIDLOW,  W_STABBING,0,       HEAD,     "%#1's jab to %a's head leaves a neat hole in %d forhead, but fails to penetrate the skull."},
{ D_MIDLOW,  W_STABBING,0,       ARM,      "%#1 %[jabs/jab] %a n the forearm, causing a shallow, if painful wound."},
{ D_MIDLOW,  W_STABBING,0,       LEG,      "%#1 %[ducks/duck] under %a's guard, but %d lunge only manages to graze %4 thigh."},

{ D_MID,     W_STABBING,0,       ARM,      "%#1 visciously %[stabs/stab] %a in the bicep."},
{ D_MID,     W_STABBING,0,       HAND,     "%#1 %[sticks/stick] %W through %a's hand, but %[misses/miss] any nerves or blood vessels."},
{ D_MID,     W_STABBING,0,       ABDOMEN,  "%#1 %[jabs/jab] %a in the belly button, but the thrust isn't very strong."},
{ D_MID,     W_STABBING,0,       LEG,      "%#1 %[stabs/stab] %w into %a's thigh, the wound is deep but misses any arteries."},

{ D_HIGH,    W_STABBING,0,       ARM,      "%#1 %[jabs/jab] the tip of %W into %a's elbow, clipping a nerve."},
{ D_HIGH,    W_STABBING,0,       NECK,     "%#1 %[stabs/stab] %a in the neck, miraculously missing windpipe, spine, and blood vessels."},
{ D_HIGH,    W_STABBING,0,       ARM,      "%#1 %[pokes/poke] %a in the armpit, the shallow-looking wound spraying blood from a punctured vein."},
{ D_HIGH,    W_STABBING,0,       PELVIS,   "A swift lunge from %1's %w leaves a painful looking wound in %a's groin."},

{ D_VERY,    W_STABBING,0,       CHEST,    "%#1 %[lunges/lunge] fowards, driving %W into %a's chest leaving a terrible wound behind."},
{ D_VERY,    W_STABBING,0,       LEG,      "%#1 %[sinks/sink] %W into %a's leg, causing a satisfying spray of blood from a ruptured artery."},
{ D_VERY,    W_STABBING,0,       ABDOMEN,  "%#1 swiftly %[stabs/stab] %W into %a's guts, causing an agonising wound."},
{ D_VERY,    W_STABBING,0,       NECK,     "%#1 %[lunges/lunge] foward, jabbing %W into %a's throat providing a free trachaeotomy."},



{ D_DEATHBLOW, W_IMPACT, 0, HEAD, "%#1 %[swings/swing] %W downwards onto %a's head, bursting %d skull like an overripe fruit.", "skull crushed", "has a crushed skull"},
{ D_DEATHBLOW, W_IMPACT, 0, HEAD, "%#1's swing connects with %a's head, smashing it clean off %d neck.", "decapitated", "has been decapitated, golf style"},
{ D_DEATHBLOW, W_IMPACT, 0, NECK, "%#1's final lunge with %W crushes %a's windpipe flat, causing swift asphixiation.", "windpipe crushed", "has choked to death"},
{ D_DEATHBLOW, W_IMPACT, 0, ABDOMEN, "%#1 %[slips/slip] %W under %a's guard, and %[smashes/smash] %d ribcage flat.", "chest crushed", "has a crushed chest"},
{ D_DEATHBLOW, W_IMPACT, 0, ABDOMEN, "%#1 %[hits/hit] %a in the guts, bursting %d vital organs and causing swift, painful death.", "vital organ soup", "has a crushed abdomen"},
{ D_DEATHBLOW, W_IMPACT, 0, PELVIS, "%#1 %[swings/swing] %W into %a's groin, shattering %d pelvis and rupturing several arteries.", "pelvis crushed", "has a shattered pelvis"},

{ D_DEATHBLOW, W_CUTTING, 0, HEAD, "%#1 %[brings/bring] %W round in a wide arc, removing %a's head in one go.", "decapitated", "has been cleanly decapitated"},
{ D_DEATHBLOW, W_CUTTING, 0, ABDOMEN, "%#1's final slash with %W cuts cleanly through %a's waist, leaving %d in two halves.", "bisected", "has been chopped in half, widthways"},
{ D_DEATHBLOW, W_CUTTING, 0, ABDOMEN, "%#1 neatly %[cuts/cut] across %a's belly, disemboweling %d in a spray of blood and entrails.", "disemboweled", "has been disemboweled"},
{ D_DEATHBLOW, W_CUTTING, 0, NECK, "%#1 %[slices/slice] %a across the throat, severing %c carotid and jugular.", "throat slit", "has a severed carotid and jugular"},
{ D_DEATHBLOW, W_CUTTING, 0, ABDOMEN, "%#1 %[swings/swing] %W downwards, splitting %a open from head to crotch.", "split open", "has bee n slit open from head to crotch"},

{ D_DEATHBLOW, W_STABBING, 0, EYE, "%#1 %[sticks/stick] %W through %a's eyesocket, causing instant death.", "stabbed", "has been stabbed through the eye"},
{ D_DEATHBLOW, W_STABBING, 0, ABDOMEN, "%#1 %[nails/nail] %a in the lower back, causing death almost instantly from internal bleeding and shock.", "stabbed", "has a nasty wound in the lower back"},
{ D_DEATHBLOW, W_STABBING, 0, ABDOMEN, "%#1 %[impales/impale] %a with %W, severing %c spinal cord.", "impaled", "has a severed spinal cord"},
{ D_DEATHBLOW, W_STABBING, 0, HEAD, "%#1 %[sinks/sink] %W into %a's solar plexus, causing %d to keel over backwards and move no more.", "run through", "has been stabbed through the solar plexus"},
{ D_DEATHBLOW, W_STABBING|R_ONLAND, 0, CHEST, "%#1 %[stabs/stab] %a straight through the chest with %W. Clutching %d chest in pain, %a falls to the floor.", "impaled", "has a stab wound through the chest"},

{ D_DEATHBLOW, W_UNARMED, HAND, NECK, "%#1 %[manages/manage] to grab %a's neck, you hear a crisp snap and %b dies instantly.", "neck broken", "has a broken neck"},
{ D_DEATHBLOW, W_UNARMED, HAND, ABDOMEN, "%#1 %[manages/manage] to pick %a up, and snaps %d back over %d knee.", "back broken", "has a broken back"},
{ D_DEATHBLOW, W_UNARMED, HAND, NECK, "%#1 %[gets/get] a good hold of %a's windpipe, and %[tears/tear] it out.", "windpipe ripped out", "won't be doing much breathing"},
{ D_DEATHBLOW, W_UNARMED, HAND, NOSE, "%#1 %[punches/punch] %a right in the nose, %b falls down dead with blood streaming from %d face.", "nose pushed into brain", "has severe skull wounds"},

  /* XXX more deathblows - we want all the deathblows from deathblow.h, plus robot deathblows */
};

static bool verb_cmsg(MudObject *who, int argc, const char **argv) {
  Player *p = dynamic_cast<Player*>(who);
  if (!p)
    return true;

  Divert d(who, "cmsg");

  const char *wty[] = { "unarmed", "impact", "cutting", "energy", "stunning", "stabbing" };
  for (size_t idx=0;idx<ARRAY_SIZE(cmsg);idx++) {
    string buffer = sprinta(who, cmsg[idx].msg, who, 0, "", 2, NULL);
    string s = explain(cmsg[idx].vicflag);
    if (cmsg[idx].maxdam == D_DEATHBLOW)
      s = "deathblow, " + s;
    who->printf("%10s %20s ^Z%s", wty[cmsg[idx].weapon&0xff], s.c_str(), buffer.c_str());
  }

  return true;
}

static int matches(MudObject * a, int b) {


  const char *bod = a->get("body");
  
  struct {
    const char *body;
    int f;
  } bodies[] = {
    { "droid", ROBOT} ,
    { "tetrapod", HEAD|FOOT|PELVIS|JAW|LEG|NECK|ABDOMEN|EAR|NOSE|EYE } ,
    { "fish", HEAD|JAW|NECK|ABDOMEN|EAR|NOSE|EYE } ,
    { "avian", HEAD|FOOT|PELVIS|JAW|LEG|NECK|ABDOMEN|EAR|NOSE|EYE|WING|FEATHERS } ,
    { NULL, HAND|HEAD|HEADHAIR|TALK|FOOT|PELVIS|JAW|LEG|NECK|CHEST|ARM|ABDOMEN|EAR|NOSE|EYE } ,
  };

  int bn = 4;
  for (int i=0;i<4;i++) {
    if (streq(bodies[i].body, bod))
      bn = i;
  }

  if ((b & bodies[bn].f) != b)
    return 0;

  if (b & TALK) {
    if (a->get_flag(FL_CANTTALK))
      return 0;
    if (a->get_flag(FL_DUMB))
      return 0;
  }

  return 1;
}

static void newblow(MudObject *att, MudObject *vic, int dam, MudObject *weapon, int wty) 
{
  srand(time(NULL));
  
  vector<int> m;  
  
  int rdam = D_VERY;
  if (dam < D_HIGH) rdam = D_HIGH;
  if (dam < D_MIDHIGH) rdam = D_MIDHIGH;
  if (dam < D_MID) rdam = D_MID;
  if (dam < D_MIDLOW) rdam = D_MIDLOW;
  if (dam < D_LOW) rdam = D_LOW;
  if (dam < D_NONE) rdam = D_NONE;

  if (dam == -100)
    rdam = D_DEATHBLOW;

  const char *cause=0;
  const char *corpsedesc=0;

  for (size_t i=0;i<ARRAY_SIZE(cmsg);i++) {
    if (rdam != cmsg[i].maxdam) continue;
    if (wty != (cmsg[i].weapon&0xff)) continue;
    if (cmsg[i].weapon & R_ONLAND && (vic->get_flag(FL_SWIMMING)
				      || vic->owner->get_flag(FL_UNDERWATER)))
      continue;
    if (!matches(att, cmsg[i].attflag)) continue;
    if (!matches(vic, cmsg[i].vicflag)) continue;

    m.push_back(i);
  }
  
  if (m.size()) {
    int x = random_number(m.size());
    att->action_to(vic, cmsg[m[x]].msg, NULL, weapon);
    vic->action_from(att, cmsg[m[x]].msg, NULL, NULL, weapon);
    att->action(vic, cmsg[m[x]].msg, NULL, weapon);
  } else {
    const char *hit_p = "hit";
    const char *hit_s = "hits";

    switch (wty) {
    case W_UNARMED: break;
    case W_CUTTING: hit_p = "slash"; hit_s = "slashes"; break;
    case W_IMPACT:  hit_p = "bash";  hit_s = "bashes"; break;
    case W_ENERGY:  hit_p = "shoot"; hit_s = "shoots"; break;
    case W_STABBING:hit_p = "stab";  hit_s = "stabs"; break;
    }

    const char *hard = "";
    if (rdam==D_NONE) hard = "very lightly";
    if (rdam==D_LOW) hard = "lightly";
    if (rdam==D_MIDLOW) hard = "not so lightly";
    if (rdam==D_MID) hard = "fairly hard";
    if (rdam==D_MIDHIGH) hard = "hard";
    if (rdam==D_HIGH) hard = "very hard";
    if (rdam==D_VERY) hard = "extremely hard";
    if (rdam==D_DEATHBLOW) hard = "lethally";

    if (weapon) {
      att->printf("You %s %M %s with %Y.\n", hit_p, vic, hard, weapon);
      vic->printf("%#M %s you %s with %P.\n", att, att->get_flag(FL_PLURAL)?hit_p:hit_s, hard, weapon);
      vic->oprintf(cansee && avoid(att), "%#M %s %M %s with %P.\n", att, att->get_flag(FL_PLURAL)?hit_p:hit_s, vic, hard, weapon);
    } else {
      att->printf("You %s %M %s.\n", hit_p, vic, hard);
      vic->printf("%#M %s you %s.\n", att, att->get_flag(FL_PLURAL)?hit_p:hit_s, hard);
      vic->oprintf(cansee && avoid(att), "%#M %s %M %s.\n", att, att->get_flag(FL_PLURAL)?hit_p:hit_s, vic, hard);
    }
  }

  if (rdam == D_DEATHBLOW) {
    if (!cause) cause = "slain";
    if (!corpsedesc) corpsedesc = "has been slain";
    combat_kill(att, vic, cause, corpsedesc);
  }
}