From abaa5b1c5930331d6376d434763fd367c4a4406f Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sun, 28 Jul 2013 08:48:29 +0000 Subject: [PATCH] Fixed #1352. Implemented correct death stare algorithm. --- config/creatures/fortress.json | 1 + server/CGameHandler.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/creatures/fortress.json b/config/creatures/fortress.json index cae1fe703..d9bd7d198 100644 --- a/config/creatures/fortress.json +++ b/config/creatures/fortress.json @@ -114,6 +114,7 @@ "deathStare" : { "type" : "DEATH_STARE", + "subtype" : 0, "val" : 10 } }, diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 6d4f71807..ef0d50dba 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5332,9 +5332,9 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat ) { // mechanics of Death Stare as in H3: // 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% std::binomial_distribution<> distr(attacker->count, chanceToKill); @@ -5342,7 +5342,8 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat ) 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); staredCreatures += (attacker->level() * attacker->valOfBonuses(Bonus::DEATH_STARE, 1)) / gs->curB->battleGetStackByID(bat.bsa[0].stackAttacked)->level();