1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

* LEVEL_SPELL_IMMUNITY (e.g. Dragon spell immunity) implemented.

* Modified the positioning of battle effects, they should look about right now.
This commit is contained in:
OnionKnight 2009-08-29 22:00:46 +00:00
parent 8fac12f957
commit c1b112d266
2 changed files with 29 additions and 20 deletions

View File

@ -2109,33 +2109,36 @@ void CBattleInterface::displayEffect(ui32 effect, int destTile)
}
}
}
else
else // Effects targeted at a specific creature/hex.
{
if(graphics->battleACToDef[effect].size() != 0)
{
const CStack* destStack = LOCPLINT->cb->battleGetStackByPos(destTile, false);
Rect &tilePos = bfield[destTile].pos;
SBattleEffect be;
be.anim = CDefHandler::giveDef(graphics->battleACToDef[effect][0]);
be.frame = 0;
be.maxFrame = be.anim->ourImages.size();
be.x = 22 * ( ((destTile/BFIELD_WIDTH) + 1)%2 ) + 44 * (destTile % BFIELD_WIDTH) + 45;
be.y = 105 + 42 * (destTile/BFIELD_WIDTH);
if(effect != 1 && effect != 0)
{
be.x -= be.anim->ourImages[0].bitmap->w/2;
be.y -= be.anim->ourImages[0].bitmap->h/2;
}
else if(effect == 1)
{
be.x -= be.anim->ourImages[0].bitmap->w;
be.y -= be.anim->ourImages[0].bitmap->h;
}
else if (effect == 0)
{
be.x -= be.anim->ourImages[0].bitmap->w/2;
be.y -= be.anim->ourImages[0].bitmap->h;
switch (effect) {
case 0: // Prayer and Lightning Bolt.
case 1:
// Position effect with it's bottom center touching the bottom center of affected tile(s).
be.x = tilePos.x + tilePos.w/2 - be.anim->width/2;
be.y = tilePos.y + tilePos.h - be.anim->height;
break;
default:
// Position effect with it's center touching the top center of affected tile(s).
be.x = tilePos.x + tilePos.w/2 - be.anim->width/2;
be.y = tilePos.y - be.anim->height/2;
break;
}
// Correction for 2-hex creatures.
if (destStack != NULL && destStack->hasFeatureOfType(StackFeature::DOUBLE_WIDE))
be.x += (destStack->attackerOwned ? -1 : 1)*tilePos.w/2;
battleEffects.push_back(be);
}
}

View File

@ -2692,7 +2692,14 @@ static std::vector<ui32> calculateResistedStacks(const CSpell * sp, const CGHero
std::vector<ui32> ret;
for(std::set<CStack*>::const_iterator it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it)
{
//non-negative spells on friendly stacks should always succeed
if ((*it)->hasFeatureOfType(StackFeature::SPELL_IMMUNITY, sp->id) //100% sure spell immunity
|| ((*it)->valOfFeatures(StackFeature::LEVEL_SPELL_IMMUNITY) >= sp->level))
{
ret.push_back((*it)->ID);
continue;
}
//non-negative spells on friendly stacks should always succeed, unless immune
if(sp->positiveness >= 0 && (*it)->owner == caster->tempOwner)
continue;
@ -2724,8 +2731,7 @@ static std::vector<ui32> calculateResistedStacks(const CSpell * sp, const CGHero
if(prob > 100) prob = 100;
if( (*it)->hasFeatureOfType(StackFeature::SPELL_IMMUNITY, sp->id) //100% sure spell immunity
|| rand()%100 < prob) //immunity from resistance
if(rand()%100 < prob) //immunity from resistance
ret.push_back((*it)->ID);
}