1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

- death stare works identically to H3

- gcc warnings fix
This commit is contained in:
Ivan Savenko 2012-08-27 10:47:02 +00:00
parent 7c09f73402
commit 7ce9e95525
2 changed files with 15 additions and 12 deletions

View File

@ -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);

View File

@ -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<int, double> p((int)mean);
boost::mt19937 rng;
boost::variate_generator<boost::mt19937&, boost::poisson_distribution<int, double> > 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<boost::mt19937&, boost::poisson_distribution<> > 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)