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

#include "stdsneezy.h"
#include "obj_portal.h"


void stop_tracking(TBeing *ch)
{
  if (!ch->isLinkdead() && (ch->in_room > 0) &&
      (ch->getPosition() >= POSITION_RESTING)) {
    act("You stop and look about blankly.",
            FALSE, ch, 0, 0, TO_CHAR);
    act("$n stops and looks about blankly.",
            FALSE, ch, 0, 0, TO_ROOM);
  }
  ch->stopTask();
  ch->remPlayerAction(PLR_HUNTING);
  if (ch->affectedBySpell(SKILL_TRACK)     )
    ch->affectFrom(SKILL_TRACK);
  if (ch->affectedBySpell(SKILL_SEEKWATER) )
    ch->affectFrom(SKILL_SEEKWATER);
  ch->specials.hunting = NULL;
  ch->hunt_dist = 0;
}

int task_tracking(TBeing *ch, cmdTypeT cmd, const char *argument, int pulse, TRoom *, TObj *obj)
{
  // Do a hard return now if they have already been given their message.
  if ((!ch || !ch->task || (ch->task->flags > 0 && ch->task->flags != 100)) &&
      cmd == CMD_TASK_CONTINUE)
    return FALSE;

  affectedData *aff;
  roomDirData *Eroom=NULL;
  TThing *t;
  int code=-1;
  int skill;
  int targetRm = -1;
  bool isSW = ch->affectedBySpell(SKILL_SEEKWATER);
  bool isTR = ch->affectedBySpell(SKILL_TRACK);
  bool isTS = ch->affectedBySpell(SPELL_TRAIL_SEEK);
  bool worked;
  char buf[256], buf2[256];

  if (ch->isLinkdead() || (ch->in_room < 0) ||
      (ch->getPosition() < POSITION_RESTING)) {
    stop_tracking(ch);
    return FALSE;  // return FALSE lets the command be interpreted
  }

  if (ch->utilityTaskCommand(cmd) ||
      ch->nobrainerTaskCommand(cmd))
    return FALSE;

  if (!ch->specials.hunting && !isSW) {
    act("For some reason your quarry can no longer be found.",
        FALSE, ch, 0, 0, TO_CHAR);
    stop_tracking(ch);
    return FALSE;
  }

  skill = 0;

  if (ch->specials.hunting)
    for (aff = ch->specials.hunting->affected; aff; aff = aff->next)
      if (aff->type == SKILL_CONCEALMENT)
        skill = -aff->modifier;

  if (isSW) {
    skill += ch->getSkillValue(SKILL_SEEKWATER);
    worked = bSuccess(ch, skill, SKILL_SEEKWATER);
  } else if (isTR) {
    skill += ch->getSkillValue(SKILL_TRACK);
    worked = bSuccess(ch, skill, SKILL_TRACK);
  } else if (isTS) {
    skill += 50;
    worked = (::number(0, 110) < skill);
  } else {
    // in theory, we would never get here.
    // however, say a mob hates a creature so has specials.hunting.
    // a god switches into the mob, and does a look.
    // look logic kicks in and we get here.
    return TRUE;
  }

  switch(cmd) {
  case CMD_TRACK:
    if (!isSW) {
        if (*argument)
          ch->sendTo("You give up tracking your quarry and choose a new one.\n\r");
        stop_tracking(ch);
        ch->addToWait(combatRound(1));
        if (*argument)
          return FALSE;
        else
          return TRUE;
    }
      warn_busy(ch);
      return TRUE;
  case CMD_SEEKWATER:
    if (isSW) {
        ch->sendTo("Your already seeking water.\n\r");
        return TRUE;
    }
      ch->sendTo("You give up tracking your quarry and choose to seek some water.\n\r");
      stop_tracking(ch);
      ch->addToWait(combatRound(1));
      return FALSE;
  case CMD_NORTH:
  case CMD_EAST:
  case CMD_SOUTH:
  case CMD_WEST:
  case CMD_UP:
  case CMD_DOWN:
  case CMD_NE:
  case CMD_NW:
  case CMD_SE:
  case CMD_SW:
      Eroom=ch->exitDir(getDirFromCmd(cmd));
  case CMD_ENTER:
    // Each time the person moves we reduce the flags value by 1.  This way
    // we eat up 1 'CMD_TASK_CONTINUE' when it is called for each move.  Now
    // we must make sure were not simply dropping this to 0, because if we
    // moved we apparently need to try and find the target again but we also
    // don't want this to occure to fast, so we drop it to -1 at Least.
    // We also eat some moves should the exit exist.
      if (ch->task->flags > -5)
        ch->task->flags = min(-1, ch->task->flags - 1);
      if (exit_ok(Eroom, NULL))
        ch->addToMove(-(int) (120-
			      ch->getSkillValue((isSW ? SKILL_SEEKWATER :
						 (isTR ? SKILL_TRACK : SPELL_TRAIL_SEEK))))/20);
      return FALSE;
  case CMD_TELL:
  case CMD_WHISPER:
      if (ch->task->flags > -5 && ch->task->flags < 1)
        ch->task->flags--;
      return FALSE;
  case CMD_SCAN:
      if (ch->task->flags > -4 && ch->task->flags < 1);
        ch->task->flags -= 2;
      return FALSE;
  case CMD_TASK_CONTINUE:
    // Are we supposed to eat this continue?  If less than 0, you betcha.
    // Add 1 to flags to mark the eat then return back.
    if (ch->task->flags < 0) {
        ch->task->flags++;
        return TRUE;
    }
      if (ch->task->flags > 0)
        return TRUE;
      // Guess this one wasn't to be ate.  So we check to see if we've found
      // our target yet (0==no, >=1 == yes).  If not, then we try again.
      // 100 means it was to dark last time, so lets give it another shot.
      if (ch->task->flags == 0 || ch->task->flags == 100) {
        // Is it too dark to see?  If so then we see if it was last time, also.
        // If not we pump out a too dark to see message then return, if it was<commit_msg>*** empty log message ***<commit_after>//////////////////////////////////////////////////////////////////////////
//
//      SneezyMUD - All rights reserved, SneezyMUD Coding Team
//      "task.cc" - All functions related to tasks that keep mobs/PCs busy
//
//////////////////////////////////////////////////////////////////////////

#include "stdsneezy.h"
#include "obj_portal.h"


void stop_tracking(TBeing *ch)
{
  if (!ch->isLinkdead() && (ch->in_room > 0) &&
      (ch->getPosition() >= POSITION_RESTING)) {
    act("You stop and look about blankly.",
            FALSE, ch, 0, 0, TO_CHAR);
    act("$n stops and looks about blankly.",
            FALSE, ch, 0, 0, TO_ROOM);
  }
  ch->stopTask();
  ch->remPlayerAction(PLR_HUNTING);
  if (ch->affectedBySpell(SKILL_TRACK)     )
    ch->affectFrom(SKILL_TRACK);
  if (ch->affectedBySpell(SKILL_SEEKWATER) )
    ch->affectFrom(SKILL_SEEKWATER);
  ch->specials.hunting = NULL;
  ch->hunt_dist = 0;
}

int task_tracking(TBeing *ch, cmdTypeT cmd, const char *argument, int pulse, TRoom *, TObj *obj)
{
  // Do a hard return now if they have already been given their message.
  if ((!ch || !ch->task || (ch->task->flags > 0 && ch->task->flags != 100)) &&
      cmd == CMD_TASK_CONTINUE)
    return FALSE;

  affectedData *aff;
  roomDirData *Eroom=NULL;
  TThing *t;
  int code=-1;
  int skill;
  int targetRm = -1;
  bool isSW = ch->affectedBySpell(SKILL_SEEKWATER);
  bool isTR = ch->affectedBySpell(SKILL_TRACK);
  bool isTS = ch->affectedBySpell(SPELL_TRAIL_SEEK);
  bool worked;
  char buf[256], buf2[256];

  if (ch->isLinkdead() || (ch->in_room < 0) ||
      (ch->getPosition() < POSITION_RESTING)) {
    stop_tracking(ch);
    return FALSE;  // return FALSE lets the command be interpreted
  }

  if (ch->utilityTaskCommand(cmd) ||
      ch->nobrainerTaskCommand(cmd))
    return FALSE;

  if (!ch->specials.hunting && !isSW) {
    act("For some reason your quarry can no longer be found.",
        FALSE, ch, 0, 0, TO_CHAR);
    stop_tracking(ch);
    return FALSE;
  }

  skill = 0;

  if (ch->specials.hunting)
    for (aff = ch->specials.hunting->affected; aff; aff = aff->next)
      if (aff->type == SKILL_CONCEALMENT)
        skill = -aff->modifier;

  if (isSW) {
    skill += ch->getSkillValue(SKILL_SEEKWATER);
    worked = bSuccess(ch, skill, SKILL_SEEKWATER);
  } else if (isTR) {
    skill += ch->getSkillValue(SKILL_TRACK);
    worked = bSuccess(ch, skill, SKILL_TRACK);
  } else if (isTS) {
    skill += 50;
    worked = (::number(0, 110) < skill);
  } else {
    // in theory, we would never get here.
    // however, say a mob hates a creature so has specials.hunting.
    // a god switches into the mob, and does a look.
    // look logic kicks in and we get here.
    return TRUE;
  }

  switch(cmd) {
  case CMD_TRACK:
    if (!isSW) {
        if (*argument)
          ch->sendTo("You give up tracking your quarry and choose a new one.\n\r");
        stop_tracking(ch);
        ch->addToWait(combatRound(1));
        if (*argument)
          return FALSE;
        else
          return TRUE;
    }
      warn_busy(ch);
      return TRUE;
  case CMD_SEEKWATER:
    if (isSW) {
        ch->sendTo("Your already seeking water.\n\r");
        return TRUE;
    }
      ch->sendTo("You give up tracking your quarry and choose to seek some water.\n\r");
      stop_tracking(ch);
      ch->addToWait(combatRound(1));
      return FALSE;
  case CMD_NORTH:
  case CMD_EAST:
  case CMD_SOUTH:
  case CMD_WEST:
  case CMD_UP:
  case CMD_DOWN:
  case CMD_NE:
  case CMD_NW:
  case CMD_SE:
  case CMD_SW:
      Eroom=ch->exitDir(getDirFromCmd(cmd));
  case CMD_ENTER:
    // Each time the person moves we reduce the flags value by 1.  This way
    // we eat up 1 'CMD_TASK_CONTINUE' when it is called for each move.  Now
    // we must make sure were not simply dropping this to 0, because if we
    // moved we apparently need to try and find the target again but we also
    // don't want this to occure to fast, so we drop it to -1 at Least.
    // We also eat some moves should the exit exist.
      if (ch->task->flags > -5)
        ch->task->flags = min(-1, ch->task->flags - 1);
      if (exit_ok(Eroom, NULL))
        ch->addToMove(-(int) (110-
			      ch->getSkillValue((isSW ? SKILL_SEEKWATER :
						 (isTR ? SKILL_TRACK : SPELL_TRAIL_SEEK))))/20);
      return FALSE;
  case CMD_TELL:
  case CMD_WHISPER:
      if (ch->task->flags > -5 && ch->task->flags < 1)
        ch->task->flags--;
      return FALSE;
  case CMD_SCAN:
      if (ch->task->flags > -4 && ch->task->flags < 1);
        ch->task->flags -= 2;
      return FALSE;
  case CMD_TASK_CONTINUE:
    // Are we supposed to eat this continue?  If less than 0, you betcha.
    // Add 1 to flags to mark the eat then return back.
    if (ch->task->flags < 0) {
        ch->task->flags++;
        return TRUE;
    }
      if (ch->task->flags > 0)
        return TRUE;
      // Guess this one wasn't to be ate.  So we check to see if we've found
      // our target yet (0==no, >=1 == yes).  If not, then we try again.
      // 100 means it was to dark last time, so lets give it another shot.
      if (ch->task->flags == 0 || ch->task->flags == 100) {
        // Is it too dark to see?  If so then we see if it was last time, also.
        // If not we pump out a too dark to see message then return, if it was
{'fraction_non_alphanumeric': 0.15592203898050974, 'fraction_numerical': 0.011431784107946028, 'mean_word_length': 2.264912817375344, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5066459', 'n_tokens_mistral': 3831, 'n_tokens_neox': 3608, 'n_words': 1135}