/* Dramatically Violent Skills Series
 * Part 1: The Ninja
 *
 * These functions are designed to be used as attack skills in MUDs derived from the SMAUG codebase.
 * They will almost certainly not install without modification and I make no attempt
 * to provide instructions on how they function or how to get them to install in your MUD - they
 * are simply examples provided as concept to show that a skills system can be livened up.
 *
 * This code is released exclusively to www.mudbytes.net and is not authorized for download from
 * any other location. What you do with it after that is up to you.
 *
 * Exodus (exodus AT drmultiverse DOT com)
 * mud.drmultiverse.com 6010
 */

CMDF skill_ryutsuisen( charData *ch, char *argument )
{
  char arg[MIL];
  char arg2[MIL];
  charData *victim;
  int dam = 0;
  objData *obj;
  int sn = skillLookup("ryutsuisen");

  argument = oneArgument(argument, arg);
  argument = oneArgument(argument, arg2);
  skillCheckkCharm(ch);
  skillCheckSkill(ch, sn);
  if( NULLSTR(arg) )
  {
    sendToChar( "Attack whom?\n\r", ch );
    return;
  }

  SkillCheckTargetRoom(ch, victim, arg);
  skillCheckNoSelf(ch, victim);
  skillCheckIsSafe(victim);
  checkAttacker(ch, victim);
  checkIllegalPkill(ch, victim);
  if( !(obj = getCharEquip(ch, WEAR_WIELD)) )
  {
    sendToChar( "You must be wielding a weapon!\n\r", ch );
    return;
  }

  dam = (getCurrent(ch, STAT_STRENGTH)(ch) * 2) + (gtl(ch) * 3);
  waitState(ch, skill_table[sn]->beats );
  if( canUseSkill(ch, numberPercent(), sn) )
  {
    if( NULLSTR(arg2) )
    {
      if( weaponDamageCheck(obj, CAN_SLASH) )
      {
        sendToChar( "You must be wearing a slicing or slashing weapon.\n\r", ch );
        return;
      }

      if( (dam = risDamage(victim, dam, RIS_SLASH)) EQ DAM_ABSORBED )
      {
	act( AT_SKILL, "Your powerful slash bounces off $N like it was nothing.", ch, NULL, victim, TO_CHAR );
	act( AT_SKILL, "$n's powerful slash bounces off you like it was nothing.", ch, NULL, victim, TO_VICT );
	act( AT_SKILL, "$n's powerful slash bounces off $N like it was nothing.", ch, NULL, victim, TO_NOTVICT );
	learnFromFailure(ch, sn);
	return;
      }
      
      act( AT_SKILL, "You leap into the air and bring the edge of your blade down upon $N's head!", ch, NULL, victim, TO_CHAR );
      act( AT_SKILL, "$n leaps into the air and brings the edge of $s blade down upon your head!", ch, NULL, victim, TO_VICT );
      act( AT_SKILL, "$n leaps into the air and brings the edge of $s blade down upon $N's head!", ch, NULL, victim, TO_NOTVICT );
      learnFromSuccess(ch, sn);
      learnFromSuccess(ch, skillLookup("slashing weapons");
      globalRetcode = oneHit(ch, victim, sn, obj, dam, RIS_SLASH, multimeb(ATTK_NOBLOCK, ATTK_NOMISS, -1));
    }
    else if( !stringCompare(arg2, "zan") )
    {
      if( weaponDamageCheck(obj, CAN_STAB) )
      {
        sendToChar( "You must be wielding a stabbing or piercing weapon.\n\r", ch );
        return;
      }

      if( (dam = risDamage(victim, dam, RIS_PIERCE)) DAM_ABSORBED )
      {
	act( AT_SKILL, "Your powerful stab is deflected at the last moment, rendering the attack useless.", ch, NULL, victim, TO_CHAR );
	act( AT_SKILL, "You deflect $n's powerful stab at the last moment, rendering the attack useless.", ch, NULL, victim, TO_VICT );
	act( AT_SKILL, "$N deflects $n's powerful stab at the last moment, rendering it useless.", ch, NULL, victim, TO_NOTVICT );
	return;
      }

      act( AT_SKILL, "You leap into the air and at the last second, invert your blade and bring the point straight down between $N's eyes!", ch, NULL, victim, TO_CHAR );
      act( AT_SKILL, "$n leaps into the air and at the last second, inverts $s blade and brings the point straight down between your eyes!", ch, NULL, victim, TO_VICT );
      act( AT_SKILL, "$n leaps into the air and at the last second, inverts $s blade and brings the point striaght down between $N's eyes", ch, NULL, victim, TO_NOTVICT );
      learnFromSuccess(ch, sn);
      learnFromSuccess(ch, skillLookup("stabbing weapons");
      globalRetcode = oneHit(ch, victim, sn, obj, dam, RIS_PIERCE, multimeb(ATTK_NOBLOCK, ATTK_NOMISS, -1));
    }
    else
    {
      sendToChar( "&WRyutsuisen may only be changed to: &RZAN&W\n\r", ch );
      return;
    }
  }
  else
  {
    sendToChar( "You lose your balance and fail.\n\r", ch );
    learnFromFailure(ch, sn);
    return;
  }
  return;
}


CMDF skill_ryusousen( charData *ch, char *argument )
{
  char arg[MIL];
  char arg2[MIL];
  int dam = 0;
  float bonus = 0.0;
  charData *victim = NULL;
  objData *obj = NULL;
  int sn = skillLookup("ryusousen");


  skillCheckCharm(ch);
  skillCheckSkill(ch, sn);
  argument = oneArgument(argument, arg);
  argument = oneArgument(argument, arg2);
  if( NULLSTR(arg) )
  {
    sendToChar( "Attack whom?\n\r", ch );
    return;
  }

  skillCheckTargetRoom(ch, victim, arg);
  skillCheckNoSelf(ch, victim);
  skillCheckIsSafe(victim);
  checkAttacker(ch, victim);
  checkIllegalPkill(ch, victim);
  if( !(obj = getCharEquip(ch, WEAR_WIELD)) )
  {
    sendToChar( "You must be wielding a weapon to perform this attack.\n\r", ch );
    return;
  }
  dam = 0;
  bonus = 0;
  switch( numberRange(1, 9))
  {
    case 1:
      act( AT_RED, "$n rams the pommel of $p into the side of your head, knocking you senseless!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You ram the pommel of $p into the side of $N's head, aiming straight for $s temple!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n rams the pommel of $p into the side of $N's head, knocking him senseless!", ch, obj, victim, TO_NOTVICT );
      bonus = 2.3;
      if( !savingThrow(victim, -(getCurrent(ch, STAT_STRENGTH))) )
      {
        if( numberPercent() <= 25 )
          inflictCondition(ch, victim, CONDITION_DAZED, 2);
        else
          inflictCondition(ch, victim, CONDITION_DBLVISION);
      break;

    case 2:
      act( AT_RED, "$n races towards you and slash the edge of $p across your throat!\n\r"
                   "Blood sprays wildly through the air!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You race towards $N and slash the edge of $p across $S throat!\n\r"
                   "Blood sprays wildly through the air!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n races towards $N and slashes the edge of $p across $S throat!\n\r"
                   "Blood sprays wildly through the air!", ch, obj, victim, TO_NOTVICT );
      bonus = 2.3;
      if( !savingThrow(victim, -(getCurrent(ch, STAT_STRENGTH))) )
        inflictCondition(ch, victim, CONDITION_BLEEDING, 2);
      break;

    case 3:
      act( AT_RED, "With blinding speed, $n rams $p into your ribcage!", ch, obj, victim, TO_VICT );
      act( AT_RED, "With blinding speed, you ram $p into $N's ribcage!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "With blinding speed, $n rams $p into $N's ribcage!", ch, obj, victim, TO_NOTVICT );
      bonus = 2.7;
      break;

    case 4:
      act( AT_RED, "$n deftly inverts $p and brings it point first through your left kneecap!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You deftly invert $p and bring it point first through $N's left kneecap!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n deftly inverts $p and brings it point first through $N's left kneecap!", ch, obj, victim, TO_NOTVICT );
      bonus = 2;
      if( !savingThrow(victim, -(getCurrent(ch, STAT_STRENGTH))) )
        inflictCondition(ch, victim, CONDITION_CRIPPLE, 3);
      break;

    case 5:
      act( AT_RED, "$n deftly inverts $p and brings it point first through your right kneecap!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You deftly invert $p and bring it point first through $N's right kneecap!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n deftly inverts $p and brings it point first through $N's right kneecap!", ch, obj, victim, TO_NOTVICT );
      bonus = 2;
      if( !savingThrow(victim, -(getCurrent(ch, STAT_STRENGTH))) )
        inflictCondition(ch, victim, CONDITION_CRIPPLE, 3);
      break;

    case 6:
      act( AT_RED, "$n lunges forward with $p and turns your left arm into a pin-cushion!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You lunge forward with $p and turn $N's left arm into a pin-cushion!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n lunges forward with $p and turns $S left arm into a pin-cushion!", ch, obj, victim, TO_NOTVICT );
      bonus = 2; break;

    case 7:
      act( AT_RED, "$n lunges forward with $p and turns your right arm into a pin-cushion!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You lunge forward with $p and turn $N's right arm into a pin-cushion!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n lunges forward with $p and turns $S right arm into a pin-cushion!", ch, obj, victim, TO_NOTVICT );
      bonus = 2; break;

    case 8:
      act( AT_RED, "$n leaps straight up as you charge, landing silently behind your back.\n\r"
                   "In the same second, $e thrusts $p backwards into your lower back, rupturing a kidney!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You leap straight up as $N charges, landing silently behind $S back.\n\r"
                   "In the same second, you thrust $p backwards into $S lower back, rupturing a kidney!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n leaps straight up as $N charges at $m, landing silently behind $S back.\n\r"
                   "In the same second $e thrusts $p backwards into $S lower back, rupturing a kindey!", ch, obj, victim, TO_NOTVICT );
      bonus = 2.5;
      break;

    case 9:
      act( AT_RED, "$n speeds towards you, but ducks and rolls behind you at the moment of impact, spinning wildly around to plunge $p directly into your spine!", ch, obj, victim, TO_VICT );
      act( AT_RED, "You speed towards $N, but duck and roll behind $M at the moment of impact, spinning wildly around to plunge $p directly into $S spine!", ch, obj, victim, TO_CHAR );
      act( AT_RED, "$n speeds towards $N, but ducks and rolls behind $M at the moment of impact, spinning wildly around to plunge $p directly into $S spine!", ch, obj, victim, TO_NOTVICT );
      bonus = 2.9;
      break;
  }

  dam = (int) ((getCurrent(ch, STAT_STRENGTH) * 2) + (gtl(ch) * bonus));
  waitState(ch, skill_table[sn]->beats);
  if( canUseSkill(ch, (int) LEARNED(ch, sn), sn) )
  {
    learnFromSuccess(ch, sn);
    globalRetcode = oneHit(ch, victim, sn, obj, dam, RIS_NONE, multimeb(ATTK_NOBLOCK, ATTK_NOMISS, -1));
  }
  else
    learnFromFailure(ch, sn);
  return;
}


CMDF skill_bodystrike( charData *ch, char *argument )
{
  charData *victim;
  char arg[MIL];
  int dam = 0;
  char buf[MSL];
  char buf2[MSL];
  int sn = skillLookup("bodystrike");
  
  skillCheckCharm(ch);
  argument = oneArgument(argument, arg);
  SkChkMount(ch);
  if( arg[0] == '\0' )
  {
    sendToChar( "Strike at whom?\n\r", ch );
    return;
  }

  skillCheckTargetRoom(ch, victim, arg);
  skillCheckNoSelf(ch, victim);
  skillCheckIsSafe(victim);
  checkAttacker(ch, victim);
  checkIllegalPkill(ch, victim);
  dam = (getCurrent(ch, STAT_STRENGTH) * (gtl(ch) / 2)) + numberRange(gtl(ch) * 4, gtl(ch) * 8);
  waitState(ch, skill_table[sn]->beats);
  if( canUseSkill(ch, (int) LEARNED(ch, sn), sn) )
  {
    learnFromSuccess(ch, sn);
    switch(numberRange(1, 10))
    {
      case 1:
        snprintf(buf, MSL, "You pull $n's head down and ram your knee into $S temple!" );
        snprintf(buf2, MSL, "$n pulls your head down and rams $s knee into your temple!" );
        dam += (int) (dam * 1.4);
      	break;

      case 2:
        snprintf(buf, MSL, "You lock your fingers in place and jab $N in the throat!" );
        snprintf(buf2,MSL, "$n locks $s fingers in place and jabs you in the throat!" );
        dam += (int) (dam * 1.3);
        break;

      case 3:
        snprintf(buf, MSL, "You casually tap the pressure point on $N's chest, causing him excruciating pain!" );
        snprintf(buf2, MSL, "$n casually taps the pressure point on your chest, causing excruciating pain!" );
        dam += (int) (dam * 1.2);
        break;

      case 4:
        snprintf(buf, MSL, "You slip through $N's defenses and tap a spot on $S left arm, sending a jolt of pain through $M!" );
        snprintf(buf2, MSL, "$n slips through your defenses and taps a spot on your left arm, sending a jolt of pain through you!" );
        dam += (int) (dam * 1.1);
        break;

      case 5:
        snprintf(buf, MSL, "You deftly grab $N's right wrist and twist it inward, pulling it up above your head and delivering an elbow to $S under-arm!" );
        snprintf(buf2, MSL, "$n deftly grabs your right wrist and twists it inward, pulling it up above $s head and delivering an elbo to your under-arm!" );
        if( numberPercent() <= 25 )
        {
          act( AT_RED, "You hear $N scream as something breaks...", ch, NULL, victim, TO_CHAR );
          act( AT_RED, "You scream as something breaks...", ch, NULL, victim, TO_VICT );
          dam += (int) (dam * 1.3);
        }
        else
          dam += (int) (dam * 1.1);
        break;

      case 6:
        snprintf(buf, MSL, "You deliver a low kick to $N's right knee!" );
        snprintf(buf2,MSL, "$n delivers a low, powerful kick to your right knee!" );
        dam += (int) (dam * 1.1 ;
        break;

      case 7:
        snprintf(buf, MSL, "With amazing dexterity, you kick the back of $N's right leg, causing $M to fall down and kneel on it.\n\r"
                           "You then plants your left foot firmly on $S outstreched left knee and vault into the air, only to come down right-foot-first into $S thigh!" );
        snprintf(buf2, MSL, "With amazing dexterity, $n kicks the back of your right leg, causing you to fall down and kneel on it.\n\r"
                            "$e then plants $s left foot firmly on your outstreched left knee and vaults into the air, only to come down right-foot-first into your thigh!" );
        if( numberPercent() <= 25 )
        {
          act( AT_RED, "You hear $N scream as something breaks...", ch, NULL, victim, TO_CHAR );
          act( AT_RED, "You scream as something breaks...", ch, NULL, victim, TO_VICT );
          dam += (int) (dam * 1.3);
        }
        else
          dam += (int) (dam * 1.1);
        break;              

      case 8:
        snprintf(buf, MSL, "With blazing speed, you jab your outstretched index and little fingers into $N's eye sockets!" );
        snprintf(buf2, MSL, "With blazing speed, $n jabs $s outstretched index and little fingers into your eye sockets!" );
        dam += (int) (dam * 1.2);

      case 9:
        snprintf(buf, MSL, "You grab $N by the hair and pull $S head down before rolling over them back to back.\n\r"
                           "Behind $M now, still holding $S head, you jerk it backwards and thrust your knee into the base of $S spine!" );
        snprintf(buf2, MSL, "$n grabs you by the hair and pulls your head down before rolling over you back to back.\n\r"
                            "Behind you now, still holding your head, $e jerks it backwards and thrusts $s knee into the base of your spine!" );
        dam += (int) (dam * 1.3);
        break;

      case 10:
        if( victim->sex == SEX_MALE )
        {
          snprintf(buf, MSL, "You place your left arm across $N's chest, holding $S shoulder. Sweeping your left leg behind $M as you kneel,\n\r"
                             "$E falls backwards, half-across your knee. You then proceed to deliver a series of nasty blows to $S groin..." );
          snprintf(buf2, MSL, "$N places $s left arm across your chest, holding your shoulder. Sweeping $s left leg behind you as he kneels,\n\r"
                              "You fall backwards, half-across $s knee. $e then proceeds to deliver a series of nasty blows to your groin..." );
        }
        else
        {
          snprintf(buf, MSL, "You duck down and tumble between $N's legs, and stand up quickly, thrusting backward with two powerful elbows to $S kidneys!" );
          snprintf(buf2, MSL, "$n ducks down and tumbles between your legs, and stands up quickly, thrusting backward with two powerful elbows to your kidneys!" );
        }
        dam += (int) (dam * 1.3);
        break;

      default:
        snprintf(buf, MSL, "You casually tap one of $N's pressure points, causing $M extreme pain!" );
        snprintf(buf2, MSL, "$n casually taps one of your pressure points, causing you extreme pain!" );
        break;
    }

    act( AT_SKILL, buf, ch, NULL, victim, TO_CHAR );
    act( AT_SKILL, buf2, ch, NULL, victim, TO_VICT );
    globalRetcode = damage(ch, victim, dam, NULL, sn);
    adjust_favor(ch, FAVOR_CHEAP_SHOT, 1);
  }
  else
  {
    sendToChar( "You failed.\n\r", ch );
    learnFromFailure(ch, sn);
    globalRetcode = damage(ch, victim, 0, NULL, sn);
  }
  return;
}