The only usage of secHero cast parameter is mana channeling - better to get it OTF

This commit is contained in:
AlexVinS committed 2015-09-29 17:26:33 +03:00
1 parent 46f99db8d7
commit 873979a300
4 files changed
+10 -21

No files matched your search

+9 -7
View File
@@ -232,7 +232,10 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
sc.castByHero = nullptr != parameters.casterHero;
sc.casterStack = (parameters.casterStack ? parameters.casterStack->ID : -1);
sc.manaGained = 0;
//check it there is opponent hero
const ui8 otherSide = 1-parameters.casterSide;
const CGHeroInstance * otherHero = parameters.cb->battleGetFightingHero(otherSide);
int spellCost = 0;
//calculate spell cost
@@ -240,12 +243,12 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
{
spellCost = parameters.cb->battleGetSpellCost(owner, parameters.casterHero);
if(parameters.secHero && parameters.mode == ECastingMode::HERO_CASTING) //handle mana channel
{
if(parameters.mode == ECastingMode::HERO_CASTING && nullptr != otherHero) //handle mana channel
{
int manaChannel = 0;
for(const CStack * stack : parameters.cb->battleGetAllStacks(true)) //TODO: shouldn't bonus system handle it somehow?
{
if(stack->owner == parameters.secHero->tempOwner)
if(stack->owner == otherHero->tempOwner)
{
vstd::amax(manaChannel, stack->valOfBonuses(Bonus::MANA_CHANNELING));
}
@@ -335,9 +338,9 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
if(sc.manaGained > 0)
{
assert(parameters.secHero);
assert(otherHero);
sm.hid = parameters.secHero->id;
sm.hid = otherHero->id;
sm.val = sc.manaGained;
env->sendAndApply(&sm);
}
@@ -380,7 +383,6 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
mirrorParameters.casterColor = (attackedCre)->owner;
mirrorParameters.casterHero = nullptr;
mirrorParameters.destination = targetHex;
mirrorParameters.secHero = parameters.casterHero;
mirrorParameters.mode = ECastingMode::MAGIC_MIRROR;
mirrorParameters.casterStack = (attackedCre);
mirrorParameters.selectedStack = nullptr;
+1 -1
View File
@@ -18,7 +18,7 @@
#include "CreatureSpellMechanics.h"
BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb)
: spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(nullptr), secHero(nullptr),
: spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(nullptr),
usedSpellPower(0),mode(ECastingMode::HERO_CASTING), casterStack(nullptr), selectedStack(nullptr), cb(cb)
{
-1
View File
@@ -41,7 +41,6 @@ public:
ui8 casterSide;
PlayerColor casterColor;
const CGHeroInstance * casterHero; //deprecated
const CGHeroInstance * secHero;
int usedSpellPower;
ECastingMode::ECastingMode mode;
const CStack * casterStack;
-12
View File
@@ -3878,7 +3878,6 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
vstd::amin (p.spellLvl, 3);
p.casterSide = gs->curB->whatSide(stack->owner);
p.secHero = gs->curB->getHero(gs->curB->theOtherPlayer(stack->owner));
p.mode = ECastingMode::CREATURE_ACTIVE_CASTING;
p.destination = destination;
p.casterColor = stack->owner;
@@ -4063,7 +4062,6 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
const CGHeroInstance *secondHero = gs->curB->battleGetFightingHero(!ba.side);
if(!h)
{
logGlobal->warnStream() << "Wrong caster!";
@@ -4083,8 +4081,6 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
parameters.casterSide = ba.side;
parameters.casterColor = h->tempOwner;
parameters.casterHero = h;
parameters.secHero = secondHero;
parameters.usedSpellPower = h->getPrimSkillLevel(PrimarySkill::SPELL_POWER);
parameters.mode = ECastingMode::HERO_CASTING;
parameters.casterStack = nullptr;
@@ -4242,7 +4238,6 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
parameters.casterSide = side;
parameters.casterColor = st->owner;
parameters.casterHero = nullptr;
parameters.secHero = gs->curB->getHero(gs->curB->theOtherPlayer(st->owner));
parameters.usedSpellPower = 0;
parameters.mode = ECastingMode::ENCHANTER_CASTING;
parameters.casterStack = st;
@@ -4955,8 +4950,6 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
parameters.casterSide = !attacker->attackerOwned;
parameters.casterColor = attacker->owner;
parameters.casterHero = nullptr;
parameters.secHero = nullptr;
parameters.usedSpellPower = 0;
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
parameters.casterStack = attacker;
@@ -4990,8 +4983,6 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
parameters.casterSide = !attacker->attackerOwned;
parameters.casterColor = attacker->owner;
parameters.casterHero = nullptr;
parameters.secHero = nullptr;
parameters.usedSpellPower = power;
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
parameters.casterStack = attacker;
@@ -5300,9 +5291,6 @@ void CGameHandler::runBattle()
parameters.casterSide = i;
parameters.casterColor = h->tempOwner;
parameters.casterHero = nullptr;
parameters.secHero = gs->curB->battleGetFightingHero(1-i);
parameters.mode = ECastingMode::HERO_CASTING;
parameters.casterStack = nullptr;
parameters.selectedStack = nullptr;