1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-13 11:40:38 +02:00

Various fixes related to spell effects and Creature Window.

This commit is contained in:
DjWarmonger 2011-05-21 07:07:07 +00:00
parent 2845123a0a
commit 3a6b5cbfbb
5 changed files with 74 additions and 47 deletions

View File

@ -3019,10 +3019,24 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
plural = true;
textID = 563;
break;
case 75: // Aging //TODO: hitpoints
case 75: // Aging
{
customSpell = true;
plural = true;
textID = 551;
if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1)
{
text = CGI->generaltexth->allTexts[552];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->namePl);
}
else
{
text = CGI->generaltexth->allTexts[551];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->nameSing);
}
//The %s shrivel with age, and lose %d hit points."
BonusList bl = curInt->cb->battleGetStackByID(*sc->affectedCres.begin(), false)->getBonuses(Selector::type(Bonus::STACK_HEALTH));
bl.remove_if(Selector::source(Bonus::SPELL_EFFECT, 75));
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bl.totalValue()/2));
}
break;
case 78: //Dispell helpful spells
text = CGI->generaltexth->allTexts[555];

View File

@ -22,6 +22,7 @@
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include "../lib/CGameState.h"
#include "../lib/CSpellHandler.h"
using namespace CSDL_Ext;
@ -223,7 +224,9 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
number = (stack->count * (expmax - expmin)) / expmin;
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Maximum New Recruits to remain at Rank 10 if at Maximum Experience
expArea = new LRClickableAreaWText(Rect(334, 49, 160, 44), "" , expText );
expArea = new LRClickableAreaWTextComp(Rect(334, 49, 160, 44),SComponent::experience);
expArea->text = expText;
expArea->bonusValue = 0; //TDO: some specific value or no number at all
}
}
@ -247,9 +250,15 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
std::vector<si32> spells = battleStack->activeSpells();
BOOST_FOREACH(si32 effect, spells)
{
std::string spellText;
if (effect < graphics->spellEffectsPics->ourImages.size()) //not all effects have graphics (for eg. Acid Breath)
{
spellText = CGI->generaltexth->allTexts[610]; //"%s, duration: %d rounds."
boost::replace_first (spellText, "%s", CGI->spellh->spells[effect]->name);
int duration = battleStack->getBonus(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain;
boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration));
blitAt(graphics->spellEffectsPics->ourImages[effect + 1].bitmap, 20 + 52 * printed, 184, *bitmap);
spellEffects.push_back(new LRClickableAreaWText(Rect(20 + 52 * printed, 184, 50, 38), spellText, spellText));
if (++printed >= 10) //we can fit only 10 effects
break;
}

View File

@ -35,11 +35,12 @@ public:
const CGHeroInstance *heroOwner;
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
std::vector<CBonusItem*> bonusItems;
std::vector<LRClickableAreaWText*> spellEffects;
CPicture *bitmap; //background
CCreaturePic *anim; //related creature's animation
MoraleLuckBox *luck, *morale;
LRClickableAreaWText * expArea; //displays exp details
LRClickableAreaWTextComp * expArea; //displays exp details
CArtPlace *creatureArtifact;
CSlider * slider; //Abilities
AdventureMapButton *dismiss, *upgrade, *ok;

View File

@ -938,7 +938,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src
case '7':
case '8':
case '9':
b.type = Bonus::LEVEL_SPELL_IMMUNITY; //TODO - value can't be read afterwards
b.type = Bonus::LEVEL_SPELL_IMMUNITY;
b.val = std::atoi(mod.c_str()) - 5;
break;
case ':':

View File

@ -3496,6 +3496,8 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
sse.stacks.push_back((*it)->ID);
//Apply hero specials - peculiar enchants
if ((*it)->base) // no war machines - TODO: make it work
{
ui8 tier = (*it)->base->type->level;
if (bonus)
{
@ -3539,6 +3541,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus));
}
}
}
if(!sse.stacks.empty())
sendAndApply(&sse);