<commit_before>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
// $Log: task_trance_of_blades.cc,v $
// Revision 5.2  2002/01/10 05:56:59  peel
// even more splitting up of obj2.h
//
// Revision 5.1.1.1  2001/01/09 20:00:40  batopr
// *** empty log message ***
//
// Revision 5.1  2001/01/09 20:00:32  batopr
// *** empty log message ***
//
// Revision 1.2  2000/12/27 08:27:35  dash
// added code for 'defensive trance' warrior skill
//
// Revision 1.1  2000/12/22 07:12:03  dash
// Initial revision
//
//
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//
//      SneezyMUD 4.0 - All rights reserved, SneezyMUD Coding Team
//      "task.cc" - All functions related to tasks that keep mobs/PCs busy
//
//////////////////////////////////////////////////////////////////////////

#include "stdsneezy.h"
#include "obj_base_weapon.h"

void stop_trance_of_blades(TBeing *ch)
{
  if (ch->getPosition() >= POSITION_RESTING) {
    act("You suddenly snap out of your trance.",
	FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
    act("$n suddenly snaps out of $s trance.",
	FALSE, ch, 0, 0, TO_ROOM);
  }
  ch->stopTask();
}

//void TBaseWeapon::tranceOfBladesPulse(TBeing *ch, TThing *)
//  {
//  stop_trance_of_blades(ch);
//  return;
//  }


int task_trance_of_blades(TBeing *ch, cmdTypeT cmd, const char *, int pulse, TRoom *, TObj *)
{
  TThing *o = NULL;
  int chance = 0;
  // sanity check
  if (ch->isLinkdead() ||
      (ch->in_room != ch->task->wasInRoom) ||
      (ch->getPosition() < POSITION_RESTING)) {
    stop_trance_of_blades(ch);
    return FALSE;  // returning FALSE lets command be interpreted
  }
  if (ch->utilityTaskCommand(cmd) ||
      ch->nobrainerTaskCommand(cmd))
    return FALSE;
  switch (cmd) {
  case CMD_TASK_CONTINUE:
    ch->task->calcNextUpdate(pulse, PULSE_MOBACT);
    if (!(o = ch->heldInPrimHand())) {
      act("Loss of your weapon causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Loss of $s weapon causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }   
    if (ch->getCombatMode() == ATTACK_BERSERK) {
      act("Berserking causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Berserking causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }   
    if (ch->isSwimming()) {
      act("Sudden immersion causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Sudden immersion causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (!ch->canUseArm(HAND_PRIMARY)) {
      act("Your injured arm causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR), ANSI_RED;
      act("$n's injured arm causes $m to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (ch->getMove() < 30) {
      act("Your fatigue causes you to snap out of your trance.",
	  FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("$n's fatigue causes $m to snap out of $s trance.",
	  FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;      
    }
    ch->addToMove(-10);
    chance = 150 - ch->getSkillValue(SKILL_TRANCE_OF_BLADES);
    if (!(ch->attackers)) chance *= 2;
    chance = (int)((float) chance * ch->plotStat(STAT_CURRENT, STAT_FOC, 1.25, 0.80, 1.00));
    if (chance > ::number(0,999)) {
      act("Your concentraion has been lost, and you snap out of your defensive trance.",
	  FALSE, ch, 0, 0, TO_CHAR, ANSI_YELLOW);
      act("$n loses $s concentration and snaps out of $s defensive trance.",
	  FALSE, ch, 0, 0, TO_ROOM, ANSI_YELLOW);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (!(::number(0,2)) || (ch->attackers))
      act("Your focus is good and you are able to maintain your defensive trance.",
	  FALSE, ch, 0, 0, TO_CHAR);
    return FALSE;
  case CMD_ABORT:
  case CMD_STOP:
    act("You slowly come out of your trance.",
	FALSE, ch, o, 0, TO_CHAR);
    act("$n slowly comes out of $s trance.", FALSE, ch, o, 0, TO_ROOM);
    ch->stopTask();
    ch->addToWait(combatRound(2));
    ch->cantHit += ch->loseRound(1);
    break;
  case CMD_TASK_FIGHTING:
    //    act("Your $o becomes a blur as you concentrate on your defensive trance.", FALSE, ch, o, 0, TO_CHAR);
    //    act("$n's $o becomes a blur as $e concentrates on $s defensive trance.", FALSE, ch, o, 0, TO_ROOM);<commit_msg>Fixed a typo in the lose concentration message.<commit_after>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
// $Log: task_trance_of_blades.cc,v $
// Revision 5.3  2002/12/17 00:34:47  brat
// Fixed a typo in the lose concentration message.
//
// Revision 5.2  2002/01/10 05:56:59  peel
// even more splitting up of obj2.h
//
// Revision 5.1.1.1  2001/01/09 20:00:40  batopr
// *** empty log message ***
//
// Revision 5.1  2001/01/09 20:00:32  batopr
// *** empty log message ***
//
// Revision 1.2  2000/12/27 08:27:35  dash
// added code for 'defensive trance' warrior skill
//
// Revision 1.1  2000/12/22 07:12:03  dash
// Initial revision
//
//
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//
//      SneezyMUD 4.0 - All rights reserved, SneezyMUD Coding Team
//      "task.cc" - All functions related to tasks that keep mobs/PCs busy
//
//////////////////////////////////////////////////////////////////////////

#include "stdsneezy.h"
#include "obj_base_weapon.h"

void stop_trance_of_blades(TBeing *ch)
{
  if (ch->getPosition() >= POSITION_RESTING) {
    act("You suddenly snap out of your trance.",
	FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
    act("$n suddenly snaps out of $s trance.",
	FALSE, ch, 0, 0, TO_ROOM);
  }
  ch->stopTask();
}

//void TBaseWeapon::tranceOfBladesPulse(TBeing *ch, TThing *)
//  {
//  stop_trance_of_blades(ch);
//  return;
//  }


int task_trance_of_blades(TBeing *ch, cmdTypeT cmd, const char *, int pulse, TRoom *, TObj *)
{
  TThing *o = NULL;
  int chance = 0;
  // sanity check
  if (ch->isLinkdead() ||
      (ch->in_room != ch->task->wasInRoom) ||
      (ch->getPosition() < POSITION_RESTING)) {
    stop_trance_of_blades(ch);
    return FALSE;  // returning FALSE lets command be interpreted
  }
  if (ch->utilityTaskCommand(cmd) ||
      ch->nobrainerTaskCommand(cmd))
    return FALSE;
  switch (cmd) {
  case CMD_TASK_CONTINUE:
    ch->task->calcNextUpdate(pulse, PULSE_MOBACT);
    if (!(o = ch->heldInPrimHand())) {
      act("Loss of your weapon causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Loss of $s weapon causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }   
    if (ch->getCombatMode() == ATTACK_BERSERK) {
      act("Berserking causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Berserking causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }   
    if (ch->isSwimming()) {
      act("Sudden immersion causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("Sudden immersion causes $n to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (!ch->canUseArm(HAND_PRIMARY)) {
      act("Your injured arm causes you to snap out of your trance.",
          FALSE, ch, 0, 0, TO_CHAR), ANSI_RED;
      act("$n's injured arm causes $m to snap out of $s trance.",
          FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (ch->getMove() < 30) {
      act("Your fatigue causes you to snap out of your trance.",
	  FALSE, ch, 0, 0, TO_CHAR, ANSI_RED);
      act("$n's fatigue causes $m to snap out of $s trance.",
	  FALSE, ch, 0, 0, TO_ROOM);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;      
    }
    ch->addToMove(-10);
    chance = 150 - ch->getSkillValue(SKILL_TRANCE_OF_BLADES);
    if (!(ch->attackers)) chance *= 2;
    chance = (int)((float) chance * ch->plotStat(STAT_CURRENT, STAT_FOC, 1.25, 0.80, 1.00));
    if (chance > ::number(0,999)) {
      act("Your concentration has been lost, and you snap out of your defensive trance.",
	  FALSE, ch, 0, 0, TO_CHAR, ANSI_YELLOW);
      act("$n loses $s concentration and snaps out of $s defensive trance.",
	  FALSE, ch, 0, 0, TO_ROOM, ANSI_YELLOW);
      ch->stopTask();
      ch->addToWait(combatRound(2));
      ch->cantHit += ch->loseRound(1);
      return FALSE;
    }
    if (!(::number(0,2)) || (ch->attackers))
      act("Your focus is good and you are able to maintain your defensive trance.",
	  FALSE, ch, 0, 0, TO_CHAR);
    return FALSE;
  case CMD_ABORT:
  case CMD_STOP:
    act("You slowly come out of your trance.",
	FALSE, ch, o, 0, TO_CHAR);
    act("$n slowly comes out of $s trance.", FALSE, ch, o, 0, TO_ROOM);
    ch->stopTask();
    ch->addToWait(combatRound(2));
    ch->cantHit += ch->loseRound(1);
    break;
  case CMD_TASK_FIGHTING:
    //    act("Your $o becomes a blur as you concentrate on your defensive trance.", FALSE, ch, o, 0, TO_CHAR);
    //    act("$n's $o becomes a blur as $e concentrates on $s defensive trance.", FALSE, ch, o, 0, TO_ROOM);
{'fraction_non_alphanumeric': 0.20179924242424244, 'fraction_numerical': 0.03125, 'mean_word_length': 2.2326293235384145, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3490422', 'n_tokens_mistral': 3955, 'n_tokens_neox': 3651, 'n_words': 1051}