Exemple #1
0
int Armor::takeDurabilityHitAndGetReducedDamage(const int DAMAGE_BEFORE, const DamageTypes_t damageType) {
  tracer << "Armor::takeDurabilityHitAndGetReducedDamage()..." << endl;
  //Absorption points = damage soaked up by armor instead of hitting the player
  //DDF = Damage (to) Durability Factor, how much damage the durability takes per attack damage point

  const int ABSORPTION_POINTS_BEFORE = getAbsorptionPoints(damageType);

  const double DDF_INTRINSIC = def_->armorData.damageToDurabilityFactors[damageType];
  const double DDF_RANDOM = static_cast<float>(eng->dice.getInRange(1, 100)) / 100.0;
  const double DDF_ADJUST = 3.0;

  durability = max(0, durability - static_cast<int>(static_cast<double>(DAMAGE_BEFORE) * DDF_INTRINSIC * DDF_RANDOM * DDF_ADJUST));

  const int ABSORPTION_POINTS_CURRENT = getAbsorptionPoints(damageType_physical);
  if(ABSORPTION_POINTS_CURRENT < ABSORPTION_POINTS_BEFORE && ABSORPTION_POINTS_CURRENT != 0) {
    const string armorName = eng->itemData->getItemRef(this, itemRef_plain, true);
    eng->log->addMessage("My " + armorName + " is damaged!");
  }

  tracer << "Armor: Damage before: " + intToString(DAMAGE_BEFORE) << endl;

  const int DAMAGE_REDUCTION = max(1, DAMAGE_BEFORE - ABSORPTION_POINTS_BEFORE);

  tracer << "Armor: Damage reduction: " + intToString(DAMAGE_REDUCTION) << endl;

  tracer << "Armor::takeDurabilityHitAndGetReducedDamage() [DONE]" << endl;
  return DAMAGE_REDUCTION;
}
Exemple #2
0
int Armor::takeDurabilityHitAndGetReducedDamage(const int DMG_BEFORE) {
  trace << "Armor::takeDurabilityHitAndGetReducedDamage()..." << endl;

  //Absorption points (AP) = damage soaked up instead of hitting the player
  //DDF = Damage (to) Durability Factor
  //(how much damage the durability takes per attack damage point)

  const int AP_BEFORE = getAbsorptionPoints();

  const double DDF_BASE         = data_->armorData.dmgToDurabilityFactor;
  //TODO Add check for if wearer is player
  const double DDF_WAR_VET_MOD  = PlayerBon::getBg() == Bg::warVet ?
                                  0.5 : 1.0;
  const double DDF_K            = 1.5;

  const double DMG_BEFORE_DB = double(DMG_BEFORE);

  dur_ -= int(DMG_BEFORE_DB * DDF_BASE * DDF_WAR_VET_MOD * DDF_K);

  dur_ = max(0, dur_);

  const int AP_AFTER = getAbsorptionPoints();

  if(AP_AFTER < AP_BEFORE && AP_AFTER != 0) {
    const string armorName =
      eng.itemDataHandler->getItemRef(*this, ItemRefType::plain, true);
    eng.log->addMsg("My " + armorName + " is damaged!", clrMsgWarning);
  }

  trace << "Armor: Damage before: " + toStr(DMG_BEFORE) << endl;

  const int DMG_AFTER = max(1, DMG_BEFORE - AP_BEFORE);

  trace << "Armor: Damage after: " + toStr(DMG_AFTER) << endl;

  trace << "Armor::takeDurabilityHitAndGetReducedDamage() [DONE]" << endl;
  return DMG_AFTER;
}
Exemple #3
0
string Armor::getArmorDataLine(const bool WITH_BRACKETS) const {

  const int AP = getAbsorptionPoints();

  if(AP <= 0) {assert(false && "Armor AP less than 1"); return "";}

  const string absorptionPointsStr = toStr(AP);

  if(WITH_BRACKETS) {
    return "[" + absorptionPointsStr + "]";
  } else {
    return absorptionPointsStr;
  }
}
Exemple #4
0
string Armor::getArmorDataLine(const bool WITH_BRACKETS) const {
  const string apLabelOverRide = def_->armorData.overRideAbsorptionPointLabel;
  const int ABS_POINTS = getAbsorptionPoints(damageType_physical);

  if(apLabelOverRide == "" && ABS_POINTS <= 0) {
    return "";
  }

  const string absorptionPointsStr = apLabelOverRide == "" ? intToString(ABS_POINTS) : apLabelOverRide;
  if(WITH_BRACKETS) {
    return "[" + absorptionPointsStr + "]";
  } else {
    return absorptionPointsStr;
  }
}