From 7ce9e95525d41582d9bc43f19a2c7845f20f290a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 27 Aug 2012 10:47:02 +0000 Subject: [PATCH] - death stare works identically to H3 - gcc warnings fix --- lib/CBattleCallback.h | 4 ++-- server/CGameHandler.cpp | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/CBattleCallback.h b/lib/CBattleCallback.h index 534e58b86..cc3576ff8 100644 --- a/lib/CBattleCallback.h +++ b/lib/CBattleCallback.h @@ -36,10 +36,10 @@ protected: int player; // -1 gives access to all information, otherwise callback provides only information "visible" for player CCallbackBase(CGameState *GS, int Player) - : gs(GS), player(Player), battle(nullptr) + : battle(nullptr), gs(GS), player(Player) {} CCallbackBase() - : gs(NULL), player(-1), battle(nullptr) + : battle(nullptr), gs(nullptr), player(-1) {} void setBattle(const BattleInfo *B); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index ae08131d4..dac7873d2 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5257,17 +5257,20 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat ) if (attacker->hasBonusOfType(Bonus::DEATH_STARE)) // spell id 79 { + // mechanics of Death Stare as in H3: + // each gorgon have 10% chance to kill (counted separately in H3) -> poisson distribution + // maximum amount that can be killed is (1 + gorgons / 5 ), rounded up + int staredCreatures = 0; - double mean = attacker->count * attacker->valOfBonuses(Bonus::DEATH_STARE, 0) / 100; - if (mean >= 1) - { - boost::poisson_distribution p((int)mean); - boost::mt19937 rng; - boost::variate_generator > dice (rng, p); - staredCreatures += dice(); - } - if (((int)(mean * 100)) < rand() % 100) //fractional chance for one last kill - ++staredCreatures; + double mean = double(attacker->count * attacker->valOfBonuses(Bonus::DEATH_STARE, 0)) / 100; + + boost::poisson_distribution<> p(mean); + boost::mt19937 rng(rand()); + boost::variate_generator > dice (rng, p); + staredCreatures += dice(); + + int maxToKill = 1 + (attacker->count + 4) / 5; + vstd::amin(staredCreatures, maxToKill); staredCreatures += attacker->type->level * attacker->valOfBonuses(Bonus::DEATH_STARE, 1); if (staredCreatures)