1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-29 22:57:49 +02:00

* fixed bug with displaying mass spells

* fixed defender projectile animation
* you don't have to select location for spells which don't need them
* fixed calculating stack speed when it's under slow spell effect
* changed some 17's into BFIELD_WIDTH
This commit is contained in:
mateuszb 2009-01-16 17:58:41 +00:00
parent a5c4586d13
commit 9ef5519f89
4 changed files with 47 additions and 44 deletions

View File

@ -616,7 +616,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
else if(isTileAttackable(myNumber)) //available enemy (melee attackable) else if(isTileAttackable(myNumber)) //available enemy (melee attackable)
{ {
int fromHex = previouslyHoveredHex; int fromHex = previouslyHoveredHex;
if(fromHex!=-1 && fromHex%17!=0 && fromHex%17!=16 && vstd::contains(shadedHexes, fromHex)) if(fromHex!=-1 && fromHex%BFIELD_WIDTH!=0 && fromHex%BFIELD_WIDTH!=(BFIELD_WIDTH-1) && vstd::contains(shadedHexes, fromHex))
{ {
switch(BattleInfo::mutualPosition(fromHex, myNumber)) switch(BattleInfo::mutualPosition(fromHex, myNumber))
{ {
@ -1311,19 +1311,19 @@ void CBattleInterface::hexLclicked(int whichOne)
switch(CGI->curh->number) switch(CGI->curh->number)
{ {
case 12: case 12:
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 17 : 18 ),activeStack,whichOne); giveCommand(6,whichOne + ( (whichOne/BFIELD_WIDTH)%2 ? BFIELD_WIDTH : BFIELD_WIDTH+1 ),activeStack,whichOne);
break; break;
case 7: case 7:
giveCommand(6,whichOne + ( (whichOne/17)%2 ? 16 : 17 ),activeStack,whichOne); giveCommand(6,whichOne + ( (whichOne/BFIELD_WIDTH)%2 ? BFIELD_WIDTH-1 : BFIELD_WIDTH ),activeStack,whichOne);
break; break;
case 8: case 8:
giveCommand(6,whichOne - 1,activeStack,whichOne); giveCommand(6,whichOne - 1,activeStack,whichOne);
break; break;
case 9: case 9:
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 18 : 17 ),activeStack,whichOne); giveCommand(6,whichOne - ( (whichOne/BFIELD_WIDTH)%2 ? BFIELD_WIDTH+1 : BFIELD_WIDTH ),activeStack,whichOne);
break; break;
case 10: case 10:
giveCommand(6,whichOne - ( (whichOne/17)%2 ? 17 : 16 ),activeStack,whichOne); giveCommand(6,whichOne - ( (whichOne/BFIELD_WIDTH)%2 ? BFIELD_WIDTH : BFIELD_WIDTH-1 ),activeStack,whichOne);
break; break;
case 11: case 11:
giveCommand(6,whichOne + 1,activeStack,whichOne); giveCommand(6,whichOne + 1,activeStack,whichOne);
@ -1345,12 +1345,13 @@ void CBattleInterface::stackIsShooting(int ID, int dest)
float projectileAngle; //in radians; if positive, projectiles goes up float projectileAngle; //in radians; if positive, projectiles goes up
float straightAngle = 0.2f; //maximal angle in radians between straight horizontal line and shooting line for which shot is considered to be straight (absoulte value) float straightAngle = 0.2f; //maximal angle in radians between straight horizontal line and shooting line for which shot is considered to be straight (absoulte value)
int fromHex = LOCPLINT->cb->battleGetPos(ID); int fromHex = LOCPLINT->cb->battleGetPos(ID);
projectileAngle = atan2(float(abs(dest - fromHex)/17), float(abs(dest - fromHex)%17)); projectileAngle = atan2(float(abs(dest - fromHex)/BFIELD_WIDTH), float(abs(dest - fromHex)%BFIELD_WIDTH));
if(fromHex < dest) if(fromHex < dest)
projectileAngle = -projectileAngle; projectileAngle = -projectileAngle;
SProjectileInfo spi; SProjectileInfo spi;
spi.creID = LOCPLINT->cb->battleGetStackByID(ID)->creature->idNumber; spi.creID = LOCPLINT->cb->battleGetStackByID(ID)->creature->idNumber;
spi.reverse = !LOCPLINT->cb->battleGetStackByID(ID)->attackerOwned;
spi.step = 0; spi.step = 0;
spi.frameNum = 0; spi.frameNum = 0;
@ -1425,25 +1426,6 @@ void CBattleInterface::spellCasted(SpellCasted * sc)
{ {
std::vector< std::string > anims; //for magic arrow and ice bolt std::vector< std::string > anims; //for magic arrow and ice bolt
#define DISPLAY2(SP_ID) \
if(sc->skill < 3) \
{ \
displayEffect(SP_ID, sc->tile); \
} \
else \
{ \
std::map<int, CStack> stacks = LOCPLINT->cb->battleGetStacks(); \
for(std::map<int, CStack>::iterator it = stacks.begin(); it!=stacks.end(); ++it) \
{ \
if((CGI->spellh->spells[sc->id].positiveness >= 0 && it->second.owner == LOCPLINT->playerID) \
||(CGI->spellh->spells[sc->id].positiveness <= 0 && it->second.owner != LOCPLINT->playerID ) \
) \
{ \
displayEffect(SP_ID, it->second.position); \
} \
} \
}
switch(sc->id) switch(sc->id)
{ {
case 15: //magic arrow case 15: //magic arrow
@ -1518,68 +1500,67 @@ void CBattleInterface::spellCasted(SpellCasted * sc)
} }
case 27: //shield case 27: //shield
{ {
DISPLAY2(27); displayEffect(27, sc->tile);
break; break;
} }
case 28: //air shield case 28: //air shield
{ {
DISPLAY2(2); displayEffect(2, sc->tile);
break; break;
} }
case 41: //bless case 41: //bless
{ {
DISPLAY2(36); displayEffect(36, sc->tile);
break; break;
} }
case 42: //curse case 42: //curse
{ {
DISPLAY2(40); displayEffect(40, sc->tile);
break; break;
} }
case 43: //bloodlust case 43: //bloodlust
{ {
DISPLAY2(4); displayEffect(4, sc->tile);
//TODO: give better animation for this spell //TODO: give better animation for this spell
break; break;
} }
case 45: //weakness case 45: //weakness
{ {
DISPLAY2(56); displayEffect(56, sc->tile);
//TODO: give better animation for this spell //TODO: give better animation for this spell
break; break;
} }
case 46: //stone skin case 46: //stone skin
{ {
DISPLAY2(54); displayEffect(54, sc->tile);
break; break;
} }
case 48: //prayer case 48: //prayer
{ {
DISPLAY2(0); displayEffect(0, sc->tile);
break; break;
} }
case 53: //haste case 53: //haste
{ {
DISPLAY2(31); displayEffect(31, sc->tile);
break; break;
} }
case 54: //slow case 54: //slow
{ {
DISPLAY2(19); displayEffect(19, sc->tile);
break; break;
} }
case 56: //frenzy case 56: //frenzy
{ {
DISPLAY2(17); displayEffect(17, sc->tile);
break; break;
} }
case 61: //forgetfulness case 61: //forgetfulness
{ {
DISPLAY2(42); displayEffect(42, sc->tile);
break; break;
} }
} }
#undef DISPLAY2
} }
void CBattleInterface::castThisSpell(int spellID) void CBattleInterface::castThisSpell(int spellID)
@ -1633,7 +1614,19 @@ void CBattleInterface::castThisSpell(int spellID)
spellSelMode = -1; spellSelMode = -1;
} }
} }
CGI->curh->changeGraphic(3, 0); if(spellSelMode == -1) //user does not have to select location
{
spellToCast->destinationTile = -1;
LOCPLINT->cb->battleMakeAction(spellToCast);
delete spellToCast;
spellToCast = NULL;
spellDestSelectMode = false;
CGI->curh->changeGraphic(1, 6);
}
else
{
CGI->curh->changeGraphic(3, 0);
}
} }
void CBattleInterface::displayEffect(ui32 effect, int destTile) void CBattleInterface::displayEffect(ui32 effect, int destTile)
@ -1897,8 +1890,8 @@ void CBattleInterface::redrawBackgroundWithHexes(int activeStack)
{ {
for(size_t m=0; m<shadedHexes.size(); ++m) //rows for(size_t m=0; m<shadedHexes.size(); ++m) //rows
{ {
int i = shadedHexes[m]/17; //row int i = shadedHexes[m]/BFIELD_WIDTH; //row
int j = shadedHexes[m]%17-1; //column int j = shadedHexes[m]%BFIELD_WIDTH-1; //column
int x = 58 + (i%2==0 ? 22 : 0) + 44*j; int x = 58 + (i%2==0 ? 22 : 0) + 44*j;
int y = 86 + 42 * i; int y = 86 + 42 * i;
CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, backgroundWithHexes, &genRect(cellShade->h, cellShade->w, x, y)); CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, backgroundWithHexes, &genRect(cellShade->h, cellShade->w, x, y));
@ -1946,7 +1939,16 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
dst.w = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->w; dst.w = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->w;
dst.x = it->x; dst.x = it->x;
dst.y = it->y; dst.y = it->y;
CSDL_Ext::blit8bppAlphaTo24bpp(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap, NULL, to, &dst); if(it->reverse)
{
SDL_Surface * rev = CSDL_Ext::rotate01(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap);
CSDL_Ext::blit8bppAlphaTo24bpp(rev, NULL, to, &dst);
SDL_FreeSurface(rev);
}
else
{
CSDL_Ext::blit8bppAlphaTo24bpp(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap, NULL, to, &dst);
}
//actualizing projectile //actualizing projectile
++it->step; ++it->step;
if(it->step == it->lastStep) if(it->step == it->lastStep)

View File

@ -170,6 +170,7 @@ private:
int frameNum; //frame to display form projectile animation int frameNum; //frame to display form projectile animation
bool spin; //if true, frameNum will be increased bool spin; //if true, frameNum will be increased
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit) int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
bool reverse; //if true, projectile will be flipped by vertical asix
}; };
std::list<SProjectileInfo> projectiles; std::list<SProjectileInfo> projectiles;
void projectileShowHelper(SDL_Surface * to=NULL); //prints projectiles present on the battlefield void projectileShowHelper(SDL_Surface * to=NULL); //prints projectiles present on the battlefield

View File

@ -343,7 +343,7 @@ ui32 CStack::speed() const
//slow effect check //slow effect check
effect = getEffect(54); effect = getEffect(54);
if(effect) if(effect)
premy -= VLC->spellh->spells[effect->id].powers[effect->level]; premy -= (creature->speed * VLC->spellh->spells[effect->id].powers[effect->level])/100;
//prayer effect check //prayer effect check
effect = getEffect(48); effect = getEffect(48);
if(effect) if(effect)

View File

@ -541,7 +541,7 @@ void CClient::process(int what)
*serv >> sse; *serv >> sse;
gs->apply(&sse); gs->apply(&sse);
SpellCasted sc; SpellCasted sc;
sc.id = sse.stack; sc.id = sse.effect.id;
sc.side = 3; //doesn't matter sc.side = 3; //doesn't matter
sc.skill = sse.effect.level; sc.skill = sse.effect.level;
sc.tile = gs->curB->getStack(sse.stack)->position; sc.tile = gs->curB->getStack(sse.stack)->position;