chamber
if (defendPhase < 0)
{
if (dstAttackPhase != ap_ready)
return 0;
float progress = dstAgent->m_actionChannels[1].m_progress;
if (srcAttackType == at_overswing)
{
if (dstAttackType != at_overswing)
return 0;
}
else if (srcAttackType == at_swing_left)
{
if (dstAttackType != at_swing_right)
return 0;
}
else if (srcAttackType == at_swing_right)
{
if (dstAttackType != at_swing_left)
return 0;
}
else
{
if (dstAttackType == at_overswing)
{
if (hasUpperStab)
return 0;
}
else if (dstAttackType != at_thrust)
{
return 0;
}
}
if (rglBetween(progress, 0.3f, 0.7f) && (rglConfig::Battle::bCouchedLanceChambered || !srcAgent->isCouching()))
return mct_chambered;
return 0;
}
bAdjustedAttackHoldFactor
float mbAttack::getHoldFactor()
{
float factor;
if (rglConfig::Battle::bAdjustedAttackHoldFactor)
{
if (m_holdTime < 0.5f)
factor = m_holdTime + 1.0f;
else if (m_holdTime < 0.6f)
factor = 1.5f;
else if (m_holdTime < 1.1f)
factor = 1.2f + (1.1f - m_holdTime) * 0.6f;
else
factor = 1.2f - (m_holdTime - 1.1f) * 0.3f;
return rglClamp(factor, 0.5f, 1.5f);
}
else
{
if (m_holdTime < 0.5f)
factor = m_holdTime + 1.0f;
else if (m_holdTime < 0.6f)
factor = 1.5f;
else if (m_holdTime < 1.1f)
factor = 1.2f + (1.1f - m_holdTime) * 0.6f;
else
factor = 1.2f;
return rglClamp(factor, 1.0f, 2.0f);
}
}
bAdjustedCrushthrough
bool mbMission::checkCrushthrough(int agentNo, mbBlow &blow, mbAttack &attack)
{
float crushFactor = blow.m_damageType != dt_cut ? 3.0f : 2.0f;
float defendFactor = 1.0f;
mbAgent *defendAgent = getAgent(agentNo);
mbItem defendItem = defendAgent->getWieldedItem(ah_secondary);
if (!defendItem.isValid() || defendItem.isNotShield())
defendItem = defendAgent->getWieldedItem(ah_primary);
if (rglConfig::Battle::bAdjustedCrushthrough)
{
crushFactor *= (blow.m_rawDamage + 40.0f) / 40.0f * 0.4f;
if (blow.m_item.isValid())
{
mbItemKind *itemKind = blow.m_item.getItemKind();
if (!(itemKind->m_properties & itp_crush_through))
return false;
if (itemKind->m_properties & itp_two_handed)
crushFactor *= 1.5f;
crushFactor *= (itemKind->m_weight + 10.0f) / 10.0f;
}
crushFactor *= rglPow(attack.getHoldFactor(), 1.5f);
if (defendItem.isValid())
{
mbItemKind *defendItemKind = defendItem.getItemKind();
if (defendItemKind->isShield())
{
defendFactor = 1.0f + defendItemKind->m_weight * 0.4f;
}
else
{
defendFactor = 3.0f + defendItemKind->m_weight * 0.5f;
if (defendItemKind->m_properties & itp_two_handed)
defendFactor *= 1.2f;
}
}
}
else
{
crushFactor *= blow.m_rawDamage * 0.02f;
if (blow.m_item.isValid())
{
mbItemKind *itemKind = blow.m_item.getItemKind();
if (itemKind->getType() == itp_type_two_handed || itemKind->getType() == itp_type_polearm)
crushFactor *= 2.0f;
if (!(itemKind->m_properties & itp_crush_through))
crushFactor = 0.0f;
crushFactor *= (itemKind->m_weight + 4.0f) / 5.0f;
}
if (attack.m_power > 1.25f)
crushFactor *= 1.3f;
if (attack.m_type == at_thrust)
crushFactor *= 0.5f;
if (defendItem.isValid())
{
mbItemKind *defendItemKind = defendItem.getItemKind();
defendFactor = defendItemKind->m_weight * 0.2f + 5.0f;
if (defendItemKind->getType() == itp_type_two_handed || defendItemKind->getType() == itp_type_polearm)
defendFactor *= 1.2f;
}
}
return rglConfig::Battle::fCrushthroughThreshold < crushFactor / defendFactor;
}
bAdjustedTwoHandedAndPolearmPenalties
if (type == itp_type_two_handed || type == itp_type_polearm)
{
if (rglConfig::Battle::bAdjustedTwoHandedAndPolearmPenalties)
{
if (srcAgent->hasMount())
{
if (type == itp_type_polearm)
damage *= 0.75f;
if (itemKind->m_properties & itp_two_handed)
damage *= 0.8f;
}
else if (shieldItem.isValid())
{
damage *= 0.9f;
}
}
else
{
if (shieldItem.isValid() || srcAgent->hasMount())
{
damage *= 0.85f;
if (type == itp_type_polearm)
damage *= 0.85f;
if (itemKind->m_properties & itp_two_handed)
damage *= 0.9f;
}
}
}
bAdjustedShieldSkillDamage
damage = (rglConfig::Battle::bAdjustedShieldSkillDamage) ? rglRound(damage * (1.0f - (0.1f + g_game->getTroopSkill(m_troopNo, skl_shield, true) * 0.06f))) : (int)(damage * (1.0f - g_game->getTroopSkill(m_troopNo, skl_shield, true) * 0.08f));
bAdjustedStagger and bAdjustedKnockdown
if (itemKind && (itemKind->isRangedWeapon() || itemKind->getType() == itp_type_polearm && !(itemKind->m_properties & itp_can_knock_down)) || m_blow.hasFlags(blf_stagger))
{
if (!noInterrupt)
{
if (rglConfig::Battle::bAdjustedStagger)
{
if (m_blow.hasFlags(blf_stagger) ||
itemKind->getType() == itp_type_polearm && rglRandf() < 0.5f && m_blow.m_rawDamage > 15.0f && rglConfig::Battle::bPolearmStagger || //FEATURE: use a flag
itemKind->getType() == itp_type_thrown && rglRandf() < (0.4f + staggerAdd) && inflictedDamage > (25.0f + staggerChanceAdd) ||
itemKind->getType() == itp_type_bow && rglRandf() < (0.3f + staggerAdd) && inflictedDamage > (20.0f + staggerChanceAdd) ||
itemKind->getType() == itp_type_crossbow && rglRandf() < (0.3f + staggerAdd) && inflictedDamage > (20.0f + staggerChanceAdd))
{
lowerActionNo = getStrikeAction(2);
knockBack = true;
knockBackForce = m_blow.m_direction * rglRandf(2.1f, 2.3f);
}
else
{
upperActionNo = getStrikeAction(1);
}
}
else
{
if (m_blow.hasFlags(blf_stagger) ||
itemKind->getType() == itp_type_polearm && rglRandf() < 0.5f && m_blow.m_rawDamage > 15.0f && rglConfig::Battle::bPolearmStagger || //FEATURE: use a flag
itemKind->getType() == itp_type_thrown && rglRandf() < 0.4f && m_blow.m_rawDamage > 15.0f ||
itemKind->getType() == itp_type_bow && rglRandf() < 0.3f && m_blow.m_rawDamage > 25.0f ||
itemKind->getType() == itp_type_crossbow && rglRandf() < 0.3f && m_blow.m_rawDamage > 25.0f)
{
lowerActionNo = getStrikeAction(2);
knockBack = true;
knockBackForce = m_blow.m_direction * rglRandf(2.1f, 2.3f);
}
else
{
lowerActionNo = getStrikeAction(1);
}
}
}
}
else if (rglConfig::Battle::bAdjustedKnockdown && (m_blow.hasFlags(blf_horse_charge) && m_blow.m_rawDamage > 10.0f ||
(rglClamp((itemKind ? itemKind->m_weight : 1.0f) * 0.33f, 1.0f, 2.0f) * rglClamp((m_blow.m_rawDamage - 40.0f) * kdRawDamageMult, itemKind ? 5.0f : 2.5f, 15.0f) * 0.015f > (rglRandf() + kdRandAdd)) && m_blow.m_damageType == dt_blunt) &&
!m_blow.hasFlags(blf_crushthrough) && !m_blow.hasFlags(blf_no_knockdown) && (!itemKind || itemKind->m_properties & itp_can_knock_down) && m_actionChannels[0].m_actionNo != anim_strike_fall_back_rise)
{
lowerActionNo = anim_strike_fall_back_rise;
upperActionNo = anim_strike_fall_back_rise_upper;
knockBack = true;
knockBackForce = m_movementDir * -0.6f;
if (m_blow.hasFlags(blf_horse_charge))
knockBackForce += m_blow.m_direction * rglRandf(1.5f, 1.9f);
}
else if (!rglConfig::Battle::bAdjustedKnockdown && (m_blow.hasFlags(blf_horse_charge) && m_blow.m_rawDamage > 10.0f ||
(rglMin((itemKind ? itemKind->m_weight : 1.0f) * 0.33f, 2.0f) * rglMin((m_blow.m_rawDamage - 20.0f) * 0.5f, 10.0f) * 0.015f > rglRandf()) && m_blow.m_damageType == dt_blunt) &&
!m_blow.hasFlags(blf_crushthrough) && (!itemKind || itemKind->m_properties & itp_can_knock_down) && m_actionChannels[0].m_actionNo != anim_strike_fall_back_rise)
{
lowerActionNo = anim_strike_fall_back_rise;
upperActionNo = anim_strike_fall_back_rise_upper;
knockBack = true;
knockBackForce = m_movementDir * -0.6f;
if (m_blow.hasFlags(blf_horse_charge))
knockBackForce += m_blow.m_direction * rglRandf(1.5f, 1.9f);
}
else
{
upperActionNo = getStrikeAction(1);
if (m_blow.hasFlags(blf_horse_charge) || m_blow.m_rawDamage > 15.0f && rglRandf() < 0.3f)
{
knockBack = true;
knockBackForce = m_blow.m_direction * rglRandf(0.6f, 1.6f) * (m_blow.m_rawDamage + 30.0f) * 0.02f + m_scaledTransform.s * rglRandf(-0.5f, 0.5f) * 0.5f;
}
}
bParry
else if (rglConfig::Battle::bParry && wasDefending && m_defendTimer.getElapsedTime() < 0.15f && m_parryTimer.getElapsedTime() > 1.0f)
{
m_parryTimer.reset();
m_isParry = true;
}
m_defendAction = m_isParry ? da_parrying : da_blocking;