1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Console texts for creature casting spells.

Fixes related to war machines in battle.
This commit is contained in:
DjWarmonger 2011-10-22 07:05:57 +00:00
parent 10fce0025a
commit 57216eea44
6 changed files with 35 additions and 8 deletions

View File

@ -2047,6 +2047,11 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{ {
CCS->curh->changeGraphic(3, 0); CCS->curh->changeGraphic(3, 0);
stackCastsSpell = true; stackCastsSpell = true;
std::string buf = CGI->generaltexth->allTexts[27]; //cast %s on &s
boost::replace_first (buf, "%s", spell->name);
boost::replace_first (buf, "%s", shere->getName());
console->alterTxt = buf;
console->whoSetAlter = 0;
} }
} }
} }
@ -2059,6 +2064,10 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{ {
CCS->curh->changeGraphic(3, 0); CCS->curh->changeGraphic(3, 0);
stackCastsSpell = true; stackCastsSpell = true;
std::string buf = CGI->generaltexth->allTexts[301]; //Cast spell on %s
boost::replace_first (buf, "%s", shere->getName());
console->alterTxt = buf;
console->whoSetAlter = 0;
} }
} }
} }
@ -3336,12 +3345,12 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1) if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1)
{ {
text = CGI->generaltexth->allTexts[textID + 1]; text = CGI->generaltexth->allTexts[textID + 1];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl); boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->getName());
} }
else else
{ {
text = CGI->generaltexth->allTexts[textID]; text = CGI->generaltexth->allTexts[textID];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->nameSing); boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->getName());
} }
} }
} }

View File

@ -48,7 +48,7 @@ CCreatureWindow::CCreatureWindow (const CStack &stack, int Type)
else else
{ {
CStackInstance * s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks CStackInstance * s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks
init(s, stack.type, NULL); init(s, &stack, NULL);
delete s; delete s;
} }
} }

View File

@ -2369,7 +2369,10 @@ ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
si32 CStack::magicResistance() const si32 CStack::magicResistance() const
{ {
si32 magicResistance = base->magicResistance(); si32 magicResistance;
if (base) //TODO: make war machines receive aura of magic resistance
{
magicResistance = base->magicResistance();
int auraBonus = 0; int auraBonus = 0;
BOOST_FOREACH (CStack * stack, base->armyObj->battle->getAdjacentCreatures(this)) BOOST_FOREACH (CStack * stack, base->armyObj->battle->getAdjacentCreatures(this))
{ {
@ -2380,6 +2383,9 @@ si32 CStack::magicResistance() const
} }
magicResistance += auraBonus; magicResistance += auraBonus;
amin (magicResistance, 100); amin (magicResistance, 100);
}
else
magicResistance = type->magicResistance();
return magicResistance; return magicResistance;
} }
@ -2792,6 +2798,11 @@ bool CStack::ableToRetaliate() const
&& !hasBonusOfType(Bonus::HYPNOTIZED); && !hasBonusOfType(Bonus::HYPNOTIZED);
} }
std::string CStack::getName() const
{
return (count > 1) ? type->namePl : type->nameSing; //War machines can't use base
}
bool CMP_stack::operator()( const CStack* a, const CStack* b ) bool CMP_stack::operator()( const CStack* a, const CStack* b )
{ {
switch(phase) switch(phase)

View File

@ -175,6 +175,7 @@ public:
void init(); //set initial (invalid) values void init(); //set initial (invalid) values
void postInit(); //used to finish initialization when inheriting creature parameters is working void postInit(); //used to finish initialization when inheriting creature parameters is working
std::string getName() const; //plural or singular
const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP) const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP)
ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack
bool willMove(int turn = 0) const; //if stack has remaining move this turn bool willMove(int turn = 0) const; //if stack has remaining move this turn

View File

@ -940,6 +940,11 @@ int CStackInstance::getCreatureID() const
return -1; return -1;
} }
std::string CStackInstance::getName() const
{
return (count > 1) ? type->namePl : type->nameSing;
}
CStackBasicDescriptor::CStackBasicDescriptor() CStackBasicDescriptor::CStackBasicDescriptor()
{ {
type = NULL; type = NULL;

View File

@ -54,6 +54,7 @@ public:
int getExpRank() const; int getExpRank() const;
si32 magicResistance() const; si32 magicResistance() const;
int getCreatureID() const; //-1 if not available int getCreatureID() const; //-1 if not available
std::string getName() const; //plural or singular
void init(); void init();
CStackInstance(); CStackInstance();
CStackInstance(TCreature id, TQuantity count); CStackInstance(TCreature id, TQuantity count);