mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixes compilation due to changes in callback interface
This commit is contained in:
parent
1418ce4678
commit
b86969909a
@ -49,7 +49,8 @@ int64_t AttackPossibility::calculateDamageReduce(
|
||||
|
||||
vstd::amin(damageDealt, defender->getAvailableHealth());
|
||||
|
||||
auto enemyDamageBeforeAttack = cb.battleEstimateDamage(BattleAttackInfo(defender, attacker, defender->canShoot()));
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
auto enemyDamageBeforeAttack = cb.battleEstimateDamage(defender, attacker, 0);
|
||||
auto enemiesKilled = damageDealt / defender->MaxHealth() + (damageDealt % defender->MaxHealth() >= defender->getFirstHPleft() ? 1 : 0);
|
||||
auto enemyDamage = averageDmg(enemyDamageBeforeAttack);
|
||||
auto damagePerEnemy = enemyDamage / (double)defender->getCount();
|
||||
@ -74,10 +75,11 @@ int64_t AttackPossibility::evaluateBlockedShootersDmg(const BattleAttackInfo & a
|
||||
if(!state.battleCanShoot(st))
|
||||
continue;
|
||||
|
||||
BattleAttackInfo rangeAttackInfo(st, attacker, true);
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
BattleAttackInfo rangeAttackInfo(st, attacker, 0, true);
|
||||
rangeAttackInfo.defenderPos = hex;
|
||||
|
||||
BattleAttackInfo meleeAttackInfo(st, attacker, false);
|
||||
BattleAttackInfo meleeAttackInfo(st, attacker, 0, false);
|
||||
meleeAttackInfo.defenderPos = hex;
|
||||
|
||||
auto rangeDmg = state.battleEstimateDamage(rangeAttackInfo);
|
||||
|
@ -210,7 +210,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
|
||||
bestAttack.attackerState->unitType()->identifier,
|
||||
bestAttack.affectedUnits[0]->unitType()->identifier,
|
||||
(int)bestAttack.affectedUnits[0]->getCount(), action, (int)bestAttack.from, (int)bestAttack.attack.attacker->getPosition().hex,
|
||||
bestAttack.attack.chargedFields, bestAttack.attack.attacker->Speed(0, true),
|
||||
bestAttack.attack.chargeDistance, bestAttack.attack.attacker->Speed(0, true),
|
||||
bestAttack.defenderDamageReduce, bestAttack.attackerDamageReduce, bestAttack.attackValue()
|
||||
);
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ int64_t BattleExchangeVariant::trackAttack(
|
||||
const bool counterAttacksBlocked = attacker->hasBonus(selectorBlocksRetaliation, cachingStringBlocksRetaliation);
|
||||
|
||||
TDmgRange retaliation;
|
||||
BattleAttackInfo bai(attacker.get(), defender.get(), shooting);
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
BattleAttackInfo bai(attacker.get(), defender.get(), 0, shooting);
|
||||
|
||||
if(shooting)
|
||||
{
|
||||
@ -234,7 +235,8 @@ MoveTarget BattleExchangeEvaluator::findMoveTowardsUnreachable(const battle::Uni
|
||||
|
||||
for(auto hex : hexes)
|
||||
{
|
||||
auto bai = BattleAttackInfo(activeStack, closestStack, cb->battleCanShoot(activeStack));
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
auto bai = BattleAttackInfo(activeStack, closestStack, 0, cb->battleCanShoot(activeStack));
|
||||
auto attack = AttackPossibility::evaluate(bai, hex, hb);
|
||||
|
||||
attack.shootersBlockedDmg = 0; // we do not want to count on it, it is not for sure
|
||||
|
@ -46,10 +46,8 @@ PotentialTargets::PotentialTargets(const battle::Unit * attacker, const Hypothet
|
||||
|
||||
auto GenerateAttackInfo = [&](bool shooting, BattleHex hex) -> AttackPossibility
|
||||
{
|
||||
auto bai = BattleAttackInfo(attackerInfo, defender, shooting);
|
||||
|
||||
if(hex.isValid() && !shooting)
|
||||
bai.chargedFields = reachability.distances[hex];
|
||||
int distance = hex.isValid() ? reachability.distances[hex] : 0;
|
||||
auto bai = BattleAttackInfo(attackerInfo, defender, distance, shooting);
|
||||
|
||||
return AttackPossibility::evaluate(bai, hex, state);
|
||||
};
|
||||
|
@ -55,7 +55,8 @@ public:
|
||||
{}
|
||||
void calcDmg(const CStack * ourStack)
|
||||
{
|
||||
TDmgRange retal, dmg = cbc->battleEstimateDamage(ourStack, s, &retal);
|
||||
// FIXME: provide distance info for Jousting bonus
|
||||
TDmgRange retal, dmg = cbc->battleEstimateDamage(ourStack, s, 0, &retal);
|
||||
adi = static_cast<int>((dmg.first + dmg.second) / 2);
|
||||
adr = static_cast<int>((retal.first + retal.second) / 2);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
|
||||
${MAIN_LIB_DIR}/battle/CObstacleInstance.cpp
|
||||
${MAIN_LIB_DIR}/battle/CPlayerBattleCallback.cpp
|
||||
${MAIN_LIB_DIR}/battle/CUnitState.cpp
|
||||
${MAIN_LIB_DIR}/battle/DamageCalculator.cpp
|
||||
${MAIN_LIB_DIR}/battle/Destination.cpp
|
||||
${MAIN_LIB_DIR}/battle/IBattleState.cpp
|
||||
${MAIN_LIB_DIR}/battle/ReachabilityInfo.cpp
|
||||
@ -253,6 +254,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
|
||||
${MAIN_LIB_DIR}/battle/CObstacleInstance.h
|
||||
${MAIN_LIB_DIR}/battle/CPlayerBattleCallback.h
|
||||
${MAIN_LIB_DIR}/battle/CUnitState.h
|
||||
${MAIN_LIB_DIR}/battle/DamageCalculator.h
|
||||
${MAIN_LIB_DIR}/battle/Destination.h
|
||||
${MAIN_LIB_DIR}/battle/IBattleInfoCallback.h
|
||||
${MAIN_LIB_DIR}/battle/IBattleState.h
|
||||
|
@ -1126,6 +1126,7 @@ public:
|
||||
GOLD_GOLEM = 116,
|
||||
DIAMOND_GOLEM = 117,
|
||||
PSYCHIC_ELEMENTAL = 120,
|
||||
MAGIC_ELEMENTAL = 121,
|
||||
CATAPULT = 145,
|
||||
BALLISTA = 146,
|
||||
FIRST_AID_TENT = 147,
|
||||
|
@ -13,31 +13,21 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
BattleAttackInfo::BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, bool Shooting)
|
||||
BattleAttackInfo::BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, int chargeDistance, bool Shooting)
|
||||
: attacker(Attacker),
|
||||
defender(Defender)
|
||||
{
|
||||
shooting = Shooting;
|
||||
chargedFields = 0;
|
||||
additiveBonus = 0.0;
|
||||
multBonus = 1.0;
|
||||
attackerPos = BattleHex::INVALID;
|
||||
defenderPos = BattleHex::INVALID;
|
||||
}
|
||||
defender(Defender),
|
||||
shooting(Shooting),
|
||||
attackerPos(BattleHex::INVALID),
|
||||
defenderPos(BattleHex::INVALID),
|
||||
chargeDistance(chargeDistance)
|
||||
{}
|
||||
|
||||
BattleAttackInfo BattleAttackInfo::reverse() const
|
||||
{
|
||||
BattleAttackInfo ret = *this;
|
||||
|
||||
std::swap(ret.attacker, ret.defender);
|
||||
std::swap(ret.defenderPos, ret.attackerPos);
|
||||
|
||||
ret.shooting = false;
|
||||
ret.chargedFields = 0;
|
||||
|
||||
ret.additiveBonus = 0.0;
|
||||
ret.multBonus = 1.0;
|
||||
BattleAttackInfo ret(defender, attacker, 0, false);
|
||||
|
||||
ret.defenderPos = attackerPos;
|
||||
ret.attackerPos = defenderPos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,14 @@ struct DLL_LINKAGE BattleAttackInfo
|
||||
BattleHex attackerPos;
|
||||
BattleHex defenderPos;
|
||||
|
||||
bool shooting;
|
||||
int chargedFields;
|
||||
int chargeDistance = 0;
|
||||
bool shooting = false;
|
||||
bool luckyStrike = false;
|
||||
bool unluckyStrike = false;
|
||||
bool deathBlow = false;
|
||||
bool doubleDamage = false;
|
||||
|
||||
double additiveBonus;
|
||||
double multBonus;
|
||||
|
||||
BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, bool Shooting = false);
|
||||
BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, int chargeDistance, bool Shooting);
|
||||
BattleAttackInfo reverse() const;
|
||||
};
|
||||
|
||||
|
@ -1224,21 +1224,12 @@ int64_t CGameHandler::applyBattleEffects(BattleAttack & bat, std::shared_ptr<bat
|
||||
bsa.attackerID = attackerState->unitId();
|
||||
bsa.stackAttacked = def->unitId();
|
||||
{
|
||||
BattleAttackInfo bai(attackerState.get(), def, bat.shot());
|
||||
bai.chargedFields = distance;
|
||||
BattleAttackInfo bai(attackerState.get(), def, distance, bat.shot());
|
||||
|
||||
if(bat.deathBlow())
|
||||
bai.additiveBonus += 1.0;
|
||||
|
||||
if(bat.ballistaDoubleDmg())
|
||||
bai.additiveBonus += 1.0;
|
||||
|
||||
if(bat.lucky())
|
||||
bai.additiveBonus += 1.0;
|
||||
|
||||
//unlucky hit, used only if negative luck is enabled
|
||||
if(bat.unlucky())
|
||||
bai.additiveBonus -= 0.5; // FIXME: how bad (and luck in general) should work with following bonuses?
|
||||
bai.deathBlow = bat.deathBlow();
|
||||
bai.doubleDamage = bat.ballistaDoubleDmg();
|
||||
bai.luckyStrike = bat.lucky();
|
||||
bai.unluckyStrike = bat.unlucky();
|
||||
|
||||
auto range = gs->curB->calculateDmgRange(bai);
|
||||
bsa.damageAmount = gs->curB->getActualDamage(range, attackerState->getCount(), getRandomGenerator());
|
||||
|
Loading…
Reference in New Issue
Block a user