1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

* massive spells go via one SetStackEffect

This commit is contained in:
mateuszb 2009-03-21 16:03:07 +00:00
parent b2c4f3e0fd
commit 2a7ad63495
8 changed files with 67 additions and 123 deletions

View File

@ -248,6 +248,26 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
SDL_SetColorKey(idToObstacle[obst[t].ID]->ourImages[n].bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(idToObstacle[obst[t].ID]->ourImages[n].bitmap->format,0,255,255));
}
}
//initializing spellToEffect
spellToEffect[17] = 1; //lightning bolt
spellToEffect[18] = 10; //implosion
spellToEffect[27] = 27; //shield
spellToEffect[28] = 2; //air shield
spellToEffect[41] = 36; //bless
spellToEffect[42] = 40; //curse
spellToEffect[43] = 4; //bloodlust
spellToEffect[45] = 56; //weakness
spellToEffect[46] = 54; //stone skin
spellToEffect[48] = 0; //prayer
spellToEffect[49] = 20; //mirth
spellToEffect[50] = 30; //sorrow
spellToEffect[51] = 18; //fortune
spellToEffect[52] = 48; //misfortune
spellToEffect[53] = 31; //haste
spellToEffect[54] = 19; //slow
spellToEffect[56] = 17; //frenzy
spellToEffect[61] = 42; //forgetfulness
}
CBattleInterface::~CBattleInterface()
@ -1710,98 +1730,14 @@ void CBattleInterface::spellCasted(SpellCasted * sc)
SDL_SetClipRect(screen, &buf); //restoring previous clip rect
break; //for 15 and 16 cases
}
case 17: //lightning bolt
{
displayEffect(1, sc->tile);
break;
}
case 18: //implosion
{
displayEffect(10, sc->tile);
break;
}
case 27: //shield
{
displayEffect(27, sc->tile);
break;
}
case 28: //air shield
{
displayEffect(2, sc->tile);
break;
}
case 41: //bless
{
displayEffect(36, sc->tile);
break;
}
case 42: //curse
{
displayEffect(40, sc->tile);
break;
}
case 43: //bloodlust
{
displayEffect(4, sc->tile);
//TODO: give better animation for this spell
break;
}
case 45: //weakness
{
displayEffect(56, sc->tile);
//TODO: give better animation for this spell
break;
}
case 46: //stone skin
{
displayEffect(54, sc->tile);
break;
}
case 48: //prayer
{
displayEffect(0, sc->tile);
break;
}
case 49: //mirth
{
displayEffect(20, sc->tile);
break;
}
case 50: //sorrow
{
displayEffect(30, sc->tile);
break;
}
case 51: //fortune
{
displayEffect(18, sc->tile);
break;
}
case 52: //misfortune
{
displayEffect(48, sc->tile);
break;
}
case 53: //haste
{
displayEffect(31, sc->tile);
break;
}
case 54: //slow
{
displayEffect(19, sc->tile);
break;
}
case 56: //frenzy
{
displayEffect(17, sc->tile);
break;
}
case 61: //forgetfulness
{
displayEffect(42, sc->tile);
break;
}
}
}
void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
{
for(std::set<ui32>::const_iterator ci = sse.stacks.begin(); ci!=sse.stacks.end(); ++ci)
{
displayEffect(spellToEffect[sse.effect.id], LOCPLINT->cb->battleGetStackByID(*ci)->position);
}
}
@ -1819,7 +1755,7 @@ void CBattleInterface::castThisSpell(int spellID)
//choosing possible tragets
const CGHeroInstance * castingHero = (attackingHeroInstance->tempOwner == LOCPLINT->playerID) ? attackingHeroInstance : attackingHeroInstance;
spellSelMode = 0;
if(CGI->spellh->spells[spellID].attributes.find("CREATURE_TARGET") != std::string::npos)
if(CGI->spellh->spells[spellID].attributes.find("CREATURE_TARGET") != std::string::npos) //spell to be cast on one specific creature
{
switch(CGI->spellh->spells[spellID].positiveness)
{
@ -1834,7 +1770,7 @@ void CBattleInterface::castThisSpell(int spellID)
break;
}
}
if(CGI->spellh->spells[spellID].attributes.find("CREATURE_TARGET_2") != std::string::npos)
if(CGI->spellh->spells[spellID].attributes.find("CREATURE_TARGET_2") != std::string::npos) //spell to be cast on a specific creature but massive on expert
{
if(castingHero && castingHero->getSpellSecLevel(spellID) < 3)
{

View File

@ -135,6 +135,7 @@ private:
std::map< int, CDefHandler * > idToProjectile; //projectiles of creaures (creatureID, defhandler)
std::map< int, CDefHandler * > idToObstacle; //obstacles located on the battlefield
std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation>
std::map< int, int > spellToEffect; //which effect should be played when different spells are casted (spellID, effectID)
unsigned char animCount;
int activeStack; //number of active stack; -1 - no one
int mouseHoveredStack; //stack hovered by mouse; if -1 -> none
@ -257,6 +258,7 @@ public:
void stackIsShooting(int ID, int dest); //called when stack with id ID is shooting to hex dest
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
void spellCasted(SpellCasted * sc); //called when a hero casts a spell
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
void castThisSpell(int spellID); //called when player has chosen a spell from spellbook
void displayEffect(ui32 effect, int destTile); //displays effect of a spell on the battlefield; affected: true - attacker. false - defender

View File

@ -23,6 +23,7 @@ struct BattleResult;
struct BattleAttack;
struct BattleStackAttacked;
struct SpellCasted;
struct SetStackEffect;
struct HeroBonus;
class CObstacle
{
@ -80,6 +81,7 @@ public:
virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
virtual void battleStackMoved(int ID, int dest, int distance){};
virtual void battleSpellCasted(SpellCasted *sc){};
virtual void battleStacksEffectsSet(SetStackEffect & sse){};//called when a specific effect is set to stacks
virtual void battleStart(CCreatureSet *army1, CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
};

View File

@ -2288,6 +2288,11 @@ void CPlayerInterface::battleSpellCasted(SpellCasted *sc)
boost::unique_lock<boost::recursive_mutex> un(*pim);
battleInt->spellCasted(sc);
}
void CPlayerInterface::battleStacksEffectsSet(SetStackEffect & sse)
{
boost::unique_lock<boost::recursive_mutex> un(*pim);
battleInt->battleStacksEffectsSet(sse);
}
void CPlayerInterface::battleStacksAttacked(std::set<BattleStackAttacked> & bsa)
{
tlog5 << "CPlayerInterface::battleStackAttacked - locking...";

View File

@ -495,6 +495,7 @@ public:
void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
void battleStackMoved(int ID, int dest, int distance);
void battleSpellCasted(SpellCasted *sc);
void battleStacksEffectsSet(SetStackEffect & sse); //called when a specific effect is set to stacks
void battleStacksAttacked(std::set<BattleStackAttacked> & bsa);
void battleStart(CCreatureSet *army1, CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning

View File

@ -379,14 +379,12 @@ void SetStackEffect::applyCl( CClient *cl )
sc.id = effect.id;
sc.side = 3; //doesn't matter
sc.skill = effect.level;
BOOST_FOREACH(ui32 stack, stacks)
{
sc.tile = GS(cl)->curB->getStack(stack)->position;
if(cl->playerint.find(GS(cl)->curB->side1) != cl->playerint.end())
cl->playerint[GS(cl)->curB->side1]->battleSpellCasted(&sc);
if(cl->playerint.find(GS(cl)->curB->side2) != cl->playerint.end())
cl->playerint[GS(cl)->curB->side2]->battleSpellCasted(&sc);
}
//informing about effects
if(cl->playerint.find(GS(cl)->curB->side1) != cl->playerint.end())
cl->playerint[GS(cl)->curB->side1]->battleStacksEffectsSet(*this);
if(cl->playerint.find(GS(cl)->curB->side2) != cl->playerint.end())
cl->playerint[GS(cl)->curB->side2]->battleStacksEffectsSet(*this);
}
CGameState* CPackForClient::GS( CClient *cl )

View File

@ -36,7 +36,7 @@ public:
virtual const CGTownInstance* getTown(int objid);
virtual const CGHeroInstance* getSelectedHero(int player); //NULL if no hero is selected
virtual int getCurrentPlayer()=0;
virtual int getSelectedHero()=0;
virtual int getSelectedHero()=0;
virtual const PlayerSettings * getPlayerSettings(int color);
virtual int getHeroCount(int player, bool includeGarrisoned);
virtual void getTilesInRange(std::set<int3> &tiles, int3 pos, int radious, int player=-1, int mode=0); //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only unrevealed

View File

@ -2226,30 +2226,30 @@ void CGameHandler::makeCustomAction( BattleAction &ba )
//TODO: check resistances
#define SPELL_CAST_TEMPLATE_1(NUMBER, DURATION) SetStackEffect sse; \
if(getSchoolLevel(h,s) < 3) /*not expert */ \
if(getSchoolLevel(h,s) < 3) /*not expert */ \
{ \
sse.stacks.insert(gs->curB->getStackT(ba.destinationTile)->ID); \
sse.effect.id = (NUMBER); \
sse.effect.level = getSchoolLevel(h,s); \
sse.effect.turnsRemain = (DURATION); /*! - any duration */ \
sendAndApply(&sse); \
sse.stacks.insert(gs->curB->getStackT(ba.destinationTile)->ID); \
sse.effect.id = (NUMBER); \
sse.effect.level = getSchoolLevel(h,s); \
sse.effect.turnsRemain = (DURATION); /*! - any duration */ \
sendAndApply(&sse); \
} \
else \
{ \
for(int it=0; it<gs->curB->stacks.size(); ++it) \
{ \
/*if it's non negative spell and our unit or non positive spell and hostile unit */ \
if((VLC->spellh->spells[ba.additionalInfo].positiveness >= 0 && gs->curB->stacks[it]->owner == h->tempOwner) \
||(VLC->spellh->spells[ba.additionalInfo].positiveness <= 0 && gs->curB->stacks[it]->owner != h->tempOwner ) \
) \
{ \
sse.stacks.insert(gs->curB->stacks[it]->ID); \
sse.effect.id = (NUMBER); \
sse.effect.level = getSchoolLevel(h,s); \
sse.effect.turnsRemain = (DURATION); \
sendAndApply(&sse); \
} \
} \
for(int it=0; it<gs->curB->stacks.size(); ++it) \
{ \
/*if it's non negative spell and our unit or non positive spell and hostile unit */ \
if((VLC->spellh->spells[ba.additionalInfo].positiveness >= 0 && gs->curB->stacks[it]->owner == h->tempOwner) \
||(VLC->spellh->spells[ba.additionalInfo].positiveness <= 0 && gs->curB->stacks[it]->owner != h->tempOwner ) \
) \
{ \
sse.stacks.insert(gs->curB->stacks[it]->ID); \
} \
} \
sse.effect.id = (NUMBER); \
sse.effect.level = getSchoolLevel(h,s); \
sse.effect.turnsRemain = (DURATION); \
sendAndApply(&sse); \
}
SpellCasted sc;