1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

* fixed start move animation

* added receiving exp (and leveling-up) after a won battle
This commit is contained in:
Michał W. Urbańczyk
2008-09-29 10:16:02 +00:00
parent 65ae3c3821
commit 917be0693d
4 changed files with 28 additions and 4 deletions

View File

@ -722,12 +722,10 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
int hexWbase = 44, hexHbase = 42; int hexWbase = 44, hexHbase = 42;
bool twoTiles = LOCPLINT->cb->battleGetCreature(number).isDoubleWide(); bool twoTiles = LOCPLINT->cb->battleGetCreature(number).isDoubleWide();
if(startMoving && creAnims[number]->framesInGroup(20)!=0) //animation of starting move; some units don't have this animation (ie. halberdier) if(startMoving) //animation of starting move; some units don't have this animation (ie. halberdier)
{ {
deactivate(); deactivate();
CGI->curh->hide(); CGI->curh->hide();
creAnims[number]->setType(20);
//LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i) for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i)
{ {
show(); show();
@ -1910,6 +1908,7 @@ CBattleReslutWindow::~CBattleReslutWindow()
void CBattleReslutWindow::activate() void CBattleReslutWindow::activate()
{ {
LOCPLINT->showingDialog->set(true);
exit->activate(); exit->activate();
} }

View File

@ -217,4 +217,5 @@ public:
friend class CBattleHex; friend class CBattleHex;
friend class CBattleReslutWindow; friend class CBattleReslutWindow;
friend class CPlayerInterface;
}; };

View File

@ -2019,6 +2019,12 @@ void CPlayerInterface::battleNewRound(int round) //called at the beggining of ea
void CPlayerInterface::actionStarted(const BattleAction* action) void CPlayerInterface::actionStarted(const BattleAction* action)
{ {
curAction = action; curAction = action;
if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))
&& static_cast<CBattleInterface*>(curint)->creAnims[action->stackNumber]->framesInGroup(20)
)
{
static_cast<CBattleInterface*>(curint)->creAnims[action->stackNumber]->setType(20);
}
} }
void CPlayerInterface::actionFinished(const BattleAction* action) void CPlayerInterface::actionFinished(const BattleAction* action)
@ -2061,6 +2067,7 @@ void CPlayerInterface::battleResultQuited()
delete curint; delete curint;
curint = adventureInt; curint = adventureInt;
adventureInt->activate(); adventureInt->activate();
LOCPLINT->showingDialog->setn(false);
} }
void CPlayerInterface::battleStackMoved(int ID, int dest) void CPlayerInterface::battleStackMoved(int ID, int dest)

View File

@ -56,6 +56,15 @@ double distance(int3 a, int3 b)
{ {
return std::sqrt( (double)(a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); return std::sqrt( (double)(a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
} }
void giveExp(BattleResult &r)
{
r.exp[0] = 0;
r.exp[1] = 0;
for(std::set<std::pair<ui32,si32> >::iterator i = r.casualties[!r.winner].begin(); i!=r.casualties[!r.winner].end(); i++)
{
r.exp[r.winner] += VLC->creh->creatures[i->first].hitPoints * i->second;
}
}
//bool CGameState::checkFunc(int obid, std::string name) //bool CGameState::checkFunc(int obid, std::string name)
//{ //{
// if (objscr.find(obid)!=objscr.end()) // if (objscr.find(obid)!=objscr.end())
@ -314,6 +323,7 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile
sendAndApply(&sg); sendAndApply(&sg);
//end battle, remove all info, free memory //end battle, remove all info, free memory
giveExp(*battleResult.data);
sendAndApply(battleResult.data); sendAndApply(battleResult.data);
if(cb) if(cb)
cb(battleResult.data); cb(battleResult.data);
@ -330,6 +340,12 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile
sendAndApply(&ro); sendAndApply(&ro);
} }
//give exp
if(battleResult.data->exp[0] && hero1)
changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
if(battleResult.data->exp[1] && hero2)
changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
delete battleResult.data; delete battleResult.data;
} }
@ -916,6 +932,7 @@ upgend:
br->result = 1; br->result = 1;
br->winner = !ba.side; //fleeing side loses br->winner = !ba.side; //fleeing side loses
gs->curB->calculateCasualties(br->casualties); gs->curB->calculateCasualties(br->casualties);
giveExp(*br);
battleResult.set(br); battleResult.set(br);
break; break;
} }