mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* forgetfulness spell implemented
* partial support for many creatures being attacked at once (killed - not killed mixes and callback/engine support must be added)
This commit is contained in:
parent
333e1d9878
commit
2d1fc64dd9
@ -912,17 +912,28 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
|
|||||||
creAnims[number]->pos.y = coords.second;
|
creAnims[number]->pos.y = coords.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)
|
void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAttackedInfo> attackedInfos)
|
||||||
{
|
{
|
||||||
while(creAnims[ID]->getType() != 2 || (attackingInfo && attackingInfo->IDby == IDby))
|
while(true)
|
||||||
{
|
{
|
||||||
show();
|
show();
|
||||||
CSDL_Ext::update();
|
CSDL_Ext::update();
|
||||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||||
|
|
||||||
|
//checking break conditions
|
||||||
|
bool break_loop = true;
|
||||||
|
for(int g=0; g<attackedInfos.size(); ++g)
|
||||||
|
{
|
||||||
|
if(creAnims[attackedInfos[g].ID]->getType() != 2)
|
||||||
|
break_loop = false;
|
||||||
|
if(attackingInfo && attackingInfo->IDby == attackedInfos[g].IDby)
|
||||||
|
break_loop = false;
|
||||||
|
}
|
||||||
|
if(break_loop) break;
|
||||||
}
|
}
|
||||||
if(byShooting) //delay hit animation
|
if(attackedInfos.size() == 1 && attackedInfos[0].byShooting) //delay hit animation
|
||||||
{
|
{
|
||||||
CStack attacker = *LOCPLINT->cb->battleGetStackByID(IDby);
|
CStack attacker = *LOCPLINT->cb->battleGetStackByID(attackedInfos[0].IDby);
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -944,20 +955,41 @@ void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
creAnims[ID]->setType(3); //getting hit
|
std::vector<int> animLengths;
|
||||||
int firstFrame = creAnims[ID]->getFrame();
|
int maxLen = 0;
|
||||||
for(int i=0; creAnims[ID]->getFrame() != creAnims[ID]->framesInGroup(3) + firstFrame - 1; ++i)
|
for(int g=0; g<attackedInfos.size(); ++g)
|
||||||
|
{
|
||||||
|
creAnims[attackedInfos[g].ID]->setType(3); //getting hit
|
||||||
|
animLengths.push_back( creAnims[attackedInfos[g].ID]->framesInGroup(3) );
|
||||||
|
if(creAnims[attackedInfos[g].ID]->framesInGroup(3) > maxLen)
|
||||||
|
{
|
||||||
|
maxLen = creAnims[attackedInfos[g].ID]->framesInGroup(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0; i<maxLen; ++i)
|
||||||
{
|
{
|
||||||
show();
|
show();
|
||||||
CSDL_Ext::update();
|
CSDL_Ext::update();
|
||||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||||
/*if((animCount+1)%(4/animSpeed)==0)
|
/*if((animCount+1)%(4/animSpeed)==0)
|
||||||
creAnims[ID]->incrementFrame();*/
|
creAnims[ID]->incrementFrame();*/
|
||||||
|
for(int g=0; g<attackedInfos.size(); ++g)
|
||||||
|
{
|
||||||
|
if(i>=animLengths[g] && creAnims[attackedInfos[g].ID]->getType() == 3)
|
||||||
|
creAnims[attackedInfos[g].ID]->setType(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int g=0; g<attackedInfos.size(); ++g)
|
||||||
|
{
|
||||||
|
if(creAnims[attackedInfos[g].ID]->getType() == 3)
|
||||||
|
creAnims[attackedInfos[g].ID]->setType(2);
|
||||||
}
|
}
|
||||||
creAnims[ID]->setType(2);
|
|
||||||
|
|
||||||
if(IDby!=-1)
|
for(int g=0; g<attackedInfos.size(); ++g)
|
||||||
printConsoleAttacked(ID, dmg, killed, IDby);
|
{
|
||||||
|
if(attackedInfos[g].IDby!=-1)
|
||||||
|
printConsoleAttacked(attackedInfos[g].ID, attackedInfos[g].dmg, attackedInfos[g].killed, attackedInfos[g].IDby);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::stackAttacking(int ID, int dest)
|
void CBattleInterface::stackAttacking(int ID, int dest)
|
||||||
@ -1392,6 +1424,11 @@ void CBattleInterface::spellCasted(SpellCasted * sc)
|
|||||||
displayEffect(19, sc->tile);
|
displayEffect(19, sc->tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 61: //forgetfulness
|
||||||
|
{
|
||||||
|
displayEffect(42, sc->tile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,13 +219,22 @@ public:
|
|||||||
void mouseMoved(const SDL_MouseMotionEvent &sEvent);
|
void mouseMoved(const SDL_MouseMotionEvent &sEvent);
|
||||||
bool reverseCreature(int number, int hex, bool wideTrick = false); //reverses animation of given creature playing animation of reversing
|
bool reverseCreature(int number, int hex, bool wideTrick = false); //reverses animation of given creature playing animation of reversing
|
||||||
|
|
||||||
|
struct SStackAttackedInfo
|
||||||
|
{
|
||||||
|
int ID; //id of attacked stack
|
||||||
|
int dmg; //damage dealt
|
||||||
|
int killed; //how many creatures in stack has been killed
|
||||||
|
int IDby; //ID of attacking stack
|
||||||
|
bool byShooting; //if true, stack has been attacked by shooting
|
||||||
|
};
|
||||||
|
|
||||||
//call-ins
|
//call-ins
|
||||||
void newStack(CStack stack); //new stack appeared on battlefield
|
void newStack(CStack stack); //new stack appeared on battlefield
|
||||||
void stackRemoved(CStack stack); //stack disappeared from batlefiled
|
void stackRemoved(CStack stack); //stack disappeared from batlefiled
|
||||||
void stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting); //stack has been killed (but corpses remain)
|
void stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting); //stack has been killed (but corpses remain)
|
||||||
void stackActivated(int number); //active stack has been changed
|
void stackActivated(int number); //active stack has been changed
|
||||||
void stackMoved(int number, int destHex, bool endMoving); //stack with id number moved to destHex
|
void stackMoved(int number, int destHex, bool endMoving); //stack with id number moved to destHex
|
||||||
void stackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting); //called when stack id attacked by stack with id IDby
|
void stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
|
||||||
void stackAttacking(int ID, int dest); //called when stack with id ID is attacking something on hex dest
|
void stackAttacking(int ID, int dest); //called when stack with id ID is attacking something on hex dest
|
||||||
void newRound(int number); //caled when round is ended; number is the number of round
|
void newRound(int number); //caled when round is ended; number is the number of round
|
||||||
void hexLclicked(int whichOne); //hex only call-in
|
void hexLclicked(int whichOne); //hex only call-in
|
||||||
|
@ -526,8 +526,15 @@ bool CCallback::battleIsStackMine(int ID)
|
|||||||
bool CCallback::battleCanShoot(int ID, int dest)
|
bool CCallback::battleCanShoot(int ID, int dest)
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||||
CStack *our=battleGetStackByID(ID), *dst=battleGetStackByPos(dest);
|
CStack *our = battleGetStackByID(ID), *dst = battleGetStackByPos(dest);
|
||||||
if(!our || !dst) return false;
|
if(!our || !dst) return false;
|
||||||
|
|
||||||
|
for(int g=0; g<our->effects.size(); ++g)
|
||||||
|
{
|
||||||
|
if(61 == our->effects[g].id) //forgetfulness
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(vstd::contains(our->abilities,SHOOTER)//it's shooter
|
if(vstd::contains(our->abilities,SHOOTER)//it's shooter
|
||||||
&& our->owner != dst->owner
|
&& our->owner != dst->owner
|
||||||
&& dst->alive()
|
&& dst->alive()
|
||||||
|
@ -2120,7 +2120,12 @@ void CPlayerInterface::battleStackAttacked(BattleStackAttacked * bsa)
|
|||||||
if(bsa->killed())
|
if(bsa->killed())
|
||||||
battleInt->stackKilled(bsa->stackAttacked, bsa->damageAmount, bsa->killedAmount, LOCPLINT->curAction->stackNumber, LOCPLINT->curAction->actionType==7 );
|
battleInt->stackKilled(bsa->stackAttacked, bsa->damageAmount, bsa->killedAmount, LOCPLINT->curAction->stackNumber, LOCPLINT->curAction->actionType==7 );
|
||||||
else
|
else
|
||||||
battleInt->stackIsAttacked(bsa->stackAttacked, bsa->damageAmount, bsa->killedAmount, LOCPLINT->curAction->stackNumber, LOCPLINT->curAction->actionType==7);
|
{
|
||||||
|
std::vector<CBattleInterface::SStackAttackedInfo> arg;
|
||||||
|
CBattleInterface::SStackAttackedInfo to_put = {bsa->stackAttacked, bsa->damageAmount, bsa->killedAmount, LOCPLINT->curAction->stackNumber, LOCPLINT->curAction->actionType==7};
|
||||||
|
arg.push_back(to_put);
|
||||||
|
battleInt->stacksAreAttacked(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void CPlayerInterface::battleAttack(BattleAttack *ba)
|
void CPlayerInterface::battleAttack(BattleAttack *ba)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef MAPHANDLER_H
|
#ifndef MAPHANDLER_H
|
||||||
#define MAPHANDLER_H
|
#define MAPHANDLER_H
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include <SDL.h>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
const int Woff = 12; //width of map's frame
|
const int Woff = 12; //width of map's frame
|
||||||
@ -14,6 +13,8 @@ class CGDefInfo;
|
|||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
class CDefHandler;
|
class CDefHandler;
|
||||||
struct TerrainTile;
|
struct TerrainTile;
|
||||||
|
struct SDL_Surface;
|
||||||
|
struct SDL_Rect;
|
||||||
|
|
||||||
struct TerrainTile2
|
struct TerrainTile2
|
||||||
{
|
{
|
||||||
|
@ -1162,6 +1162,11 @@ upgend:
|
|||||||
|| !vstd::contains(curStack->abilities,SHOOTER) //our stack is shooting unit
|
|| !vstd::contains(curStack->abilities,SHOOTER) //our stack is shooting unit
|
||||||
)
|
)
|
||||||
break;
|
break;
|
||||||
|
for(int g=0; g<curStack->effects.size(); ++g)
|
||||||
|
{
|
||||||
|
if(61 == curStack->effects[g].id) //forgetfulness
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
sendAndApply(&StartAction(ba)); //start shooting
|
sendAndApply(&StartAction(ba)); //start shooting
|
||||||
|
|
||||||
@ -1314,6 +1319,16 @@ upgend:
|
|||||||
sendAndApply(&sse);
|
sendAndApply(&sse);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 61: //forgetfulness
|
||||||
|
{
|
||||||
|
SetStackEffect sse;
|
||||||
|
sse.stack = gs->curB->getStackT(ba.destinationTile)->ID;
|
||||||
|
sse.effect.id = 61;
|
||||||
|
sse.effect.level = getSchoolLevel(h,s);
|
||||||
|
sse.effect.turnsRemain = h->getPrimSkillLevel(2);
|
||||||
|
sendAndApply(&sse);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: spells to support possibly soon (list by Zamolxis):
|
//TODO: spells to support possibly soon (list by Zamolxis):
|
||||||
|
Loading…
Reference in New Issue
Block a user