mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Fixed #1352. Implemented correct death stare algorithm.
This commit is contained in:
@@ -114,6 +114,7 @@
|
|||||||
"deathStare" :
|
"deathStare" :
|
||||||
{
|
{
|
||||||
"type" : "DEATH_STARE",
|
"type" : "DEATH_STARE",
|
||||||
|
"subtype" : 0,
|
||||||
"val" : 10
|
"val" : 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -5332,9 +5332,9 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
|
|||||||
{
|
{
|
||||||
// mechanics of Death Stare as in H3:
|
// mechanics of Death Stare as in H3:
|
||||||
// each gorgon have 10% chance to kill (counted separately in H3) -> binomial distribution
|
// each gorgon have 10% chance to kill (counted separately in H3) -> binomial distribution
|
||||||
// maximum amount that can be killed is ( gorgons_count / 10 ), rounded up
|
//original formula x = min(x, (gorgons_count + 9)/10);
|
||||||
|
|
||||||
double chanceToKill = double(attacker->count * attacker->valOfBonuses(Bonus::DEATH_STARE, 0)) / 100;
|
double chanceToKill = attacker->valOfBonuses(Bonus::DEATH_STARE, 0) / 100.0f;
|
||||||
vstd::amin(chanceToKill, 1); //cap at 100%
|
vstd::amin(chanceToKill, 1); //cap at 100%
|
||||||
|
|
||||||
std::binomial_distribution<> distr(attacker->count, chanceToKill);
|
std::binomial_distribution<> distr(attacker->count, chanceToKill);
|
||||||
@@ -5342,7 +5342,8 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
|
|||||||
|
|
||||||
int staredCreatures = distr(rng);
|
int staredCreatures = distr(rng);
|
||||||
|
|
||||||
int maxToKill = (attacker->count * chanceToKill + 99) / 100;
|
double cap = 1 / std::max(chanceToKill, (double)(0.01));//don't divide by 0
|
||||||
|
int maxToKill = (attacker->count + cap - 1) / cap; //not much more than chance * count
|
||||||
vstd::amin(staredCreatures, maxToKill);
|
vstd::amin(staredCreatures, maxToKill);
|
||||||
|
|
||||||
staredCreatures += (attacker->level() * attacker->valOfBonuses(Bonus::DEATH_STARE, 1)) / gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->level();
|
staredCreatures += (attacker->level() * attacker->valOfBonuses(Bonus::DEATH_STARE, 1)) / gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->level();
|
||||||
|
Reference in New Issue
Block a user