<commit_before>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
//      "damage.cc" - functions for doing damage
//
//////////////////////////////////////////////////////////////////////////

#include "stdsneezy.h"
#include "combat.h"
#include "statistics.h"
#include "obj_base_corpse.h"
#include "database.h"
#include "cmd_trophy.h"

// there is another one of these defines in combat.cc
#define DAMAGE_DEFINE 0

// -1 = v is dead, needs to go bye-bye
int TBeing::reconcileDamage(TBeing *v, int dam, spellNumT how)
{
  int rc;
  spellNumT how2;

  if (desc && !fight()) {
    SET_BIT(specials.affectedBy, AFF_AGGRESSOR);
    if (checkEngagementStatus()) 
      SET_BIT(specials.affectedBy, AFF_ENGAGER);
  }

  dam = getActualDamage(v, NULL, dam, how);

#if 0
  // Do more damage if you're much larger. Doesn't apply to mobs less than 5th.
  if (!isPc() && (getLevel(bestClass()) < 5)) {
    if (dam)
      dam += (int)((getWeight() / v->getWeight())/2);
  }
#endif
#if 0
  // hey cool, my spells do more damage!!!!!!  - Bad to do this here
  // FYI use getStrDamModifier instead too
  // Modify by strength.
  if (dam)
    dam += plotStat(STAT_CURRENT, STAT_STR, 1, 7, 4);
#endif

  // make um fly if appropriate
  if (!v->isPc() && v->canFly() && !v->isFlying())  {
    // in general, we did text before we applied the dam
    // if we incapacitated um, keep um on the ground.
    // if we knocked um over, also reconsider flying
    TMonster *tv = dynamic_cast<TMonster *>(v);
    if ((v->getHit() - dam > 0) &&
        (v->getPosition() == tv->default_pos))
      v->doFly();
  }

  switch (how) {
    case DAMAGE_KICK_HEAD:
    case DAMAGE_KICK_SIDE:
    case DAMAGE_KICK_SHIN:
    case DAMAGE_KICK_SOLAR:
      how2 = getSkillNum(SKILL_KICK);
      break;
    case DAMAGE_HEADBUTT_THROAT:
    case DAMAGE_HEADBUTT_BODY:
    case DAMAGE_HEADBUTT_CROTCH:
    case DAMAGE_HEADBUTT_LEG:
    case DAMAGE_HEADBUTT_FOOT:
    case DAMAGE_HEADBUTT_JAW:
    case DAMAGE_HEADBUTT_SKULL:
      how2 = SKILL_HEADBUTT;
      break;
    case DAMAGE_KNEESTRIKE_FOOT:
    case DAMAGE_KNEESTRIKE_SHIN:
    case DAMAGE_KNEESTRIKE_KNEE:
    case DAMAGE_KNEESTRIKE_THIGH:
    case DAMAGE_KNEESTRIKE_CROTCH:
    case DAMAGE_KNEESTRIKE_SOLAR:
    case DAMAGE_KNEESTRIKE_CHIN:
    case DAMAGE_KNEESTRIKE_FACE:
      how2 = SKILL_KNEESTRIKE;
      break;
    default:
      how2 = how;
  }

  // some places we want to insure a kill so we send HUGE damage through
  // account for this by just reducing it to smallest required amount
  // dam2 is strictly for logging, this adjustment is done again
  // later on, but with some other quirks
  int dam2 = min(dam, 11 + v->getHit());

  if (how2 >= MIN_SPELL && how2 < MAX_SKILL && this != v) 
    LogDam(this, how2, dam2);

  if (!v->isPc()) {
    TMonster *tmons = dynamic_cast<TMonster *>(v);
    if (!tmons->isPet(PETTYPE_PET | PETTYPE_CHARM | PETTYPE_THRALL)) {
      tmons->developHatred(this);

      // if we are fighting an NPC pet, develop hatred toward the master
      // however, only do this is the pet was the aggressor (PC ordere pet
      // to attack), to avoid guards "get thee back to.." from hating
      // elemental's owner.  Only hate if the pet was the aggressor, or
      // if the pet's owner is also fighting
      if (!isPc() && isPet(PETTYPE_PET | PETTYPE_CHARM | PETTYPE_THRALL)) {
        if (master && (master->isPc() || master->desc)) {
          if (isAffected(AFF_AGGRESSOR) ||
              master->fight() == tmons) {
            tmons->developHatred(master);
          }
        }<commit_msg>fixed a crashed bug I believe<commit_after>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
//      "damage.cc" - functions for doing damage
//
//////////////////////////////////////////////////////////////////////////

#include "stdsneezy.h"
#include "combat.h"
#include "statistics.h"
#include "obj_base_corpse.h"
#include "database.h"
#include "cmd_trophy.h"

// there is another one of these defines in combat.cc
#define DAMAGE_DEFINE 0

// -1 = v is dead, needs to go bye-bye
int TBeing::reconcileDamage(TBeing *v, int dam, spellNumT how)
{
  int rc;
  spellNumT how2;

  if (desc && !fight()) {
    SET_BIT(specials.affectedBy, AFF_AGGRESSOR);
    if (checkEngagementStatus()) 
      SET_BIT(specials.affectedBy, AFF_ENGAGER);
  }

  dam = getActualDamage(v, NULL, dam, how);

#if 0
  // Do more damage if you're much larger. Doesn't apply to mobs less than 5th.
  if (!isPc() && (getLevel(bestClass()) < 5)) {
    if (dam)
      dam += (int)((getWeight() / v->getWeight())/2);
  }
#endif
#if 0
  // hey cool, my spells do more damage!!!!!!  - Bad to do this here
  // FYI use getStrDamModifier instead too
  // Modify by strength.
  if (dam)
    dam += plotStat(STAT_CURRENT, STAT_STR, 1, 7, 4);
#endif

  // make um fly if appropriate
  if (!v->isPc() && v->canFly() && !v->isFlying())  {
    // in general, we did text before we applied the dam
    // if we incapacitated um, keep um on the ground.
    // if we knocked um over, also reconsider flying
    TMonster *tv = dynamic_cast<TMonster *>(v);
    if ((v->getHit() - dam > 0) &&
        (v->getPosition() == tv->default_pos))
      v->doFly();
  }

  switch (how) {
    case DAMAGE_KICK_HEAD:
    case DAMAGE_KICK_SIDE:
    case DAMAGE_KICK_SHIN:
    case DAMAGE_KICK_SOLAR:
      how2 = getSkillNum(SKILL_KICK);
      break;
    case DAMAGE_HEADBUTT_THROAT:
    case DAMAGE_HEADBUTT_BODY:
    case DAMAGE_HEADBUTT_CROTCH:
    case DAMAGE_HEADBUTT_LEG:
    case DAMAGE_HEADBUTT_FOOT:
    case DAMAGE_HEADBUTT_JAW:
    case DAMAGE_HEADBUTT_SKULL:
      how2 = SKILL_HEADBUTT;
      break;
    case DAMAGE_KNEESTRIKE_FOOT:
    case DAMAGE_KNEESTRIKE_SHIN:
    case DAMAGE_KNEESTRIKE_KNEE:
    case DAMAGE_KNEESTRIKE_THIGH:
    case DAMAGE_KNEESTRIKE_CROTCH:
    case DAMAGE_KNEESTRIKE_SOLAR:
    case DAMAGE_KNEESTRIKE_CHIN:
    case DAMAGE_KNEESTRIKE_FACE:
      how2 = SKILL_KNEESTRIKE;
      break;
    default:
      how2 = how;
  }

  // some places we want to insure a kill so we send HUGE damage through
  // account for this by just reducing it to smallest required amount
  // dam2 is strictly for logging, this adjustment is done again
  // later on, but with some other quirks
  int dam2 = min(dam, 11 + v->getHit());

  if (how2 >= MIN_SPELL && how2 < MAX_SKILL && this != v) 
    LogDam(this, how2, dam2);

  if (!v->isPc()) {
    TMonster *tmons = dynamic_cast<TMonster *>(v);
    if (tmons && !tmons->isPet(PETTYPE_PET | PETTYPE_CHARM | PETTYPE_THRALL)) {
      tmons->developHatred(this);

      // if we are fighting an NPC pet, develop hatred toward the master
      // however, only do this is the pet was the aggressor (PC ordere pet
      // to attack), to avoid guards "get thee back to.." from hating
      // elemental's owner.  Only hate if the pet was the aggressor, or
      // if the pet's owner is also fighting
      if (!isPc() && isPet(PETTYPE_PET | PETTYPE_CHARM | PETTYPE_THRALL)) {
        if (master && (master->isPc() || master->desc)) {
          if (isAffected(AFF_AGGRESSOR) ||
              master->fight() == tmons) {
            tmons->developHatred(master);
          }
        }
{'fraction_non_alphanumeric': 0.15176743551248806, 'fraction_numerical': 0.00655111232428006, 'mean_word_length': 2.482889733840304, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, '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': '5673887', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2486, 'n_words': 730}