1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00
This commit is contained in:
DjWarmonger 2011-08-12 19:38:30 +00:00
parent 4895540f80
commit 287761a93d
3 changed files with 29 additions and 21 deletions

View File

@ -566,8 +566,8 @@ void CDefenceAnim::endAnim()
//printing info to console
if(attacker!=NULL)
owner->printConsoleAttacked(stack, dmg, amountKilled, attacker);
//if(attacker!=NULL)
// owner->printConsoleAttacked(stack, dmg, amountKilled, attacker);
//const CStack * attacker = owner->curInt->cb->battleGetStackByID(IDby, false);
//const CStack * attacked = owner->curInt->cb->battleGetStackByID(stackID, false);
@ -2561,6 +2561,18 @@ void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> attacke
}
}
waitForAnims();
int targets = 0, killed = 0, damage = 0;
for(int h = 0; h < attackedInfos.size(); ++h)
{
++targets;
killed += attackedInfos[h].killed;
damage += attackedInfos[h].dmg;
}
if (targets > 1)
printConsoleAttacked(attackedInfos.front().defender, damage, killed, attackedInfos.front().attacker, true); //creatures perish
else
printConsoleAttacked(attackedInfos.front().defender, damage, killed, attackedInfos.front().attacker, false);
for(int h = 0; h < attackedInfos.size(); ++h)
{
if (attackedInfos[h].rebirth)
@ -3626,21 +3638,26 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
}
}
void CBattleInterface::printConsoleAttacked( const CStack * defender, int dmg, int killed, const CStack * attacker )
void CBattleInterface::printConsoleAttacked( const CStack * defender, int dmg, int killed, const CStack * attacker, bool multiple )
{
char tabh[200];
int end = sprintf(tabh, CGI->generaltexth->allTexts[attacker->count > 1 ? 377 : 376].c_str(),
(attacker->count > 1 ? attacker->getCreature()->namePl.c_str() : attacker->getCreature()->nameSing.c_str()),
dmg);
int end = 0;
if (attacker) //ignore if stacks were killed by spell
{
end = sprintf(tabh, CGI->generaltexth->allTexts[attacker->count > 1 ? 377 : 376].c_str(),
(attacker->count > 1 ? attacker->getCreature()->namePl.c_str() : attacker->getCreature()->nameSing.c_str()), dmg);
}
if(killed > 0)
{
if(killed > 1)
{
sprintf(tabh + end, CGI->generaltexth->allTexts[379].c_str(), killed, defender->getCreature()->namePl.c_str());
sprintf(tabh + end, CGI->generaltexth->allTexts[379].c_str(), killed,
multiple ? CGI->generaltexth->allTexts[43].c_str() : defender->getCreature()->namePl.c_str()); // creatures perish
}
else //killed == 1
{
sprintf(tabh + end, CGI->generaltexth->allTexts[378].c_str(), defender->getCreature()->nameSing.c_str());
sprintf(tabh + end, CGI->generaltexth->allTexts[378].c_str(),
multiple ? CGI->generaltexth->allTexts[42].c_str() : defender->getCreature()->nameSing.c_str()); // creature perishes
}
}

View File

@ -453,7 +453,7 @@ private:
void showPieceOfWall(SDL_Surface * to, int hex, const std::vector<const CStack*> & stacks); //helper function for show
void showObstacles(std::multimap<THex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
void redrawBackgroundWithHexes(const CStack * activeStack);
void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker);
void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker, bool Multiple);
std::list<SProjectileInfo> projectiles; //projectiles flying on battlefield
void projectileShowHelper(SDL_Surface * to); //prints projectiles present on the battlefield

View File

@ -3453,6 +3453,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
if (spellID == 79)
amin(sc.dmgToDisplay, (*attackedCres.begin())->count); //stack is already reduced after attack
}
StacksInjured si;
//applying effects
switch(spellID)
@ -3480,7 +3481,6 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
else //Faerie Dragon
usedSpellPower = stack->valOfBonuses(Bonus::CREATURE_SPELL_POWER) * stack->count / 100;
}
StacksInjured si;
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
{
if(vstd::contains(sc.resisted, (*it)->ID)) //this creature resisted the spell
@ -3501,8 +3501,6 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
(*it)->prepareAttacked(bsa);
si.stacks.push_back(bsa);
}
if(!si.stacks.empty())
sendAndApply(&si);
break;
}
// permanent effects
@ -3628,7 +3626,6 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
bsm.tilesToMove = tiles;
bsm.teleporting = true;
sendAndApply(&bsm);
break;
}
case 37: //cure
@ -3687,13 +3684,11 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
}
if(!obr.obstacles.empty())
sendAndApply(&obr);
break;
}
break;
case 79: //Death stare - handled in a bit different way
{
StacksInjured si;
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
{
if((*it)->hasBonusOfType(Bonus::UNDEAD) || (*it)->hasBonusOfType(Bonus::NON_LIVING)) //this creature is immune
@ -3711,13 +3706,10 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
(*it)->prepareAttacked(bsa);
si.stacks.push_back(bsa);
}
if(!si.stacks.empty())
sendAndApply(&si);
}
break;
case 81: //Acid breath damage - new effect, separate from acid breath defense reduction
{
StacksInjured si;
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it) //no immunities
{
BattleStackAttacked bsa;
@ -3729,14 +3721,13 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
(*it)->prepareAttacked(bsa);
si.stacks.push_back(bsa);
}
if(!si.stacks.empty())
sendAndApply(&si);
}
break;
}
sendAndApply(&sc);
if(!si.stacks.empty()) //after spellcast info shows
sendAndApply(&si);
//Magic Mirror effect
if (spell->positiveness < 0 && mode != SpellCasting::MAGIC_MIRROR && spell->level && spell->range[0] == "0") //it is actual spell and can be reflected to single target, no recurrence
{