mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +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;
|
plural = true;
|
||||||
textID = 563;
|
textID = 563;
|
||||||
break;
|
break;
|
||||||
case 75: // Aging //TODO: hitpoints
|
case 75: // Aging
|
||||||
|
{
|
||||||
customSpell = true;
|
customSpell = true;
|
||||||
plural = true;
|
if (curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->count > 1)
|
||||||
textID = 551;
|
{
|
||||||
|
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;
|
break;
|
||||||
case 78: //Dispell helpful spells
|
case 78: //Dispell helpful spells
|
||||||
text = CGI->generaltexth->allTexts[555];
|
text = CGI->generaltexth->allTexts[555];
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include "../lib/CGameState.h"
|
#include "../lib/CGameState.h"
|
||||||
|
#include "../lib/CSpellHandler.h"
|
||||||
|
|
||||||
using namespace CSDL_Ext;
|
using namespace CSDL_Ext;
|
||||||
|
|
||||||
@ -223,7 +224,9 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
|||||||
number = (stack->count * (expmax - expmin)) / expmin;
|
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
|
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();
|
std::vector<si32> spells = battleStack->activeSpells();
|
||||||
BOOST_FOREACH(si32 effect, spells)
|
BOOST_FOREACH(si32 effect, spells)
|
||||||
{
|
{
|
||||||
|
std::string spellText;
|
||||||
if (effect < graphics->spellEffectsPics->ourImages.size()) //not all effects have graphics (for eg. Acid Breath)
|
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);
|
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
|
if (++printed >= 10) //we can fit only 10 effects
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,12 @@ public:
|
|||||||
const CGHeroInstance *heroOwner;
|
const CGHeroInstance *heroOwner;
|
||||||
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||||
std::vector<CBonusItem*> bonusItems;
|
std::vector<CBonusItem*> bonusItems;
|
||||||
|
std::vector<LRClickableAreaWText*> spellEffects;
|
||||||
|
|
||||||
CPicture *bitmap; //background
|
CPicture *bitmap; //background
|
||||||
CCreaturePic *anim; //related creature's animation
|
CCreaturePic *anim; //related creature's animation
|
||||||
MoraleLuckBox *luck, *morale;
|
MoraleLuckBox *luck, *morale;
|
||||||
LRClickableAreaWText * expArea; //displays exp details
|
LRClickableAreaWTextComp * expArea; //displays exp details
|
||||||
CArtPlace *creatureArtifact;
|
CArtPlace *creatureArtifact;
|
||||||
CSlider * slider; //Abilities
|
CSlider * slider; //Abilities
|
||||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||||
|
@ -938,7 +938,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src
|
|||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
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;
|
b.val = std::atoi(mod.c_str()) - 5;
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
|
@ -3496,48 +3496,51 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
|
|||||||
sse.stacks.push_back((*it)->ID);
|
sse.stacks.push_back((*it)->ID);
|
||||||
|
|
||||||
//Apply hero specials - peculiar enchants
|
//Apply hero specials - peculiar enchants
|
||||||
ui8 tier = (*it)->base->type->level;
|
if ((*it)->base) // no war machines - TODO: make it work
|
||||||
if (bonus)
|
{
|
||||||
{
|
ui8 tier = (*it)->base->type->level;
|
||||||
switch(bonus->additionalInfo)
|
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
|
int damagePercent = caster->level * caster->valOfBonuses(Bonus::SPECIAL_BLESS_DAMAGE, spellID) / tier;
|
||||||
{
|
Bonus specialBonus = CStack::featureGenerator(Bonus::CREATURE_DAMAGE, 0, damagePercent, pseudoBonus.turnsRemain);
|
||||||
switch(tier)
|
specialBonus.valType = Bonus::PERCENT_TO_ALL;
|
||||||
{
|
specialBonus.sid = spellID;
|
||||||
case 1: case 2:
|
sse.uniqueBonuses.push_back (std::pair<ui32,Bonus> ((*it)->ID, specialBonus));
|
||||||
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
|
|
||||||
{
|
|
||||||
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())
|
if(!sse.stacks.empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user