mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Cleaned some code.
This commit is contained in:
parent
364a207f71
commit
2e0ca6d162
@ -3164,12 +3164,12 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
|
||||
switch(sc->id)
|
||||
{
|
||||
case 15: //magic arrow
|
||||
case Spells::MAGIC_ARROW:
|
||||
{
|
||||
//initialization of anims
|
||||
anims.push_back("C20SPX0.DEF"); anims.push_back("C20SPX1.DEF"); anims.push_back("C20SPX2.DEF"); anims.push_back("C20SPX3.DEF"); anims.push_back("C20SPX4.DEF");
|
||||
}
|
||||
case 16: //ice bolt
|
||||
case Spells::ICE_BOLT:
|
||||
{
|
||||
if(anims.size() == 0) //initialization of anims
|
||||
{
|
||||
@ -3218,23 +3218,26 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
|
||||
break; //for 15 and 16 cases
|
||||
}
|
||||
case 17: //lightning bolt
|
||||
case 57: //Titan's Thunder
|
||||
case 77: //thunderbolt
|
||||
case Spells::LIGHTNING_BOLT:
|
||||
case Spells::TITANS_LIGHTNING_BOLT:
|
||||
case Spells::THUNDERBOLT:
|
||||
displayEffect(1, sc->tile);
|
||||
displayEffect(spell.mainEffectAnim, sc->tile);
|
||||
break;
|
||||
case 35: //dispel
|
||||
case 37: //cure
|
||||
case 38: //resurrection
|
||||
case 39: //animate dead
|
||||
case 78: //Dispell beneficial spells
|
||||
case Spells::DISPEL:
|
||||
case Spells::CURE:
|
||||
case Spells::RESURRECTION:
|
||||
case Spells::ANIMATE_DEAD:
|
||||
case Spells::DISPEL_HELPFUL_SPELLS:
|
||||
for(std::set<ui32>::const_iterator it = sc->affectedCres.begin(); it != sc->affectedCres.end(); ++it)
|
||||
{
|
||||
displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(*it, false)->position);
|
||||
}
|
||||
break;
|
||||
case 66: case 67: case 68: case 69: //summon elemental
|
||||
case Spells::SUMMON_FIRE_ELEMENTAL:
|
||||
case Spells::SUMMON_EARTH_ELEMENTAL:
|
||||
case Spells::SUMMON_WATER_ELEMENTAL:
|
||||
case Spells::SUMMON_AIR_ELEMENTAL:
|
||||
addNewAnim(new CDummyAnim(this, 2));
|
||||
break;
|
||||
} //switch(sc->id)
|
||||
@ -3263,32 +3266,32 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
{
|
||||
switch(sc->id)
|
||||
{
|
||||
case 70: //Stone Gaze
|
||||
case Spells::STONE_GAZE:
|
||||
customSpell = true;
|
||||
plural = true;
|
||||
textID = 558;
|
||||
break;
|
||||
case 71: //Poison
|
||||
case Spells::POISON:
|
||||
customSpell = true;
|
||||
plural = true;
|
||||
textID = 561;
|
||||
break;
|
||||
case 72: //Bind
|
||||
case Spells::BIND:
|
||||
customSpell = true;
|
||||
text = CGI->generaltexth->allTexts[560];
|
||||
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin(), false)->getCreature()->namePl );
|
||||
break; //Roots and vines bind the %s to the ground!
|
||||
case 73: //Disease
|
||||
case Spells::DISEASE:
|
||||
customSpell = true;
|
||||
plural = true;
|
||||
textID = 553;
|
||||
break;
|
||||
case 74: //Paralyze
|
||||
case Spells::PARALYZE:
|
||||
customSpell = true;
|
||||
plural = true;
|
||||
textID = 563;
|
||||
break;
|
||||
case 75: // Aging
|
||||
case Spells::AGE:
|
||||
{
|
||||
customSpell = true;
|
||||
if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1)
|
||||
@ -3307,7 +3310,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bl->totalValue()/2));
|
||||
}
|
||||
break;
|
||||
case 77: //Thunderbolt
|
||||
case Spells::THUNDERBOLT:
|
||||
text = CGI->generaltexth->allTexts[367];
|
||||
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl);
|
||||
console->addText(text);
|
||||
@ -3317,12 +3320,12 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
customSpell = true;
|
||||
text = ""; //yeah, it's a terrible mess
|
||||
break;
|
||||
case 78: //Dispell helpful spells
|
||||
case Spells::DISPEL_HELPFUL_SPELLS:
|
||||
text = CGI->generaltexth->allTexts[555];
|
||||
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl);
|
||||
customSpell = true;
|
||||
break;
|
||||
case 79: // Death Stare
|
||||
case Spells::DEATH_STARE:
|
||||
customSpell = true;
|
||||
if (sc->dmgToDisplay)
|
||||
{
|
||||
|
@ -1962,8 +1962,8 @@ TSpell BattleInfo::getRandomBeneficialSpell(const CStack * subject) const
|
||||
continue;
|
||||
switch (i)
|
||||
{
|
||||
case 27: //shield
|
||||
case 29: //fire shield - not if all enemy units are shooters
|
||||
case Spells::SHIELD:
|
||||
case Spells::FIRE_SHIELD: // not if all enemy units are shooters
|
||||
{
|
||||
bool walkerPresent = false;
|
||||
BOOST_FOREACH (CStack * stack, stacks)
|
||||
@ -1978,7 +1978,7 @@ TSpell BattleInfo::getRandomBeneficialSpell(const CStack * subject) const
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 28: //air shield - only against active shooters
|
||||
case Spells::AIR_SHIELD: //only against active shooters
|
||||
{
|
||||
bool shooterPresent = false;
|
||||
BOOST_FOREACH (CStack * stack, stacks)
|
||||
@ -1993,32 +1993,32 @@ TSpell BattleInfo::getRandomBeneficialSpell(const CStack * subject) const
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
case 34: //anti-magic
|
||||
case 36: //magic mirror
|
||||
case Spells::ANTI_MAGIC:
|
||||
case Spells::MAGIC_MIRROR:
|
||||
{
|
||||
if (!heroes[whatSide(theOtherPlayer(subject->owner))]) //only if there is enemy hero
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 37: //Cure - only damaged units - what about affected by curse?
|
||||
case Spells::CURE: //only damaged units - what about affected by curse?
|
||||
{
|
||||
if (subject->firstHPleft >= subject->MaxHealth())
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 43: //bloodlust
|
||||
case Spells::BLOODLUST:
|
||||
{
|
||||
if (subject->shots) //if can shoot - only if enemy uits are adjacent
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 44: //precision
|
||||
case Spells::PRECISION:
|
||||
{
|
||||
if (!(subject->hasBonusOfType(Bonus::SHOOTER) && subject->shots))
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 55: //slayer - only if monsters are present
|
||||
case Spells::SLAYER://only if monsters are present
|
||||
{
|
||||
bool monsterPresent = false;
|
||||
BOOST_FOREACH (CStack * stack, stacks)
|
||||
@ -2034,7 +2034,7 @@ TSpell BattleInfo::getRandomBeneficialSpell(const CStack * subject) const
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 65: //clone - not allowed
|
||||
case Spells::CLONE: //not allowed
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
@ -2108,30 +2108,30 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance
|
||||
|
||||
switch (spell->id) //TODO: more general logic for new spells?
|
||||
{
|
||||
case 25: //Destroy Undead
|
||||
case Spells::DESTROY_UNDEAD:
|
||||
if (!subject->hasBonusOfType(Bonus::UNDEAD))
|
||||
return SpellCasting::STACK_IMMUNE_TO_SPELL;
|
||||
break;
|
||||
case 24: // Death Ripple
|
||||
case Spells::DEATH_RIPPLE:
|
||||
if (subject->hasBonusOfType(Bonus::SIEGE_WEAPON))
|
||||
return SpellCasting::STACK_IMMUNE_TO_SPELL; //don't break here - undeads and war machines are immune, non-living are not
|
||||
case 41:
|
||||
case 42: //undeads are immune to bless & curse
|
||||
case Spells::BLESS:
|
||||
case Spells::CURSE: //undeads are immune to bless & curse
|
||||
if (subject->hasBonusOfType(Bonus::UNDEAD))
|
||||
return SpellCasting::STACK_IMMUNE_TO_SPELL;
|
||||
break;
|
||||
case 53: //haste
|
||||
case 54: //slow
|
||||
case 63: //teleport
|
||||
case 65: //clone
|
||||
case Spells::HASTE:
|
||||
case Spells::SLOW:
|
||||
case Spells::TELEPORT:
|
||||
case Spells::CLONE:
|
||||
if (subject->hasBonusOfType(Bonus::SIEGE_WEAPON))
|
||||
return SpellCasting::STACK_IMMUNE_TO_SPELL; //war machines are mmune to some spells than involve movement
|
||||
break;
|
||||
case 61: //Forgetfulness
|
||||
case Spells::FORGETFULNESS:
|
||||
if (!subject->hasBonusOfType(Bonus::SHOOTER))
|
||||
return SpellCasting::STACK_IMMUNE_TO_SPELL;
|
||||
break;
|
||||
case 78: //dispel helpful spells
|
||||
case Spells::DISPEL_HELPFUL_SPELLS:
|
||||
{
|
||||
TBonusListPtr spellBon = subject->getSpellBonuses();
|
||||
bool hasPositiveSpell = false;
|
||||
|
@ -3551,30 +3551,30 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
continue;
|
||||
sc.dmgToDisplay += gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower);
|
||||
}
|
||||
if (spellID == 79 || spellID == 81) // Death stare or Acid Breath
|
||||
if (spellID == Spells::DEATH_STARE || spellID == Spells::ACID_BREATH_DAMAGE)
|
||||
{
|
||||
sc.dmgToDisplay = usedSpellPower;
|
||||
if (spellID == 79)
|
||||
if (spellID == Spells::DEATH_STARE)
|
||||
amin(sc.dmgToDisplay, (*attackedCres.begin())->count); //stack is already reduced after attack
|
||||
}
|
||||
StacksInjured si;
|
||||
|
||||
//applying effects
|
||||
switch(spellID)
|
||||
{
|
||||
case 15: //magic arrow
|
||||
case 16: //ice bolt
|
||||
case 17: //lightning bolt
|
||||
case 18: //implosion
|
||||
case 20: //frost ring
|
||||
case 21: //fireball
|
||||
case 22: //inferno
|
||||
case 23: //meteor shower
|
||||
case 24: //death ripple
|
||||
case 25: //destroy undead
|
||||
case 26: //armageddon
|
||||
case 57: //Titan's Lightning bolt
|
||||
case 77: //Thunderbolt (thunderbirds)
|
||||
switch (spellID)
|
||||
{ //damage spells
|
||||
case Spells::MAGIC_ARROW:
|
||||
case Spells::ICE_BOLT:
|
||||
case Spells::LIGHTNING_BOLT:
|
||||
case Spells::IMPLOSION:
|
||||
case Spells::FROST_RING:
|
||||
case Spells::FIREBALL:
|
||||
case Spells::INFERNO:
|
||||
case Spells::METEOR_SHOWER:
|
||||
case Spells::DEATH_RIPPLE:
|
||||
case Spells::DESTROY_UNDEAD:
|
||||
case Spells::ARMAGEDDON:
|
||||
case Spells::TITANS_LIGHTNING_BOLT:
|
||||
case Spells::THUNDERBOLT: //(thunderbirds)
|
||||
{
|
||||
int spellDamage = 0;
|
||||
if (stack && mode != SpellCasting::MAGIC_MIRROR)
|
||||
@ -3613,44 +3613,44 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
}
|
||||
break;
|
||||
}
|
||||
// permanent effects
|
||||
case 27: //shield
|
||||
case 28: //air shield
|
||||
case 29: //fire shield
|
||||
case 30: //protection from air
|
||||
case 31: //protection from fire
|
||||
case 32: //protection from water
|
||||
case 33: //protection from earth
|
||||
case 34: //anti-magic
|
||||
case 36: //magic mirror
|
||||
case 41: //bless
|
||||
case 42: //curse
|
||||
case 43: //bloodlust
|
||||
case 44: //precision
|
||||
case 45: //weakness
|
||||
case 46: //stone skin
|
||||
case 47: //disrupting ray
|
||||
case 48: //prayer
|
||||
case 49: //mirth
|
||||
case 50: //sorrow
|
||||
case 51: //fortune
|
||||
case 52: //misfortune
|
||||
case 53: //haste
|
||||
case 54: //slow
|
||||
case 55: //slayer
|
||||
case 56: //frenzy
|
||||
case 58: //counterstrike
|
||||
case 59: //berserk
|
||||
case 60: //hypnotize
|
||||
case 61: //forgetfulness
|
||||
case 62: //blind
|
||||
case 70: //Stone Gaze
|
||||
case 71: //Poison
|
||||
case 72: //Bind
|
||||
case 73: //Disease
|
||||
case 74: //Paralyze
|
||||
case 75: //Aging
|
||||
case 80: //Acid Breath defense reduction
|
||||
// permanent effects
|
||||
case Spells::SHIELD:
|
||||
case Spells::AIR_SHIELD:
|
||||
case Spells::FIRE_SHIELD:
|
||||
case Spells::PROTECTION_FROM_AIR:
|
||||
case Spells::PROTECTION_FROM_FIRE:
|
||||
case Spells::PROTECTION_FROM_WATER:
|
||||
case Spells::PROTECTION_FROM_EARTH:
|
||||
case Spells::ANTI_MAGIC:
|
||||
case Spells::MAGIC_MIRROR:
|
||||
case Spells::BLESS:
|
||||
case Spells::CURSE:
|
||||
case Spells::BLOODLUST:
|
||||
case Spells::PRECISION:
|
||||
case Spells::WEAKNESS:
|
||||
case Spells::STONE_SKIN:
|
||||
case Spells::DISRUPTING_RAY:
|
||||
case Spells::PRAYER:
|
||||
case Spells::MIRTH:
|
||||
case Spells::SORROW:
|
||||
case Spells::FORTUNE:
|
||||
case Spells::MISFORTUNE:
|
||||
case Spells::HASTE:
|
||||
case Spells::SLOW:
|
||||
case Spells::SLAYER:
|
||||
case Spells::FRENZY:
|
||||
case Spells::COUNTERSTRIKE:
|
||||
case Spells::BERSERK:
|
||||
case Spells::HYPNOTIZE:
|
||||
case Spells::FORGETFULNESS:
|
||||
case Spells::BLIND:
|
||||
case Spells::STONE_GAZE:
|
||||
case Spells::POISON:
|
||||
case Spells::BIND:
|
||||
case Spells::DISEASE:
|
||||
case Spells::PARALYZE:
|
||||
case Spells::AGE:
|
||||
case Spells::ACID_BREATH_DEFENSE:
|
||||
{
|
||||
int stackSpellPower = 0;
|
||||
if (stack && mode != SpellCasting::MAGIC_MIRROR)
|
||||
@ -3730,7 +3730,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
sendAndApply(&sse);
|
||||
break;
|
||||
}
|
||||
case 63: //teleport
|
||||
case Spells::TELEPORT:
|
||||
{
|
||||
BattleStackMoved bsm;
|
||||
bsm.distance = -1;
|
||||
@ -3742,9 +3742,9 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
sendAndApply(&bsm);
|
||||
break;
|
||||
}
|
||||
case 37: //cure
|
||||
case 38: //resurrection
|
||||
case 39: //animate dead
|
||||
case Spells::CURE:
|
||||
case Spells::RESURRECTION:
|
||||
case Spells::ANIMATE_DEAD:
|
||||
{
|
||||
int hpGained = 0;
|
||||
if (stack)
|
||||
@ -3761,7 +3761,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
|
||||
{
|
||||
if(vstd::contains(sc.resisted, (*it)->ID) //this creature resisted the spell
|
||||
|| (spellID == 39 && !(*it)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack
|
||||
|| (spellID == Spells::ANIMATE_DEAD && !(*it)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack
|
||||
)
|
||||
continue;
|
||||
StacksHealedOrResurrected::HealInfo hi;
|
||||
@ -3784,25 +3784,25 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
sendAndApply(&shr);
|
||||
break;
|
||||
}
|
||||
case 66:
|
||||
case 67:
|
||||
case 68:
|
||||
case 69:
|
||||
case Spells::SUMMON_FIRE_ELEMENTAL:
|
||||
case Spells::SUMMON_EARTH_ELEMENTAL:
|
||||
case Spells::SUMMON_WATER_ELEMENTAL:
|
||||
case Spells::SUMMON_AIR_ELEMENTAL:
|
||||
{ //elemental summoning
|
||||
int creID;
|
||||
switch(spellID)
|
||||
{
|
||||
case 66:
|
||||
creID = 114; //fire elemental
|
||||
case Spells::SUMMON_FIRE_ELEMENTAL:
|
||||
creID = 114;
|
||||
break;
|
||||
case 67:
|
||||
creID = 113; //earth elemental
|
||||
case Spells::SUMMON_EARTH_ELEMENTAL:
|
||||
creID = 113;
|
||||
break;
|
||||
case 68:
|
||||
creID = 115; //water elemental
|
||||
case Spells::SUMMON_WATER_ELEMENTAL:
|
||||
creID = 115;
|
||||
break;
|
||||
case 69:
|
||||
creID = 112; //air elemental
|
||||
case Spells::SUMMON_AIR_ELEMENTAL:
|
||||
creID = 112;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3819,7 +3819,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
sendAndApply(&bsa);
|
||||
}
|
||||
break;
|
||||
case 64: //remove obstacle
|
||||
case Spells::REMOVE_OBSTACLE:
|
||||
{
|
||||
ObstaclesRemoved obr;
|
||||
for(int g=0; g<gs->curB->obstacles.size(); ++g)
|
||||
@ -3836,7 +3836,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 79: //Death stare - handled in a bit different way
|
||||
case Spells::DEATH_STARE: //handled in a bit different way
|
||||
{
|
||||
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
|
||||
{
|
||||
@ -3857,7 +3857,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 81: //Acid breath damage - new effect, separate from acid breath defense reduction
|
||||
case Spells::ACID_BREATH_DAMAGE: //new effect, separate from acid breath defense reduction
|
||||
{
|
||||
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it) //no immunities
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user