mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Use BattleSpellCastParameters for spell parameters override
This commit is contained in:
parent
10318a3da3
commit
e454649886
@ -17,7 +17,7 @@
|
|||||||
///HealingSpellMechanics
|
///HealingSpellMechanics
|
||||||
void HealingSpellMechanics::applyBattleEffects(const SpellCastEnvironment* env, BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
void HealingSpellMechanics::applyBattleEffects(const SpellCastEnvironment* env, BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
||||||
{
|
{
|
||||||
EHealLevel healLevel = getHealLevel(ctx.effectLevel);
|
EHealLevel healLevel = getHealLevel(parameters.effectLevel);
|
||||||
int hpGained = calculateHealedHP(env, parameters, ctx);
|
int hpGained = calculateHealedHP(env, parameters, ctx);
|
||||||
StacksHealedOrResurrected shr;
|
StacksHealedOrResurrected shr;
|
||||||
shr.lifeDrain = false;
|
shr.lifeDrain = false;
|
||||||
@ -39,9 +39,9 @@ void HealingSpellMechanics::applyBattleEffects(const SpellCastEnvironment* env,
|
|||||||
|
|
||||||
int HealingSpellMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
int HealingSpellMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
||||||
{
|
{
|
||||||
if(ctx.effectValue != 0)
|
if(parameters.effectValue != 0)
|
||||||
return ctx.effectValue; //Archangel
|
return parameters.effectValue; //Archangel
|
||||||
return owner->calculateRawEffectValue(ctx.effectLevel, ctx.effectPower); //???
|
return owner->calculateRawEffectValue(parameters.effectLevel, parameters.effectPower); //???
|
||||||
}
|
}
|
||||||
|
|
||||||
///AntimagicMechanics
|
///AntimagicMechanics
|
||||||
@ -390,8 +390,8 @@ void ObstacleMechanics::applyBattleEffects(const SpellCastEnvironment * env, Bat
|
|||||||
obstacle->pos = pos;
|
obstacle->pos = pos;
|
||||||
obstacle->casterSide = parameters.casterSide;
|
obstacle->casterSide = parameters.casterSide;
|
||||||
obstacle->ID = owner->id;
|
obstacle->ID = owner->id;
|
||||||
obstacle->spellLevel = parameters.spellLvl;
|
obstacle->spellLevel = parameters.effectLevel;
|
||||||
obstacle->casterSpellPower = ctx.effectPower;
|
obstacle->casterSpellPower = parameters.effectPower;
|
||||||
obstacle->uniqueID = obstacleIdToGive++;
|
obstacle->uniqueID = obstacleIdToGive++;
|
||||||
|
|
||||||
BattleObstaclePlaced bop;
|
BattleObstaclePlaced bop;
|
||||||
@ -569,7 +569,7 @@ int SacrificeMechanics::calculateHealedHP(const SpellCastEnvironment* env, const
|
|||||||
if(nullptr == parameters.selectedStack)
|
if(nullptr == parameters.selectedStack)
|
||||||
env->complain("No stack to sacrifice.");
|
env->complain("No stack to sacrifice.");
|
||||||
else
|
else
|
||||||
res = (ctx.effectPower + parameters.selectedStack->MaxHealth() + owner->getPower(ctx.effectLevel)) * parameters.selectedStack->count;
|
res = (parameters.effectPower + parameters.selectedStack->MaxHealth() + owner->getPower(parameters.effectLevel)) * parameters.selectedStack->count;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ void SummonMechanics::applyBattleEffects(const SpellCastEnvironment * env, Battl
|
|||||||
//TODO stack casting -> probably power will be zero; set the proper number of creatures manually
|
//TODO stack casting -> probably power will be zero; set the proper number of creatures manually
|
||||||
int percentBonus = parameters.casterHero ? parameters.casterHero->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, owner->id.toEnum()) : 0;
|
int percentBonus = parameters.casterHero ? parameters.casterHero->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, owner->id.toEnum()) : 0;
|
||||||
|
|
||||||
bsa.amount = ctx.effectPower
|
bsa.amount = parameters.effectPower
|
||||||
* owner->getPower(parameters.spellLvl)
|
* owner->getPower(parameters.spellLvl)
|
||||||
* (100 + percentBonus) / 100.0; //new feature - percentage bonus
|
* (100 + percentBonus) / 100.0; //new feature - percentage bonus
|
||||||
if(bsa.amount)
|
if(bsa.amount)
|
||||||
|
@ -223,7 +223,38 @@ ESpellCastResult DefaultSpellMechanics::applyAdventureEffects(const SpellCastEnv
|
|||||||
|
|
||||||
void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const
|
void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "Started spell cast. Spell: "<<owner->name<<"; mode:"<<parameters.mode<<"; level: "<<parameters.spellLvl<<"; SP: "<<parameters.usedSpellPower;
|
logGlobal->debugStream() << "Started spell cast. Spell: "<<owner->name<<"; mode:"<<parameters.mode<<"; level: "<<parameters.spellLvl;
|
||||||
|
|
||||||
|
|
||||||
|
parameters.effectLevel = calculateEffectLevel(parameters);
|
||||||
|
|
||||||
|
if(parameters.casterStack)
|
||||||
|
{
|
||||||
|
if(parameters.enchantPower == 0)
|
||||||
|
parameters.enchantPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_ENCHANT_POWER);;
|
||||||
|
if(parameters.enchantPower == 0)
|
||||||
|
parameters.enchantPower = 3; //default for creatures
|
||||||
|
//Fairy Dragon, etc.
|
||||||
|
int effectPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_SPELL_POWER) * parameters.casterStack->count / 100;
|
||||||
|
if(parameters.effectPower == 0)
|
||||||
|
parameters.effectPower = effectPower;
|
||||||
|
//Archangel, etc
|
||||||
|
int unitSpellPower = parameters.casterStack->valOfBonuses(Bonus::SPECIFIC_SPELL_POWER, owner->id.toEnum());
|
||||||
|
if(parameters.effectValue == 0)
|
||||||
|
parameters.effectValue = parameters.casterStack->count * unitSpellPower;
|
||||||
|
}
|
||||||
|
else if (parameters.casterHero)
|
||||||
|
{
|
||||||
|
if(parameters.enchantPower == 0)
|
||||||
|
parameters.enchantPower = parameters.casterHero->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + parameters.casterHero->valOfBonuses(Bonus::SPELL_DURATION);
|
||||||
|
if(parameters.effectPower == 0)
|
||||||
|
parameters.effectPower = parameters.casterHero->getPrimSkillLevel(PrimarySkill::SPELL_POWER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
env->complain("No spell-caster provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BattleSpellCast sc;
|
BattleSpellCast sc;
|
||||||
prepareBattleCast(parameters, sc);
|
prepareBattleCast(parameters, sc);
|
||||||
@ -299,37 +330,13 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
|
|||||||
|
|
||||||
StacksInjured si;
|
StacksInjured si;
|
||||||
SpellCastContext ctx(attackedCres, sc, si);
|
SpellCastContext ctx(attackedCres, sc, si);
|
||||||
ctx.effectLevel = calculateEffectLevel(parameters);
|
|
||||||
ctx.effectPower = parameters.usedSpellPower;
|
|
||||||
ctx.enchantPower = parameters.usedSpellPower;
|
|
||||||
ctx.effectValue = 0;
|
|
||||||
if(parameters.casterStack)
|
if(parameters.casterStack)
|
||||||
ctx.caster = parameters.casterStack;
|
ctx.caster = parameters.casterStack;
|
||||||
else if(parameters.casterHero)
|
else if(parameters.casterHero)
|
||||||
ctx.caster = parameters.casterHero;
|
ctx.caster = parameters.casterHero;
|
||||||
else if(parameters.mode == ECastingMode::HERO_CASTING)
|
|
||||||
ctx.caster = parameters.cb->battleGetFightingHero(parameters.casterSide);
|
|
||||||
|
|
||||||
if(ctx.caster == nullptr)
|
|
||||||
{
|
|
||||||
env->complain("No spell-caster provided.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parameters.casterStack)
|
|
||||||
{
|
|
||||||
auto enchantPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_ENCHANT_POWER);
|
|
||||||
if(ctx.enchantPower == 0)
|
|
||||||
ctx.enchantPower = enchantPower;
|
|
||||||
//Fairy Dragon, etc.
|
|
||||||
int effectPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_SPELL_POWER) * parameters.casterStack->count / 100;
|
|
||||||
if(ctx.effectPower == 0)
|
|
||||||
ctx.effectPower = effectPower;
|
|
||||||
//Archangel, etc
|
|
||||||
int unitSpellPower = parameters.casterStack->valOfBonuses(Bonus::SPECIFIC_SPELL_POWER, owner->id.toEnum());
|
|
||||||
if(unitSpellPower != 0)
|
|
||||||
ctx.effectValue = parameters.casterStack->count * unitSpellPower;
|
|
||||||
}
|
|
||||||
applyBattleEffects(env, parameters, ctx);
|
applyBattleEffects(env, parameters, ctx);
|
||||||
|
|
||||||
env->sendAndApply(&sc);
|
env->sendAndApply(&sc);
|
||||||
@ -396,7 +403,7 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, BattleS
|
|||||||
mirrorParameters.casterStack = (attackedCre);
|
mirrorParameters.casterStack = (attackedCre);
|
||||||
mirrorParameters.selectedStack = nullptr;
|
mirrorParameters.selectedStack = nullptr;
|
||||||
|
|
||||||
castMagicMirror(env, mirrorParameters, ctx);
|
castMagicMirror(env, mirrorParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,19 +505,6 @@ void DefaultSpellMechanics::battleLogSingleTarget(std::vector<std::string> & log
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefaultSpellMechanics::calculateDuration(const CGHeroInstance * caster, int usedSpellPower) const
|
|
||||||
{
|
|
||||||
if(caster == nullptr)
|
|
||||||
{
|
|
||||||
if (!usedSpellPower)
|
|
||||||
return 3; //default duration of all creature spells
|
|
||||||
else
|
|
||||||
return usedSpellPower; //use creature spell power
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return caster->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + caster->valOfBonuses(Bonus::SPELL_DURATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DefaultSpellMechanics::calculateEffectLevel(const BattleSpellCastParameters& parameters) const
|
int DefaultSpellMechanics::calculateEffectLevel(const BattleSpellCastParameters& parameters) const
|
||||||
{
|
{
|
||||||
int effectLevel = parameters.spellLvl;
|
int effectLevel = parameters.spellLvl;
|
||||||
@ -530,7 +524,7 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
//applying effects
|
//applying effects
|
||||||
if(owner->isOffensiveSpell())
|
if(owner->isOffensiveSpell())
|
||||||
{
|
{
|
||||||
int spellDamage = ctx.effectValue;
|
int spellDamage = parameters.effectValue;
|
||||||
|
|
||||||
int chainLightningModifier = 0;
|
int chainLightningModifier = 0;
|
||||||
for(auto & attackedCre : ctx.attackedCres)
|
for(auto & attackedCre : ctx.attackedCres)
|
||||||
@ -539,7 +533,7 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
if(spellDamage != 0)
|
if(spellDamage != 0)
|
||||||
bsa.damageAmount = owner->adjustRawDamage(ctx.caster, attackedCre, spellDamage) >> chainLightningModifier;
|
bsa.damageAmount = owner->adjustRawDamage(ctx.caster, attackedCre, spellDamage) >> chainLightningModifier;
|
||||||
else
|
else
|
||||||
bsa.damageAmount = owner->calculateDamage(ctx.caster, attackedCre, ctx.effectLevel, ctx.effectPower) >> chainLightningModifier;
|
bsa.damageAmount = owner->calculateDamage(ctx.caster, attackedCre, parameters.effectLevel, parameters.effectPower) >> chainLightningModifier;
|
||||||
|
|
||||||
ctx.sc.dmgToDisplay += bsa.damageAmount;
|
ctx.sc.dmgToDisplay += bsa.damageAmount;
|
||||||
|
|
||||||
@ -560,12 +554,12 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
{
|
{
|
||||||
SetStackEffect sse;
|
SetStackEffect sse;
|
||||||
//get default spell duration (spell power with bonuses for heroes)
|
//get default spell duration (spell power with bonuses for heroes)
|
||||||
int duration = calculateDuration(parameters.casterHero, ctx.enchantPower);
|
int duration = parameters.enchantPower;
|
||||||
//generate actual stack bonuses
|
//generate actual stack bonuses
|
||||||
{
|
{
|
||||||
int maxDuration = 0;
|
int maxDuration = 0;
|
||||||
std::vector<Bonus> tmp;
|
std::vector<Bonus> tmp;
|
||||||
owner->getEffects(tmp, ctx.effectLevel);
|
owner->getEffects(tmp, parameters.effectLevel);
|
||||||
for(Bonus& b : tmp)
|
for(Bonus& b : tmp)
|
||||||
{
|
{
|
||||||
//use configured duration if present
|
//use configured duration if present
|
||||||
@ -810,7 +804,7 @@ void DefaultSpellMechanics::doDispell(BattleInfo * battle, const BattleSpellCast
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultSpellMechanics::castMagicMirror(const SpellCastEnvironment* env, BattleSpellCastParameters& parameters, const SpellCastContext& originalContext) const
|
void DefaultSpellMechanics::castMagicMirror(const SpellCastEnvironment* env, BattleSpellCastParameters& parameters) const
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "Started spell cast. Spell: "<<owner->name<<"; mode: MAGIC_MIRROR";
|
logGlobal->debugStream() << "Started spell cast. Spell: "<<owner->name<<"; mode: MAGIC_MIRROR";
|
||||||
if(parameters.mode != ECastingMode::MAGIC_MIRROR)
|
if(parameters.mode != ECastingMode::MAGIC_MIRROR)
|
||||||
@ -845,10 +839,6 @@ void DefaultSpellMechanics::castMagicMirror(const SpellCastEnvironment* env, Bat
|
|||||||
|
|
||||||
StacksInjured si;
|
StacksInjured si;
|
||||||
SpellCastContext ctx(attackedCres, sc, si);
|
SpellCastContext ctx(attackedCres, sc, si);
|
||||||
ctx.effectLevel = originalContext.effectLevel;
|
|
||||||
ctx.effectPower = originalContext.effectPower;
|
|
||||||
ctx.enchantPower = originalContext.enchantPower;
|
|
||||||
ctx.effectValue = originalContext.effectValue;
|
|
||||||
ctx.caster = parameters.casterStack;
|
ctx.caster = parameters.casterStack;
|
||||||
applyBattleEffects(env, parameters, ctx);
|
applyBattleEffects(env, parameters, ctx);
|
||||||
|
|
||||||
|
@ -19,21 +19,13 @@ class StacksInjured;
|
|||||||
struct SpellCastContext
|
struct SpellCastContext
|
||||||
{
|
{
|
||||||
SpellCastContext(std::vector<const CStack *> & attackedCres, BattleSpellCast & sc, StacksInjured & si):
|
SpellCastContext(std::vector<const CStack *> & attackedCres, BattleSpellCast & sc, StacksInjured & si):
|
||||||
attackedCres(attackedCres), sc(sc), si(si),
|
attackedCres(attackedCres), sc(sc), si(si)
|
||||||
effectLevel(0),effectPower(0),enchantPower(0),effectValue(0)
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
std::vector<const CStack *> & attackedCres;
|
std::vector<const CStack *> & attackedCres;
|
||||||
BattleSpellCast & sc;
|
BattleSpellCast & sc;
|
||||||
StacksInjured & si;
|
StacksInjured & si;
|
||||||
///spell school level to use for effects
|
|
||||||
int effectLevel;
|
|
||||||
///actual spell-power affecting effect values
|
|
||||||
int effectPower;
|
|
||||||
///actual spell-power affecting effect duration
|
|
||||||
int enchantPower;
|
|
||||||
///for FairyDragon-like casting, if !=0 ignores effectPower
|
|
||||||
int effectValue;
|
|
||||||
///stack or hero
|
///stack or hero
|
||||||
const ISpellCaster * caster;
|
const ISpellCaster * caster;
|
||||||
};
|
};
|
||||||
@ -66,7 +58,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
virtual void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
||||||
|
|
||||||
virtual int calculateDuration(const CGHeroInstance * caster, int usedSpellPower) const;
|
|
||||||
int calculateEffectLevel(const BattleSpellCastParameters & parameters) const;
|
int calculateEffectLevel(const BattleSpellCastParameters & parameters) const;
|
||||||
|
|
||||||
///actual adventure cast implementation
|
///actual adventure cast implementation
|
||||||
@ -74,7 +65,7 @@ protected:
|
|||||||
|
|
||||||
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
||||||
private:
|
private:
|
||||||
void castMagicMirror(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, const SpellCastContext & originalContext) const;
|
void castMagicMirror(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const;
|
||||||
void handleResistance(const SpellCastEnvironment * env, std::vector<const CStack*> & attackedCres, BattleSpellCast & sc) const;
|
void handleResistance(const SpellCastEnvironment * env, std::vector<const CStack*> & attackedCres, BattleSpellCast & sc) const;
|
||||||
void prepareBattleCast(const BattleSpellCastParameters & parameters, BattleSpellCast & sc) const;
|
void prepareBattleCast(const BattleSpellCastParameters & parameters, BattleSpellCast & sc) const;
|
||||||
};
|
};
|
||||||
|
@ -18,15 +18,16 @@
|
|||||||
///AcidBreathDamageMechanics
|
///AcidBreathDamageMechanics
|
||||||
void AcidBreathDamageMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
void AcidBreathDamageMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
||||||
{
|
{
|
||||||
|
//todo: this should be effectValue
|
||||||
//calculating dmg to display
|
//calculating dmg to display
|
||||||
ctx.sc.dmgToDisplay = ctx.effectPower;
|
ctx.sc.dmgToDisplay = parameters.effectPower;
|
||||||
|
|
||||||
for(auto & attackedCre : ctx.attackedCres) //no immunities
|
for(auto & attackedCre : ctx.attackedCres) //no immunities
|
||||||
{
|
{
|
||||||
BattleStackAttacked bsa;
|
BattleStackAttacked bsa;
|
||||||
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
||||||
bsa.spellID = owner->id;
|
bsa.spellID = owner->id;
|
||||||
bsa.damageAmount = ctx.effectPower; //damage times the number of attackers
|
bsa.damageAmount = parameters.effectPower; //damage times the number of attackers
|
||||||
bsa.stackAttacked = (attackedCre)->ID;
|
bsa.stackAttacked = (attackedCre)->ID;
|
||||||
bsa.attackerID = -1;
|
bsa.attackerID = -1;
|
||||||
(attackedCre)->prepareAttacked(bsa, env->getRandomGenerator());
|
(attackedCre)->prepareAttacked(bsa, env->getRandomGenerator());
|
||||||
@ -38,7 +39,7 @@ void AcidBreathDamageMechanics::applyBattleEffects(const SpellCastEnvironment *
|
|||||||
void DeathStareMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
void DeathStareMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
||||||
{
|
{
|
||||||
//calculating dmg to display
|
//calculating dmg to display
|
||||||
ctx.sc.dmgToDisplay = ctx.effectPower;
|
ctx.sc.dmgToDisplay = parameters.effectPower;
|
||||||
if(!ctx.attackedCres.empty())
|
if(!ctx.attackedCres.empty())
|
||||||
vstd::amin(ctx.sc.dmgToDisplay, (*ctx.attackedCres.begin())->count); //stack is already reduced after attack
|
vstd::amin(ctx.sc.dmgToDisplay, (*ctx.attackedCres.begin())->count); //stack is already reduced after attack
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ void DeathStareMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
|
|||||||
BattleStackAttacked bsa;
|
BattleStackAttacked bsa;
|
||||||
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
||||||
bsa.spellID = owner->id;
|
bsa.spellID = owner->id;
|
||||||
bsa.damageAmount = ctx.effectPower * (attackedCre)->valOfBonuses(Bonus::STACK_HEALTH);//todo: move here all DeathStare calculation
|
bsa.damageAmount = parameters.effectPower * (attackedCre)->valOfBonuses(Bonus::STACK_HEALTH);//todo: move here all DeathStare calculation
|
||||||
bsa.stackAttacked = (attackedCre)->ID;
|
bsa.stackAttacked = (attackedCre)->ID;
|
||||||
bsa.attackerID = -1;
|
bsa.attackerID = -1;
|
||||||
(attackedCre)->prepareAttacked(bsa, env->getRandomGenerator());
|
(attackedCre)->prepareAttacked(bsa, env->getRandomGenerator());
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb)
|
BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb)
|
||||||
: spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(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)
|
mode(ECastingMode::HERO_CASTING), casterStack(nullptr), selectedStack(nullptr), cb(cb),
|
||||||
|
effectLevel(0), effectPower(0), enchantPower(0), effectValue(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,25 @@ struct DLL_LINKAGE BattleSpellCastParameters
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BattleSpellCastParameters(const BattleInfo * cb);
|
BattleSpellCastParameters(const BattleInfo * cb);
|
||||||
|
///spell school level , 0-use default
|
||||||
int spellLvl;
|
int spellLvl;
|
||||||
BattleHex destination;
|
BattleHex destination;
|
||||||
ui8 casterSide;
|
ui8 casterSide;
|
||||||
PlayerColor casterColor;
|
PlayerColor casterColor;
|
||||||
const CGHeroInstance * casterHero; //deprecated
|
const CGHeroInstance * casterHero; //deprecated
|
||||||
int usedSpellPower;
|
|
||||||
ECastingMode::ECastingMode mode;
|
ECastingMode::ECastingMode mode;
|
||||||
const CStack * casterStack;
|
const CStack * casterStack;
|
||||||
const CStack * selectedStack;
|
const CStack * selectedStack;
|
||||||
const BattleInfo * cb;
|
const BattleInfo * cb;
|
||||||
|
|
||||||
|
///spell school level to use for effects, 0-use spellLvl
|
||||||
|
int effectLevel;
|
||||||
|
///actual spell-power affecting effect values, 0-use default
|
||||||
|
int effectPower;
|
||||||
|
///actual spell-power affecting effect duration, 0-use default
|
||||||
|
int enchantPower;
|
||||||
|
///for Archangel-like casting, 0-use default
|
||||||
|
int effectValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DLL_LINKAGE AdventureSpellCastParameters
|
struct DLL_LINKAGE AdventureSpellCastParameters
|
||||||
|
@ -3868,26 +3868,25 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
complain("That stack can't cast spells!");
|
complain("That stack can't cast spells!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BattleSpellCastParameters p(gs->curB);
|
BattleSpellCastParameters parameters(gs->curB);
|
||||||
|
|
||||||
p.spellLvl = 0;
|
parameters.spellLvl = 0;
|
||||||
if (spellcaster)
|
if (spellcaster)
|
||||||
vstd::amax(p.spellLvl, spellcaster->val);
|
vstd::amax(parameters.spellLvl, spellcaster->val);
|
||||||
if (randSpellcaster)
|
if (randSpellcaster)
|
||||||
vstd::amax(p.spellLvl, randSpellcaster->val);
|
vstd::amax(parameters.spellLvl, randSpellcaster->val);
|
||||||
vstd::amin (p.spellLvl, 3);
|
vstd::amin (parameters.spellLvl, 3);
|
||||||
|
|
||||||
p.casterSide = gs->curB->whatSide(stack->owner);
|
parameters.casterSide = gs->curB->whatSide(stack->owner);
|
||||||
p.mode = ECastingMode::CREATURE_ACTIVE_CASTING;
|
parameters.mode = ECastingMode::CREATURE_ACTIVE_CASTING;
|
||||||
p.destination = destination;
|
parameters.destination = destination;
|
||||||
p.casterColor = stack->owner;
|
parameters.casterColor = stack->owner;
|
||||||
p.casterHero = nullptr;
|
parameters.casterHero = nullptr;
|
||||||
p.usedSpellPower = 0;
|
parameters.casterStack = stack;
|
||||||
p.casterStack = stack;
|
parameters.selectedStack = nullptr;
|
||||||
p.selectedStack = nullptr;
|
|
||||||
|
|
||||||
const CSpell * spell = SpellID(spellID).toSpell();
|
const CSpell * spell = SpellID(spellID).toSpell();
|
||||||
spell->battleCast(spellEnv, p);
|
spell->battleCast(spellEnv, parameters);
|
||||||
}
|
}
|
||||||
sendAndApply(&end_action);
|
sendAndApply(&end_action);
|
||||||
break;
|
break;
|
||||||
@ -4081,7 +4080,6 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
|||||||
parameters.casterSide = ba.side;
|
parameters.casterSide = ba.side;
|
||||||
parameters.casterColor = h->tempOwner;
|
parameters.casterColor = h->tempOwner;
|
||||||
parameters.casterHero = h;
|
parameters.casterHero = h;
|
||||||
parameters.usedSpellPower = h->getPrimSkillLevel(PrimarySkill::SPELL_POWER);
|
|
||||||
parameters.mode = ECastingMode::HERO_CASTING;
|
parameters.mode = ECastingMode::HERO_CASTING;
|
||||||
parameters.casterStack = nullptr;
|
parameters.casterStack = nullptr;
|
||||||
parameters.selectedStack = gs->curB->battleGetStackByID(ba.selectedStack, false);
|
parameters.selectedStack = gs->curB->battleGetStackByID(ba.selectedStack, false);
|
||||||
@ -4238,13 +4236,13 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
|
|||||||
parameters.casterSide = side;
|
parameters.casterSide = side;
|
||||||
parameters.casterColor = st->owner;
|
parameters.casterColor = st->owner;
|
||||||
parameters.casterHero = nullptr;
|
parameters.casterHero = nullptr;
|
||||||
parameters.usedSpellPower = 0;
|
|
||||||
parameters.mode = ECastingMode::ENCHANTER_CASTING;
|
parameters.mode = ECastingMode::ENCHANTER_CASTING;
|
||||||
parameters.casterStack = st;
|
parameters.casterStack = st;
|
||||||
parameters.selectedStack = nullptr;
|
parameters.selectedStack = nullptr;
|
||||||
|
|
||||||
spell->battleCast(spellEnv, parameters);
|
spell->battleCast(spellEnv, parameters);
|
||||||
|
|
||||||
|
//todo: move to mechanics
|
||||||
BattleSetStackProperty ssp;
|
BattleSetStackProperty ssp;
|
||||||
ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER;
|
ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER;
|
||||||
ssp.absolute = false;
|
ssp.absolute = false;
|
||||||
@ -4950,7 +4948,6 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
|
|||||||
parameters.casterSide = !attacker->attackerOwned;
|
parameters.casterSide = !attacker->attackerOwned;
|
||||||
parameters.casterColor = attacker->owner;
|
parameters.casterColor = attacker->owner;
|
||||||
parameters.casterHero = nullptr;
|
parameters.casterHero = nullptr;
|
||||||
parameters.usedSpellPower = 0;
|
|
||||||
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
|
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
|
||||||
parameters.casterStack = attacker;
|
parameters.casterStack = attacker;
|
||||||
parameters.selectedStack = nullptr;
|
parameters.selectedStack = nullptr;
|
||||||
@ -4983,7 +4980,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
|
|||||||
parameters.casterSide = !attacker->attackerOwned;
|
parameters.casterSide = !attacker->attackerOwned;
|
||||||
parameters.casterColor = attacker->owner;
|
parameters.casterColor = attacker->owner;
|
||||||
parameters.casterHero = nullptr;
|
parameters.casterHero = nullptr;
|
||||||
parameters.usedSpellPower = power;
|
parameters.effectPower = power;
|
||||||
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
|
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
|
||||||
parameters.casterStack = attacker;
|
parameters.casterStack = attacker;
|
||||||
parameters.selectedStack = nullptr;
|
parameters.selectedStack = nullptr;
|
||||||
@ -5297,7 +5294,7 @@ void CGameHandler::runBattle()
|
|||||||
|
|
||||||
for (Bonus *b : *bl)
|
for (Bonus *b : *bl)
|
||||||
{
|
{
|
||||||
parameters.usedSpellPower = b->val;
|
parameters.enchantPower = b->val;
|
||||||
|
|
||||||
const CSpell * spell = SpellID(b->subtype).toSpell();
|
const CSpell * spell = SpellID(b->subtype).toSpell();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user