1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +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);
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);
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)
{
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
{
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
{
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;
}
}

View File

@ -2369,17 +2369,23 @@ ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
si32 CStack::magicResistance() const
{
si32 magicResistance = base->magicResistance();
int auraBonus = 0;
BOOST_FOREACH (CStack * stack, base->armyObj->battle->getAdjacentCreatures(this))
si32 magicResistance;
if (base) //TODO: make war machines receive aura of magic resistance
{
magicResistance = base->magicResistance();
int auraBonus = 0;
BOOST_FOREACH (CStack * stack, base->armyObj->battle->getAdjacentCreatures(this))
{
if (stack->owner == owner)
{
amax(auraBonus, stack->valOfBonuses(Bonus::SPELL_RESISTANCE_AURA)); //max value
}
}
magicResistance += auraBonus;
amin (magicResistance, 100);
magicResistance += auraBonus;
amin (magicResistance, 100);
}
else
magicResistance = type->magicResistance();
return magicResistance;
}
@ -2792,6 +2798,11 @@ bool CStack::ableToRetaliate() const
&& !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 )
{
switch(phase)

View File

@ -175,6 +175,7 @@ public:
void init(); //set initial (invalid) values
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)
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

View File

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

View File

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