mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
Various fixes related to spell effects and Creature Window.
This commit is contained in:
parent
2845123a0a
commit
3a6b5cbfbb
@ -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];
|
||||
|
@ -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)
|
||||
{
|
||||
blitAt(graphics->spellEffectsPics->ourImages[effect + 1].bitmap, 20 + 52 * printed, 184, *bitmap);
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 ':':
|
||||
|
@ -3496,48 +3496,51 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
|
||||
sse.stacks.push_back((*it)->ID);
|
||||
|
||||
//Apply hero specials - peculiar enchants
|
||||
ui8 tier = (*it)->base->type->level;
|
||||
if (bonus)
|
||||
{
|
||||
switch(bonus->additionalInfo)
|
||||
if ((*it)->base) // no war machines - TODO: make it work
|
||||
{
|
||||
ui8 tier = (*it)->base->type->level;
|
||||
if (bonus)
|
||||
{
|
||||
switch(bonus->additionalInfo)
|
||||
{
|
||||
case 0: //normal
|
||||
{
|
||||
switch(tier)
|
||||
{
|
||||
case 1: case 2:
|
||||
power = 3;
|
||||
break;
|
||||
case 3: case 4:
|
||||
power = 2;
|
||||
break;
|
||||
case 5: case 6:
|
||||
power = 1;
|
||||
break;
|
||||
}
|
||||
Bonus specialBonus(sse.effect.back());
|
||||
specialBonus.val = power; //it doesn't necessarily make sense for some spells, use it wisely
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus)); //additional premy to given effect
|
||||
}
|
||||
break;
|
||||
case 1: //only Coronius as yet
|
||||
{
|
||||
power = std::max(5 - tier, 0);
|
||||
Bonus specialBonus = CStack::featureGenerator(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK, power, pseudoBonus.turnsRemain);
|
||||
specialBonus.sid = spellID;
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus)); //additional attack to Slayer effect
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (caster && caster->hasBonusOfType(Bonus::SPECIAL_BLESS_DAMAGE, spellID)) //TODO: better handling of bonus percentages
|
||||
{
|
||||
case 0: //normal
|
||||
{
|
||||
switch(tier)
|
||||
{
|
||||
case 1: case 2:
|
||||
power = 3;
|
||||
break;
|
||||
case 3: case 4:
|
||||
power = 2;
|
||||
break;
|
||||
case 5: case 6:
|
||||
power = 1;
|
||||
break;
|
||||
}
|
||||
Bonus specialBonus(sse.effect.back());
|
||||
specialBonus.val = power; //it doesn't necessarily make sense for some spells, use it wisely
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus)); //additional premy to given effect
|
||||
}
|
||||
break;
|
||||
case 1: //only Coronius as yet
|
||||
{
|
||||
power = std::max(5 - tier, 0);
|
||||
Bonus specialBonus = CStack::featureGenerator(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK, power, pseudoBonus.turnsRemain);
|
||||
specialBonus.sid = spellID;
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus)); //additional attack to Slayer effect
|
||||
}
|
||||
break;
|
||||
int damagePercent = caster->level * caster->valOfBonuses(Bonus::SPECIAL_BLESS_DAMAGE, spellID) / tier;
|
||||
Bonus specialBonus = CStack::featureGenerator(Bonus::CREATURE_DAMAGE, 0, damagePercent, pseudoBonus.turnsRemain);
|
||||
specialBonus.valType = Bonus::PERCENT_TO_ALL;
|
||||
specialBonus.sid = spellID;
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus));
|
||||
}
|
||||
}
|
||||
if (caster && caster->hasBonusOfType(Bonus::SPECIAL_BLESS_DAMAGE, spellID)) //TODO: better handling of bonus percentages
|
||||
{
|
||||
int damagePercent = caster->level * caster->valOfBonuses(Bonus::SPECIAL_BLESS_DAMAGE, spellID) / tier;
|
||||
Bonus specialBonus = CStack::featureGenerator(Bonus::CREATURE_DAMAGE, 0, damagePercent, pseudoBonus.turnsRemain);
|
||||
specialBonus.valType = Bonus::PERCENT_TO_ALL;
|
||||
specialBonus.sid = spellID;
|
||||
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!sse.stacks.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user